RepairDetails.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. <template>
  2. <view>
  3. <!-- 状态 -->
  4. <view class="label" v-if="(form.status == 2 || form.status == 3 || form.status == 4) && userInfoRoleName.indexOf('admin') == -1">
  5. <view class="tab" ref="wx" :style="{'color':wxStyle,'height':'100%','border-right': '1rpx solid #f4f4f4'}" @click="tab('wx')">
  6. <text>报修单</text>
  7. </view>
  8. <view class="tab" ref="gz" :style="{'color':gzStyle,'height':'100%','border-left': '1rpx solid #f4f4f4'}" @click="tab('gz')">
  9. <text>工作单</text>
  10. </view>
  11. </view>
  12. <view class="repairdetails" v-if="form.status == 1">
  13. <view class="cardBox">
  14. <!-- <view class="text">设备信息:</view> -->
  15. <u-input v-model="form.deviceName" disabledColor="#fff" disabled
  16. border="none" placeholder="请选择设备信息" >
  17. <template slot="suffix">
  18. <u-icon name="scan" color="#bbb" size="32"></u-icon>
  19. </template>
  20. </u-input>
  21. </view>
  22. <view class="cardBox">
  23. <!-- <view class="text">客户名称:</view> -->
  24. <u-input v-model="form.corpName" disabled disabledColor="#fff"
  25. border="none" placeholder="客户名称" ></u-input>
  26. </view>
  27. <view class="cardBox">
  28. <!-- <view class="text">地址:</view> -->
  29. <u-input v-model="form.deviceAddress" disabledColor="#fff" disabled
  30. border="none" placeholder="设备地址" ></u-input>
  31. </view>
  32. <view class="cardBox">
  33. <!-- <view class="text">故障描述:</view> -->
  34. <u--textarea v-model="form.faultDescribe" placeholder="故障描述" disabled
  35. border="none" >
  36. </u--textarea>
  37. </view>
  38. <view class="kapian">
  39. <!-- <view style="font-size: 30rpx;color: #999;margin-left: 10rpx;">添加图片</view> -->
  40. <view style="margin-top: 20rpx;">
  41. <u-upload
  42. :fileList="form.maintenanceFiles"
  43. :disabled="form.status != 3"
  44. @afterRead="afterRead"
  45. @delete="deletePic"
  46. name="1"
  47. multiple
  48. :maxCount="10"
  49. ></u-upload>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="repairdetails" v-if="wxStyle != ''">
  54. <view class="cardBox">
  55. <!-- <view class="text">设备信息:</view> -->
  56. <u-input v-model="form.deviceName" disabledColor="#fff" disabled
  57. border="none" placeholder="请选择设备信息" >
  58. <template slot="suffix">
  59. <u-icon name="scan" color="#bbb" size="32"></u-icon>
  60. </template>
  61. </u-input>
  62. </view>
  63. <view class="cardBox">
  64. <!-- <view class="text">客户名称:</view> -->
  65. <u-input v-model="form.corpName" disabled disabledColor="#fff"
  66. border="none" placeholder="客户名称" ></u-input>
  67. </view>
  68. <view class="cardBox">
  69. <!-- <view class="text">地址:</view> -->
  70. <u-input v-model="form.deviceAddress" disabledColor="#fff" disabled
  71. border="none" placeholder="设备地址" ></u-input>
  72. </view>
  73. <view class="cardBox">
  74. <!-- <view class="text">故障描述:</view> -->
  75. <u--textarea v-model="form.faultDescribe" placeholder="故障描述" disabled
  76. border="none" >
  77. </u--textarea>
  78. </view>
  79. <view class="kapian">
  80. <!-- <view style="font-size: 30rpx;color: #999;margin-left: 10rpx;">添加图片</view> -->
  81. <view style="margin-top: 20rpx;">
  82. <u-upload
  83. :fileList="form.maintenanceFiles"
  84. :disabled="form.status != 3"
  85. @afterRead="afterRead"
  86. @delete="deletePic"
  87. name="1"
  88. multiple
  89. :maxCount="10"
  90. ></u-upload>
  91. </view>
  92. </view>
  93. </view>
  94. <view class="repairdetails" v-if="gzStyle != ''">
  95. <view class="cardBox">
  96. <!-- <view class="text">设备信息:</view> -->
  97. <u-input v-model="form.deviceName" disabledColor="#fff" disabled
  98. border="none" placeholder="请选择设备信息" >
  99. <template slot="suffix">
  100. <u-icon name="scan" color="#bbb" size="32"></u-icon>
  101. </template>
  102. </u-input>
  103. </view>
  104. <view class="cardBox">
  105. <u--textarea v-model="form.repairDescription" placeholder="维修描述" border="none" :disabled="form.status != 3" >
  106. </u--textarea>
  107. </view>
  108. <view class="kapian">
  109. <!-- <view style="font-size: 30rpx;color: #999;margin-left: 10rpx;">添加图片</view> -->
  110. <view style="margin-top: 20rpx;">
  111. <u-upload
  112. :fileList="form.maintenanceFiles"
  113. :disabled="form.status != 3"
  114. @afterRead="afterRead"
  115. @delete="deletePic"
  116. name="1"
  117. multiple
  118. :maxCount="10"
  119. ></u-upload>
  120. </view>
  121. </view>
  122. <view >
  123. <view class="kapian" v-for="(item,index) in form.maintenanceFees" :key="item.id">
  124. <view class="WXflex">
  125. <view class="wxscfun" v-if="form.status == 3" @click="maintenanceDe(item,index)">删除</view>
  126. </view>
  127. <view class="repairProject">
  128. <view class="wxbox">
  129. <u-input v-model="item.costName" disabledColor="#fff" :disabled="form.status != 3"
  130. border="none" placeholder="添加项目" ></u-input>
  131. </view>
  132. <view class="wxbox">
  133. <u-input v-model="item.amount" disabledColor="#fff" :disabled="form.status != 3"
  134. border="none" inputAlign="right" @input="moneyInput" placeholder="金额" >
  135. <u--text
  136. text="元"
  137. slot="suffix"
  138. margin="0 3px 0 0"
  139. type="tips"
  140. ></u--text>
  141. </u-input>
  142. </view>
  143. </view>
  144. </view>
  145. </view>
  146. <view class="kapian" >
  147. <view class="wxtitleflex">
  148. <view class="wxtitle">添加费用</view>
  149. <view v-if="form.status == 3 && type != 'XQ'" class="addwx" @click="wxaddfun">添加</view>
  150. </view>
  151. </view>
  152. </view>
  153. <u-gap height="60"></u-gap>
  154. <view class="bottombox" v-if="type != 'XQ'">
  155. <view class="bottombox_name" v-if="form.status != 3 && form.status != 1">
  156. <text>{{form.maintenanceWorkerName}}</text>
  157. </view>
  158. <view class="bottombox_name" @click="pickerShowfun" v-if="form.status == 1 && userInfoRoleName.indexOf('admin') != -1">
  159. <text>{{form.maintenanceWorkerName == null || form.maintenanceWorkerName == '' ? '请选择维修工' : form.maintenanceWorkerName}}</text>
  160. </view>
  161. <view v-if="form.status == 3" style="color: #FD4B09;">维修费:{{form.maintenanceAmount}}元</view>
  162. <view class="bottombox_right">
  163. <view class="buttonClass"
  164. v-if="form.status == 1 && userInfoRoleName.indexOf('admin') != -1"
  165. @click="maintenanceDispatchingWorkersfun">确认派工</view>
  166. <view class="buttonClass"
  167. v-if="form.status == 2 && userInfoRoleName.indexOf('admin') != -1"
  168. @click="maintenanceRevokeDispatchingWorkersfun">撤销派工</view>
  169. <view class="buttonClass" v-if="form.status == 2 && userInfoRoleName.indexOf('维修工') != -1" @click="receivingOrdersfun">确认接单</view>
  170. <view class="buttonClass" v-if="form.status == 3" @click="Confirmexpenses">确认费用</view>
  171. <view class="buttonClass" v-if="form.status == 4" @click="Confirmexpenses">确认结算</view>
  172. </view>
  173. </view>
  174. <u-picker :show="pickerShow" :columns="pickerList" keyName="name"
  175. @confirm="pickerShowConfirm" @cancel="pickerShowCancel"></u-picker>
  176. <u-toast ref="uToast"></u-toast>
  177. </view>
  178. </template>
  179. <script>
  180. import {
  181. maintenanceDetail,
  182. maintenanceReceivingOrders,
  183. maintenanceConfirm,
  184. userList,
  185. maintenanceDispatchingWorkers,
  186. maintenanceRevokeDispatchingWorkers
  187. } from '@/api/device/index.js'
  188. import http from '@/http/api.js'
  189. import {
  190. clientId,
  191. clientSecret
  192. } from '@/common/setting'
  193. export default {
  194. data() {
  195. return {
  196. id:null,
  197. wxStyle: '',
  198. gzStyle: '',
  199. range: [
  200. { value: 0, text: "篮球" },
  201. { value: 1, text: "足球" },
  202. { value: 2, text: "游泳" },
  203. ],
  204. form:{
  205. maintenanceFees:[
  206. {
  207. id:null,
  208. costId:null,
  209. costName:null,
  210. number:1,
  211. price:null,
  212. amount:null,
  213. currency:'CNY',
  214. settlementAmount:null,
  215. remarks:null,
  216. }
  217. ]
  218. },
  219. // 弹窗的开启
  220. pickerShow:false,
  221. pickerList:[],
  222. userInfoRoleName:[]
  223. }
  224. },
  225. onLoad(e) {
  226. this.id = e.id
  227. this.type = e.type
  228. this.userInfoRoleName = uni.getStorageSync('userInfo').role_name.split(',')
  229. this.maintenanceDetailfun()
  230. },
  231. onShow() {
  232. },
  233. methods: {
  234. moneyInput() {
  235. var money = 0
  236. for (let fees of this.form.maintenanceFees) {
  237. money += Number(fees.amount)
  238. }
  239. this.form.maintenanceAmount = money;
  240. },
  241. tab(type) {
  242. if(type == "wx") {
  243. this.wxStyle = "#fd4b09"
  244. this.gzStyle = ""
  245. // this.form.status = 2
  246. } else if (type == "gz") {
  247. this.gzStyle = "#fd4b09"
  248. this.wxStyle = ""
  249. // this.form.status = 3
  250. }
  251. },
  252. // 设备删除
  253. maintenanceDe(row,index){
  254. this.form.maintenanceFees.splice(index,1)
  255. this.moneyInput()
  256. },
  257. // 撤销派工
  258. maintenanceRevokeDispatchingWorkersfun(){
  259. maintenanceRevokeDispatchingWorkers(this.form).then(res=>{
  260. if (res.code == 200) {
  261. this.$refs.uToast.show({
  262. type: 'success',
  263. message: "撤销派工成功",
  264. })
  265. this.form = res.data
  266. }else {
  267. this.$refs.uToast.show({
  268. type: 'error',
  269. message: res.msg,
  270. })
  271. }
  272. })
  273. },
  274. // 派工
  275. maintenanceDispatchingWorkersfun(){
  276. if (!this.form.maintenanceWorkerId) {
  277. return this.$refs.uToast.show({type: 'warning',message: '请选择维修工'})
  278. }
  279. // if (!this.form.maintenanceWorkerTel) {
  280. // return this.$refs.uToast.show({type: 'warning',message: '请输入维修工电话'})
  281. // }
  282. maintenanceDispatchingWorkers(this.form).then(res=>{
  283. if (res.code == 200) {
  284. this.$refs.uToast.show({
  285. type: 'success',
  286. message: "派工成功",
  287. })
  288. this.form = res.data
  289. }else {
  290. this.$refs.uToast.show({
  291. type: 'error',
  292. message: res.msg,
  293. })
  294. }
  295. })
  296. },
  297. // 维修工弹窗开启
  298. pickerShowfun(){
  299. this.pickerShow = true
  300. this.userListfun()
  301. },
  302. // 维修工获取
  303. userListfun(){
  304. userList({roleAlias:'维修工'}).then(res=>{
  305. this.pickerList = [res.data]
  306. })
  307. },
  308. // 维修工弹窗的确认
  309. pickerShowConfirm(e){
  310. console.log(e.value[0],181);
  311. this.form.maintenanceWorkerId = e.value[0].id
  312. this.form.maintenanceWorkerName = e.value[0].name
  313. this.form.maintenanceWorkerTel = e.value[0].phone
  314. this.pickerShow = false
  315. },
  316. // 维修工弹窗取消
  317. pickerShowCancel() {
  318. this.pickerShow = false
  319. },
  320. // 维修费用的添加
  321. wxaddfun(){
  322. this.form.maintenanceFees.push({
  323. id:null,
  324. costId:null,
  325. costName:null,
  326. number:1,
  327. price:null,
  328. amount:null,
  329. currency:'CNY',
  330. settlementAmount:null,
  331. remarks:null,
  332. })
  333. },
  334. // 确认费用
  335. Confirmexpenses(){
  336. let a = true
  337. if (this.form.maintenanceFees.length <= 0) {
  338. return this.$refs.uToast.show({type: 'warning',message: '请添加维修费用'})
  339. }else {
  340. this.form.maintenanceFees.map((item,index)=>{
  341. if (!item.costName) {
  342. this.$refs.uToast.show({type: 'warning',message: `请填写序号${index + 1}的费用名称`})
  343. a = false
  344. return
  345. }
  346. if (!item.amount) {
  347. this.$refs.uToast.show({type: 'warning',message: `请填写序号${index + 1}的金额`})
  348. a = false
  349. return
  350. }
  351. })
  352. if (a == false) return
  353. maintenanceConfirm(this.form).then(res=>{
  354. if (res.code == 200) {
  355. this.$refs.uToast.show({
  356. type: 'success',
  357. message: "接单成功",
  358. })
  359. // uni.navigateBack({
  360. // delta: 1
  361. // });
  362. this.form = res.data
  363. }else {
  364. this.$refs.uToast.show({
  365. type: 'error',
  366. message: res.msg,
  367. })
  368. }
  369. })
  370. }
  371. },
  372. // 确认接单接口
  373. receivingOrdersfun(){
  374. maintenanceReceivingOrders(this.form).then(res=>{
  375. console.log(res,180);
  376. if (res.code == 200) {
  377. this.$refs.uToast.show({
  378. type: 'success',
  379. message: "接单成功",
  380. })
  381. this.form = res.data
  382. }else {
  383. this.$refs.uToast.show({
  384. type: 'error',
  385. message: res.msg,
  386. })
  387. }
  388. })
  389. },
  390. // 维修设备详情
  391. maintenanceDetailfun(){
  392. maintenanceDetail({id:this.id}).then(res=>{
  393. this.form = res.data
  394. if (this.form.status == 3) {
  395. this.gzStyle = "#fd4b09"
  396. this.wxStyle = ""
  397. } else if (this.form.status == 2) {
  398. console.log(this.form.status);
  399. this.wxStyle = "#fd4b09"
  400. this.gzStyle = ""
  401. } else if (this.form.status == 1) {
  402. userList({roleAlias:'维修工'}).then(res=>{
  403. this.wxUserList = [res.data]
  404. })
  405. }
  406. // if (this.type == 'JD') {
  407. // this.form.maintenanceFees.push({
  408. // id:null,
  409. // costId:null,
  410. // costName:null,
  411. // number:1,
  412. // price:null,
  413. // amount:null,
  414. // currency:'CNY',
  415. // settlementAmount:null,
  416. // remarks:null,
  417. // })
  418. // }
  419. })
  420. },
  421. // 图片删除
  422. deletePic(e){
  423. if(e.file.uploadType == 0) return this.$refs.uToast.show({ type: 'warning', message: '请勿删除客户添加的图片',})
  424. this.form.maintenanceFiles.splice(e.index,1)
  425. },
  426. // 上传图片
  427. async afterRead(event){
  428. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  429. let lists = [].concat(event.file)
  430. console.log(lists);
  431. let fileListLen = this.form.maintenanceFiles.length
  432. lists.map((item) => {
  433. this.form.maintenanceFiles.push({
  434. uploadType:1,
  435. ...item
  436. })
  437. })
  438. for (let i = 0; i < lists.length; i++) {
  439. const result = await this.uploadFilePromise(lists[i].url)
  440. let item = this.form.maintenanceFiles[fileListLen]
  441. this.form.maintenanceFiles.splice(fileListLen, 1, Object.assign(item, {
  442. sort: this.form.maintenanceFiles.length,
  443. fileName: JSON.parse(result).data.originalName,
  444. url: JSON.parse(result).data.link
  445. }))
  446. fileListLen++
  447. }
  448. },
  449. uploadFilePromise(url) {
  450. return new Promise((resolve, reject) => {
  451. let a = uni.uploadFile({
  452. url: http.config.baseURL +
  453. '/blade-resource/oss/endpoint/put-file', // 仅为示例,非真实的接口地址
  454. filePath: url,
  455. name: 'file',
  456. formData: {
  457. user: 'test'
  458. },
  459. header: {
  460. // 客户端认证参数
  461. 'Authorization': 'Basic ' + Base64.encode(clientId + ':' +
  462. clientSecret),
  463. 'Blade-Auth': 'bearer ' + uni.getStorageSync('accessToken')
  464. },
  465. success: (res) => {
  466. setTimeout(() => {
  467. resolve(res.data)
  468. }, 1000)
  469. }
  470. });
  471. })
  472. },
  473. }
  474. }
  475. </script>
  476. <style lang="scss" scoped>
  477. .label {
  478. left: 0rpx;
  479. top: 190rpx;
  480. width: 100%;
  481. height: 114rpx;
  482. line-height: 40rpx;
  483. background-color: rgba(255, 255, 255, 1);
  484. text-align: center;
  485. display: flex;
  486. align-items: center;
  487. .tab {
  488. width: 50%;
  489. display: flex;
  490. color: #c4c4c4;
  491. align-items: center;
  492. justify-content: center;
  493. font-size: 40rpx;
  494. text-align: left;
  495. font-family: PingFangSC-semiBold;
  496. }
  497. }
  498. .repairdetails {
  499. padding: 20rpx;
  500. box-sizing: border-box;
  501. }
  502. .cardBox {
  503. background: #fff;
  504. border-radius: 12rpx;
  505. width: 100%;
  506. padding: 30rpx;
  507. box-sizing: border-box;
  508. margin-bottom: 20rpx;
  509. display: flex;
  510. align-items: center;
  511. justify-content: center;
  512. }
  513. .text {
  514. font-size: 30rpx;
  515. color: #999;
  516. margin-right: 10rpx;
  517. }
  518. .kapian {
  519. background: #fff;
  520. border-radius: 12rpx;
  521. width: 100%;
  522. padding: 30rpx;
  523. box-sizing: border-box;
  524. margin-bottom: 20rpx;
  525. .repairProject {
  526. display: flex;
  527. }
  528. .wxtitleflex {
  529. display: flex;
  530. align-items: center;
  531. justify-content: space-between;
  532. }
  533. .wxtitle {
  534. font-size: 34rpx;
  535. color: #888;
  536. }
  537. .wxbox {
  538. border-bottom: 2rpx solid #eee;
  539. display: flex;
  540. align-items: center;
  541. justify-content: center;
  542. padding: 20rpx 0;
  543. margin: 10rpx 0;
  544. }
  545. .addwx {
  546. color: #dd451b;
  547. font-size: 30rpx;
  548. padding: 10rpx 20rpx;
  549. border: 2rpx solid;
  550. border-radius: 30rpx;
  551. }
  552. .WXflex {
  553. display: flex;
  554. justify-content: space-between;
  555. align-items: center;
  556. .xuhao {
  557. font-size: 32rpx;
  558. color: #101010;
  559. }
  560. .wxscfun {
  561. color: red;
  562. font-size: 30rpx;
  563. padding: 10rpx 20rpx;
  564. border: 2rpx solid;
  565. border-radius: 28rpx;
  566. }
  567. }
  568. }
  569. .bottombox {
  570. position: fixed;
  571. bottom: 0;
  572. width: 100%;
  573. height: 120rpx;
  574. background: #fff;
  575. box-shadow: 0rpx 4rpx 4rpx 4rpx rgba(0, 0, 0, 0.5);
  576. padding: 0 40rpx;
  577. box-sizing: border-box;
  578. display: flex;
  579. justify-content: space-between;
  580. align-items: center;
  581. .bottombox_name {
  582. font-size: 38rpx;
  583. color: #101010;
  584. }
  585. .bottombox_right {
  586. display: flex;
  587. .buttonClass {
  588. // background: #2d4a6a;
  589. background: #FD4B09;
  590. padding: 10rpx 60rpx;
  591. border-radius: 30rpx;
  592. color: #fff;
  593. // font-weight: bold;
  594. // margin: 0 10rpx;
  595. }
  596. }
  597. }
  598. </style>