quick-check.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. } from 'vue';
  70. import { onLoad, onShow } from "@dcloudio/uni-app"
  71. const selectedBatchId = ref('');
  72. const showBatchSelector = ref(false);
  73. const count = ref(0);
  74. const formData = ref({
  75. batchNum: '',
  76. packageCode: '',
  77. searchType: '2',
  78. packageStatus: ''
  79. })
  80. // 批次列表数据
  81. const batchList = ref([]);
  82. function getBatchList() {
  83. uni.$u.http.get('/app/batchnum/pagelist').then(res => {
  84. batchList.value = res.rows
  85. })
  86. }
  87. getBatchList()
  88. // 打开批次选择器
  89. const openBatchSelector = () => {
  90. showBatchSelector.value = true;
  91. };
  92. // 选择批次
  93. const selectBatch = (batch) => {
  94. selectedBatchId.value = batch.id;
  95. count.value = Number(batch.num);
  96. formData.value.batchNum = batch.batchNum;
  97. showBatchSelector.value = false;
  98. };
  99. // 处理查询
  100. const handleSearch = () => {
  101. console.log('查询:', formData.value.packageCode);
  102. };
  103. //处理提交批次
  104. const handleSubmitBatch = () => {
  105. console.log('提交批次:', formData.value.batchNum);
  106. if (!formData.value.batchNum) {
  107. uni.$u.toast('请选择批次')
  108. return
  109. }
  110. if (!formData.value.packageCode) {
  111. uni.$u.toast('请扫描/输入物流单号')
  112. return
  113. }
  114. uni.$u.http.post('/app/ordersign/deliverySign', formData.value).then(res => {
  115. console.log(res)
  116. if (res.code == 200) {
  117. let text = code + '快递验收成功'
  118. uni.$u.ttsModule.speak(text)
  119. } else {
  120. let text = code + '订单不存在'
  121. uni.$u.ttsModule.speak(text)
  122. }
  123. })
  124. };
  125. // 处理扫码
  126. const handleScan = () => {
  127. uni.scanCode({
  128. success: (res) => {
  129. formData.value.packageCode = res.result;
  130. handleSubmitBatch();
  131. }
  132. });
  133. };
  134. // Function to handle creating a new batch
  135. const createNewBatch = () => {
  136. uni.$u.http.post('/app/batchnum/add').then(res => {
  137. if (res.code == 200) {
  138. getBatchList()
  139. }
  140. })
  141. };
  142. onLoad(() => {
  143. // #ifdef APP-PLUS
  144. uni.$u.useGlobalEvent((e) => {
  145. formData.value.packageCode = e.barcode
  146. handleSubmitBatch()
  147. })
  148. // #endif
  149. })
  150. onShow(() => {
  151. uni.$u.updateActivePageOnShow()
  152. })
  153. </script>
  154. <style lang="scss" scoped>
  155. @import "../components/common.scss";
  156. </style>
  157. <style>
  158. .popup-header {
  159. display: flex;
  160. justify-content: space-between;
  161. align-items: center;
  162. padding: 20rpx;
  163. }
  164. </style>