diff --git a/frontend/src/views/home/components/channelsTest.vue b/frontend/src/views/home/components/channelsTest.vue index 1be3cb5..f2ba72c 100644 --- a/frontend/src/views/home/components/channelsTest.vue +++ b/frontend/src/views/home/components/channelsTest.vue @@ -649,7 +649,7 @@ const updateErrorState = (index: number, hasError: boolean) => { const emit = defineEmits<{ (e: 'quitClicked'): void; - (e: 'submitClicked'): void; + (e: 'submitClicked', callback: (resolve: (value: boolean) => void) => void): void; }>(); const handleCancel=() => { @@ -693,18 +693,27 @@ const checkForErrors = (data: ChannelsTest.CoefficientVO[]): boolean => { }; const handleSubmit = async () => { + // 创建一个 Promise 来等待父组件的回调 + const response = await new Promise((resolve) => { + emit('submitClicked', resolve); + }); + + if (!response) { + return; + } + isButtonDisabled.value = true; // 禁用按钮 tableLoading('big','系数下装') await getCoefficientCheck({ userPageId: "cdf", - devIds:devIdArray.value, + devIds:devIdArray.value, planId:planId.value, errorSysId: select_Plan.value?.errorSysId,      scriptId: select_Plan.value?.scriptId, operateType:'0' // '0'为预检测、‘1‘为正式检测 }) active.value++; - emit('submitClicked'); // 触发事件 + // 初始化 loadingStates 为 true // loadingStates.value = new Array(name.value.length).fill(true); diff --git a/frontend/src/views/home/components/table.vue b/frontend/src/views/home/components/table.vue index b6113a8..e11a7ea 100644 --- a/frontend/src/views/home/components/table.vue +++ b/frontend/src/views/home/components/table.vue @@ -988,7 +988,6 @@ const handleTest = async (val: string) => { // return; // } - socketClient.Instance.connect(); dataSocket.socketServe = socketClient.Instance; @@ -1144,13 +1143,14 @@ const handleQuitClicked = () => { } -const handleSubmitClicked =() =>{ - //console.log('handleSubmitClicked') - if(!dataSocket.socketServe.connected){ - ElMessage.error('webSocket连接中断!请退出重新进行系数校准') - return +const handleSubmitClicked = async (resolve: (value: boolean) => void) => { + if (!dataSocket.socketServe.connected) { + ElMessage.error('webSocket连接中断!请退出重新进行系数校准'); + resolve(false); + } else { + resolve(true); } -} +}; defineExpose({ changeActiveTabs })