tearOldPipe.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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>
  99. <view class="uni-list">
  100. <view style="font-size: 16px;margin-left: 10px;margin-top: 10px;">
  101. 拆旧管
  102. <span
  103. style="color: blue;font-size: 14px; display: flex;justify-content:flex-end; margin-right: 15px;">历史</span>
  104. </view>
  105. <view class="container" style="margin-bottom: 20PX;">
  106. <view>
  107. 腐蚀等级
  108. </view>
  109. <view v-if="this.isEmpty(this.LevelValue.dictValue)" style="margin-top: 10;"
  110. @click="pickerShow('fsdj')">
  111. <span style="color: darkgray;">请选择腐蚀等级</span>
  112. </view>
  113. <view v-else class="uni-list-cell-db" style="margin-top: 10;" @click="pickerShow('fsdj')">
  114. <span style="color: black;">{{LevelValue.dictLabel}}</span>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. <view class="align-items" style="margin-top: 20px;margin-bottom: 20px;">
  120. <view class="container" style="color: gainsboro;">*请上传照片</view>
  121. <view class="" style="display: flex; flex-wrap: wrap;margin-top: 10px; margin-left: 10px;">
  122. <image src="/static/images/chooseimg.png" mode=""
  123. style="width: 100rpx; height: 100rpx; margin: 0 12rpx;; " @click="choose()"></image>
  124. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  125. <view
  126. v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ">
  127. <image :src="item" mode="" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"
  128. @click="showPhoto(index)">
  129. </image>
  130. </view>
  131. <view v-else>
  132. <video :src="item" style="width: 100rpx; height: 100rpx; margin: 0 12rpx;"></video>
  133. </view>
  134. <view @click="remove(index)"
  135. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%;">
  136. <uni-icons type="close" color="darkgray" size="18"></uni-icons>
  137. </view>
  138. </view>
  139. </view>
  140. </view>
  141. </view>
  142. <view class="action-btn">
  143. <button @click="submit" class="btn cu-btn block bg-blue lg round">确认上传</button>
  144. </view>
  145. </view>
  146. </template>
  147. <script>
  148. import SelectPicker from '../../../components/selectPicker/select_picker.vue'
  149. import uniIcons from '../../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue'
  150. import {
  151. getDicts
  152. } from "@/api/system/dict/data";
  153. import {
  154. getAreaList,
  155. getBuildingList,
  156. getUnitList,
  157. getHousesList,
  158. addTearOldPipe,
  159. } from '@/api/common'
  160. import {
  161. getToken
  162. } from '../../../utils/auth';
  163. export default {
  164. components: {
  165. SelectPicker,
  166. uniIcons
  167. },
  168. data() {
  169. return {
  170. headers: {
  171. Authorization: "Bearer " + getToken()
  172. },
  173. type: '',
  174. open: false,
  175. openDict: false,
  176. selectList: [],
  177. dictOptions: [],
  178. imgArr: [],
  179. XQValue: {},
  180. XZQValue: {},
  181. projectValue: {},
  182. LevelValue: {},
  183. LDValue: {},
  184. DYValue: {},
  185. FJValue: {},
  186. FSValue: {},
  187. XQList: '',
  188. LDList: '',
  189. DYList: '',
  190. FJList: '',
  191. progress: 0, //上传图片进度百分比
  192. loading: false,
  193. isCheck: true //是否按照施工图纸施工
  194. }
  195. },
  196. created() {
  197. },
  198. onLoad() {
  199. uni.setNavigationBarTitle({
  200. title: '旧改工程-室内'
  201. })
  202. },
  203. methods: {
  204. //判断是否选择
  205. isEmpty(str) {
  206. return (!str || 0 === str.length);
  207. },
  208. showPhoto(index) {
  209. uni.previewImage({
  210. current: index,
  211. urls: this.imgArr,
  212. })
  213. console.log('sss')
  214. },
  215. remove(index) {
  216. uni.showModal({
  217. title: '提示',
  218. content: '是否删除该图片或视频?',
  219. success: (res) => {
  220. if (res.confirm) {
  221. this.imgArr.splice(index, 1)
  222. console.log('this.imgarr', this.imgArr)
  223. if (this.imgArr.length <= 0) {
  224. this.photo = true;
  225. }
  226. }
  227. }
  228. })
  229. },
  230. choose() {
  231. let _this = this;
  232. uni.showActionSheet({
  233. title: '上传',
  234. itemList: ['图片', '视频'],
  235. success: (res) => {
  236. console.log(res)
  237. if (res.tapIndex == 0) {
  238. this.chooseimage()
  239. } else {
  240. this.choosevideo()
  241. }
  242. }
  243. })
  244. },
  245. chooseimage() {
  246. let _this = this;
  247. console.log('图片', _this.headers)
  248. uni.chooseImage({
  249. sizeType: ['album', 'camera'],
  250. success(resp) {
  251. resp.tempFiles.forEach((item, index) => {
  252. const task = uni.uploadFile({
  253. url: _this.$HTTP + `/obs`,
  254. filePath: item.path,
  255. name: 'file',
  256. formData: {},
  257. header: _this.headers,
  258. success: res => {
  259. // 判断是否json字符串,将其转为json格式
  260. console.log("结果", res)
  261. // let data = _this.$u.test.jsonString(res
  262. // .data) ? JSON.parse(res.data) : res.data;
  263. let data = JSON.parse(res.data);
  264. if (![200].includes(data.code)) {
  265. // this.uploadError(index, data);
  266. _this.$modal.msg(data.msg)
  267. } else {
  268. if (_this.progress === 100) {
  269. console.log('_this.progress', _this.progress)
  270. //console.log('data----', data)data
  271. console.log('res--', res)
  272. _this.imgArr.push(data.data.url)
  273. console.log('imgArr', _this.imgArr)
  274. _this.$modal.msg('上传成功!')
  275. _this.photo = false;
  276. }
  277. }
  278. },
  279. fail: e => {
  280. console.log(e)
  281. _this.$modal.msg('上传失败!')
  282. //_this.uploadError(index, e);
  283. },
  284. complete: res => {
  285. uni.hideLoading();
  286. _this.uploading = false;
  287. }
  288. });
  289. task.onProgressUpdate(res => {
  290. _this.progress = res.progress;
  291. console.log('onProgressUpdate', res)
  292. console.log('task.onProgressUpdate', _this.progress)
  293. uni.showLoading({
  294. title: '上传中'
  295. })
  296. if (_this.progress != 100) {
  297. _this.loading = false
  298. console.log('_this.loading false', _this.loading)
  299. } else {
  300. _this.loading = true
  301. console.log('_this.loading true', _this.loading)
  302. }
  303. });
  304. })
  305. },
  306. })
  307. },
  308. choosevideo() {
  309. let _this = this;
  310. console.log('视频')
  311. uni.chooseVideo({
  312. sourceType: ['album', 'camera'],
  313. maxDuration: 30,
  314. success(resp) {
  315. const task = uni.uploadFile({
  316. url: _this.$HTTP + `/obs`,
  317. filePath: resp.tempFilePath,
  318. name: 'file',
  319. formData: {},
  320. header: _this.headers,
  321. success: res => {
  322. // 判断是否json字符串,将其转为json格式
  323. let data = JSON.parse(res.data);
  324. if (![200].includes(res.statusCode)) {
  325. this.uploadError(index, data);
  326. } else {
  327. //上传成功
  328. if (_this.progress === 100) {
  329. console.log('_this.progress', _this.progress)
  330. _this.imgArr.push(data.data.url)
  331. console.log('imgArr', _this.imgArr)
  332. _this.$UTILS.showPrompt('上传成功!')
  333. _this.photo = false;
  334. }
  335. }
  336. },
  337. fail: e => {
  338. _this.$UTILS.showPrompt('上传失败!')
  339. this.uploadError(index, e);
  340. },
  341. complete: res => {
  342. uni.hideLoading();
  343. _this.uploading = false;
  344. }
  345. });
  346. task.onProgressUpdate(res => {
  347. _this.progress = res.progress;
  348. console.log('onProgressUpdate', res)
  349. uni.showLoading({
  350. title: '上传中'
  351. })
  352. if (_this.progress != 100) {
  353. _this.loading = false
  354. console.log('_this.loading false', _this.loading)
  355. } else {
  356. _this.loading = true
  357. console.log('_this.loading true', _this.loading)
  358. }
  359. });
  360. },
  361. })
  362. },
  363. pickerShow(e) {
  364. this.type = e; //赋值类型
  365. if (e == 'fsdj') {
  366. //腐蚀等级
  367. this.openDict = true;
  368. //腐蚀等级
  369. getDicts("corrosion_level").then(response => {
  370. console.log(response)
  371. this.dictOptions = response.data;
  372. });
  373. } else if (e == 'gczq') { //工程周期
  374. this.openDict = true;
  375. getDicts("engin_cycle").then(response => {
  376. this.dictOptions = response.data;
  377. });
  378. } else if (e == 'xzq') { //行政区
  379. if (this.isEmpty(this.projectValue.dictValue)) {
  380. this.$modal.msg('请选择工程周期')
  381. } else {
  382. this.openDict = true;
  383. getDicts("district").then(response => {
  384. this.dictOptions = response.data;
  385. });
  386. }
  387. //this.selectList = this.dictOptions;
  388. } else if (e == 'xq') { //小区
  389. if (this.isEmpty(this.XZQValue.dictValue)) {
  390. this.$modal.msg('请选择行政区')
  391. } else {
  392. this.open = true;
  393. this.selectList = this.XQList;
  394. }
  395. } else if (e == 'ld') { //楼栋
  396. if (this.isEmpty(this.XQValue.id)) {
  397. this.$modal.msg('请选择小区')
  398. } else {
  399. this.open = true;
  400. this.selectList = this.LDList;
  401. }
  402. } else if (e == 'dy') { //单元
  403. if (this.isEmpty(this.LDValue.id)) {
  404. this.$modal.msg('请选择楼栋')
  405. } else {
  406. this.open = true;
  407. this.selectList = this.DYList;
  408. }
  409. } else if (e == 'fj') { //房间
  410. if (this.isEmpty(this.DYValue.id)) {
  411. this.$modal.msg('请选择单元')
  412. } else {
  413. this.open = true;
  414. this.selectList = this.FJList;
  415. }
  416. }
  417. },
  418. switchChange(e) {
  419. console.log('switch2 发生 change 事件,携带值为', e.detail.value)
  420. this.isCheck = e.detail.value;
  421. },
  422. changeSelectDict(item, index) {
  423. this.openDict = false;
  424. if (this.type == 'gczq') {
  425. this.projectValue = item
  426. } else if (this.type == 'xzq') {
  427. this.XZQValue = item;
  428. //根据行政区id获取小区数据
  429. this.XQValue = ''; //重置小区数据
  430. this.LDValue = ''; //重置楼栋数据
  431. this.DYValue = ''; //重置单元数据
  432. this.FJValue = ''; //重置房间数据
  433. getAreaList(item.dictValue).then(res => {
  434. this.XQList = res.data;
  435. })
  436. } else {
  437. this.LevelValue = item;
  438. }
  439. },
  440. changeSelect(item, index) {
  441. // this.index = index;
  442. // this.address = item.communityName;
  443. this.open = false;
  444. if (this.type == 'xq') {
  445. this.XQValue = item;
  446. //根据小区id 获取楼栋数据
  447. this.LDValue = ''; //重置楼栋数据
  448. this.DYValue = ''; //重置单元数据
  449. this.FJValue = ''; //重置房间数据
  450. getBuildingList(item.id).then(res => {
  451. this.LDList = res.data
  452. // console.log("楼栋=", res)
  453. })
  454. } else if (this.type == 'ld') {
  455. this.LDValue = item;
  456. //根据楼栋ID 获取单元数据
  457. this.DYValue = ''; //重置单元数据
  458. this.FJValue = ''; //重置房间数据
  459. getUnitList(item.id).then(res => {
  460. this.DYList = res.data
  461. // console.log("单元=", res)
  462. })
  463. } else if (this.type == 'dy') {
  464. this.DYValue = item;
  465. //根据单元数据 获取房间数据
  466. this.FJValue = ''; //重置房间数据
  467. getHousesList(item.id).then(res => {
  468. this.FJList = res.data
  469. // console.log("房间=", res)
  470. })
  471. } else if (this.type == 'fj') {
  472. this.FJValue = item;
  473. }
  474. },
  475. //关闭弹窗
  476. close(e) {
  477. this.open = false
  478. },
  479. //关闭弹窗
  480. closeDict(e) {
  481. this.openDict = false
  482. },
  483. //提交数据
  484. submit() {
  485. if (this.isEmpty(this.projectValue.dictValue)) {
  486. this.$modal.msg("请选择工程周期")
  487. } else if (this.isEmpty(this.XZQValue.dictValue)) {
  488. this.$modal.msg("请选择行政区")
  489. } else if (this.isEmpty(this.XQValue.id)) {
  490. this.$modal.msg("请选择小区")
  491. } else if (this.isEmpty(this.LDValue.id)) {
  492. this.$modal.msg("请选择楼栋")
  493. } else if (this.isEmpty(this.DYValue.id)) {
  494. this.$modal.msg("请选择单元")
  495. } else if (this.isEmpty(this.FJValue.id)) {
  496. this.$modal.msg("请选择房间")
  497. } else if (this.isEmpty(this.LevelValue.dictValue)) {
  498. this.$modal.msg("请选择腐蚀等级")
  499. } else if (this.imgArr.length <= 0) {
  500. this.$modal.msg('请上传照片')
  501. } else if (this.loading == false) {
  502. this.$modal.msg('照片未上传完毕,无法提交!')
  503. } else {
  504. //提交
  505. let param = {
  506. district: this.XZQValue.dictValue,
  507. areaId: this.XQValue.id,
  508. buildingId: this.LDValue.id,
  509. unitId: this.DYValue.id,
  510. houseId: this.FJValue.id,
  511. enginType: 'old_renovation', //写死
  512. enginClassification: 'indoor_engineering', //写死
  513. enginCycle: this.projectValue.dictValue, //工程周期
  514. zEngineeringNodeBo: {
  515. type: "dismantling_old_pipes",
  516. zEngineeringInfoBo: {
  517. constructAccordingDrawings: this.isCheck, //是否按图纸施工
  518. zEngiineeringPhotoBoList: this.imgArr, //照片集合
  519. zEngineeringMaterialBo: [{
  520. corrosionLevel: this.LevelValue.dictValue
  521. }]
  522. }
  523. }
  524. }
  525. addTearOldPipe(param).then(res => {
  526. if (res.code == '200') {
  527. uni.showToast({
  528. title: res.msg,
  529. icon: 'none',
  530. //显示持续时间为 2秒
  531. duration: 1000
  532. })
  533. uni.navigateBack();
  534. }
  535. })
  536. }
  537. }
  538. }
  539. }
  540. </script>
  541. <style>
  542. .container {
  543. display: flex;
  544. margin-left: 10px;
  545. margin-top: 10px;
  546. margin-right: 10px;
  547. align-items: flex-start;
  548. justify-content: space-between;
  549. }
  550. .text {
  551. font-size: 16px;
  552. color: #333;
  553. }
  554. .background {
  555. border: 15px solid hsla(0, 0%, 100%, .5);
  556. background: white;
  557. background-clip: padding-box;
  558. /*从padding开始往外面裁剪背景*/
  559. }
  560. .btn {
  561. margin-top: 40px;
  562. margin-right: 20px;
  563. margin-bottom: 120px;
  564. margin-left: 20px;
  565. height: 45px;
  566. }
  567. </style>