emergencyRepairOrder.vue 19 KB

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