emergencyRepairOrder.vue 14 KB

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