tearOldPipe.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. <template>
  2. <view>
  3. <view class="background">
  4. <view class="uni-list">
  5. <view class="container">
  6. <view>
  7. 工程周期
  8. </view>
  9. <view v-if="this.isEmpty(this.projectValue.dictValue)" style="margin-top: 10;"
  10. @click="pickerShow('gczq')">
  11. <span style="color: darkgray;">请选择工程周期</span>
  12. </view>
  13. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('gczq')">
  14. <span style="color: black;">{{projectValue.dictLabel}}</span>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="uni-list">
  19. <view class="container">
  20. <view>
  21. 行政区
  22. </view>
  23. <view v-if="this.isEmpty(this.XZQValue.dictValue)" style="margin-top: 10;"
  24. @click="pickerShow('xzq')">
  25. <span style="color: darkgray;">请选择行政区</span>
  26. </view>
  27. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xzq')">
  28. <span style="color: black;">{{XZQValue.dictLabel}}</span>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="uni-list">
  33. <view class="container">
  34. <view>
  35. 小区
  36. </view>
  37. <view v-if="this.isEmpty(this.XQValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  38. @click="pickerShow('xq')">
  39. <span style="color: darkgray;">请选择小区</span>
  40. </view>
  41. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('xq')">
  42. <span style="color: black;">{{XQValue.name}}</span>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="uni-list">
  47. <view class="container">
  48. <view class="uni-list-cell-left">
  49. 楼栋
  50. </view>
  51. <view v-if="this.isEmpty(this.LDValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  52. @click="pickerShow('ld')">
  53. <span style="color: darkgray;">请选择楼栋</span>
  54. </view>
  55. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('ld')">
  56. <span style="color: black;">{{LDValue.name}}</span>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="uni-list" style="margin-top: 10;">
  61. <view class="container">
  62. <view class="uni-list-cell-left">
  63. 单元
  64. </view>
  65. <view v-if="this.isEmpty(this.DYValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  66. @click="pickerShow('dy')">
  67. <span style="color: darkgray;">请选择单元</span>
  68. </view>
  69. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('dy')">
  70. <span style="color: black;">{{DYValue.name}}</span>
  71. </view>
  72. </view>
  73. </view>
  74. <view class="uni-list">
  75. <view class="container">
  76. <view class="uni-list-cell-left">
  77. 房间
  78. </view>
  79. <view v-if="this.isEmpty(this.FJValue.id)" class="uni-list-cell-db" style="margin-top: 10;"
  80. @click="pickerShow('fj')">
  81. <span style="color: darkgray;">请选择房间</span>
  82. </view>
  83. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('fj')">
  84. <span style="color: black;">{{FJValue.name}}</span>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="container">
  89. <view class="title">是否按照施工图纸施工</view>
  90. <switch style="transform: scale(0.6,0.6);" @change="switchChange" checked="isChick" />
  91. </view>
  92. <SelectPicker :list="selectList" @change="changeSelect" v-if="open" @close="close" titleKey="name"
  93. subtitleKey="id" v-model="name"></SelectPicker>
  94. <SelectPicker :list="dictOptions" @change="changeSelectDict" v-if="openDict" @close="closeDict"
  95. titleKey="dictLabel" subtitleKey="dictValue" v-model="dictLabel"></SelectPicker>
  96. </view>
  97. <view class="background">
  98. <view class="uni-list">
  99. <view style="font-size: 16px;margin-left: 10px;margin-top: 10px;">
  100. 拆旧管
  101. <span
  102. style="color: blue;font-size: 14px; display: flex;justify-content:flex-end; margin-right: 15px;">历史</span>
  103. </view>
  104. <view class="container">
  105. <view>
  106. 腐蚀等级
  107. </view>
  108. <view v-if="this.isEmpty(this.LevelValue.dictValue)" style="margin-top: 10;"
  109. @click="pickerShow('fsdj')">
  110. <span style="color: darkgray;">请选择腐蚀等级</span>
  111. </view>
  112. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('fsdj')">
  113. <span style="color: black;">{{LevelValue.dictLabel}}</span>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  119. <view class="container" style="color: gainsboro;">*请上传照片</view>
  120. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px;">
  121. <image src="/static/images/chooseimg.png" mode=""
  122. style="width: 190rpx; height: 190rpx; margin: 0 12rpx;; " @click="chooseimage()"></image>
  123. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  124. <view>
  125. <image :src="item" mode="" style="width: 190rpx; height: 190rpx; margin: 0 12rpx;"
  126. @click="showPhoto(index)">
  127. </image>
  128. </view>
  129. <view @click="remove(index)"
  130. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  131. <u-icon name="close" color="#FFFFFF" size="35"></u-icon>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. <view class="action-btn">
  137. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  138. </view>
  139. </view>
  140. </template>
  141. <script>
  142. import SelectPicker from '../../../components/selectPicker/select_picker.vue'
  143. import {
  144. getDicts
  145. } from "@/api/system/dict/data";
  146. import {
  147. getAreaList,
  148. getBuildingList,
  149. getUnitList,
  150. getHousesList,
  151. addTearOldPipe,
  152. } from '@/api/common'
  153. import {
  154. getToken
  155. } from '../../../utils/auth';
  156. export default {
  157. components: {
  158. SelectPicker
  159. },
  160. data() {
  161. return {
  162. headers: {
  163. Authorization: "Bearer " + getToken()
  164. },
  165. type: '',
  166. open: false,
  167. openDict: false,
  168. selectList: [],
  169. dictOptions: [],
  170. imgArr: [],
  171. XQValue: {},
  172. XZQValue: {},
  173. projectValue: {},
  174. LevelValue: {},
  175. LDValue: {},
  176. DYValue: {},
  177. FJValue: {},
  178. FSValue: {},
  179. XQList: '',
  180. LDList: '',
  181. DYList: '',
  182. FJList: '',
  183. progress: 0, //上传图片进度百分比
  184. loading: false,
  185. isCheck: true //是否按照施工图纸施工
  186. }
  187. },
  188. created() {
  189. },
  190. onLoad() {
  191. uni.setNavigationBarTitle({
  192. title: '旧改工程-室内'
  193. })
  194. },
  195. methods: {
  196. //判断是否选择
  197. isEmpty(str) {
  198. return (!str || 0 === str.length);
  199. },
  200. showPhoto(index) {
  201. uni.previewImage({
  202. current: index,
  203. urls: this.imgArr,
  204. })
  205. console.log('sss')
  206. },
  207. remove(index) {
  208. uni.showModal({
  209. title: '提示',
  210. content: '是否删除该图片或视频?',
  211. success: (res) => {
  212. if (res.confirm) {
  213. this.imgArr.splice(index, 1)
  214. console.log('this.imgarr', this.imgArr)
  215. if (this.imgArr.length <= 0) {
  216. this.photo = true;
  217. }
  218. }
  219. }
  220. })
  221. },
  222. chooseimage() {
  223. let _this = this;
  224. console.log('图片', _this.headers)
  225. uni.chooseImage({
  226. sizeType: ['album', 'camera'],
  227. success(resp) {
  228. resp.tempFiles.forEach((item, index) => {
  229. const task = uni.uploadFile({
  230. url: _this.$HTTP + `/obs`,
  231. filePath: item.path,
  232. name: 'file',
  233. formData: {},
  234. header: _this.headers,
  235. success: res => {
  236. // 判断是否json字符串,将其转为json格式
  237. console.log("结果", res)
  238. // let data = _this.$u.test.jsonString(res
  239. // .data) ? JSON.parse(res.data) : res.data;
  240. let data = JSON.parse(res.data);
  241. if (![200].includes(data.code)) {
  242. // this.uploadError(index, data);
  243. _this.$modal.msg(data.msg)
  244. } else {
  245. if (_this.progress === 100) {
  246. console.log('_this.progress', _this.progress)
  247. //console.log('data----', data)data
  248. console.log('res--', res)
  249. _this.imgArr.push(data.data.url)
  250. console.log('imgArr', _this.imgArr)
  251. _this.$modal.msg('上传成功!')
  252. _this.photo = false;
  253. }
  254. }
  255. },
  256. fail: e => {
  257. console.log(e)
  258. _this.$modal.msg('上传失败!')
  259. //_this.uploadError(index, e);
  260. },
  261. complete: res => {
  262. uni.hideLoading();
  263. _this.uploading = false;
  264. }
  265. });
  266. task.onProgressUpdate(res => {
  267. _this.progress = res.progress;
  268. console.log('onProgressUpdate', res)
  269. console.log('task.onProgressUpdate', _this.progress)
  270. uni.showLoading({
  271. title: '上传中'
  272. })
  273. if (_this.progress != 100) {
  274. _this.loading = false
  275. console.log('_this.loading false', _this.loading)
  276. } else {
  277. _this.loading = true
  278. console.log('_this.loading true', _this.loading)
  279. }
  280. });
  281. })
  282. },
  283. })
  284. },
  285. pickerShow(e) {
  286. this.type = e; //赋值类型
  287. if (e == 'fsdj') {
  288. //腐蚀等级
  289. this.openDict = true;
  290. //腐蚀等级
  291. getDicts("corrosion_level").then(response => {
  292. console.log(response)
  293. this.dictOptions = response.data;
  294. });
  295. } else if (e == 'gczq') { //工程周期
  296. this.openDict = true;
  297. getDicts("engin_cycle").then(response => {
  298. this.dictOptions = response.data;
  299. });
  300. } else if (e == 'xzq') { //行政区
  301. if (this.isEmpty(this.projectValue.dictValue)) {
  302. this.$modal.msg('请选择工程周期')
  303. } else {
  304. this.openDict = true;
  305. getDicts("district").then(response => {
  306. this.dictOptions = response.data;
  307. });
  308. }
  309. //this.selectList = this.dictOptions;
  310. } else if (e == 'xq') { //小区
  311. if (this.isEmpty(this.XZQValue.dictValue)) {
  312. this.$modal.msg('请选择行政区')
  313. } else {
  314. this.open = true;
  315. this.selectList = this.XQList;
  316. }
  317. } else if (e == 'ld') { //楼栋
  318. if (this.isEmpty(this.XQValue.id)) {
  319. this.$modal.msg('请选择小区')
  320. } else {
  321. this.open = true;
  322. this.selectList = this.LDList;
  323. }
  324. } else if (e == 'dy') { //单元
  325. if (this.isEmpty(this.LDValue.id)) {
  326. this.$modal.msg('请选择楼栋')
  327. } else {
  328. this.open = true;
  329. this.selectList = this.DYList;
  330. }
  331. } else if (e == 'fj') { //房间
  332. if (this.isEmpty(this.DYValue.id)) {
  333. this.$modal.msg('请选择单元')
  334. } else {
  335. this.open = true;
  336. this.selectList = this.FJList;
  337. }
  338. }
  339. },
  340. switchChange(e) {
  341. console.log('switch2 发生 change 事件,携带值为', e.detail.value)
  342. this.isCheck = e.detail.value;
  343. },
  344. changeSelectDict(item, index) {
  345. this.openDict = false;
  346. if (this.type == 'gczq') {
  347. this.projectValue = item
  348. } else if (this.type == 'xzq') {
  349. this.XZQValue = item;
  350. //根据行政区id获取小区数据
  351. this.XQValue = ''; //重置小区数据
  352. this.LDValue = ''; //重置楼栋数据
  353. this.DYValue = ''; //重置单元数据
  354. this.FJValue = ''; //重置房间数据
  355. getAreaList(item.dictValue).then(res => {
  356. this.XQList = res.data;
  357. })
  358. } else {
  359. this.LevelValue = item;
  360. }
  361. },
  362. changeSelect(item, index) {
  363. // this.index = index;
  364. // this.address = item.communityName;
  365. this.open = false;
  366. if (this.type == 'xq') {
  367. this.XQValue = item;
  368. //根据小区id 获取楼栋数据
  369. this.LDValue = ''; //重置楼栋数据
  370. this.DYValue = ''; //重置单元数据
  371. this.FJValue = ''; //重置房间数据
  372. getBuildingList(item.id).then(res => {
  373. this.LDList = res.data
  374. // console.log("楼栋=", res)
  375. })
  376. } else if (this.type == 'ld') {
  377. this.LDValue = item;
  378. //根据楼栋ID 获取单元数据
  379. this.DYValue = ''; //重置单元数据
  380. this.FJValue = ''; //重置房间数据
  381. getUnitList(item.id).then(res => {
  382. this.DYList = res.data
  383. // console.log("单元=", res)
  384. })
  385. } else if (this.type == 'dy') {
  386. this.DYValue = item;
  387. //根据单元数据 获取房间数据
  388. this.FJValue = ''; //重置房间数据
  389. getHousesList(item.id).then(res => {
  390. this.FJList = res.data
  391. // console.log("房间=", res)
  392. })
  393. } else if (this.type == 'fj') {
  394. this.FJValue = item;
  395. }
  396. },
  397. //关闭弹窗
  398. close(e) {
  399. this.open = false
  400. },
  401. //关闭弹窗
  402. closeDict(e) {
  403. this.openDict = false
  404. },
  405. //提交数据
  406. submit() {
  407. if (this.isEmpty(this.projectValue.dictValue)) {
  408. this.$modal.msg("请选择工程周期")
  409. } else if (this.isEmpty(this.XZQValue.dictValue)) {
  410. this.$modal.msg("请选择行政区")
  411. } else if (this.isEmpty(this.XQValue.id)) {
  412. this.$modal.msg("请选择小区")
  413. } else if (this.isEmpty(this.LDValue.id)) {
  414. this.$modal.msg("请选择楼栋")
  415. } else if (this.isEmpty(this.DYValue.id)) {
  416. this.$modal.msg("请选择单元")
  417. } else if (this.isEmpty(this.FJValue.id)) {
  418. this.$modal.msg("请选择房间")
  419. } else if (this.isEmpty(this.LevelValue.dictValue)) {
  420. this.$modal.msg("请选择腐蚀等级")
  421. } else if (this.imgArr.length <= 0) {
  422. this.$modal.msg('请上传照片')
  423. } else if (this.loading == false) {
  424. this.$modal.msg('照片未上传完毕,无法提交!')
  425. } else {
  426. //提交
  427. let param = {
  428. district: this.XZQValue.dictValue,
  429. areaId: this.XQValue.id,
  430. buildingId: this.LDValue.id,
  431. unitId: this.DYValue.id,
  432. houseId: this.FJValue.id,
  433. enginType: 'old_renovation', //写死
  434. enginClassification: 'indoor_engineering', //写死
  435. enginCycle: this.projectValue.dictValue, //工程周期
  436. zEngineeringNodeBo: {
  437. type: "dismantling_old_pipes",
  438. zEngineeringInfoBo: {
  439. constructAccordingDrawings: this.isCheck, //是否按图纸施工
  440. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  441. zEngineeringMaterialBo: [{
  442. corrosionLevel: this.LevelValue.dictValue
  443. }]
  444. }
  445. }
  446. }
  447. addTearOldPipe(param).then(res => {
  448. if (res.code == '200') {
  449. this.$modal.msg(res.msg)
  450. uni.navigateBack();
  451. }
  452. })
  453. }
  454. }
  455. }
  456. }
  457. </script>
  458. <style>
  459. .container {
  460. display: flex;
  461. margin-left: 10px;
  462. margin-top: 10px;
  463. margin-right: 10px;
  464. align-items: flex-start;
  465. justify-content: space-between;
  466. }
  467. .text {
  468. font-size: 16px;
  469. color: #333;
  470. }
  471. .background {
  472. border: 15px solid hsla(0, 0%, 100%, .5);
  473. background: white;
  474. background-clip: padding-box;
  475. /*从padding开始往外面裁剪背景*/
  476. }
  477. .btn {
  478. margin-top: 40px;
  479. margin-right: 20px;
  480. margin-bottom: 120px;
  481. margin-left: 20px;
  482. height: 45px;
  483. }
  484. </style>