quick-check.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="container">
  3. <!-- 批次选择区域 -->
  4. <view class="select-section">
  5. <view class="batch-select">
  6. <text class="required">*</text>
  7. <text style="font-size: 32rpx;">批次:</text>
  8. <view class="batch-input">
  9. <view class="batch-input-text" @tap="openBatchSelector"></view>
  10. <u-input v-model="formData.batchNum" placeholder="请选择/新建批次" readonly border="surround"
  11. placeholder-style="font-size: 32rpx" custom-style="font-size: 32rpx;height: 88rpx;">
  12. <template #suffix>
  13. <u-icon name="arrow-down" size="18" />
  14. </template>
  15. </u-input>
  16. </view>
  17. </view>
  18. </view>
  19. <!-- 数量显示 -->
  20. <view class="count-badge">
  21. 数量 <text style="font-size: 32rpx;">{{ count }}</text>
  22. </view>
  23. <!-- 底部按钮 -->
  24. <view class="footer">
  25. <!-- 查询区域 -->
  26. <view class="query-section">
  27. <u-radio-group v-model="formData.searchType" class="query-radio">
  28. <u-radio label="查订单" name="1" labelSize="16px" iconSize="16px" />
  29. <u-radio label="查物流" custom-style="margin-left:20px" name="2" labelSize="16px" iconSize="16px" />
  30. </u-radio-group>
  31. <view class="search-box">
  32. <u-input custom-style="font-size: 32rpx;" placeholder-style="font-size: 32rpx;"
  33. v-model="formData.packageCode" :adjustPosition="true" placeholder="扫描/输入物流单号" border="surround"
  34. clearable>
  35. </u-input>
  36. <u-button color="#c8c8c8" text="查询" @click="handleSearch" />
  37. </view>
  38. </view>
  39. <u-divider></u-divider>
  40. <view style="display: flex;">
  41. <u-button size="large" type="warning" text="验收扫码" @click="handleScan" />
  42. <u-button size="large" type="primary" text="提交批次" @click="handleSubmitBatch"
  43. v-permission="'app:express:quickCheck:confirm'" />
  44. </view>
  45. </view>
  46. <!-- 批次选择弹窗 -->
  47. <u-popup :show="showBatchSelector" mode="bottom" @close="showBatchSelector = false">
  48. <view class="batch-popup" style="min-height: 300px;">
  49. <view class="popup-header">
  50. <text style="font-size: 32rpx;">批次</text>
  51. <view style="font-size: 32rpx;color: #007AFF;" @click="createNewBatch">
  52. <text>新建批次</text>
  53. </view>
  54. </view>
  55. <scroll-view scroll-y class="batch-list">
  56. <view v-for="batch in batchList" :key="batch.id" class="batch-item"
  57. :class="{ active: selectedBatchId === batch.id }" @click="selectBatch(batch)">
  58. <text>{{ batch.batchNum }}</text>
  59. <text>{{ batch.num }}</text>
  60. </view>
  61. </scroll-view>
  62. </view>
  63. </u-popup>
  64. </view>
  65. </template>
  66. <script setup>
  67. import {
  68. ref,
  69. computed,
  70. nextTick,
  71. onUnmounted
  72. } from 'vue';
  73. import { onLoad, onShow } from "@dcloudio/uni-app"
  74. const selectedBatchId = ref('');
  75. const showBatchSelector = ref(false);
  76. const count = ref(0);
  77. const formData = ref({
  78. batchNum: '',
  79. packageCode: '',
  80. searchType: '2',
  81. packageStatus: ''
  82. })
  83. // 批次列表数据
  84. const batchList = ref([]);
  85. function getBatchList() {
  86. uni.$u.http.get('/app/batchnum/pagelist').then(res => {
  87. batchList.value = res.rows
  88. })
  89. }
  90. getBatchList()
  91. // 打开批次选择器
  92. const openBatchSelector = () => {
  93. showBatchSelector.value = true;
  94. };
  95. // 选择批次
  96. const selectBatch = (batch) => {
  97. selectedBatchId.value = batch.id;
  98. count.value = Number(batch.num);
  99. formData.value.batchNum = batch.batchNum;
  100. showBatchSelector.value = false;
  101. };
  102. // 处理查询
  103. const handleSearch = () => {
  104. console.log('查询:', formData.value.packageCode);
  105. };
  106. //处理提交批次
  107. const handleSubmitBatch = () => {
  108. console.log('提交批次:', formData.value.batchNum);
  109. if (!formData.value.batchNum) {
  110. uni.$u.toast('请选择批次')
  111. return
  112. }
  113. if (!formData.value.packageCode) {
  114. uni.$u.toast('请扫描/输入物流单号')
  115. return
  116. }
  117. uni.$u.http.post('/app/ordersign/deliverySign', formData.value).then(res => {
  118. console.log(res)
  119. if (res.code == 200) {
  120. let text = code + '快递验收成功'
  121. uni.$u.ttsModule.speak(text)
  122. } else {
  123. let text = code + '订单不存在'
  124. uni.$u.ttsModule.speak(text)
  125. }
  126. })
  127. };
  128. // 处理扫码
  129. const handleScan = () => {
  130. uni.scanCode({
  131. success: (res) => {
  132. formData.value.packageCode = res.result;
  133. handleSubmitBatch();
  134. }
  135. });
  136. };
  137. // Function to handle creating a new batch
  138. const createNewBatch = () => {
  139. uni.$u.http.post('/app/batchnum/add').then(res => {
  140. if (res.code == 200) {
  141. getBatchList()
  142. }
  143. })
  144. };
  145. // #ifdef APP-PLUS
  146. const { unregister } = uni.$u.useEventListener((e) => {
  147. if (e.barcode) {
  148. handleScanData(e.barcode)
  149. }
  150. });
  151. // #endif
  152. onUnmounted(() => {
  153. // #ifdef APP-PLUS
  154. unregister();
  155. // #endif
  156. });
  157. </script>
  158. <style lang="scss" scoped>
  159. @import "../components/common.scss";
  160. </style>
  161. <style>
  162. .popup-header {
  163. display: flex;
  164. justify-content: space-between;
  165. align-items: center;
  166. padding: 20rpx;
  167. }
  168. </style>