RepairDetails.vue 18 KB

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