tearOldPipe.vue 13 KB

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