x-orderManagement.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. <template>
  2. <view style="width: 100%;">
  3. <view class="card_ordermang" v-for="(item,index) in orderList" :key="index" @click="goOrderDetails(item)">
  4. <view class="head_ordermang space_between">
  5. <view class="waybill_title">运单号:<span>{{item.waybillNo}}</span></view>
  6. <span class="card_state" :style="{color:getState(item.status)}">{{orderStatus(item.status)}}</span>
  7. </view>
  8. <view class="title_ordermang"><span>订单号:</span>{{item.orderNo}}</view>
  9. <view class="title_ordermang"><span>收货人地址:</span>{{item.consigneeAddressDetails}}</view>
  10. <view class="title_ordermang"><span>收货人电话:</span>{{item.consigneeAddressPhone}}</view>
  11. <view class="title_ordermang"><span>下单时间:</span>{{item.orderTime}}</view>
  12. <view style="display: flex;margin-top: 15rpx;"
  13. v-if="item.status == 1 || item.status == 2 || item.status == 3">
  14. <!-- <view class="btn_printil markd10"
  15. @click.stop="modifyOrder(item)">
  16. <u-button size="small" type="warning" text="修改运单"></u-button>
  17. </view>
  18. <view class="btn_printil markd10" @click.stop="antiDismantle(item)">
  19. <u-button size="small" type="primary" text="防拆标签"></u-button>
  20. </view>
  21. <view class="btn_printil markd10" @click.stop="sendOrders(item)">
  22. <u-button size="small" type="success" text="派单"></u-button>
  23. </view> -->
  24. <view class="btn_printil markd10" @click.stop="toDeliver(item)">
  25. <u-button size="small" type="success" text="去配送"></u-button>
  26. </view>
  27. </view>
  28. <view style="display: flex;" v-if="item.status == 4 && !item.is_secondary_distribution">
  29. <view class="btn_printil markd10" @click.stop="rejection(item)">
  30. <u-button size="small" type="error" text="拒收"></u-button>
  31. </view>
  32. <view class="btn_printil markd10" @click.stop="signFor(item)">
  33. <u-button size="small" type="primary" text="签收"></u-button>
  34. </view>
  35. </view>
  36. <view style="display: flex;" v-else-if="item.status == 4 && item.is_secondary_distribution">
  37. <view class="btn_printil markd10" @click.stop="finished(item)">
  38. <u-button size="small" type="success" text="已完成"></u-button>
  39. </view>
  40. <view class="btn_printil markd10" @click.stop="distributionOrder(item)">
  41. <u-button size="small" type="primary" text="分配订单"></u-button>
  42. </view>
  43. </view>
  44. </view>
  45. <u-popup :show="signForShow" mode="center" round="6" closeable :closeOnClickOverlay="false" @close="close">
  46. <view class="center_in title_sign">{{signRejection}}</view>
  47. <view class="card_sign_for">
  48. <view class="img_sign_rejection">运单号: {{orderNumber}}</view>
  49. <view style="margin-bottom: 20rpx;" v-if="!rejectionFlag">
  50. <u-radio-group v-model="modePayment">
  51. <span style="font-size: 30rpx;margin: 0rpx 20rpx 15rpx 0rpx;">支付方式:</span>
  52. <u-radio style="margin: 0rpx 20rpx 15rpx 0rpx;" v-for="(item, index) in radiolist" :key="index"
  53. :label="item.name" :name="item.value"></u-radio>
  54. </u-radio-group>
  55. </view>
  56. <view style="margin-bottom: 20rpx;" v-if="!rejectionFlag">
  57. <u-radio-group v-model="statePayment">
  58. <span style="font-size: 30rpx;margin: 0rpx 20rpx 15rpx 0rpx;">支付状态:</span>
  59. <u-radio style="margin: 0rpx 20rpx 15rpx 0rpx;" v-for="(item, index) in stateList" :key="index"
  60. :label="item.name" :name="item.value"></u-radio>
  61. </u-radio-group>
  62. <view v-if="statePayment == 2">
  63. <u--input placeholder="请输入未结清备注" border="surround" v-model="remarksSettled"></u--input>
  64. </view>
  65. </view>
  66. <view class="card_image_sign">
  67. <view class="img_sign_rejection">{{signRejection}}图片</view>
  68. <u-upload :fileList="fileList1" name="1" multiple :maxCount="10" @afterRead="afterRead"
  69. @delete="deletePic"></u-upload>
  70. </view>
  71. <view class="card_image_sign">
  72. <view class="img_sign_rejection" @click="goSignature('client')">客户签字</view>
  73. <u-image :showLoading="true" :src="imageData" width="300rpx" height="155rpx"
  74. @click="goSignature('client')" mode="scaleToFill"></u-image>
  75. </view>
  76. <view class="rejection_card" v-if="rejectionFlag">
  77. <view class="img_sign_rejection">拒收原因</view>
  78. <u-textarea v-model="rejectionValue" placeholder="请输入拒收原因" autoHeight></u-textarea>
  79. </view>
  80. <u-button style="margin-top: 30rpx;" size="small" type="primary" text="确定" :loading="signLoading"
  81. @click="confirm()"></u-button>
  82. </view>
  83. </u-popup>
  84. <u-popup :show="antiShow" mode="center" closeable :closeOnClickOverlay="false" round="6" @close="close">
  85. <view class="card_dismantle">
  86. <view class="headline_anti">防拆标签</view>
  87. <x-form ref="goods" :list="goodsList" :model="goodsModel" :rules="goodsRules"></x-form>
  88. <u-button style="margin-top: 10rpx;" size="small" type="primary" text="确定"
  89. @click="modifiedTamper()"></u-button>
  90. </view>
  91. </u-popup>
  92. <!-- 确定完成 -->
  93. <u-modal :show="logoutShow" showCancelButton :title="title" :content='content' @cancel="cancel"
  94. @confirm="definiteCompletion"></u-modal>
  95. </view>
  96. </template>
  97. <script>
  98. const ENV = require('@/.env.js')
  99. import {
  100. formRules,
  101. } from "./waybill.js";
  102. export default {
  103. name: 'xOrderManagement',
  104. props: {
  105. // 运单列表
  106. orderList: {
  107. type: Array,
  108. default: () => [],
  109. },
  110. userInfo: {
  111. type: Object,
  112. default: () => {},
  113. }
  114. },
  115. data() {
  116. return {
  117. signForShow: false,
  118. fileList1: [],
  119. rejectionValue: '',
  120. rejectionFlag: false,
  121. signRejection: '',
  122. orderNumber: '',
  123. imageUrl: '',
  124. antiShow: false,
  125. goodsList: formRules(),
  126. goodsModel: {
  127. tamperProofLabel: '',
  128. tamperProofLabelImg: '',
  129. },
  130. goodsRules: {
  131. tamperProofLabel: {
  132. required: true,
  133. message: '请输入防拆标签码',
  134. trigger: ['blur', 'change']
  135. },
  136. tamperProofLabelImg: {
  137. required: true,
  138. message: '请上传防拆标签图片',
  139. trigger: ['blur', 'change']
  140. },
  141. },
  142. antiList: {},
  143. imageData: '',
  144. radiolist: [{
  145. name: '现金',
  146. value: 1,
  147. }, {
  148. name: '线上支付',
  149. value: 2,
  150. }, {
  151. name: '银行卡',
  152. value: 3,
  153. }, {
  154. name: '医保',
  155. value: 4,
  156. }, {
  157. name: '其他',
  158. value: 5,
  159. }],
  160. stateList: [{
  161. name: '已结清',
  162. value: 1,
  163. }, {
  164. name: '未结清',
  165. value: 2,
  166. }],
  167. modePayment: null,
  168. statePayment: null,
  169. remarksSettled: '',
  170. logoutShow: false,
  171. title: '确定完成该订单?',
  172. content: '确定完成后将无法分配运单,重新下单后即可分配',
  173. orderId: null,
  174. signLoading: false,
  175. }
  176. },
  177. mounted() {
  178. // console.log(this.userInfo, 26)
  179. },
  180. methods: {
  181. // 打印条码
  182. printBarCode(value) {
  183. this.$cache.setCache('commodity', JSON.stringify(value))
  184. uni.navigateTo({
  185. url: '/pages/order/quantum?waybillNo=' + value.waybillNo + '&printType=barCode'
  186. });
  187. },
  188. // 派单
  189. sendOrders(value) {
  190. this.$emit('sendOrders', value)
  191. },
  192. // 防拆标签
  193. antiDismantle(value) {
  194. this.antiList = value
  195. this.antiShow = true
  196. this.goodsModel.tamperProofLabel = value.tamperProofLabel
  197. this.goodsModel.tamperProofLabelImg = value.tamperProofLabelImg
  198. this.goodsModel.id = value.id
  199. if (value.tamperProofLabelImg) {
  200. let arrImg = value.tamperProofLabelImg.split(',')
  201. let arrImgList = []
  202. arrImg.forEach((item) => {
  203. const arr = {
  204. url: item,
  205. }
  206. arrImgList.push(arr)
  207. })
  208. this.$nextTick(() => {
  209. this.$refs.goods.fileList1 = arrImgList
  210. })
  211. }
  212. },
  213. // 去配送
  214. toDeliver(event) {
  215. uni.setStorageSync('incubatorValue', event.coolerBox)
  216. uni.setStorageSync('orderValue', JSON.stringify(event))
  217. uni.navigateTo({
  218. url: '/pages/order/dispatching'
  219. });
  220. },
  221. // 拒收
  222. rejection(value) {
  223. this.orderNumber = value.waybillNo
  224. this.signForShow = true
  225. this.rejectionFlag = true
  226. this.signRejection = '拒收'
  227. },
  228. // 签收
  229. signFor(value) {
  230. this.orderNumber = value.waybillNo
  231. this.signForShow = true
  232. this.rejectionFlag = false
  233. this.signRejection = '签收'
  234. },
  235. // 已完成
  236. finished(event) {
  237. this.orderId = event.id
  238. this.logoutShow = true
  239. },
  240. // 分配订单
  241. distributionOrder(event) {
  242. uni.navigateTo({
  243. url: '/pages/order/distributionOrder?flag=true&waybillNo=' + event.waybillNo
  244. });
  245. },
  246. // 确定签收/拒收
  247. confirm() {
  248. let params = {
  249. waybillNo: this.orderNumber,
  250. receiptImg: this.imageUrl,
  251. status: 5,
  252. rejectionReason: this.rejectionValue,
  253. receiptsign: this.imageData,
  254. paymentType: this.modePayment,
  255. paymentStatus: this.statePayment,
  256. paymentremark: this.remarksSettled,
  257. }
  258. let verify = false
  259. if (this.rejectionFlag) {
  260. params.status = 6
  261. verify = this.verification(params)
  262. } else {
  263. params.status = 5
  264. verify = this.verification(params)
  265. }
  266. if (verify) {
  267. this.signLoading = true
  268. this.$api.post('/api/waybill/receipt', params).then(res => {
  269. if (res.code == 200) {
  270. this.signForShow = false
  271. uni.$u.toast(res.msg)
  272. this.$emit('operateSuccessfully')
  273. } else {
  274. uni.$u.toast(res.msg)
  275. }
  276. this.signLoading = false
  277. })
  278. }
  279. },
  280. // 拒收签收验证
  281. verification(params) {
  282. let flag = false
  283. if (this.rejectionFlag) {
  284. if (params.receiptImg) {
  285. flag = true
  286. } else {
  287. uni.$u.toast('请上传' + this.signRejection + '图片')
  288. }
  289. } else {
  290. if (params.paymentType) {
  291. if (params.paymentStatus) {
  292. if (params.receiptImg) {
  293. flag = true
  294. // if (params.receiptsign) {
  295. // flag = true
  296. // } else {
  297. // uni.$u.toast('请上传客户签字图片')
  298. // }
  299. } else {
  300. uni.$u.toast('请上传' + this.signRejection + '图片')
  301. }
  302. } else {
  303. uni.$u.toast('请选择支付状态')
  304. }
  305. } else {
  306. uni.$u.toast('请选择支付方式')
  307. }
  308. }
  309. return flag
  310. },
  311. // 修改防拆标签
  312. async modifiedTamper() {
  313. let flag2 = await this.$refs['goods'].validateForm();
  314. if (flag2) {
  315. let params = {
  316. senderAddressName: this.antiList.senderAddressName,
  317. senderAddressPhone: this.antiList.senderAddressPhone,
  318. senderAddressDetails: this.antiList.senderAddressDetails,
  319. consigneeAddressName: this.antiList.consigneeAddressName,
  320. consigneeAddressPhone: this.antiList.consigneeAddressPhone,
  321. consigneeAddressDetails: this.antiList.consigneeAddressDetails,
  322. deliveryName: this.antiList.deliveryName,
  323. deliveryPhone: this.antiList.deliveryPhone,
  324. ...this.goodsModel,
  325. }
  326. uni.showLoading();
  327. // 修改运单
  328. this.$api.put('/api/waybill', params).then(res => {
  329. if (res.code == 200) {
  330. this.antiShow = false
  331. uni.$u.toast(res.msg)
  332. this.$emit('proofRenewal')
  333. } else {
  334. uni.$u.toast('修改失败')
  335. }
  336. uni.hideLoading();
  337. }).catch(() => {
  338. uni.hideLoading();
  339. })
  340. }
  341. },
  342. // 打印温湿度记录
  343. humidityRecording(value) {
  344. this.$cache.setCache('commodity', JSON.stringify(value))
  345. uni.navigateTo({
  346. url: '/pages/order/quantum?waybillNo=' + value.waybillNo + '&printType=record'
  347. });
  348. },
  349. // 修改运单
  350. modifyOrder(value) {
  351. this.$cache.setCache('orderDetails', value)
  352. uni.redirectTo({
  353. url: '/pages/order/addWaybill?title=修改运单&type=2'
  354. });
  355. },
  356. // 运单详情
  357. goOrderDetails(value) {
  358. this.$cache.setCache('orderDetails', value)
  359. uni.navigateTo({
  360. url: '/pages/order/orderDetails?type=details'
  361. });
  362. },
  363. // 运单状态
  364. orderStatus(value) {
  365. if (value == 3) {
  366. return '待配送'
  367. } else if (value == 4) {
  368. return '配送中'
  369. } else if (value == 5) {
  370. return '已送达'
  371. } else if (value == 6) {
  372. return '已拒收'
  373. } else if (value == 8) {
  374. return '已取消'
  375. }
  376. },
  377. // 运单文字颜色
  378. getState(value) {
  379. if (value == 3) {
  380. return '#9ddd54'
  381. } else if (value == 4) {
  382. return '#4bc7fc'
  383. } else if (value == 5) {
  384. return '#1cc723'
  385. } else if (value == 6) {
  386. return '#fe880e'
  387. } else if (value == 8) {
  388. return '#fa3534'
  389. }
  390. },
  391. // 新增图片
  392. async afterRead(event) {
  393. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  394. let lists = [].concat(event.file)
  395. let fileListLen = this[`fileList${event.name}`].length
  396. lists.map((item) => {
  397. this[`fileList${event.name}`].push({
  398. ...item,
  399. status: 'uploading',
  400. message: '上传中'
  401. })
  402. })
  403. uni.showLoading({
  404. title: '上传中',
  405. mask: true,
  406. })
  407. for (let i = 0; i < lists.length; i++) {
  408. const result = await this.uploadFilePromise(lists[i].url)
  409. let item = this[`fileList${event.name}`][fileListLen]
  410. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  411. status: 'success',
  412. message: '',
  413. url: result
  414. }))
  415. fileListLen++
  416. }
  417. var arr = []
  418. this.fileList1.forEach(item1 => {
  419. arr.push(item1.url)
  420. })
  421. uni.hideLoading();
  422. this.imageUrl = arr.join()
  423. },
  424. // 删除图片
  425. deletePic(event) {
  426. this[`fileList${event.name}`].splice(event.index, 1)
  427. var arr = []
  428. this.fileList1.forEach(item1 => {
  429. arr.push(item1.url)
  430. })
  431. this.imageUrl = arr.join()
  432. },
  433. // 签字
  434. goSignature(title) {
  435. uni.navigateTo({
  436. url: '/pages/order/signatureBoard'
  437. });
  438. },
  439. uploadFilePromise(url) {
  440. return new Promise((resolve, reject) => {
  441. let a = uni.uploadFile({
  442. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  443. filePath: url,
  444. name: 'file',
  445. header: {
  446. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  447. },
  448. success: (res) => {
  449. let state = JSON.parse(res.data)
  450. setTimeout(() => {
  451. if (state.code == 200) {
  452. resolve(state.data)
  453. }
  454. }, 100)
  455. }
  456. });
  457. })
  458. },
  459. // 确定完成订单
  460. definiteCompletion() {
  461. this.$api.put('/api/waybill/update-status', {
  462. id: [this.orderId],
  463. status: 5,
  464. }).then(res => {
  465. if (res.code == 200) {
  466. uni.$u.toast('操作成功')
  467. this.$emit('definiteCompletion')
  468. } else {
  469. uni.$u.toast(res.msg)
  470. }
  471. this.logoutShow = false
  472. })
  473. console.log('确定完成订单')
  474. },
  475. // 取消
  476. cancel() {
  477. this.logoutShow = false
  478. },
  479. close() {
  480. this.signForShow = false
  481. this.modePayment = null
  482. this.statePayment = null
  483. this.remarksSettled = ''
  484. this.fileList1 = []
  485. this.imageData = ''
  486. this.rejectionValue = ''
  487. this.antiShow = false
  488. },
  489. }
  490. }
  491. </script>
  492. <style lang="scss">
  493. .card_ordermang {
  494. background-color: #fff;
  495. padding: 20rpx;
  496. border-radius: 10rpx;
  497. margin: 20rpx;
  498. }
  499. .head_ordermang {
  500. margin-bottom: 10rpx;
  501. }
  502. .title_ordermang {
  503. margin-top: 10rpx;
  504. font-size: 26rpx;
  505. color: #909399;
  506. span {
  507. font-size: 26rpx;
  508. color: #909399;
  509. margin-right: 10rpx;
  510. }
  511. }
  512. .waybill_title {
  513. font-size: 30rpx;
  514. span {
  515. margin-left: 10rpx;
  516. }
  517. }
  518. .card_state {
  519. color: #606266;
  520. font-size: 28rpx;
  521. }
  522. .card_specification {
  523. display: flex;
  524. align-items: center;
  525. }
  526. .specification_title {
  527. margin-right: 20rpx;
  528. }
  529. .btn_printil {
  530. flex: 1;
  531. margin-top: 10px;
  532. }
  533. .markd10:nth-child(1) {
  534. margin: 10rpx 10rpx 0rpx 0rpx;
  535. }
  536. .markd10:nth-child(2) {
  537. margin: 10rpx 0rpx 0rpx 10rpx;
  538. }
  539. .markd10:nth-child(3) {
  540. margin: 10rpx 0rpx 0rpx 20rpx;
  541. }
  542. .title_sign {
  543. padding: 10rpx 0rpx;
  544. height: 60rpx;
  545. }
  546. .card_sign_for {
  547. width: 640rpx;
  548. padding: 10rpx 30rpx 30rpx 30rpx;
  549. }
  550. .rejection_card {
  551. margin-bottom: 20rpx;
  552. }
  553. .card_image_sign {
  554. display: flex;
  555. flex-direction: column;
  556. margin-bottom: 10rpx;
  557. }
  558. .img_sign_rejection {
  559. font-size: 30rpx;
  560. margin-bottom: 20rpx;
  561. }
  562. .card_dismantle {
  563. padding: 30rpx;
  564. }
  565. .headline_anti {
  566. font-size: 38rpx;
  567. font-weight: 600;
  568. display: flex;
  569. justify-content: center;
  570. border-bottom: 1rpx solid #e7e6e4;
  571. padding-bottom: 15rpx;
  572. margin-bottom: 15rpx;
  573. align-items: center;
  574. }
  575. ::v-deep .u-radio-group--row {
  576. flex-wrap: wrap;
  577. }
  578. </style>