From 0d6e0f0efa92c9347884c83170ec8d47dd5f5ef4 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 13 十一月 2025 16:03:48 +0800
Subject: [PATCH] fix: 扫码18层的单丝12层也能扫上。
---
src/pages/production/twist/receive/monofil.vue | 44 +++++++++++++++++++++++++++++++++-----------
1 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/src/pages/production/twist/receive/monofil.vue b/src/pages/production/twist/receive/monofil.vue
index 526969d..ebf1542 100644
--- a/src/pages/production/twist/receive/monofil.vue
+++ b/src/pages/production/twist/receive/monofil.vue
@@ -79,7 +79,7 @@
import MonofilCard from "../components/MonofilCard.vue";
import StatisticsModal from "../components/StatisticsModal.vue";
import { useToast } from "wot-design-uni";
-import { onLoad, onUnload } from "@dcloudio/uni-app";
+import { onLoad, onUnload, onShow, onHide } from "@dcloudio/uni-app";
import Scan from "@/components/scan/index.vue";
import ManageApi from "@/api/product/manage";
import TwistApi from "@/api/product/twist";
@@ -95,20 +95,21 @@
const showStatisticsModal = ref(false);
const showManualInput = ref(false);
const manualOutPutId = ref("");
+const isPageVisible = ref(false); // 鏍囪椤甸潰鏄惁鍙
// 鐩戝惉鏍囩鍒囨崲
watch(tab, () => {
if (tab.value) {
- console.log("tab.value:===========1", tab.value);
getList();
}
});
const getScanCode = async (code: any) => {
- console.log("鑷畾涔夋壂鎻忕殑缁撴灉鍥炶皟鍑芥暟:", code);
- // let parseData = code.trim();
- console.log("code:===========", JSON.parse(code.code));
- console.log("id:=============", JSON.parse(code.code).id);
+ // 妫�鏌ラ〉闈㈡槸鍚﹀彲瑙侊紝濡傛灉涓嶅彲瑙佸垯涓嶅鐞嗘壂鐮佹暟鎹�
+ if (!isPageVisible.value) {
+ return;
+ }
+
try {
// 妫�鏌ユ槸鍚﹀凡閫夋嫨鏍囩
if (!tab.value) {
@@ -117,15 +118,25 @@
}
// 鎵惧埌褰撳墠閫変腑鐨勫眰
- console.log("tab.value:===========2", tab.value);
const currentLayer = nodeList.value.find((node) => node.twistedLayer === tab.value);
if (!currentLayer) {
toast.error("鏈壘鍒板綋鍓嶉�変腑鐨勫眰");
return;
}
- console.log("tab.value:===========3", currentLayer);
+
+ // 瑙f瀽鎵爜鏁版嵁
+ const scanData = JSON.parse(code.code);
+
+ // 鍒ゆ柇灞傜骇鏄惁鍖归厤
+ if (scanData.layer && scanData.layer !== currentLayer.twistedLayer) {
+ toast.error(
+ `棰嗙敤灞傜骇涓嶅锛屽綋鍓嶅眰鏄細${currentLayer.twistedLayer}锛岄鐢ㄥ崟涓濆眰鏄細${scanData.layer}`
+ );
+ // return;
+ }
+
const { data } = await TwistApi.getScarn({
- outPutId: JSON.parse(code.code).id,
+ outPutId: scanData.id,
twistId: currentLayer.twistId,
});
@@ -259,7 +270,6 @@
// 璁剧疆榛樿绗竴灞�
if (nodeList.value && nodeList.value.length > 0 && !tab.value) {
tab.value = nodeList.value[0].twistedLayer;
- console.log("璁剧疆榛樿绗竴灞�:", tab.value);
// 璁剧疆榛樿鏍囩鍚庯紝鍔犺浇绗竴灞傜殑鏁版嵁
getList();
}
@@ -344,9 +354,21 @@
getRootNumber(options.id);
// getRootNumber(118);
});
+
+onShow(() => {
+ // 椤甸潰鏄剧ず鏃舵爣璁颁负鍙
+ isPageVisible.value = true;
+});
+
+onHide(() => {
+ // 椤甸潰闅愯棌鏃舵爣璁颁负涓嶅彲瑙�
+ isPageVisible.value = false;
+});
+
onUnload(() => {
- // 寮�鍚箍鎾洃鍚簨浠�
+ // 鍙栨秷骞挎挱鐩戝惉浜嬩欢
uni.$off("scanMono", getScanCode);
+ isPageVisible.value = false;
});
</script>
--
Gitblit v1.9.3