From b5d01891fbbd69d8d50d2b4fb562fac3130fc2d6 Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期一, 20 四月 2026 11:01:22 +0800
Subject: [PATCH] 虚拟出入库单据锁定
---
项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue | 497 ++++++++++++++++++++++++++++++++-----------------------
1 files changed, 289 insertions(+), 208 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue"
index 7e80215..7fc2023 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue"
@@ -8,6 +8,14 @@
title="铏氭嫙鍑哄叆搴�"
class="custom-vol-box"
>
+ <!-- 鎻愪氦閬僵灞傦細瑕嗙洊鏁翠釜寮圭獥鍐呭鍖哄煙 -->
+ <div class="submit-mask" v-show="submitLoading">
+ <div class="mask-content">
+ <el-loading-spinner class="loading-icon" />
+ <span class="loading-text">姝e湪鎻愪氦鍑哄簱锛岃绋嶅��...</span>
+ </div>
+ </div>
+
<div>
<!-- 鍗曟嵁杈撳叆鍖哄煙锛堟敮鎸佹壂鐮侊級 -->
<el-form
@@ -23,13 +31,12 @@
clearable
style="width: 220px; margin-right: 10px;"
@input="handleOutboundInput"
- @keyup.enter="(e) => {
- e.stopPropagation(); // 闃绘浜嬩欢鍐掓场
- e.preventDefault(); // 闃绘榛樿琛屼负
- focusBarcodeInputDirectly();
- }"
+ @keyup.enter="validateOutboundOrder"
ref="outboundInputRef"
+ :disabled="loading || submitLoading || isOutboundVerified"
></el-input>
+ <span v-if="isOutboundVerified" class="verified-tag">鉁� 宸查獙璇�</span>
+ <span v-else-if="loading" class="loading-tag">鉁� 楠岃瘉涓�...</span>
</el-form-item>
<el-form-item label="閲囪喘鍗曟嵁:" name="purchaseOrderNo">
<el-input
@@ -40,6 +47,7 @@
@input="handlePurchaseInput"
readonly
ref="purchaseInputRef"
+ :disabled="submitLoading"
></el-input>
</el-form-item>
</el-form>
@@ -56,7 +64,6 @@
label="鎵弿鏉$爜:"
style="width: 80%"
name="barcode"
- :rules="[{ required: true, message: '璇锋壂鎻忔垨杈撳叆鏉$爜', trigger: 'blur' }]"
>
<el-input
ref="barcodeInputRef"
@@ -65,7 +72,7 @@
@keydown.enter="debouncedHandleScan"
autofocus
class="custom-input"
- :disabled="!orderForm.outboundOrderNo || loading"
+ :disabled="!isOutboundVerified || loading || submitLoading"
></el-input>
</el-form-item>
<el-form-item>
@@ -74,7 +81,7 @@
size="small"
@click="handleScan"
class="custom-button"
- :disabled="!orderForm.outboundOrderNo || loading"
+ :disabled="!isOutboundVerified || loading || submitLoading"
>
<Search /> 纭鎵弿
</el-button>
@@ -90,19 +97,28 @@
<div class="card-body">
<el-scrollbar height="400px" class="custom-scrollbar">
<transition-group name="barcode-item-transition">
- <div class="barcode-item" v-for="(item, index) in scannedBarcodes" :key="item.barcode" :data-index="index">
- <span class="barcode-text">{{ index + 1 }}. {{ item.barcode }}</span>
+ <div class="barcode-item" v-for="(item, index) in scannedBarcodes" :key="`${item.barcode}-${index}`">
+ <div class="barcode-detail">
+ <div class="detail-row"><span class="label">鏉$爜锛�</span><span class="value">{{ item.barcode || '-' }}</span></div>
+ <div class="detail-row"><span class="label">鐗╂枡缂栫爜锛�</span><span class="value">{{ item.materielCode || '-' }}</span></div>
+ <div class="detail-row"><span class="label">鐗╂枡鍚嶇О锛�</span><span class="value">{{ item.materielName || '-' }}</span></div>
+ <div class="detail-row"><span class="label">鎵规鍙凤細</span><span class="value">{{ item.batchNo || '-' }}</span></div>
+ <div class="detail-row"><span class="label">鏉$爜鏁伴噺锛�</span><span class="value">{{ item.orderQuantity || item.quantity || 0 }}</span></div>
+ <div class="detail-row"><span class="label">渚涘簲鍟嗙紪鐮侊細</span><span class="value">{{ item.supplyCode || '-' }}</span></div>
+ <div class="detail-row"><span class="label">閲囪喘鍗曞彿锛�</span><span class="value">{{ item.purchaseOrderNo || '-' }}</span></div>
+ </div>
<el-button
class="delete-btn"
@click="removeItem(index, item.barcode)"
icon="Delete"
circle
- :disabled="loading"
+ :disabled="loading || submitLoading"
></el-button>
</div>
</transition-group>
<div class="empty-tip" v-if="scannedBarcodes.length === 0">
- <span>鏆傛棤鎵弿璁板綍锛岃鍏堣緭鍏ュ嚭搴撳崟鎹悗鎵弿鏉$爜</span>
+ <span v-if="isOutboundVerified">鏆傛棤鎵弿璁板綍锛岃鎵弿鏉$爜</span>
+ <span v-else>璇峰厛杈撳叆骞堕獙璇佹湁鏁堢殑鍑哄簱鍗曟嵁鍙�</span>
</div>
</el-scrollbar>
</div>
@@ -116,7 +132,7 @@
type="primary"
size="small"
@click="submit"
- :disabled="scannedBarcodes.length === 0 || !orderForm.outboundOrderNo || !orderForm.purchaseOrderNo || loading"
+ :disabled="scannedBarcodes.length === 0 || !isOutboundVerified || loading || submitLoading"
class="submit-btn"
>
<Check /> 鎻愪氦鍑哄簱
@@ -124,13 +140,9 @@
<el-button
type="text"
size="small"
- @click="(e) => {
- e.stopPropagation();
- e.preventDefault();
- showDetailBox = false;
- }"
+ @click="handleCancel"
class="cancel-btn"
- :disabled="loading"
+ :disabled="loading || submitLoading"
>
鍙栨秷
</el-button>
@@ -141,26 +153,21 @@
</template>
<script setup>
-import { ref, reactive, onMounted, nextTick, watch } from 'vue';
+import { ref, reactive, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
import { ElMessage } from 'element-plus';
import { Search, Check } from '@element-plus/icons-vue';
-
import VolBox from "@/components/basic/VolBox.vue";
import http from '@/api/http';
// 鍝嶅簲寮忔暟鎹�
const showDetailBox = ref(false);
-const orderForm = reactive({
- outboundOrderNo: "",
- purchaseOrderNo: ""
-});
-const formData = reactive({
- barcode: "",
-});
+const orderForm = reactive({ outboundOrderNo: "", purchaseOrderNo: "" });
+const formData = reactive({ barcode: "" });
const scannedBarcodes = ref([]);
const loading = ref(false);
-// 鏂板锛氬瓨鍌ㄩ娆℃壂鎻忕殑閲囪喘鍗曞彿锛堢敤浜庝竴鑷存�ф牎楠岋級
-const firstPurchaseOrderNo = ref(null);
+const submitLoading = ref(false);
+const isOutboundVerified = ref(false);
+let unlockCalled = false; // 闃叉閲嶅瑙i攣
// 妯℃澘寮曠敤
const formRef = ref(null);
@@ -168,237 +175,257 @@
const outboundInputRef = ref(null);
const purchaseInputRef = ref(null);
-// 缁勪欢鎸傝浇鏃惰仛鐒﹀埌鍑哄簱鍗曡緭鍏ユ
-onMounted(() => {
- nextTick(() => {
- outboundInputRef.value?.focus();
- });
-});
+// 闊抽璧勬簮
+const successAudioSrc = require('@/assets/audio/success.mp3');
+const errorAudioSrc = require('@/assets/audio/error.mp3');
+const playAudio = (src, volume = 0.8) => {
+ try { const audio = new Audio(src); audio.volume = volume; audio.play().catch(() => {}); } catch(e) {}
+};
+const playSuccess = () => playAudio(successAudioSrc);
+const playError = () => playAudio(errorAudioSrc);
-// 鐩戝惉鎵弿鍒楄〃锛岃嫢涓虹┖鍒欓噸缃娆¢噰璐崟鍙�
-watch(scannedBarcodes, (newVal) => {
- if (newVal.length === 0) {
- firstPurchaseOrderNo.value = null;
- orderForm.purchaseOrderNo = ""; // 鍚屾娓呯┖閲囪喘鍗曡緭鍏ユ
+// ========== 瑙i攣鏍稿績閫昏緫锛堜娇鐢ㄦ柊鎺ュ彛 MovePickingOrders锛� ==========
+const unlockOutboundOrder = async () => {
+ if (!isOutboundVerified.value || !orderForm.outboundOrderNo?.trim()) return;
+ if (unlockCalled) return;
+ unlockCalled = true;
+ const outboundOrderNo = orderForm.outboundOrderNo.trim();
+ try {
+ // 鏇挎崲涓� MovePickingOrders 鎺ュ彛
+ await http.post(`/api/OutboundPicking/MovePickingOrders?outOrder=${outboundOrderNo}`, null, "瑙i攣鍑哄簱鍗曚腑...").catch(() => {});
+ } catch (error) {
+ // 闈欓粯澶辫触
}
-}, { deep: true });
-
-// 绠�鍗曢槻鎶栧嚱鏁帮紙鏃犻渶渚濊禆lodash锛�
-const debounce = (fn, delay = 100) => {
- let timer = null;
- return (...args) => {
- if (timer) clearTimeout(timer);
- timer = setTimeout(() => {
- fn.apply(this, args);
- }, delay);
- };
};
-// 鎵撳紑寮圭獥
+// 椤甸潰鍏抽棴/鍒锋柊鏃剁殑鍚屾瑙i攣锛堜娇鐢� sendBeacon 鎴� fetch keepalive锛�
+const unlockOnPageUnload = () => {
+ if (!isOutboundVerified.value || !orderForm.outboundOrderNo?.trim()) return;
+ const outboundOrderNo = orderForm.outboundOrderNo.trim();
+ const url = `/api/OutboundPicking/MovePickingOrders?outOrder=${encodeURIComponent(outboundOrderNo)}`;
+ // 浣跨敤 fetch keepalive 鍙戦��
+ fetch(url, { method: 'POST', keepalive: true, headers: { 'Content-Type': 'application/json' } }).catch(() => {});
+};
+
+// 鐩戝惉寮圭獥鍏抽棴锛堜换浣曟柟寮忥細鍙夊彿銆丒SC銆侀伄缃┿�佸彇娑堟寜閽瓑锛�
+watch(showDetailBox, (newVal, oldVal) => {
+ if (oldVal === true && newVal === false) {
+ // 寮圭獥鍏抽棴鏃惰皟鐢ㄨВ閿�
+ unlockOutboundOrder();
+ }
+});
+
+// 鍙栨秷鎸夐挳
+const handleCancel = (e) => {
+ e?.stopPropagation();
+ e?.preventDefault();
+ showDetailBox.value = false;
+};
+
+// 鎵撳紑寮圭獥锛堥噸缃墍鏈夌姸鎬侊級
const open = () => {
+ unlockCalled = false;
showDetailBox.value = true;
scannedBarcodes.value = [];
formData.barcode = "";
orderForm.outboundOrderNo = "";
orderForm.purchaseOrderNo = "";
- // 閲嶇疆棣栨閲囪喘鍗曞彿
- firstPurchaseOrderNo.value = null;
- nextTick(() => {
- outboundInputRef.value?.focus();
- });
+ submitLoading.value = false;
+ isOutboundVerified.value = false;
+ nextTick(() => outboundInputRef.value?.focus());
};
-// 鍑哄簱鍗曡緭鍏ュ鐞嗭紙鎵爜鎴栨墜鍔ㄨ緭鍏ワ級
-const handleOutboundInput = (value) => {
- if (value && value.trim()) {
- // 鍑哄簱鍗曞彿鏍煎紡楠岃瘉閫昏緫锛堟寜闇�淇濈暀锛�
- }
-};
-
-// 閲囪喘鍗曡緭鍏ュ鐞嗭紙鎵爜鎴栨墜鍔ㄨ緭鍏ワ級
-const handlePurchaseInput = (value) => {
- if (value && value.trim()) {
- // 閲囪喘鍗曞彿鏍煎紡楠岃瘉閫昏緫锛堟寜闇�淇濈暀锛�
- }
-};
-
-// 鐩存帴璺宠浆鍒版潯鐮佽緭鍏ユ锛堟棤闇�鍏堝~閲囪喘鍗曪級
-const focusBarcodeInputDirectly = () => {
- if (orderForm.outboundOrderNo.trim()) {
- barcodeInputRef.value?.focus();
- } else {
- ElMessage.warning("璇峰厛杈撳叆鏈夋晥鐨勫嚭搴撳崟鎹彿");
- }
-};
-
-/**
- * 鏍规嵁鏉$爜鏌ヨ閲囪喘鍗曟帴鍙o紙瀹屽叏瀵归綈绀轰緥璇锋眰鏍煎紡锛�
- * @param {string} barcode 鏉$爜
- * @returns {Promise<string>} 閲囪喘鍗曞彿
- */
-const getPurchaseOrderByBarcode = async (barcode) => {
- // 瀹屽叏鎸夌収绀轰緥鏍煎紡锛歶rl鎷兼帴鍙傛暟 + 绗簩涓弬鏁颁紶鎻愮ず鏂囨湰
- const res = await http.post(`/api/OutboundPicking/GetPurchaseOrderByBarcode?barCode=${encodeURIComponent(barcode)}`, "鏌ヨ閲囪喘鍗曚腑...");
-
- if (res.status !== true) {
- throw new Error(res.message || "鏌ヨ閲囪喘鍗曞け璐�");
- }
- if (!res.data?.purchaseOrderNo) {
- throw new Error("鏈煡璇㈠埌璇ユ潯鐮佸搴旂殑閲囪喘鍗�");
- }
- return res.data.purchaseOrderNo;
-};
-
-// 鎵弿鏉$爜鏍稿績閫昏緫
-const handleScan = async () => {
- if (!formRef.value) return;
- // 楠岃瘉鏉$爜蹇呭~
- await formRef.value.validateField('barcode');
-
- const barcode = formData.barcode.trim();
+// 楠岃瘉鍑哄簱鍗曞彿锛堜粛浣跨敤鍘熸帴鍙o紝姝ゆ帴鍙g敤浜庨獙璇佸崟鎹湁鏁堟�э級
+const validateOutboundOrder = async () => {
const outboundOrderNo = orderForm.outboundOrderNo.trim();
+ if (!outboundOrderNo) { ElMessage.warning("璇疯緭鍏ュ嚭搴撳崟鎹彿"); return; }
+ try {
+ loading.value = true;
+ const res = await http.post(`/api/OutboundPicking/GetAvailablePickingOrders?outOrder=${outboundOrderNo}`, "楠岃瘉鍑哄簱鍗曟嵁鍙蜂腑...");
+ if (res.status !== true) {
+ orderForm.outboundOrderNo = "";
+ isOutboundVerified.value = false;
+ ElMessage.error(res.message || "鍑哄簱鍗曟嵁鍙烽獙璇佸け璐�");
+ nextTick(() => outboundInputRef.value?.focus());
+ return;
+ }
+ isOutboundVerified.value = true;
+ ElMessage.success("鍑哄簱鍗曟嵁鍙烽獙璇侀�氳繃");
+ nextTick(() => barcodeInputRef.value?.focus());
+ } catch (error) {
+ orderForm.outboundOrderNo = "";
+ isOutboundVerified.value = false;
+ ElMessage.error(`楠岃瘉寮傚父锛�${error.message || "缃戠粶閿欒"}`);
+ nextTick(() => outboundInputRef.value?.focus());
+ } finally {
+ loading.value = false;
+ }
+};
- // 妫�鏌ユ潯鐮佹槸鍚﹀凡鎵弿
- if (scannedBarcodes.value.some(item => item.barcode === barcode)) {
- ElMessage.warning(`鏉$爜 ${barcode} 宸叉壂鎻忚繃锛岃鍕块噸澶嶆壂鎻廯);
+const handleOutboundInput = (val) => { if (val?.trim()) isOutboundVerified.value = false; };
+const handlePurchaseInput = (val) => {};
+
+// 鑾峰彇閲囪喘鍗曞彿
+const getPurchaseOrderByBarcode = async (barcode) => {
+ const res = await http.post(`/api/OutboundPicking/GetPurchaseOrderByBarcode?barCode=${encodeURIComponent(barcode)}`, "鏌ヨ閲囪喘鍗曞彿涓�...");
+ if (res.status !== true) throw new Error(res.message || "鏌ヨ澶辫触");
+ let purchaseOrderNo = '';
+ if (Array.isArray(res.data) && res.data.length > 0) purchaseOrderNo = res.data[0].purchaseOrderNo || res.data[0].orderId;
+ else purchaseOrderNo = res.data?.purchaseOrderNo || res.data?.orderId;
+ return purchaseOrderNo;
+};
+
+// 鎵弿鏉$爜
+const handleScan = async () => {
+ if (!isOutboundVerified.value) {
+ ElMessage.warning("璇峰厛楠岃瘉鍑哄簱鍗曟嵁鍙�");
+ playError();
+ nextTick(() => outboundInputRef.value?.focus());
+ return;
+ }
+ const barcode = formData.barcode.trim();
+ if (!barcode) return;
+ const isDuplicate = scannedBarcodes.value.some(item => item.barcode === barcode);
+ if (isDuplicate) {
+ ElMessage.warning(`鏉$爜銆�${barcode}銆戝凡瀛樺湪`);
+ playError();
formData.barcode = "";
nextTick(() => barcodeInputRef.value?.focus());
return;
}
-
try {
loading.value = true;
-
- // 姝ラ1锛氫粎浼犳潯鐮佹煡璇㈤噰璐崟锛堜娇鐢ㄧず渚嬫牸寮忕殑璇锋眰锛�
- const purchaseOrderNo = await getPurchaseOrderByBarcode(barcode);
-
- // 鏍稿績鏍¢獙锛氶噰璐崟涓�鑷存�ф鏌�
- if (firstPurchaseOrderNo.value) {
- // 闈為娆℃壂鎻忥紝鏍¢獙閲囪喘鍗曞彿鏄惁涓�鑷�
- if (purchaseOrderNo !== firstPurchaseOrderNo.value) {
- throw new Error(`褰撳墠鏉$爜瀵瑰簲鐨勯噰璐崟銆�${purchaseOrderNo}銆戜笌棣栨鎵弿鐨勯噰璐崟銆�${firstPurchaseOrderNo.value}銆戜笉涓�鑷达紝绂佹鎵弿锛乣);
- }
- } else {
- // 棣栨鎵弿锛岃褰曢噰璐崟鍙�
- firstPurchaseOrderNo.value = purchaseOrderNo;
- }
-
- // 璧嬪�奸噰璐崟鍒拌緭鍏ユ
- orderForm.purchaseOrderNo = purchaseOrderNo;
- ElMessage.success(`鎴愬姛鏌ヨ鍒伴噰璐崟锛�${purchaseOrderNo}`);
-
- // 姝ラ2锛氳皟鐢ㄥ師鏈夋潯鐮侀獙璇佹帴鍙o紙濡傞渶瀵归綈鏍煎紡鍙悓姝ヤ慨鏀癸紝姝ゅ淇濈暀鍘熸湁鏍煎紡锛�
+ let purchaseOrderNo = '';
+ try {
+ purchaseOrderNo = await getPurchaseOrderByBarcode(barcode);
+ if (purchaseOrderNo) orderForm.purchaseOrderNo = purchaseOrderNo;
+ } catch (e) { ElMessage.info("鏈煡璇㈠埌閲囪喘鍗曞彿锛岀户缁獙璇佹潯鐮�"); playError(); }
const validateRes = await http.post("/api/OutboundPicking/BarcodeValidate", {
- outOder: outboundOrderNo,
- inOder: purchaseOrderNo,
+ outOder: orderForm.outboundOrderNo,
+ inOder: purchaseOrderNo || orderForm.purchaseOrderNo,
barCode: barcode
});
-
- if (validateRes.status === true) {
- scannedBarcodes.value.push({ barcode });
- ElMessage.success("鎵弿鎴愬姛");
+ if (validateRes.status === true && Array.isArray(validateRes.data) && validateRes.data.length) {
+ const newItems = validateRes.data.map(item => ({
+ barcode: item.barcode || '',
+ materielCode: item.materielCode || '',
+ materielName: item.materielName || '',
+ batchNo: item.batchNo || '',
+ orderQuantity: item.orderQuantity || item.quantity || 0,
+ supplyCode: item.supplyCode || '',
+ purchaseOrderNo: purchaseOrderNo || ''
+ }));
+ scannedBarcodes.value.push(...newItems);
+ ElMessage.success(`鎵弿鎴愬姛锛屾柊澧� ${newItems.length} 鏉);
+ playSuccess();
formData.barcode = "";
} else {
- ElMessage.error("鎵弿澶辫触锛�" + (validateRes.message || '鏉$爜楠岃瘉澶辫触'));
+ ElMessage.error(validateRes.message || '鏉$爜楠岃瘉澶辫触');
+ playError();
+ formData.barcode = "";
}
} catch (error) {
- // 鎹曡幏閲囪喘鍗曚笉涓�鑷寸瓑閿欒骞舵彁绀�
- ElMessage.error(error.message);
- // 娓呯┖褰撳墠杈撳叆妗嗭紝鑱氱劍鏉$爜杈撳叆妗�
+ ElMessage.error('鏉$爜楠岃瘉寮傚父');
+ playError();
formData.barcode = "";
- nextTick(() => barcodeInputRef.value?.focus());
} finally {
loading.value = false;
- // 寮哄埗鑱氱劍鏉$爜杈撳叆妗嗭紝閬垮厤鐒︾偣璺冲埌寮圭獥澶�
- nextTick(() => {
- if (barcodeInputRef.value) {
- barcodeInputRef.value.focus();
- // 娓呯┖杈撳叆妗嗛�変腑鐘舵�侊紙鎵爜鏋彲鑳芥畫鐣欓�変腑锛�
- if (barcodeInputRef.value.input) {
- barcodeInputRef.value.input.select = () => {};
- }
- }
- });
+ nextTick(() => barcodeInputRef.value?.focus());
}
};
-// 甯﹂槻鎶栧拰浜嬩欢鎷︽埅鐨勬壂鎻忓鐞嗭紙閫傞厤鎵爜鏋級
-const debouncedHandleScan = debounce(async (e) => {
- // 闃绘浜嬩欢鍐掓场鍜岄粯璁よ涓�
- e.stopPropagation();
- e.preventDefault();
- await handleScan();
-}, 100);
+const debounce = (fn, delay = 100) => {
+ let timer = null;
+ return (...args) => { if (timer) clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), delay); };
+};
+const debouncedHandleScan = debounce(async (e) => { e.stopPropagation(); e.preventDefault(); await handleScan(); }, 100);
-// 绉婚櫎鍗曟潯鎵弿璁板綍
+// 鍒犻櫎鏉$爜
const removeItem = async (index, barcode) => {
try {
loading.value = true;
+ const currentItem = scannedBarcodes.value[index];
const res = await http.post("/api/OutboundPicking/DeleteBarcode", {
outOder: orderForm.outboundOrderNo,
- inOder: orderForm.purchaseOrderNo,
+ inOder: currentItem?.purchaseOrderNo || orderForm.purchaseOrderNo,
barCode: barcode
});
-
if (res.status === true) {
scannedBarcodes.value.splice(index, 1);
ElMessage.success("鍒犻櫎鎴愬姛");
- // 鑻ュ垹闄ゅ悗鏃犳潯鐮侊紝鑷姩閲嶇疆棣栨閲囪喘鍗曞彿鍜岄噰璐崟杈撳叆妗�
- if (scannedBarcodes.value.length === 0) {
- firstPurchaseOrderNo.value = null;
- orderForm.purchaseOrderNo = "";
- }
+ if (scannedBarcodes.value.length === 0) orderForm.purchaseOrderNo = "";
} else {
- ElMessage.error("鍒犻櫎澶辫触锛�" + (res.message || '鍒犻櫎澶辫触'));
+ ElMessage.error("鍒犻櫎澶辫触锛�" + (res.message || ''));
}
} catch (error) {
- ElMessage.error("鍒犻櫎鏉$爜寮傚父锛�" + error.message);
+ ElMessage.error("鍒犻櫎寮傚父");
} finally {
loading.value = false;
+ nextTick(() => barcodeInputRef.value?.focus());
}
};
// 鎻愪氦鍑哄簱
const submit = async () => {
- if (scannedBarcodes.value.length === 0) {
- ElMessage.warning("璇峰厛鎵弿鑷冲皯涓�鏉℃潯鐮�");
+ if (!isOutboundVerified.value) {
+ ElMessage.warning("鍑哄簱鍗曟嵁鍙锋湭楠岃瘉");
+ nextTick(() => outboundInputRef.value?.focus());
return;
}
-
+ if (scannedBarcodes.value.length === 0) {
+ ElMessage.warning("璇峰厛鎵弿鏉$爜");
+ nextTick(() => barcodeInputRef.value?.focus());
+ return;
+ }
const barcodes = scannedBarcodes.value.map(item => item.barcode);
-
+ const purchaseOrderNos = [...new Set(scannedBarcodes.value.map(item => item.purchaseOrderNo).filter(Boolean))];
try {
- loading.value = true;
+ submitLoading.value = true;
const res = await http.post("/api/OutboundPicking/NoStockOutSubmit", {
OutOderSubmit: orderForm.outboundOrderNo,
- InOderSubmit: orderForm.purchaseOrderNo,
+ InOderSubmit: purchaseOrderNos.join(',') || '',
BarCodeSubmit: barcodes
});
-
if (res.status === true) {
ElMessage.success("鍑哄簱鎻愪氦鎴愬姛");
- showDetailBox.value = false;
- // 鎻愪氦鎴愬姛鍚庨噸缃姸鎬�
- firstPurchaseOrderNo.value = null;
- scannedBarcodes.value = [];
+ unlockOutboundOrder();
+ showDetailBox.value = false; // 瑙﹀彂 watch 瑙i攣锛堜絾鎻愪氦鎴愬姛鍚庨�氬父涓嶉渶瑕佽В閿侊紝鍥犱负宸茬粡鍑哄簱浜嗭紝涓嶈繃鍚庣搴旇嚜琛屽鐞嗙姸鎬侊級
+ // 娉ㄦ剰锛氭彁浜ゆ垚鍔熷悗涓嶅簲璇ュ啀璋冪敤瑙i攣鎺ュ彛锛屽洜涓哄崟鎹凡澶勭悊瀹屾瘯銆傝繖閲岄�氳繃鏍囧織閬垮厤锛歴ubmit 鎴愬姛鍚庨噸缃獙璇佺姸鎬�
+ isOutboundVerified.value = false;
+ unlockCalled = true; // 闃叉 watch 鍐嶆璋冪敤瑙i攣
} else {
- ElMessage.error("鍑哄簱鎻愪氦澶辫触锛�" + (res.message || '鎻愪氦澶辫触'));
+ unlockOutboundOrder();
+ ElMessage.error("鍑哄簱鎻愪氦澶辫触锛�" + (res.message || ''));
+ nextTick(() => barcodeInputRef.value?.focus());
}
} catch (error) {
- ElMessage.error("鍑哄簱鎻愪氦寮傚父锛�" + error.message);
+ unlockOutboundOrder();
+ ElMessage.error("鎻愪氦寮傚父锛�" + error.message);
+ nextTick(() => barcodeInputRef.value?.focus());
} finally {
+ submitLoading.value = false;
loading.value = false;
}
};
-// 鏆撮湶缁欑埗缁勪欢鐨勬柟娉�
-defineExpose({
- open
+// 鐢熷懡鍛ㄦ湡锛氭坊鍔犻〉闈㈠叧闂椂鐨勮В閿佺洃鍚�
+onMounted(() => {
+ window.addEventListener('beforeunload', unlockOnPageUnload);
});
+onBeforeUnmount(() => {
+ window.removeEventListener('beforeunload', unlockOnPageUnload);
+ // 缁勪欢鍗歌浇鏃跺鏋滃脊绐楄繕寮�鐫�锛屼篃灏濊瘯瑙i攣锛堜絾閫氬父椤甸潰鍏抽棴浼氳Е鍙� beforeunload锛�
+ if (showDetailBox.value) {
+ unlockOutboundOrder();
+ }
+});
+
+// 鏆撮湶鏂规硶
+defineExpose({ open });
</script>
<style scoped>
-/* 鍏抽敭锛氬畾涔夊垪琛ㄩ」鐨勮繃娓″姩鐢� */
+/* 杩囨浮鍔ㄧ敾 */
.barcode-item-transition-enter-active,
.barcode-item-transition-leave-active {
transition: all 0.3s ease;
@@ -411,15 +438,59 @@
opacity: 0;
transform: translateX(30px);
}
-/* 纭繚鍒犻櫎鏃跺叾浠栧厓绱犲钩婊戜笂绉� */
.barcode-item-transition-move {
transition: transform 1s ease;
+}
+
+/* 鎻愪氦閬僵灞傛牱寮� */
+.submit-mask {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background-color: rgba(255, 255, 255, 0.85);
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ z-index: 100;
+ border-radius: inherit;
+}
+.mask-content {
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ gap: 12px;
+ color: #409eff;
+ font-size: 15px;
+}
+.loading-icon {
+ font-size: 24px;
+ animation: el-loading-circle 1.5s linear infinite;
+}
+
+/* 楠岃瘉鐘舵�佹爣绛炬牱寮� */
+.verified-tag {
+ color: #67c23a;
+ font-size: 12px;
+ margin-left: 8px;
+ font-weight: 500;
+}
+.loading-tag {
+ color: #409eff;
+ font-size: 12px;
+ margin-left: 8px;
+ font-weight: 500;
+ animation: spin 1s linear infinite;
+}
+@keyframes spin {
+ 0% { transform: rotate(0deg); }
+ 100% { transform: rotate(360deg); }
}
.scan-list {
width: 100%;
}
-
.custom-card {
border-radius: 12px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
@@ -428,7 +499,6 @@
.custom-card:hover {
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12) !important;
}
-
.card-header {
display: flex;
justify-content: space-between;
@@ -442,12 +512,9 @@
font-size: 15px;
color: #333;
}
-
.card-body {
padding: 0;
}
-
-/* 鑷畾涔夋粴鍔ㄦ潯 */
.custom-scrollbar :deep(.el-scrollbar__thumb) {
background: rgba(0, 0, 0, 0.2);
border-radius: 4px;
@@ -460,37 +527,58 @@
.custom-scrollbar :deep(.el-scrollbar__wrap) {
overflow-x: hidden;
}
-
.barcode-item {
display: flex;
justify-content: space-between;
- align-items: center;
- padding: 10px 15px;
+ align-items: flex-start;
+ padding: 15px;
border-bottom: 1px solid #f7f7f7;
transition: background-color 0.2s ease;
}
.barcode-item:hover {
background-color: #fafafa;
}
-/* 涓哄鏁拌娣诲姞杞诲井鐨勮儗鏅壊锛屽寮哄彲璇绘�� */
.barcode-item:nth-child(odd) {
background-color: #f9f9f9;
}
-.barcode-text {
+.barcode-detail {
flex: 1;
+ display: grid;
+ grid-template-columns: repeat(4, 1fr);
+ gap: 8px 15px;
font-size: 14px;
+}
+@media (max-width: 1200px) {
+ .barcode-detail {
+ grid-template-columns: repeat(3, 1fr);
+ }
+}
+@media (max-width: 992px) {
+ .barcode-detail {
+ grid-template-columns: repeat(2, 1fr);
+ }
+}
+.detail-row {
+ display: flex;
+ align-items: center;
+}
+.label {
+ color: #999;
+ margin-right: 5px;
+ white-space: nowrap;
+}
+.value {
color: #666;
- transition: color 0.2s;
+ flex: 1;
+ word-break: break-all;
}
-.barcode-item:hover .barcode-text {
- color: #409eff;
-}
-
.delete-btn {
color: #ea1919;
font-size: 16px;
transition: all 0.2s;
opacity: 0.7;
+ margin-left: 10px;
+ flex-shrink: 0;
}
.barcode-item:hover .delete-btn {
opacity: 1;
@@ -499,7 +587,6 @@
color: #f56c6c !important;
background: rgba(245, 108, 108, 0.1);
}
-
.empty-tip {
text-align: center;
padding: 80px 0;
@@ -515,8 +602,6 @@
font-size: 40px;
color: #dcdfe6;
}
-
-/* 鑷畾涔夎緭鍏ユ */
.custom-input :deep(.el-input__inner) {
border-radius: 6px;
border-color: #e4e7ed;
@@ -528,8 +613,6 @@
border-color: #409eff;
box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
}
-
-/* 鑷畾涔夋寜閽� */
.custom-button {
border-radius: 6px;
height: 36px;
@@ -542,7 +625,6 @@
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(64, 158, 255, 0.2);
}
-
.footer-actions {
text-align: right;
}
@@ -568,7 +650,6 @@
</style>
<style>
-/* 鍏ㄥ眬鏍峰紡閮ㄥ垎淇濇寔涓嶅彉 */
.text-button:hover {
background-color: #f0f9eb !important;
}
--
Gitblit v1.9.3