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