patrolFleet.vue 13 KB

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