emergencyRepairOrder.vue 20 KB

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