emergencyRepairOrder.vue 20 KB

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