乐菲 1 week ago
parent
commit
a5653cc8a0

+ 1 - 1
pages/workbranch/warehouse/scanInOut/In/scanInPage.vue

@@ -31,7 +31,7 @@
 					<view class="search-item">
 						<text class="search-label">申请单号</text>
 						<view class="search-input-wrapper">
-							<input type="text" v-model="requestNo" placeholder="请输入申请单号" class="search-input" />
+							<input type="text" v-model="requestNo" placeholder="请输入申请单号" class="search-input" focus />
 							<text class="scan-icon font-icons" @tap="scanCode">
 								&#xe6b7;
 							</text>

+ 5 - 1
pages/workbranch/warehouse/scanInOut/In/scannedMaterials.vue

@@ -40,7 +40,7 @@
 						@confirm="handleKeydown" /> -->
               <!-- 不禁用软键盘 -->
               <uni-easyinput ref="easyinput" v-model="scanBatchNumber" :input-border="false"
-						:clearable="false" type="text" focus placeholder="请扫描物料二维码"
+						:clearable="false" type="text" placeholder="请扫描物料二维码"
 						@confirm="handleKeydown" />
 					<text class="font-icons" @click="handleScanMaterial">
 						&#xe6b7;
@@ -730,6 +730,10 @@ const checkFifo = (qrCode) => {
           }
           erpStockName.value = data.erpStockName // 仓库名称
           wmsStoreName.value = data.wmsStoreName // 货位名称
