quick-check.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. </view>
  44. </view>
  45. <!-- 批次选择弹窗 -->
  46. <u-popup :show="showBatchSelector" mode="bottom" @close="showBatchSelector = false">
  47. <view class="batch-popup" style="min-height: 300px;">
  48. <view class="popup-header">
  49. <text style="font-size: 32rpx;">批次</text>
  50. </view>
  51. <scroll-view scroll-y class="batch-list">
  52. <view class="batch-item" :class="{ active: selectedBatchId === 'new' }" @click="createNewBatch">
  53. <text>新建批次</text>
  54. </view>
  55. <view v-for="batch in batchList" :key="batch.id" class="batch-item"
  56. :class="{ active: selectedBatchId === batch.id }" @click="selectBatch(batch)">
  57. <text>{{ batch.batchNum }}</text>
  58. <text>{{ batch.num }}</text>
  59. </view>
  60. </scroll-view>
  61. </view>
  62. </u-popup>
  63. </view>
  64. </template>
  65. <script setup>
  66. import {
  67. ref
  68. } from 'vue';
  69. import { onLoad } from "@dcloudio/uni-app"
  70. const selectedBatchId = ref('');
  71. const showBatchSelector = ref(false);
  72. const count = ref(0);
  73. const formData = ref({
  74. batchNum: '',
  75. packageCode: '',
  76. searchType: '2',
  77. packageStatus: ''
  78. })
  79. // 批次列表数据
  80. const batchList = ref([]);
  81. function getBatchList() {
  82. uni.$u.http.get('/app/batchnum/pagelist').then(res => {
  83. batchList.value = res.rows
  84. })
  85. }
  86. getBatchList()
  87. // 打开批次选择器
  88. const openBatchSelector = () => {
  89. showBatchSelector.value = true;
  90. };
  91. // 选择批次
  92. const selectBatch = (batch) => {
  93. selectedBatchId.value = batch.id;
  94. count.value = Number(batch.num);
  95. formData.value.batchNum = batch.batchNum;
  96. showBatchSelector.value = false;
  97. };
  98. // 处理查询
  99. const handleSearch = () => {
  100. console.log('查询:', formData.value.packageCode);
  101. };
  102. //处理提交批次
  103. const handleSubmitBatch = () => {
  104. console.log('提交批次:', formData.value.batchNum);
  105. if (!formData.value.batchNum) {
  106. uni.$u.toast('请选择批次')
  107. return
  108. }
  109. if (!formData.value.packageCode) {
  110. uni.$u.toast('请扫描/输入物流单号')
  111. return
  112. }
  113. uni.$u.http.post('/app/ordersign/deliverySign', formData.value).then(res => {
  114. console.log(res)
  115. if (res.code == 200) {
  116. let text = code + '快递验收成功'
  117. uni.$u.ttsModule.speak(text)
  118. } else {
  119. let text = code + '订单不存在'
  120. uni.$u.ttsModule.speak(text)
  121. }
  122. })
  123. };
  124. // 处理扫码
  125. const handleScan = () => {
  126. uni.scanCode({
  127. success: (res) => {
  128. formData.value.packageCode = res.result;
  129. handleSubmitBatch();
  130. }
  131. });
  132. };
  133. // Function to handle creating a new batch
  134. const createNewBatch = () => {
  135. selectedBatchId.value = 'new';
  136. formData.value.batchNum = '新建批次';
  137. count.value = 0; // Reset count or set to a default value
  138. };
  139. onLoad(() => {
  140. // #ifdef APP-PLUS
  141. uni.$u.useGlobalEvent((e) => {
  142. formData.value.packageCode = e.barcode
  143. handleSubmitBatch()
  144. })
  145. // #endif
  146. })
  147. </script>
  148. <style lang="scss" scoped>
  149. @import "../components/common.scss"
  150. </style>