From 36095bd4b257ea559c1d09af13999756f9a58c46 Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Fri, 10 Jan 2025 16:47:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AE=E8=AF=A2=E8=AE=BE=E5=A4=87=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/dialogs/ErrorModal.vue | 3 +- src/pages/Index/Index.vue | 43 +++++++++++++++++----- .../components/Consumables/Warn/LoadingModal.vue | 6 ++- src/services/Index/init.ts | 16 ++++---- src/services/osControl/os.ts | 9 +++++ 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/src/components/dialogs/ErrorModal.vue b/src/components/dialogs/ErrorModal.vue index 1673baf..ed8a2dc 100644 --- a/src/components/dialogs/ErrorModal.vue +++ b/src/components/dialogs/ErrorModal.vue @@ -239,7 +239,7 @@ cursor: pointer; transition: all 0.3s; background: var(--theme-color); - color: white; + color: red; &:hover { opacity: 0.9; @@ -323,7 +323,6 @@ const toggleDetails = () => { onMounted(() => { eventBus.on('show-error-modal', handleErrorModal) - console.log('onMounted') }) onUnmounted(() => { eventBus.off('show-error-modal', handleErrorModal) diff --git a/src/pages/Index/Index.vue b/src/pages/Index/Index.vue index 7352be1..d5e95ab 100644 --- a/src/pages/Index/Index.vue +++ b/src/pages/Index/Index.vue @@ -60,8 +60,10 @@ icon="/src/assets/Warn.svg" cancelText="返回" confirmText="确认取下/开始复位" @close="showModal = false" @confirm="handleConfirm" /> - + + import { ref, onMounted, onBeforeUnmount } from 'vue'; import { Time, InitWarn, LoadingModal } from './Components/Consumables'; -import { startWork, pauseWork, continueWork, stopWork, getInitState, initDevice, saveMountedCardInfo, openBuzzer, closeBuzzer } from '../../services/index'; +import { startWork, pauseWork, continueWork, stopWork, getDeviceWorkState, getInitState, initDevice, saveMountedCardInfo, openBuzzer, closeBuzzer } from '../../services/index'; import { CheckItem, User } from '../../types/Index'; import { useConsumablesStore } from '../../store'; import { createWebSocket } from '../../websocket/socket'; @@ -94,7 +96,8 @@ const selectedTab = ref(sessionStorage.getItem('selectedTab') || '常规'); const lineWidth = ref(0); const lineLeft = ref(0); const showModal = ref(false); -const showLoadingModal = ref(false); +const showDeviceResettingModal = ref(false); +const showDeviceWaitingModal = ref(false); const showAlreadyModal = ref(false); const showFailModal = ref(false); const checkData = ref([]); @@ -104,6 +107,7 @@ const consumableStore = useConsumablesStore(); const user = ref(JSON.parse(sessionStorage.getItem('token') || '{}') as unknown as User) const isTesting = ref(false); // 是否处理运行中,用于控制按钮的显示 const isPaused = ref(false); // 是否运行中 点击了暂停,用于控制是否暂停测试 +let deviceReadyCallback: any = null const username = ref(user.value.account) const failMessage = ref(''); // 存储动态生成的错误信息 @@ -194,6 +198,21 @@ const generateErrorMessages = (data: CheckItem[]): string[] => { .map(item => `错误:${item.typechinfo} 检测未通过,请检查设备状态。`); }; +const untilDeviceReady = async () => { + showDeviceWaitingModal.value = true + const res = await getDeviceWorkState(); + if (res.ecode === "SUC") { + if (res.data.pending) { + setTimeout(async () => await untilDeviceReady(), 250) + } else { + showDeviceWaitingModal.value = false; + deviceReadyCallback && deviceReadyCallback() + } + } else { + showDeviceWaitingModal.value = false; + } +} + // 开始测试 const startTest = async () => { const res = await getInitState() @@ -204,7 +223,8 @@ const startTest = async () => { try { const res = await startWork(); if (res.success) { - isTesting.value = true; + deviceReadyCallback = () => isTesting.value = true; + await untilDeviceReady() } } catch (error) { console.error('开始测试失败:', error); @@ -216,7 +236,8 @@ const startTest = async () => { const pauseTest = async () => { const res = await pauseWork(); if (res.success) { - isPaused.value = true; + deviceReadyCallback = () => isPaused.value = true; + await untilDeviceReady() } // 在这里添加暂停测试的逻辑 }; @@ -226,14 +247,16 @@ const stopTest = async () => { console.log('测试已停止'); const res = await stopWork(); if (res.success) { - isTesting.value = false; + deviceReadyCallback = () => isTesting.value = false; + await untilDeviceReady() } }; //继续测试 const continueTest = async () => { const res = await continueWork(); if (res.success) { - isPaused.value = false; + deviceReadyCallback = () => isPaused.value = false; + await untilDeviceReady() console.log('继续测试'); } }; @@ -248,13 +271,13 @@ const startInit = async () => { } const pollingInitState = async () => { - showLoadingModal.value = true; // 显示 LoadingModal + showDeviceResettingModal.value = true; // 显示 LoadingModal const res = await getInitState(); if (res.ecode === "SUC") { if (res.data.isBusy) { setTimeout(async () => await pollingInitState(), 500) } else { - showLoadingModal.value = false; + showDeviceResettingModal.value = false; if (res.data.passed) { console.log("初始化成功") sessionStorage.setItem('deviceResetFinished', "true"); diff --git a/src/pages/Index/components/Consumables/Warn/LoadingModal.vue b/src/pages/Index/components/Consumables/Warn/LoadingModal.vue index b262fb2..dcf1ed9 100644 --- a/src/pages/Index/components/Consumables/Warn/LoadingModal.vue +++ b/src/pages/Index/components/Consumables/Warn/LoadingModal.vue @@ -14,7 +14,7 @@ -