+          // 关键:让物料输入框获得焦点
+          nextTick(() => {
+            easyinput.value.onFocus()
+          })
         } else {
           // #ifdef APP-PLUS
           plus.device.beep(2)

+ 1 - 1
pages/workbranch/warehouse/scanInOut/Out/scanOutPage.vue

@@ -31,7 +31,7 @@
 					<view class="search-item">
 						<text class="search-label">申请单号</text>
 						<view class="search-input-wrapper">
-							<input type="text" v-model="requestNo" placeholder="请输入申请单号" class="search-input" />
+							<input type="text" v-model="requestNo" placeholder="请输入申请单号" class="search-input" focus />
 							<text class="scan-icon font-icons" @tap="scanCode">
 								&#xe6b7;
 							</text>

+ 86 - 79
pages/workbranch/warehouse/scanInOut/Out/scannedMaterials.vue

@@ -289,88 +289,95 @@ export default defineComponent({
       uni.$goBack('/pages/workbranch/warehouse/scanInOut/Out/scanOutPage')
     }
 
-    const handleScanMaterial = function() {
+    const handleScanMaterial = async function() {
       // #ifdef APP-PLUS
+      /* 0. 基本校验 */
+
+      /* 1. 先调摄像头 */
       const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module');
-      mpaasScanModule.mpaasScan(
-        { scanType: ['qrCode', 'barCode'], hideAlbum: false },
-        async (ret) => {
-          if (ret.resp_code !== 1000) return;
-          const qrCode = ret.resp_result;
-          /* ===== 新增 FIFO 校验 ===== */
-          const ok = await checkFifo(qrCode);
-          if (!ok && !fifoGo.value) return;
-          /* ========================= */
-          uni.$reqGet('scanPrepareMaterial', { qrCode })
-            .then(({ code, data, msg }) => {
-              fifoGo.value = false;
-              if (code !== 0) {
-                // #ifdef APP-PLUS
-                plus.device.beep(2);
-                // #endif
-                errorTipMessage.value = msg;
-                errorTip.value.open();
-                errorState.value = 0;
-                return;
-              }
-            
-              /* ---------- 新增仓库ID校验 ---------- */
-              if (!validateWarehouseId(data)) {
-                return; // 仓库ID不一致,终止后续逻辑
-              }
-              /* ------------------------------------ */
-              
-              /* ---------- 新增批号重复校验 ---------- */
-              const cur = Array.isArray(data) ? data[0] : data;
-              if (cur && isBatchExist(cur.batchNumber)) {
-                showBatchRepeatTip();
-                return;// 直接终止
-              }
-              /* ------------------------------------ */
-            
-              scanBatchNumber.value = qrCode;
-              // 以下保持你原有逻辑不变
-              if (Object.prototype.toString.call(data) === '[object Array]') {
-                fdIndex.value = tableData.value.findIndex(
-                  (item) => item?.materialNo === data[0]?.materialNo
-                );
-              }
-              if (fdIndex.value === -1) {
-                // #ifdef APP-PLUS
-                plus.device.beep(2);
-                // #endif
-                errorTipMessage.value = '请扫描所需物料的物料条码';
-                errorTip.value.open();
-                errorState.value = 0;
-                return;
-              }
-            
-              currentScanMaterial.value = data[0] ?? [];
-              const row = tableData.value[fdIndex.value];
-              if (row.nowDeliveredQty > row.completedQty) {
-                /* ===== 前端暂存逻辑 ===== */
-                row.completedQty += currentScanMaterial.value.receiptQty || 1;
-                localScannedList.value.push({
-                  ...currentScanMaterial.value,
-                  batchQty: currentScanMaterial.value.receiptQty || 1,
-                  supplierName: currentScanMaterial.value.supplierName || '',
-                });
-                flushBeforeTableData();
-                setInputFocus();
-              } else {
-                // #ifdef APP-PLUS
-                plus.device.beep(2);
-                // #endif
-                errorTipMessage.value = '已备数量已满,无需再扫';
-                errorTip.value.open();
-                errorState.value = 0;
-              }
-            }).catch(() => {
-      // 异常也要复位
-      fifoGo.value = false
-    });
-        }
+      const ret = await new Promise(resolve => 
+        mpaasScanModule.mpaasScan(
+          { scanType: ['qrCode', 'barCode'], hideAlbum: false },
+          resolve
+        )
       );
+      if (ret.resp_code !== 1000) return;
+
+      const qrCode = ret.resp_result;
+
+      /* 2. FIFO 校验 */
+      const ok = await checkFifo(qrCode);
+      if (!ok && !fifoGo.value) return;
+
+      /* 3. 业务接口 */
+      uni.$reqGet('scanPrepareMaterial', { qrCode })
+        .then(({ code, data, msg }) => {
+          fifoGo.value = false;
+          if (code !== 0) {
+            // #ifdef APP-PLUS
+            plus.device.beep(2);
+            // #endif
+            errorTipMessage.value = msg;
+            errorTip.value.open();
+            errorState.value = 0;
+            return;
+          }
+        
+          /* ---------- 新增仓库ID校验 ---------- */
+          if (!validateWarehouseId(data)) {
+            return; // 仓库ID不一致,终止后续逻辑
+          }
+          /* ------------------------------------ */
+          
+          /* ---------- 新增批号重复校验 ---------- */
+          const cur = Array.isArray(data) ? data[0] : data;
+          if (cur && isBatchExist(cur.batchNumber)) {
+            showBatchRepeatTip();
+            return;// 直接终止
+          }
+          /* ------------------------------------ */
+        
+          scanBatchNumber.value = qrCode;
+          // 以下保持你原有逻辑不变
+          if (Object.prototype.toString.call(data) === '[object Array]') {
+            fdIndex.value = tableData.value.findIndex(
+              (item) => item?.materialNo === data[0]?.materialNo
+            );
+          }
+          if (fdIndex.value === -1) {
+            // #ifdef APP-PLUS
+            plus.device.beep(2);
+            // #endif
+            errorTipMessage.value = '请扫描所需物料的物料条码';
+            errorTip.value.open();
+            errorState.value = 0;
+            return;
+          }
+        
+          currentScanMaterial.value = data[0] ?? [];
+          const row = tableData.value[fdIndex.value];
+          if (row.nowDeliveredQty > row.completedQty) {
+            /* ===== 前端暂存逻辑 ===== */
+            row.completedQty += currentScanMaterial.value.receiptQty || 1;
+            localScannedList.value.push({
+              ...currentScanMaterial.value,
+              batchQty: currentScanMaterial.value.receiptQty || 1,
+              supplierName: currentScanMaterial.value.supplierName || '',
+            });
+            flushBeforeTableData();
+            setInputFocus();
+          } else {
+            // #ifdef APP-PLUS
+            plus.device.beep(2);
+            // #endif
+            errorTipMessage.value = '已备数量已满,无需再扫';
+            errorTip.value.open();
+            errorState.value = 0;
+          }
+        }).catch(() => {
+          // 异常也要复位
+          fifoGo.value = false;
+        });
       // #endif
     };