valveWellInspection.vue 12 KB

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