Kaynağa Gözat

epc数组变动立刻主动查询变为缓存3秒后查询

ZhangJunQuan 5 ay önce
ebeveyn
işleme
dcd78fd445

+ 2 - 2
src/finishProduct/FinishProductOut.vue

@@ -26,9 +26,9 @@
             />
           </div>
           <div class="filter-item">
-            <label class="filter-label">号</label>
+            <label class="filter-label">号</label>
             <input
-              v-model="searchForm.inventoryDrawNo" type="text" placeholder="输入号"
+              v-model="searchForm.inventoryDrawNo" type="text" placeholder="输入号"
               class="filter-input dark-input" @keyup.enter="handleSearch"
             />
           </div>

+ 2 - 0
src/gate/ControlGate.vue

@@ -148,6 +148,7 @@ import { controlGate, controlGateByBigInv, getGateStatus } from '../api/gate.js'
 
 // 图片资源
 import bgImg from '../assets/images/bj.png';
+// import { plugin } from 'postcss';
 
 const router = useRouter();
 
@@ -171,6 +172,7 @@ const handleControl = async (command, actionName, isBigInv) => {
         } else {
             res = await controlGate(command);
         }
+        // plugin.gateConfig.controlGate(command);
         if (res.errorCode === 0) {
             showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });
             if (actionName.includes('开')) {

+ 3 - 3
src/login/UserHome.vue

@@ -709,10 +709,10 @@ const handleControl = async (command, actionName) => {
         
         if (res.errorCode === 0) {
             showNotify({ type: 'success', message: `${actionName}操作成功`, duration: 2000 });
-            if (actionName.includes('开')) {
-                plugin.soundPlay.playOpen();
-            } else if (actionName.includes('关')) {
+            if (actionName.includes('关闭')) {
                 plugin.soundPlay.playClose();
+            } else if (actionName.includes('开')) {
+                plugin.soundPlay.playOpen();
             }
         } else {
             showNotify({ type: 'danger', message: res.errorMessage || `${actionName}操作失败`, duration: 3000 });

+ 25 - 10
src/stock-in/InConfirm.vue

@@ -123,6 +123,8 @@ const loading = ref(false);
 // 物料列表数据
 const materialList = ref([]);
 const epcs = ref([]);
+// 临时收集epc数据的数组
+const tempEpcs = ref([]);
 
 // 分页配置
 const pagination = reactive({
@@ -196,7 +198,7 @@ const verify = () => {
 
 // 获取物料列表(外侧校验)
 const getList = async () => {
-    loading.value = true;
+    // loading.value = true;
     try {
 
         const params = {
@@ -213,6 +215,7 @@ const getList = async () => {
                 materialList.value = [];
             }
         } else {
+            materialList.value = [];
             showNotify({ type: 'danger', message: res.errorMessage });
         }
     } catch (error) {
@@ -244,18 +247,14 @@ const generateCFStockIn = async params => {
     }
 };
 
+let timer = null; // 用于保存当前定时器引用
+
 const addEpc = data => {
     const newEpcs = data.map(item => item.epc);
     
-    // 深度判断新数据与当前epcs是否相等
-    if (areArraysEqual(newEpcs, epcs.value)) {
-        return; // 如果相等,直接返回,不执行后续操作
-    }
-    
-    // 如果不相等,则更新epcs并获取列表
-    epcs.value = [];
-    epcs.value = newEpcs;
-    getList();
+    // 将新epc添加到临时数组中(使用Set去重)
+    const uniqueEpcs = [...new Set([...tempEpcs.value, ...newEpcs])];
+    tempEpcs.value = uniqueEpcs;
 };
 
 onMounted(() => {
@@ -267,10 +266,26 @@ onMounted(() => {
             addEpc(data);
         }
     };
+    
+    // 创建全局唯一定时器,每2秒执行一次getList
+    timer = setInterval(() => {
+        // 只有当临时数组有数据时才执行getList
+        // 将临时数组的数据赋值给epcs
+        epcs.value = [...tempEpcs.value];
+        // 执行获取列表
+        getList();
+        // 清空临时数组
+        tempEpcs.value = [];
+    }, 3000);
 });
 
 onUnmounted(() => {
     plugin.gateConfig.sendEpc = null;
+    // 清除定时器
+    if (timer) {
+        clearInterval(timer);
+        timer = null;
+    }
 });
 </script>
 

+ 31 - 11
src/stock-in/ReturnedLeave.vue

@@ -125,12 +125,16 @@ const isCanLeave = ref(false);
 // 物料列表数据
 const materialList = ref([]);
 
+const userMaterialList = ref([]);
+
 // 人员对应的物料列表
 const inList = ref([]);
 
 // 校验列表
 const validateList = ref([]);
 const epcs = ref([]);
+// 临时数组用于累积EPC数据
+const tempEpcs = ref([]);
 
 // 是否可以还料离开
 const notInStockCount = computed(() => {
@@ -193,9 +197,11 @@ const getCFStockInByUser = async () => {
             if (res.datas && res.datas.length > 0) {
                 materialList.value = res.datas;
                 inList.value = res.datas;
+                userMaterialList.value = res.datas;
                 getInnerList();
             } else {
                 materialList.value = [];
+                userMaterialList.value = [];
                 inList.value = [];
             }
         } else {
@@ -210,7 +216,8 @@ const getCFStockInByUser = async () => {
 
 // 获取物料列表(内侧校验)
 const getInnerList = async () => {
-    loading.value = true;
+    console.log('epcs:', epcs.value);
+    // loading.value = true;
     const params = {
         epcList: epcs.value,
     };
@@ -218,6 +225,7 @@ const getInnerList = async () => {
         const res = await cfStockInLeave(params);
 
         if (res.errorCode === 0) {
+            materialList.value = [...userMaterialList.value];
             isCanLeave.value = true;
             showNotify({ type: 'success', message: '校验成功,请先点击【还料离开】按钮,待闸机开门后离开',duration: 6000  });
         } else {
@@ -226,7 +234,7 @@ const getInnerList = async () => {
                 res.datas.forEach(item => {
                     item.isValid = true;
                 });
-                materialList.value = [...materialList.value, ...res.datas];
+                materialList.value = [...userMaterialList.value, ...res.datas];
                 validateList.value = res.datas;
                 showNotify({ type: 'danger', message: '检测到您已携带工装设备,请将工装设备全部还料后,再次点击【重新校验】按钮,待校验通过后,请在闸机开门后离开', duration: 6000 });
             } else {
@@ -261,18 +269,15 @@ const generateCFStockIn = async params => {
     }
 };
 
+
+let timer = null; // 用于保存当前定时器引用
+
 const addEpc = data => {
     const newEpcs = data.map(item => item.epc);
     
-    // 深度判断新数据与当前epcs是否相等
-    if (areArraysEqual(newEpcs, epcs.value)) {
-        return; // 如果相等,直接返回,不执行后续操作
-    }
-    
-    // 如果不相等,则更新epcs并获取用户数据
-    epcs.value = [];
-    epcs.value = newEpcs;
-    getCFStockInByUser();
+    // 将新的EPC数据添加到临时数组中,使用Set进行去重
+    const uniqueEpcs = new Set([...tempEpcs.value, ...newEpcs]);
+    tempEpcs.value = [...uniqueEpcs];
 };
 
 onMounted(() => {
@@ -284,10 +289,25 @@ onMounted(() => {
             addEpc(data);
         }
     };
+
+    // 创建全局唯一定时器,每2秒执行一次
+    timer = setInterval(() => {
+        // 将临时数组的数据赋值给epcs
+        epcs.value = [...tempEpcs.value];
+        // 执行获取列表
+        getInnerList();
+        // 清空临时数组
+        tempEpcs.value = [];
+    }, 3000);
 });
 
 onUnmounted(() => {
     plugin.gateConfig.sendEpc = null;
+    // 清除定时器
+    if (timer) {
+        clearInterval(timer);
+        timer = null;
+    }
 });
 </script>
 

+ 23 - 10
src/stock-out/OutboundConfirm.vue

@@ -139,6 +139,8 @@ const loading = ref(false);
 // 物料列表数据
 const materialList = ref([]);
 const epcs = ref([]);
+// 临时数组用于累积EPC数据
+const tempEpcs = ref([]);
 
 // 完成数量统计
 const completedCount = computed(() => {
@@ -240,7 +242,7 @@ const handleLeave = async () => {
 
 // 获取扫描到的领料数据
 const getStockOutList = async (isOne = false) => {
-    loading.value = true;
+    // loading.value = true;
     const params = {
         epcList: epcs.value,
     };
@@ -305,18 +307,14 @@ const generateCFStockOut = async id => {
     }
 };
 
+let timer = null; // 用于保存当前定时器引用
+
 const addEpc = data => {
     const newEpcs = data.map(item => item.epc);
     
-    // 深度判断新数据与当前epcs是否相等
-    if (areArraysEqual(newEpcs, epcs.value)) {
-        return; // 如果相等,直接返回,不执行后续操作
-    }
-    
-    // 如果不相等,则更新epcs并获取出库列表
-    epcs.value = [];
-    epcs.value = newEpcs;
-    getStockOutList(false);
+    // 将新的EPC数据添加到临时数组中,使用Set进行去重
+    const uniqueEpcs = new Set([...tempEpcs.value, ...newEpcs]);
+    tempEpcs.value = [...uniqueEpcs];
 };
 
 onMounted(() => {
@@ -328,10 +326,25 @@ onMounted(() => {
             addEpc(data);
         }
     };
+
+    // 创建全局唯一定时器,每2秒执行一次
+    timer = setInterval(() => {
+        // 将临时数组的数据赋值给epcs
+        epcs.value = [...tempEpcs.value];
+        // 执行获取出库列表
+        getStockOutList(false);
+        // 清空临时数组
+        tempEpcs.value = [];
+    }, 3000);
 });
 
 onUnmounted(() => {
     plugin.gateConfig.sendEpc = null;
+    // 清除定时器
+    if (timer) {
+        clearInterval(timer);
+        timer = null;
+    }
 });
 </script>