patrolFleet.vue 13 KB

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