x-orderManagement.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  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;" 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="printBarCode(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. </view>
  49. </template>
  50. <script>
  51. const ENV = require('@/.env.js')
  52. export default {
  53. name: 'xOrderManagement',
  54. props: {
  55. // 订单列表
  56. orderList: {
  57. type: Array,
  58. default: () => [],
  59. },
  60. userInfo: {
  61. type: Object,
  62. default: () => {},
  63. }
  64. },
  65. data() {
  66. return {
  67. signForShow: false,
  68. fileList1: [],
  69. rejectionValue: '',
  70. rejectionFlag: false,
  71. signRejection: '',
  72. orderNumber: '',
  73. imageUrl: '',
  74. }
  75. },
  76. mounted() {
  77. // console.log(this.userInfo, 26)
  78. },
  79. methods: {
  80. // 打印条码
  81. printBarCode(value) {
  82. this.$cache.setCache('commodity', JSON.stringify(value))
  83. uni.navigateTo({
  84. url: '/pages/order/quantum?waybillNo=' + value.waybillNo + '&printType=barCode'
  85. });
  86. },
  87. // 派单
  88. sendOrders(value) {
  89. this.$emit('sendOrders', value)
  90. },
  91. // 拒收
  92. rejection(value) {
  93. this.orderNumber = value.waybillNo
  94. this.signForShow = true
  95. this.rejectionFlag = true
  96. this.signRejection = '拒收'
  97. },
  98. // 签收
  99. signFor(value) {
  100. this.orderNumber = value.waybillNo
  101. this.signForShow = true
  102. this.rejectionFlag = false
  103. this.signRejection = '签收'
  104. },
  105. // 确定签收/拒收
  106. confirm() {
  107. let params = {
  108. waybillNo: this.orderNumber,
  109. receiptImg: this.imageUrl,
  110. status: 3,
  111. rejectionReason: this.rejectionValue,
  112. }
  113. if (this.rejectionFlag) {
  114. params.status = 4
  115. } else {
  116. params.status = 3
  117. }
  118. this.$api.post('/api/waybill/receipt', params).then(res => {
  119. console.log(res, 266)
  120. if (res.code == 200) {
  121. uni.$u.toast(res.msg)
  122. this.signForShow = false
  123. this.$emit('operateSuccessfully')
  124. } else {
  125. uni.$u.toast(res.msg)
  126. }
  127. })
  128. },
  129. // 打印温湿度记录
  130. humidityRecording(value) {
  131. this.$cache.setCache('commodity', JSON.stringify(value))
  132. uni.navigateTo({
  133. url: '/pages/order/quantum?waybillNo=' + value.waybillNo + '&printType=record'
  134. });
  135. },
  136. // 修改订单
  137. modifyOrder(value) {
  138. this.$cache.setCache('orderDetails', value)
  139. uni.redirectTo({
  140. url: '/pages/order/addWaybill?title=修改订单&type=2'
  141. });
  142. },
  143. // 订单详情
  144. goOrderDetails(value) {
  145. this.$cache.setCache('orderDetails', value)
  146. uni.navigateTo({
  147. url: '/pages/order/orderDetails?type=details'
  148. });
  149. },
  150. // 订单状态
  151. orderStatus(value) {
  152. if (value == 1) {
  153. return '已下单'
  154. } else if (value == 2) {
  155. return '配送中'
  156. } else if (value == 3) {
  157. return '已送达'
  158. } else if (value == 4) {
  159. return '已取消'
  160. }
  161. },
  162. // 订单文字颜色
  163. getState(value) {
  164. if (value == 1) {
  165. return '#9ddd54'
  166. } else if (value == 2) {
  167. return '#4bc7fc'
  168. } else if (value == 3) {
  169. return '#1cc723'
  170. } else if (value == 4) {
  171. return '#fe880e'
  172. }
  173. },
  174. // 新增图片
  175. async afterRead(event) {
  176. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  177. let lists = [].concat(event.file)
  178. let fileListLen = this[`fileList${event.name}`].length
  179. lists.map((item) => {
  180. this[`fileList${event.name}`].push({
  181. ...item,
  182. status: 'uploading',
  183. message: '上传中'
  184. })
  185. })
  186. uni.showLoading({
  187. title: '上传中',
  188. mask: true,
  189. })
  190. for (let i = 0; i < lists.length; i++) {
  191. const result = await this.uploadFilePromise(lists[i].url)
  192. let item = this[`fileList${event.name}`][fileListLen]
  193. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  194. status: 'success',
  195. message: '',
  196. url: result
  197. }))
  198. fileListLen++
  199. }
  200. var arr = []
  201. this.fileList1.forEach(item1 => {
  202. arr.push(item1.url)
  203. })
  204. uni.hideLoading();
  205. this.imageUrl = arr.join()
  206. },
  207. // 删除图片
  208. deletePic(event) {
  209. this[`fileList${event.name}`].splice(event.index, 1)
  210. var arr = []
  211. this.fileList1.forEach(item1 => {
  212. arr.push(item1.url)
  213. })
  214. this.imageUrl = arr.join()
  215. },
  216. uploadFilePromise(url) {
  217. return new Promise((resolve, reject) => {
  218. let a = uni.uploadFile({
  219. url: ENV.APP_DEV_URL + '/api/upload', // 仅为示例,非真实的接口地址
  220. filePath: url,
  221. name: 'file',
  222. header: {
  223. 'Authorization': 'Bearer ' + uni.getStorageSync('access_token'),
  224. },
  225. success: (res) => {
  226. let state = JSON.parse(res.data)
  227. setTimeout(() => {
  228. if (state.code == 200) {
  229. resolve(state.data)
  230. }
  231. }, 100)
  232. }
  233. });
  234. })
  235. },
  236. close() {
  237. console.log(22)
  238. this.signForShow = false
  239. },
  240. }
  241. }
  242. </script>
  243. <style lang="scss">
  244. .card_ordermang {
  245. background-color: #fff;
  246. padding: 20rpx;
  247. border-radius: 20rpx;
  248. margin: 20rpx;
  249. }
  250. .head_ordermang {
  251. margin-bottom: 10rpx;
  252. }
  253. .title_ordermang {
  254. margin-top: 10rpx;
  255. font-size: 26rpx;
  256. color: #909399;
  257. span {
  258. font-size: 26rpx;
  259. color: #909399;
  260. margin-right: 10rpx;
  261. }
  262. }
  263. .waybill_title {
  264. font-size: 32rpx;
  265. span {
  266. margin-left: 10rpx;
  267. }
  268. }
  269. .card_state {
  270. color: #606266;
  271. font-size: 32rpx;
  272. }
  273. .card_specification {
  274. display: flex;
  275. align-items: center;
  276. }
  277. .specification_title {
  278. margin-right: 20rpx;
  279. }
  280. .btn_printil {
  281. flex: 1;
  282. margin-top: 10px;
  283. }
  284. .markd10:nth-child(1) {
  285. margin: 10rpx 10rpx 0rpx 0rpx;
  286. }
  287. .markd10:nth-child(2) {
  288. margin: 10rpx 0rpx 0rpx 10rpx;
  289. }
  290. .title_sign {
  291. padding: 10rpx 0rpx;
  292. height: 60rpx;
  293. }
  294. .card_sign_for {
  295. width: 600rpx;
  296. padding: 10rpx 20rpx 20rpx 20rpx;
  297. }
  298. .rejection_card {
  299. margin-bottom: 20rpx;
  300. }
  301. .card_image_sign {
  302. display: flex;
  303. flex-direction: column;
  304. margin-bottom: 10rpx;
  305. }
  306. .img_sign_rejection {
  307. font-size: 30rpx;
  308. margin-bottom: 10rpx;
  309. }
  310. </style>