|
|
@@ -222,6 +222,7 @@ const runLoading = ref(false)
|
|
|
const takePictureLoading = ref(false)
|
|
|
import { Close } from '@element-plus/icons-vue'
|
|
|
import { clickLog, setLogInfo } from '@/utils/log'
|
|
|
+import { useUuidStore } from '@/stores/modules/uuid'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
|
|
|
import useUserInfo from "@/stores/modules/user";
|
|
|
@@ -231,6 +232,9 @@ const route = useRoute();
|
|
|
import configInfo from '@/stores/modules/config';
|
|
|
const configInfoStore = configInfo();
|
|
|
import qiehuan from '@/components/header-bar/assets/qiehuan.svg'
|
|
|
+import tokenInfo from "@/stores/modules/token";
|
|
|
+
|
|
|
+const tokenInfoStore = tokenInfo();
|
|
|
|
|
|
const menu = computed(()=>{
|
|
|
if(configInfoStore.appModel === 2){
|
|
|
@@ -279,8 +283,7 @@ const menu = computed(()=>{
|
|
|
},
|
|
|
{
|
|
|
...generate
|
|
|
- },
|
|
|
- {
|
|
|
+ }, {
|
|
|
type:'ota'
|
|
|
}
|
|
|
]
|
|
|
@@ -333,6 +336,47 @@ const runAction = ref({
|
|
|
|
|
|
// 初始化 WebSocket 状态管理
|
|
|
const socketStore = socket()
|
|
|
+const uuidStore = useUuidStore();
|
|
|
+
|
|
|
+// 抠图请求去重与延迟队列(key: goods_art_no, value: timeoutId)
|
|
|
+const segmentQueue = new Map<string, ReturnType<typeof setTimeout>>()
|
|
|
+
|
|
|
+function isGoodsStillInList(goodsArtNo: string): boolean {
|
|
|
+ return goodsList.value?.some((g: any) => g.goods_art_no === goodsArtNo) || false
|
|
|
+}
|
|
|
+
|
|
|
+function scheduleSegment(goodsArtNo: string) {
|
|
|
+ if (!goodsArtNo) return
|
|
|
+ // 若已存在,则重置计时(重新插入)
|
|
|
+ if (segmentQueue.has(goodsArtNo)) {
|
|
|
+ const t = segmentQueue.get(goodsArtNo)
|
|
|
+ if (t) clearTimeout(t)
|
|
|
+ segmentQueue.delete(goodsArtNo)
|
|
|
+ }
|
|
|
+ const timeoutId = setTimeout(async () => {
|
|
|
+ segmentQueue.delete(goodsArtNo)
|
|
|
+ if (!isGoodsStillInList(goodsArtNo)) return
|
|
|
+ try {
|
|
|
+ await socketStore.connectSocket();
|
|
|
+ console.log('segment_progress',{
|
|
|
+ token:tokenInfoStore.getToken,
|
|
|
+ uuid: uuidStore?.getUuid || '',
|
|
|
+ goods_art_no: [goodsArtNo],
|
|
|
+ })
|
|
|
+ socketStore.sendMessage({
|
|
|
+ type: 'segment_progress',
|
|
|
+ data: {
|
|
|
+ token:tokenInfoStore.getToken,
|
|
|
+ uuid: uuidStore?.getUuid || '',
|
|
|
+ goods_art_no: [goodsArtNo],
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } catch (e) {
|
|
|
+ // 忽略发送异常,避免打断主流程
|
|
|
+ }
|
|
|
+ }, 30000)
|
|
|
+ segmentQueue.set(goodsArtNo, timeoutId)
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 保存货号模板到货号变量中。
|
|
|
@@ -732,6 +776,10 @@ onMounted(async () => {
|
|
|
console.log(result)
|
|
|
if(result.code === 0) {
|
|
|
setLogInfo(route, { action: '全部拍摄完成', goods_art_no: runAction.value.goods_art_no });
|
|
|
+ // 全部拍摄完成后,触发抠图队列
|
|
|
+ if (runAction.value.goods_art_no) {
|
|
|
+ scheduleSegment(runAction.value.goods_art_no)
|
|
|
+ }
|
|
|
runLoading.value = false;
|
|
|
runAction.value.goods_art_no = '';
|
|
|
runAction.value.action = '';
|
|
|
@@ -851,10 +899,17 @@ onBeforeUnmount(() => {
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_smart_shooter_photo_take');
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_run_mcu_stop');
|
|
|
clientStore.ipc.removeAllListeners(icpList.socket.message + '_digicam_take_picture');
|
|
|
+ clientStore.ipc.removeAllListeners(icpList.socket.message + '_segment_progress');
|
|
|
|
|
|
/* window.removeEventListener('storage', handleStorageEvent);*/
|
|
|
|
|
|
|
|
|
+ // 清理抠图队列的定时器
|
|
|
+ try {
|
|
|
+ segmentQueue.forEach((t) => { if (t) clearTimeout(t) })
|
|
|
+ segmentQueue.clear()
|
|
|
+ } catch (e) {}
|
|
|
+
|
|
|
})
|
|
|
|
|
|
/*
|
|
|
@@ -904,6 +959,8 @@ clientStore.ipc.on(icpList.socket.message+'_smart_shooter_photo_take', async (ev
|
|
|
setLogInfo(route, { action: '单张拍摄完成', goods_art_no: result.data.goods_art_no });
|
|
|
if(reNosObj.value?.goods_art_no === result.data.goods_art_no){
|
|
|
runLoading.value = false;
|
|
|
+ // 单张重拍完成且存在重拍货号时,触发抠图队列
|
|
|
+ scheduleSegment(result.data.goods_art_no)
|
|
|
}
|
|
|
if (smartShooterTimeout) {
|
|
|
clearTimeout(smartShooterTimeout);
|