emergencyRepairOrder.vue 15 KB

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