removal.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. },
  62. error: function (res) {
  63. console.log(res, 'error++++++++++');
  64. }
  65. });
  66. },
  67. async iconCheck(result) {
  68. const res = await appPermissionChecks({ expressNo: result, deliveryPeopleId: localStorage.getItem('courierUserId') })
  69. if (!!res.data) {
  70. this.callback(res.data.expressNo)
  71. } else {
  72. Toast('不在派送范围')
  73. }
  74. },
  75. onSearch() {
  76. if (this.keyWorld == '') {
  77. return Toast('快递单号不能为空')
  78. }
  79. if (this.codes.some((item) => this.keyWorld == item)) {
  80. Toast('您输入的单号以重复,请重新输入')
  81. this.keyWorld = ''
  82. return
  83. }
  84. this.iconCheck(this.keyWorld)
  85. },
  86. callback(code) {
  87. if (this.codes.length < 15) {
  88. this.codes.push(code)
  89. } else {
  90. Toast('扫描上限15条');
  91. }
  92. },
  93. // 生成批次
  94. async onBatch() {
  95. if (this.codes.length < 1) {
  96. return Toast('数据不能为空生成批次')
  97. }
  98. let data = {
  99. deliveryPeopleId: localStorage.getItem('courierId'), //派送员id
  100. deliveryId: this.codes.join(','), //快件单号
  101. dispatchBatchNo: getCompanyExpressNo(), //批次号
  102. // floor:expressScope
  103. }
  104. const res = await appDeliveryPersonDeliveries({ ...data }, { emulateJSON: true })
  105. if (res.msg == 'success') {
  106. this.BatDispatchBatchNo = data.dispatchBatchNo
  107. this.codesList = this.codes
  108. console.log(data.dispatchBatchNo, 'data.dispatchBatchNo')
  109. this.isRemoval = false
  110. if (res.data.length > 0) {
  111. this.noCodesList = res.data
  112. }
  113. } else {
  114. this.$toast('生成批次错误')
  115. }
  116. console.log(res, 'res')
  117. },
  118. // 删除列表中的数据
  119. onDelete(item) {
  120. this.codes = this.codes.filter((_item) => _item !== item)
  121. },
  122. // 传过去的事件
  123. iemoval(value) {
  124. console.log(value)
  125. this.isRemoval = value
  126. }
  127. },
  128. computed: {
  129. show() {
  130. return this.codes.length > 0
  131. }
  132. }
  133. };
  134. </script>
  135. <style lang="less" scoped>
  136. * {
  137. font-size: 16px;
  138. }
  139. .container {
  140. background-color: #fff;
  141. height: 100vh;
  142. img {
  143. position: fixed;
  144. height: 20px;
  145. width: 20px;
  146. right: 22px;
  147. top: 18px;
  148. }
  149. .middelBox {
  150. padding: 12px;
  151. }
  152. }
  153. .build {
  154. position: fixed;
  155. height: 40px;
  156. width: 160px;
  157. bottom: 60px;
  158. right: 10px;
  159. }
  160. </style>