valveWellInspection.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. <template>
  2. <view>
  3. <image src="https://cczdsz.cn/app/images/background-from.png" class="background"></image>
  4. <view class="project-content">
  5. <u-form :model="form" :rules="rules" ref="form">
  6. <view style="flex-flow: row;display: flex; justify-content: flex-end;">
  7. <view class="small-title">阀井 </view>
  8. <view class="small-title" style="margin-left: auto;" @click="BoxDetails()">详情<u-icon name="arrow-right"></u-icon></view>
  9. </view>
  10. <u-form-item label="阀井名称" borderBottom ref="item1" labelWidth="140">
  11. <u-input v-model="form.valveWellName" disabled borderBottom
  12. placeholder="请输入阀井名称"></u-input>
  13. </u-form-item>
  14. <u-form-item label="位置" borderBottom ref="item1" labelWidth="140">
  15. <u-input v-model="form.position" disabled borderBottom
  16. placeholder="请选择位置"></u-input>
  17. <!-- <u-select v-model="showposition" :list="buildingList" label-name="name" value-name="id"
  18. @confirm="buildingconfirm()"> </u-select>
  19. <u-icon slot="right" name="arrow-right"></u-icon> -->
  20. </u-form-item>
  21. <u-form-item label="发现问题" labelWidth="140" borderBottom ref="item1">
  22. <u-radio-group v-model="form.discoverProblems" >
  23. <u-radio @change="confirm"
  24. v-for="(item, index) in typelist.find_problem"
  25. :key="index" :name="item.dictValue">
  26. {{item.dictLabel}}
  27. </u-radio>
  28. </u-radio-group>
  29. </u-form-item>
  30. <!-- <u-form-item label="发现时间" labelWidth="140" borderBottom ref="item1">
  31. <u-input v-model="form.discoverTime" borderBottom placeholder="请选择接警时间" disabled
  32. @click="showtime=true&&type!=1"></u-input>
  33. <u-picker v-model="showtime" mode="time" :params="params" @confirm="time()"></u-picker>
  34. </u-form-item> -->
  35. <u-form-item borderBottom ref="item1">
  36. <view>巡检照片</view>
  37. <u-input v-model="WarningColumnInformation" disabled placeholder="请上传巡检照片"></u-input>
  38. <view class="" style="display: flex; flex-wrap: wrap; margin: 0 55rpx;">
  39. <image src="https://cczdsz.cn/app/images/chooseimg.png" mode=""
  40. style="width: 190rpx; height: 190rpx; margin: 0 12rpx; " @click="choose()" >
  41. </image>
  42. <view v-for="(item,index) in imgymxs" :key="index" style="position: relative;">
  43. <view v-if="item.type == 'image'">
  44. <image :src="item.url" mode="" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"
  45. @click="showPhoto(index)">
  46. </image>
  47. </view>
  48. <view v-else>
  49. <video :src="item" style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"></video>
  50. </view>
  51. <view @click="remove(index)"
  52. style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  53. <u-icon name="close" color="#FFFFFF" size="35" ></u-icon>
  54. </view>
  55. </view>
  56. </view>
  57. </u-form-item>
  58. <u-form-item borderBottom ref="item1">
  59. <view>备注</view>
  60. <u-input v-model="form.remark" type="textarea" placeholder="请输入备注" ></u-input>
  61. </u-form-item>
  62. </u-form>
  63. <u-button style="background: #2d95f4;color: #fff;border-radius: 20rpx;" @click="save()" v-if="type!=1"
  64. type='primary'>确认上传</u-button>
  65. <u-button style="background: #2d95f4;color: #fff;border-radius: 20rpx;" @click="update()"
  66. type='primary' v-else>确认修改</u-button>
  67. </view>
  68. <view>
  69. <u-popup v-model="showBoxDetails" height= "400px" border-radius="14" mode=bottom closeable=true close-icon-color="#000000">
  70. <image src="https://cczdsz.cn/app/images/background.png" class="background"></image>
  71. <view>
  72. <u-form :model="boxform" ref="boxform">
  73. <view style="text-align:center; font-size: 40rpx;">阀井详情</view>
  74. <view class="project-content" style="margin-top: 20px;">
  75. <u-form-item label="阀井名称" borderBottom ref="item1" placeholder=" " labelWidth="200" >
  76. <u-input v-model="boxform.valveWellName" disabled></u-input>
  77. </u-form-item>
  78. <u-form-item label="位置" borderBottom ref="item1" placeholder=" " labelWidth="200" >
  79. <u-input v-model="boxform.position" placeholder=" " disabled></u-input>
  80. </u-form-item>
  81. <u-form-item label="经度" borderBottom ref="item1" placeholder=" " labelWidth="200" >
  82. <u-input v-model="boxform.longitude" placeholder=" " disabled></u-input>
  83. </u-form-item>
  84. <u-form-item label="纬度" borderBottom ref="item1" placeholder=" " labelWidth="200" >
  85. <u-input v-model="boxform.latitude" placeholder=" " disabled></u-input>
  86. </u-form-item>
  87. <u-form-item label="控制区域" borderBottom ref="item1" placeholder=" " labelWidth="200" >
  88. <u-input v-model="boxform.remark" placeholder=" " disabled></u-input>
  89. </u-form-item>
  90. </view>
  91. </u-form>
  92. </view>
  93. </u-popup>
  94. </view>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import service from '@/api/index.js'
  100. export default {
  101. data() {
  102. return {
  103. repairType: [{
  104. label: '施工问题',
  105. value: 1
  106. }, {
  107. label: '施工问题',
  108. value: 2
  109. }, ],
  110. showrepairType: false,
  111. action: this.$HTTP.webUrl + `/obs`,
  112. headers: {
  113. MAuthorization: "wxBearer " + uni.getStorageSync('token')
  114. },
  115. url: [],
  116. showposition:false,
  117. params: {
  118. year: true,
  119. month: true,
  120. day: true,
  121. hour: true,
  122. minute: true,
  123. second: false
  124. },
  125. uploading: false,
  126. showtime:false,
  127. imgArr: [],
  128. imgymxs: [],
  129. progress: 0, //图片或视频上传百分比
  130. form: {discoverProblems:1},
  131. typelist: [],
  132. causesOfFamageLabel: null,
  133. dictlist: ['find_problem'],
  134. buildingName: null,
  135. unit: null,
  136. unitName: null,
  137. showbuilding: false,
  138. showunit: false,
  139. buildingList: [],
  140. unitList: [],
  141. type: 2,
  142. id: null,
  143. community: null,
  144. createBy:null,
  145. valveWellName:null,
  146. position:null,
  147. showBoxDetails:false,
  148. boxform:{},
  149. managementOfficeId:null,
  150. }
  151. },
  152. onLoad(e) {
  153. // this.building = e.building
  154. // this.buildingName = e.buildingName
  155. // this.community = e.community
  156. // this.unitName = e.unitName
  157. // this.unit = e.unit
  158. this.id = e.id
  159. this.managementOfficeId=e.managementOfficeId
  160. this.type = e.type
  161. console.log(e)
  162. this.getdictsysinfo()
  163. uni.setNavigationBarTitle({
  164. title: '阀井巡查'
  165. });
  166. uni.setNavigationBarColor({
  167. frontColor: '#ffffff',
  168. backgroundColor: '#2d95f4',
  169. })
  170. if (this.type != 1) {
  171. //this.getBuildingList()
  172. this.valveWellName=e.valveWellName
  173. this.position=e.position
  174. this.form.valveWellName=this.valveWellName
  175. this.form.position=this.position
  176. }
  177. this.getUserName()
  178. },
  179. methods: {
  180. BoxDetails()
  181. {
  182. service.getvalveWellPositionId(this.managementOfficeId).then(res=>{
  183. this.boxform=res
  184. this.showBoxDetails=true
  185. })
  186. },
  187. time(e) {
  188. console.log(`${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`)
  189. this.form.discoverTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}`
  190. },
  191. checksamplingMeterCount(e) {
  192. console.log(e)
  193. //正则表达试
  194. e = (e.match(/^\d*(\.?\d{0,10})/g)[0]) || null
  195. //重新赋值给input
  196. this.$nextTick(() => {
  197. this.form.samplingMeterCount= e
  198. })
  199. },
  200. getUserName(){
  201. service.getUserName().then(res=>{
  202. this.userId=res.id
  203. this.createBy=res.name
  204. })
  205. },
  206. // showPhoto(index) {
  207. // uni.previewImage({
  208. // current: index,
  209. // urls: this.imgArr,
  210. // })
  211. // },
  212. // showPhotos(index) {
  213. // uni.previewImage({
  214. // current: index,
  215. // urls: this.photo,
  216. // })
  217. // },
  218. buildingconfirm(e) {
  219. this.position = e[0].label
  220. this.building = e[0].value
  221. console.log(this.building)
  222. //this.getUnitList(e[0].value)
  223. },
  224. // unitconfirm(e) {
  225. // this.unitName = e[0].label
  226. // this.unit = e[0].value
  227. // },
  228. // getBuildingList() {
  229. // const _this = this
  230. // service.getBuildingList({
  231. // areaId: this.community
  232. // }).then(res => {
  233. // _this.buildingList = res
  234. // })
  235. // },
  236. // getUnitList(building) {
  237. // const _this = this
  238. // service.getUnitList({
  239. // buildingId: building
  240. // }).then(res => {
  241. // _this.unitList = res
  242. // })
  243. // },
  244. update()
  245. {
  246. let _this = this
  247. this.form.photoList = this.imgArr
  248. // if(this.building==null)
  249. // {
  250. // uni.showToast({
  251. // title: '请选择楼栋',
  252. // icon: 'none'
  253. // })
  254. // return
  255. // }
  256. if(this.imgArr.length==0)
  257. {
  258. uni.showToast({
  259. title: '请上传图片或视频!',
  260. icon: 'none'
  261. })
  262. return
  263. }
  264. // this.form.buildingId = this.building
  265. // this.form.communityId=this.community
  266. this.form.userId=this.userId
  267. this.form.processStatus = -1
  268. this.form.createBy=this.userId
  269. this.form.positionId=this.id
  270. service.updatevalveWellPosition(this.form).then(res => {
  271. console.log(res)
  272. _this.$UTILS.showPrompt('修改成功!')
  273. // setTimeout(() => {
  274. // console.log('跳')
  275. // uni.switchTab({
  276. // url: '/pages/index/index'
  277. // })
  278. // }, 2000)
  279. // this.form={discoverProblems:1}
  280. // this.form.valveWellName=this.valveWellName
  281. // this.form.position=this.position
  282. // // this.buildingName=''
  283. // this.imgArr=[]
  284. // this.imgymxs=[]
  285. })
  286. },
  287. save() {
  288. let _this = this
  289. this.form.photoList = this.imgArr
  290. // if(this.building==null)
  291. // {
  292. // uni.showToast({
  293. // title: '请选择楼栋',
  294. // icon: 'none'
  295. // })
  296. // return
  297. // }
  298. if(this.imgArr.length==0)
  299. {
  300. uni.showToast({
  301. title: '请上传图片或视频!',
  302. icon: 'none'
  303. })
  304. return
  305. }
  306. // this.form.buildingId = this.building
  307. // this.form.communityId=this.community
  308. this.form.userId=this.userId
  309. this.form.createBy=this.userId
  310. this.form.positionId=this.id
  311. service.setvalveWellPosition(this.form).then(res => {
  312. console.log(res)
  313. _this.$UTILS.showPrompt('上报成功!')
  314. // setTimeout(() => {
  315. // console.log('跳')
  316. // uni.switchTab({
  317. // url: '/pages/index/index'
  318. // })
  319. // }, 2000)
  320. this.form={discoverProblems:1}
  321. this.form.valveWellName=this.valveWellName
  322. this.form.position=this.position
  323. // this.buildingName=''
  324. this.imgArr=[]
  325. this.imgymxs=[]
  326. })
  327. },
  328. getdictsysinfo() {
  329. let _this = this
  330. service.getDictInfoList({
  331. type: this.dictlist
  332. }).then(res => {
  333. if (this.type == 1) {
  334. let _this = this
  335. console.log(this.id)
  336. service.getvalveWellPosition(this.id).then(res => {
  337. if (null != res.photoList) {
  338. res.photoList.forEach(item => {
  339. let url = {}
  340. url.url = item
  341. url.type = 'image'
  342. this.imgymxs.push(url)
  343. this.imgArr.push(item)
  344. })
  345. }
  346. this.form = res
  347. res.valveWellName=res.position.valveWellName
  348. //this.form.valveWellName=res.position.valveWellName
  349. this.form.position=res.position.position
  350. this.managementOfficeId=res.positionId
  351. console.log('123123',res)
  352. })
  353. }
  354. _this.typelist = res
  355. console.log(res)
  356. })
  357. },
  358. confirm(e) {
  359. this.form.findProblem =e
  360. },
  361. choose() {
  362. let _this = this;
  363. uni.showActionSheet({
  364. title: '上传',
  365. itemList: ['图片', '视频'],
  366. success: (res) => {
  367. // console.log(res)
  368. if (res.tapIndex == 0) {
  369. this.chooseimage()
  370. } else {
  371. this.choosevideo()
  372. }
  373. }
  374. })
  375. },
  376. chooseimage() {
  377. console.log('图片')
  378. let _this = this;
  379. uni.chooseImage({
  380. sourceType: ['camera'],
  381. success(resp) {
  382. console.log('res--uni.chooseMedia', resp);
  383. resp.tempFiles.forEach((item, index) => {
  384. const task = uni.uploadFile({
  385. url: _this.$HTTP.webUrl + `/obs`,
  386. filePath: item.path,
  387. name: 'file',
  388. formData: {},
  389. header: _this.headers,
  390. success: res => {
  391. // 判断是否json字符串,将其转为json格式
  392. let data = _this.$u.test.jsonString(res.data) ? JSON.parse(
  393. res.data) : res.data;
  394. if (![200, 201, 204].includes(res.statusCode)) {
  395. // this.uploadError(index, data);
  396. _this.$UTILS.showPrompt('选取失败!')
  397. } else {
  398. // 上传成功
  399. // this.lists[index].response = data;
  400. // this.lists[index].progress = 100;
  401. // this.lists[index].error = false;
  402. // this.$emit('on-success', data, index, this.lists, this
  403. // .index);
  404. if (_this.progress === 100) {
  405. // console.log('_this.progress', _this.progress)
  406. // console.log('data----', data)
  407. // console.log('res--', res)
  408. _this.imgymxs.push({
  409. url: data.data.url,
  410. type: 'image'
  411. })
  412. _this.imgArr.push(data.data.url)
  413. // console.log('imgArr', _this.imgArr)
  414. _this.$UTILS.showPrompt('选取成功!')
  415. }
  416. }
  417. },
  418. fail: e => {
  419. _this.$UTILS.showPrompt('选取失败!')
  420. this.uploadError(index, e);
  421. },
  422. complete: res => {
  423. _this.uploading = false;
  424. // _this.uploadFile(index + 1);
  425. // this.$emit('on-change', res, index, this.lists, this
  426. // .index);
  427. }
  428. });
  429. task.onProgressUpdate(res => {
  430. // if (res.progress > 0) {
  431. // this.lists[index].progress = res.progress;
  432. // this.$emit('on-progress', res, index, this.lists, this.index);
  433. // }
  434. _this.progress = res.progress;
  435. console.log('onProgressUpdate', res)
  436. uni.showLoading({
  437. title: '选取中'
  438. })
  439. });
  440. })
  441. },
  442. })
  443. },
  444. choosevideo() {
  445. let _this = this;
  446. console.log('视频')
  447. uni.chooseVideo({
  448. sourceType: ['camera'],
  449. maxDuration: 30,
  450. success(resp) {
  451. const task = uni.uploadFile({
  452. url: _this.$HTTP.webUrl + `/obs`,
  453. filePath: resp.tempFilePath,
  454. name: 'file',
  455. formData: {},
  456. header: _this.headers,
  457. success: res => {
  458. // 判断是否json字符串,将其转为json格式
  459. let data = _this.$u.test.jsonString(res.data) ? JSON.parse(res.data) :
  460. res.data;
  461. if (![200, 201, 204].includes(res.statusCode)) {
  462. this.uploadError(index, data);
  463. } else {
  464. // 上传成功
  465. // this.lists[index].response = data;
  466. // this.lists[index].progress = 100;
  467. // this.lists[index].error = false;
  468. // this.$emit('on-success', data, index, this.lists, this
  469. // .index);
  470. if (_this.progress === 100) {
  471. console.log('_this.progress', _this.progress)
  472. console.log('data----', data)
  473. console.log('res--', res)
  474. // _this.imgArr.push(data.data.url)
  475. _this.imgymxs.push({
  476. url: data.data.url,
  477. type: 'video'
  478. })
  479. _this.imgArr.push(data.data.url)
  480. console.log('imgArr', _this.imgArr)
  481. _this.$UTILS.showPrompt('选取成功!')
  482. }
  483. }
  484. },
  485. fail: e => {
  486. _this.$UTILS.showPrompt('选取失败!')
  487. this.uploadError(index, e);
  488. },
  489. complete: res => {
  490. uni.hideLoading();
  491. _this.uploading = false;
  492. // _this.uploadFile(index + 1);
  493. // this.$emit('on-change', res, index, this.lists, this
  494. // .index);
  495. }
  496. });
  497. task.onProgressUpdate(res => {
  498. // if (res.progress > 0) {
  499. // this.lists[index].progress = res.progress;
  500. // this.$emit('on-progress', res, index, this.lists, this.index);
  501. // }
  502. _this.progress = res.progress;
  503. console.log('onProgressUpdate', res)
  504. uni.showLoading({
  505. title: '选取中'
  506. })
  507. });
  508. },
  509. })
  510. },
  511. remove(index) {
  512. uni.showModal({
  513. title: '提示',
  514. content: '是否删除该图片或视频?',
  515. success: (res) => {
  516. if (res.confirm) {
  517. this.imgArr.splice(index, 1);
  518. this.imgymxs.splice(index, 1);
  519. console.log('this.imgarr', this.imgArr)
  520. }
  521. }
  522. })
  523. },
  524. }
  525. }
  526. </script>
  527. <style>
  528. .project-content {
  529. padding: 10rpx 20rpx;
  530. border-radius: 20rpx;
  531. background: #fff;
  532. width: 90%;
  533. margin: 0 auto;
  534. }
  535. .background {
  536. z-index: -1;
  537. position: fixed;
  538. width: 100%;
  539. height: 100%;
  540. background-size: 100% 100%;
  541. }
  542. .small-title {
  543. font-size: 38rpx;
  544. color: #2d95f4;
  545. margin: 20rpx 0;
  546. }
  547. </style>