From 82e27d0cadbddfc73e8b978e778b802dc8e51fa1 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期五, 29 三月 2024 10:51:36 +0800 Subject: [PATCH] 报工入参修改和工序ID修改 --- src/stores/plc.ts | 49 ++++++++++++++++++++++++------------------------- 1 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/stores/plc.ts b/src/stores/plc.ts index 50e7926..152c2b8 100644 --- a/src/stores/plc.ts +++ b/src/stores/plc.ts @@ -5,6 +5,7 @@ import { useRequest } from 'vue-hooks-plus' import { useTasksStore } from '@/stores/tasks' import type { PLCResponse } from '@/api/plc' +import { PLC_POLLING_DURATION } from '@/common/constants' // 鍏ㄥ眬 watcher ref 闃叉澶氭璋冪敤 usePLCStore 鏃堕噸澶嶆敞鍐屼睛鍚櫒 const unwatch = ref() @@ -12,50 +13,48 @@ export const usePLCStore = defineStore('plc', () => { const taskStore = useTasksStore() - const plcInfo = computed(() => { - return plcRes?.value?.data as PLCResponse - }) + const plcInfo = ref() /** * 濡傛灉浠诲姟鐘舵�佹槸杩涜涓�, 鍒欒疆璇� plc 鍙栬繘搴� */ - const { - data: plcRes, - run: startPLCPolling, - cancel: cancelPLCPolling - } = useRequest( - () => - getProductProgress({ - channel: taskStore.activeTask?.Channel, - procedureId: taskStore.activeTask?.Procedure.ID - } as ProductProgressParams), - { - manual: true, - pollingInterval: 6000, - pollingWhenHidden: false - } - ) + // const { + // data: plcRes, + // run: startPLCPolling, + // cancel: cancelPLCPolling + // } = useRequest( + // () => + // getProductProgress({ + // channel: taskStore.activeChannel ?? 0, + // procedureId: taskStore.activeTask?.Procedure.ID ?? undefined + // } as ProductProgressParams), + // { + // manual: true, + // pollingInterval: PLC_POLLING_DURATION, + // pollingWhenHidden: false + // } + // ) if (!unwatch.value) { /** * 濡傛灉鍒囨崲鍒板叾浠栭�氶亾鐨勪换鍔�,鍒欓噸鏂拌疆璇lc */ unwatch.value = watch( - () => taskStore.activeTask?.Channel, + () => taskStore.activeChannel, () => { - cancelPLCPolling() - startPLCPolling() + // cancelPLCPolling() + // startPLCPolling() } ) } function startPollingPLC() { - cancelPLCPolling() - startPLCPolling() + // cancelPLCPolling() + // startPLCPolling() } onUnmounted(() => { - cancelPLCPolling() + // cancelPLCPolling() }) return { plcInfo, startPollingPLC } -- Gitblit v1.8.0