RepairDetails.vue 17 KB

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