x-orderManagement.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  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.consigneeAddressDetails}}</view>
  9. <view class="title_ordermang"><span>收货电话:</span>{{item.consigneeAddressPhone}}</view>
  10. <view class="title_ordermang"><span>下单时间:</span>{{item.orderTime}}</view>
  11. <view style="display: flex;margin-top: 15rpx;" v-if="item.status == 1">
  12. <view class="btn_printil markd10" v-if="item.status == 1 || item.status == 2 || item.status == 3"
  13. @click.stop="modifyOrder(item)">
  14. <u-button size="small" type="warning" text="修改运单"></u-button>
  15. </view>
  16. <view class="btn_printil markd10" @click.stop="antiDismantle(item)">
  17. <u-button size="small" type="primary" text="防拆标签"></u-button>
  18. </view>
  19. <view class="btn_printil markd10" @click.stop="sendOrders(item)">
  20. <u-button size="small" type="success" text="派单"></u-button>
  21. </view>
  22. </view>
  23. <view style="display: flex;" v-if="item.status == 2">
  24. <view class="btn_printil markd10" @click.stop="rejection(item)">
  25. <u-button size="small" type="error" text="拒收"></u-button>
  26. </view>
  27. <view class="btn_printil markd10" @click.stop="signFor(item)">
  28. <u-button size="small" type="primary" text="签收"></u-button>
  29. </view>
  30. </view>
  31. </view>
  32. <u-popup :show="signForShow" mode="center" round="6" closeable :closeOnClickOverlay="false" @close="close">
  33. <view class="center_in title_sign">{{signRejection}}</view>
  34. <view class="card_sign_for">
  35. <view class="img_sign_rejection">运单号: {{orderNumber}}</view>
  36. <view class="card_image_sign">
  37. <view class="img_sign_rejection">{{signRejection}}图片</view>
  38. <u-upload :fileList="fileList1" name="1" multiple :maxCount="10" @afterRead="afterRead"
  39. @delete="deletePic"></u-upload>
  40. </view>
  41. <view class="rejection_card" v-if="rejectionFlag">
  42. <view class="img_sign_rejection">拒收原因</view>
  43. <u-textarea v-model="rejectionValue" placeholder="请输入拒收原因" autoHeight></u-textarea>
  44. </view>
  45. <u-button size="small" type="primary" text="确定" @click="confirm()"></u-button>
  46. </view>
  47. </u-popup>
  48. <u-popup :show="antiShow" mode="center" closeable :closeOnClickOverlay="false" round="6" @close="close">
  49. <view class="card_dismantle">
  50. <view class="headline_anti">防拆标签</view>
  51. <x-form ref="goods" :list="goodsList" :model="goodsModel" :rules="goodsRules"></x-form>
  52. <u-button style="margin-top: 10rpx;" size="small" type="primary" text="确定"
  53. @click="modifiedTamper()"></u-button>
  54. </view>
  55. </u-popup>
  56. </view>
  57. </template>
  58. <script>
  59. const ENV = require('@/.env.js')
  60. import {
  61. formRules,
  62. } from "./waybill.js";
  63. export default {
  64. name: 'xOrderManagement',
  65. props: {
  66. // 运单列表
  67. orderList: {
  68. type: Array,
  69. default: () => [],
  70. },
  71. userInfo: {
  72. type: Object,
  73. default: () => {},
  74. }
  75. },
  76. data() {
  77. return {
  78. signForShow: false,
  79. fileList1: [],
  80. rejectionValue: '',
  81. rejectionFlag: false,
  82. signRejection: '',
  83. orderNumber: '',
  84. imageUrl: '',
  85. antiShow: false,
  86. goodsList: formRules(),
  87. goodsModel: {
  88. tamperProofLabel: '',
  89. tamperProofLabelImg: '',
  90. },
  91. goodsRules: {
  92. tamperProofLabel: {
  93. required: true,
  94. message: '请输入防拆标签码',
  95. trigger: ['blur', 'change']
  96. },
  97. tamperProofLabelImg: {
  98. required: true,
  99. message: '请上传防拆标签图片',
  100. trigger: ['blur', 'change']
  101. },
  102. },
  103. antiList: {},
  104. }
  105. },
  106. mounted() {
  107. // console.log(this.userInfo, 26)
  108. },
  109. methods: {
  110. // 打印条码
  111. printBarCode(value) {
  112. this.$cache.setCache('commodity', JSON.stringify(value))
  113. uni.navigateTo({
  114. url: '/pages/order/quantum?waybillNo=' + value.waybillNo + '&printType=barCode'
  115. });
  116. },
  117. // 派单
  118. sendOrders(value) {
  119. this.$emit('sendOrders', value)
  120. },
  121. // 防拆标签
  122. antiDismantle(value) {
  123. this.antiList = value
  124. this.antiShow = true
  125. this.goodsModel.tamperProofLabel = value.tamperProofLabel
  126. this.goodsModel.tamperProofLabelImg = value.tamperProofLabelImg
  127. this.goodsModel.id = value.id
  128. if (value.tamperProofLabelImg) {
  129. let arrImg = value.tamperProofLabelImg.split(',')
  130. let arrImgList = []
  131. arrImg.forEach((item) => {
  132. const arr = {
  133. url: item,
  134. }
  135. arrImgList.push(arr)
  136. })
  137. this.$nextTick(() => {
  138. this.$refs.goods.fileList1 = arrImgList
  139. })
  140. }
  141. },
  142. // 拒收
  143. rejection(value) {
  144. this.orderNumber = value.waybillNo
  145. this.signForShow = true
  146. this.rejectionFlag = true
  147. this.signRejection = '拒收'
  148. },
  149. // 签收
  150. signFor(value) {
  151. this.orderNumber = value.waybillNo
  152. this.signForShow = true
  153. this.rejectionFlag = false
  154. this.signRejection = '签收'
  155. },
  156. // 确定签收/拒收
  157. confirm() {
  158. let params = {
  159. waybillNo: this.orderNumber,
  160. receiptImg: this.imageUrl,
  161. status: 3,
  162. rejectionReason: this.rejectionValue,
  163. }
  164. if (this.rejectionFlag) {
  165. params.status = 4
  166. } else {
  167. params.status = 3
  168. }
  169. this.$api.post('/api/waybill/receipt', params).then(res => {
  170. if (res.code == 200) {
  171. uni.$u.toast(res.msg)
  172. this.signForShow = false
  173. this.$emit('operateSuccessfully')
  174. } else {
  175. uni.$u.toast(res.msg)
  176. }
  177. })
  178. },
  179. // 修改防拆标签
  180. async modifiedTamper() {
  181. let flag2 = await this.$refs['goods'].validateForm();
  182. if (flag2) {
  183. let params = {
  184. senderAddressName: this.antiList.senderAddressName,
  185. senderAddressPhone: this.antiList.senderAddressPhone,
  186. senderAddressDetails: this.antiList.senderAddressDetails,
  187. consigneeAddressName: this.antiList.consigneeAddressName,
  188. consigneeAddressPhone: this.antiList.consigneeAddressPhone,
  189. consigneeAddressDetails: this.antiList.consigneeAddressDetails,
  190. deliveryName: this.antiList.deliveryName,
  191. deliveryPhone: this.antiList.deliveryPhone,
  192. ...this.goodsModel,
  193. }
  194. uni.showLoading();
  195. // 修改运单
  196. this.$api.put('/api/waybill', params).then(res => {
  197. if (res.code == 200) {
  198. this.antiShow = false
  199. uni.$u.toast(res.msg)
  200. this.$emit('proofRenewal')
  201. } else {
  202. uni.$u.toast('修改失败')
  203. }
  204. uni.hideLoading();
  205. }).catch(() => {
  206. uni.hideLoading();
  207. })
  208. }
  209. },
  210. // 打印温湿度记录
  211. humidityRecording(value) {
  212. this.$cache.setCache('commodity', JSON.stringify(value))
  213. uni.navigateTo({
  214. url: '/pages/order/quantum?waybillNo=' + value.waybillNo + '&printType=record'
  215. });
  216. },
  217. // 修改运单
  218. modifyOrder(value) {
  219. this.$cache.setCache('orderDetails', value)
  220. uni.redirectTo({
  221. url: '/pages/order/addWaybill?title=修改运单&type=2'
  222. });
  223. },
  224. // 运单详情
  225. goOrderDetails(value) {
  226. this.$cache.setCache('orderDetails', value)
  227. uni.navigateTo({
  228. url: '/pages/order/orderDetails?type=details'
  229. });
  230. },
  231. // 运单状态
  232. orderStatus(value) {
  233. if (value == 1) {
  234. return '已下单'
  235. } else if (value == 2) {
  236. return '配送中'
  237. } else if (value == 3) {
  238. return '已送达'
  239. } else if (value == 4) {
  240. return '已拒收'
  241. }
  242. },
  243. // 运单文字颜色
  244. getState(value) {
  245. if (value == 1) {
  246. return '#9ddd54'
  247. } else if (value == 2) {
  248. return '#4bc7fc'
  249. } else if (value == 3) {
  250. return '#1cc723'
  251. } else if (value == 4) {
  252. return '#fe880e'
  253. }
  254. },
  255. // 新增图片
  256. async afterRead(event) {
  257. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  258. let lists = [].concat(event.file)
  259. let fileListLen = this[`fileList${event.name}`].length
  260. lists.map((item) => {
  261. this[`fileList${event.name}`].push({
  262. ...item,
  263. status: 'uploading',
  264. message: '上传中'
  265. })
  266. })
  267. uni.showLoading({
  268. title: '上传中',
  269. mask: true,
  270. })
  271. for (let i = 0; i < lists.length; i++) {
  272. const result = await this.uploadFilePromise(lists[i].url)
  273. let item = this[`fileList${event.name}`][fileListLen]
  274. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  275. status: 'success',
  276. message: '',
  277. url: result
  278. }))
  279. fileListLen++
  280. }
  281. var arr = []
  282. this.fileList1.forEach(item1 => {
  283. arr.push(item1.url)
  284. })
  285. uni.hideLoading();
  286. this.imageUrl = arr.join()
  287. },
  288. // 删除图片
  289. deletePic(event) {
  290. this[`fileList${event.name}`].splice(event.index, 1)
  291. var arr = []
  292. this.fileList1.forEach(item1 => {
  293. arr.push(item1.url)
  294. })
  295. this.imageUrl = arr.join()
  296. },
  297. uploadFilePromise(url) {
  298. return new Promise((resolve, reject) => {
  299. let a = uni.uploadFile({
  300. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  301. filePath: url,
  302. name: 'file',
  303. header: {
  304. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  305. },
  306. success: (res) => {
  307. let state = JSON.parse(res.data)
  308. setTimeout(() => {
  309. if (state.code == 200) {
  310. resolve(state.data)
  311. }
  312. }, 100)
  313. }
  314. });
  315. })
  316. },
  317. close() {
  318. console.log(22)
  319. this.signForShow = false
  320. this.antiShow = false
  321. },
  322. }
  323. }
  324. </script>
  325. <style lang="scss">
  326. .card_ordermang {
  327. background-color: #fff;
  328. padding: 20rpx;
  329. border-radius: 20rpx;
  330. margin: 20rpx;
  331. }
  332. .head_ordermang {
  333. margin-bottom: 10rpx;
  334. }
  335. .title_ordermang {
  336. margin-top: 10rpx;
  337. font-size: 26rpx;
  338. color: #909399;
  339. span {
  340. font-size: 26rpx;
  341. color: #909399;
  342. margin-right: 10rpx;
  343. }
  344. }
  345. .waybill_title {
  346. font-size: 32rpx;
  347. span {
  348. margin-left: 10rpx;
  349. }
  350. }
  351. .card_state {
  352. color: #606266;
  353. font-size: 32rpx;
  354. }
  355. .card_specification {
  356. display: flex;
  357. align-items: center;
  358. }
  359. .specification_title {
  360. margin-right: 20rpx;
  361. }
  362. .btn_printil {
  363. flex: 1;
  364. margin-top: 10px;
  365. }
  366. .markd10:nth-child(1) {
  367. margin: 10rpx 10rpx 0rpx 0rpx;
  368. }
  369. .markd10:nth-child(2) {
  370. margin: 10rpx 0rpx 0rpx 10rpx;
  371. }
  372. .markd10:nth-child(3) {
  373. margin: 10rpx 0rpx 0rpx 20rpx;
  374. }
  375. .title_sign {
  376. padding: 10rpx 0rpx;
  377. height: 60rpx;
  378. }
  379. .card_sign_for {
  380. width: 600rpx;
  381. padding: 10rpx 20rpx 20rpx 20rpx;
  382. }
  383. .rejection_card {
  384. margin-bottom: 20rpx;
  385. }
  386. .card_image_sign {
  387. display: flex;
  388. flex-direction: column;
  389. margin-bottom: 10rpx;
  390. }
  391. .img_sign_rejection {
  392. font-size: 30rpx;
  393. margin-bottom: 10rpx;
  394. }
  395. .card_dismantle {
  396. padding: 30rpx;
  397. }
  398. .headline_anti {
  399. font-size: 38rpx;
  400. font-weight: 600;
  401. display: flex;
  402. justify-content: center;
  403. border-bottom: 1rpx solid #e7e6e4;
  404. padding-bottom: 15rpx;
  405. margin-bottom: 15rpx;
  406. align-items: center;
  407. }
  408. </style>