removal.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <div>
  3. <div class="container" v-if="isRemoval">
  4. <van-search v-model="keyWorld" @search="onSearch" placeholder="请输入快递单号" />
  5. <img @click="onImg" src="@/assets/user/u4.png" alt="">
  6. <div class="middelBox" style="height: calc(100vh - 79px);overflow-y: auto;" v-if="show">
  7. <div style="margin-bottom: 10px;">已添加快件:</div>
  8. <van-cell-group v-for="item in codes" :key="item">
  9. <van-cell :title="item">
  10. <!-- 使用 right-icon 插槽来自定义右侧图标 -->
  11. <template #right-icon>
  12. <van-icon name="delete-o" @click="onDelete(item)" class="delete" />
  13. </template>
  14. </van-cell>
  15. </van-cell-group>
  16. </div>
  17. <van-button @click="onBatch" class="build" type="info">生成批次</van-button>
  18. </div>
  19. <Batched :codesList="codesList" :noCodesList="noCodesList" :BatDispatchBatchNo="BatDispatchBatchNo"
  20. :isRemoval="isRemoval" @isRemoval="iemoval" v-else></Batched>
  21. </div>
  22. </template>
  23. <script>
  24. import { appDeliveryPersonDeliveries, appPermissionChecks } from '../../api/index';
  25. import { Toast } from 'vant'
  26. import Batched from './batched.vue'
  27. import { getCompanyExpressNo } from "@/utils/utils"
  28. import wx from "weixin-jsapi";
  29. export default {
  30. name: 'Removal',
  31. components: {
  32. Batched
  33. },
  34. mounted() {
  35. console.log(localStorage.getItem('courierId'), '+=====================')
  36. },
  37. data() {
  38. return {
  39. titlename: "快件出库",
  40. codes: [],
  41. keyWorld: "",//快递单号的值
  42. isRemoval: true,
  43. BatDispatchBatchNo: '',//传过去的生成的快递单号
  44. codesList: [],//传过去的数据
  45. floorId: '',//楼层id
  46. noCodesList: [],//没有进入批次的数据
  47. };
  48. },
  49. methods: {
  50. onImg() {
  51. wx.scanQRCode({
  52. needResult: 1, // 默认为0,扫描结果由微信处理,1则直接返回扫描结果,
  53. scanType: ["qrCode", "barCode"], // 可以指定扫二维码还是一维码,默认二者都有
  54. success: (res) => {
  55. var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果
  56. if (result.indexOf(",") != -1) {
  57. let result1 = res.resultStr.split(",");
  58. result = result1[result1.length - 1];
  59. }
  60. this.iconCheck(result)
  61. this.callback(result)
  62. },
  63. error: function (res) {
  64. console.log(res, 'error++++++++++');
  65. }
  66. });
  67. },
  68. async iconCheck(result) {
  69. const res = await appPermissionChecks({ expressNo: result, deliveryPeopleId: localStorage.getItem('courierUserId') })
  70. if (Object.keys(res.data).length > 0) {
  71. this.callback(res.data.expressNo)
  72. } else {
  73. Toast('不在派送范围')
  74. }
  75. },
  76. onSearch() {
  77. if (this.keyWorld == '') {
  78. return Toast('快递单号不能为空')
  79. }
  80. if (this.codes.some((item) => this.keyWorld == item)) {
  81. Toast('您输入的单号以重复,请重新输入')
  82. this.keyWorld = ''
  83. return
  84. }
  85. this.callback(this.keyWorld)
  86. this.keyWorld = ''
  87. },
  88. callback(code) {
  89. if (this.codes.length < 15) {
  90. this.codes.push(code)
  91. } else {
  92. Toast('扫描上限15条');
  93. }
  94. },
  95. // 生成批次
  96. async onBatch() {
  97. if (this.codes.length < 1) {
  98. return Toast('数据不能为空生成批次')
  99. }
  100. let data = {
  101. deliveryPeopleId: localStorage.getItem('courierId'), //派送员id
  102. deliveryId: this.codes.join(','), //快件单号
  103. dispatchBatchNo: getCompanyExpressNo(), //批次号
  104. // floor:expressScope
  105. }
  106. const res = await appDeliveryPersonDeliveries({ ...data }, { emulateJSON: true })
  107. if (res.msg == 'success') {
  108. this.BatDispatchBatchNo = data.dispatchBatchNo
  109. this.codesList = this.codes
  110. console.log(data.dispatchBatchNo, 'data.dispatchBatchNo')
  111. this.isRemoval = false
  112. if (res.data.length > 0) {
  113. this.noCodesList = res.data
  114. }
  115. } else {
  116. this.$toast('生成批次错误')
  117. }
  118. console.log(res, 'res')
  119. },
  120. // 删除列表中的数据
  121. onDelete(item) {
  122. this.codes = this.codes.filter((_item) => _item !== item)
  123. },
  124. // 传过去的事件
  125. iemoval(value) {
  126. console.log(value)
  127. this.isRemoval = value
  128. }
  129. },
  130. computed: {
  131. show() {
  132. return this.codes.length > 0
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="less" scoped>
  138. * {
  139. font-size: 16px;
  140. }
  141. .container {
  142. background-color: #fff;
  143. height: 100vh;
  144. img {
  145. position: fixed;
  146. height: 20px;
  147. width: 20px;
  148. right: 22px;
  149. top: 18px;
  150. }
  151. .middelBox {
  152. padding: 12px;
  153. }
  154. }
  155. .build {
  156. position: fixed;
  157. height: 40px;
  158. width: 160px;
  159. bottom: 60px;
  160. right: 10px;
  161. }
  162. </style>