patrolFleet.vue 17 KB

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