emergencyRepairOrder.vue 15 KB

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