|
|
@@ -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
|
|
|
};
|
|
|
|