From c334c07b39e70f21c6aef8ad2bf4c95c3c83887a Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Mon, 30 Dec 2024 14:41:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataCheckSingleChannelSingleTestPopup.vue | 43 ++++++++------ frontend/src/views/home/components/test.vue | 56 ++++++++++++------- .../src/views/home/components/testPopup.vue | 14 ++++- 3 files changed, 76 insertions(+), 37 deletions(-) diff --git a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue index da35ea5..c683141 100644 --- a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue @@ -69,6 +69,7 @@ import DataCheckResultTable from './dataCheckResultTable.vue' import DataCheckRawDataTable from './dataCheckRawDataTable.vue' import {CheckData} from "@/api/check/interface"; import {getFormData, getTreeData, getCheckData} from "@/api/check/test"; +import {useDictStore} from "@/stores/modules/dict"; const {appendToBody} = withDefaults(defineProps<{ appendToBody: boolean @@ -79,6 +80,8 @@ const defaultProps = { children: "children", }; +const dictStore = useDictStore() + const visible = ref(false) // 表单数据 @@ -90,7 +93,7 @@ const formContent = reactive({ monitorIdx: '', }) let deviceId: string = '' -let checkItemId: string = '' +let scriptType: string = '' // 通道下拉列表 let chnList: any[] = [] @@ -125,7 +128,7 @@ const handleChnChange = (data: any) => { console.log("通道号下拉框", data); // 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询) - // const result = await getTreeData({deviceId, formContent.monitorIdx, checkItemId}) + // const result = await getTreeData({deviceId, formContent.monitorIdx, scriptType}) // treeDataUnQualified=[] // treeDataAll=[] @@ -136,7 +139,7 @@ const handleChnChange = (data: any) => { // console.log("通道号下拉框", newVal, oldVal); // // // 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询) -// // const result = await getTreeData({deviceId, formContent.monitorIdx, checkItemId}) +// // const result = await getTreeData({deviceId, formContent.monitorIdx, scriptType}) // // treeDataUnQualified=[] // // treeDataAll=[] // @@ -155,7 +158,7 @@ watch(checkedScriptId, (newVal, oldVal) => { if (newVal) { console.log("左侧树被选中的叶子节点id", newVal); // 发起请求,查询该测试项的检测结果 - // const result = await getCheckData({deviceId, formContent.monitorIdx, checkItemId}) + // const result = await getCheckData({deviceId, formContent.monitorIdx, scriptType}) Object.assign(checkResultTableData, [{ chnNum: '1', standardValue: 57.74, @@ -308,27 +311,35 @@ watch(switchItem, (newVal, oldVal) => { defaultExpandedKeys = [node?.id] }) -const open = async (_deviceId: string, chnNum: number, _checkItemId?: string) => { - console.log(deviceId, chnNum, checkItemId); +const open = async (_deviceId: string, chnNum: number, _scriptType?: string) => { + console.log(_deviceId, chnNum, _scriptType); deviceId = _deviceId - checkItemId = _checkItemId ?? '' + scriptType = _scriptType ?? '' switchItem.value = 0 // 发起后端请求,查询详细信息 当chnNum为-1时,查询所有通道号 //const result1 = await getFormData({deviceId, chnNum}) // 数据处理 - chnList = [ - {value: 1, label: '1'}, - {value: 2, label: '2 (不合格)'}, - {value: 3, label: '3'}, - {value: 4, label: '4 (不合格)'}] - Object.assign(formContent, { + let resFormContent = { scriptName: 'Q/GDW 10650.4-2021 模拟式', errorSysName: 'Q/GDW 10650.2-2021', - dataRule: '所有值', + dataRule: '505f063f9f91ab108d895a9fe96b5dce', deviceName: '被检设备1', - monitorIdx: chnList[0].value - }) + chnList:[ + {value: '1', label: '1'}, + {value: '2', label: '0'}, + {value: '3', label: '1'}, + {value: '4', label: '0'}], + } + chnList = resFormContent.chnList.map(item => ({ + value: item.value, + label: item.label == '1' ? `${item.value}` : `${item.value}(不符合)` + })) + + let dataRuleName = dictStore.getDictData('Data_Rule').find(item=>item.id==resFormContent.dataRule)?.name + + Object.assign(formContent, {...resFormContent,dataRule:dataRuleName,monitorIdx: chnList[0].value}) + // const result2 = await getTreeData({deviceId, formContent.monitorIdx, checkItemId}) treeDataAll = [{ diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index bc44691..1fa518d 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -11,7 +11,7 @@ v-if="testStatus=='process' && activeIndex < checkTotal" :disabled="activeIndex===0" :icon="VideoPause" - @click="emit('update:testStatus','paused')">停止检测 + @click="handlePauseTest">停止检测 检测完成 @@ -20,7 +20,7 @@ type="warning" v-if="testStatus=='paused' && activeIndex < checkTotal" :icon="Refresh" - @click="emit('update:testStatus','process')" + @click="handleResumeTest" >继续检测 检测项进度 @@ -145,6 +145,7 @@ import {reactive, ref, watch} from "vue"; import {dialogBig} from "@/utils/elementBind"; import {CheckData} from "@/api/check/interface" import {useCheckStore} from "@/stores/modules/check"; +import {ElMessage, ElMessageBox} from "element-plus"; const checkStore = useCheckStore() @@ -165,7 +166,7 @@ const props = defineProps({ } }) -const emit = defineEmits(['update:testStatus', 'update:webMsgSend']); +const emit = defineEmits(['update:testStatus', 'update:webMsgSend','sendPause','sendResume']); // 用来保存测试项进度抽屉是否打开 const drawer = ref(false) @@ -187,7 +188,7 @@ const timeDifference = ref(0) // 真正的检测结果(详细到通道) const checkResult = reactive([]) // 用来存放检测出现失败的测试项id。只要有一个通道检测不合格,则该检测项的id会被加入该数组。 -let errorCheckItem:Array<{ scriptId: string, type: 'info' | 'warning' | 'error' }> = [] +let errorCheckItem: Array<{ scriptId: string, type: 'info' | 'warning' | 'error' }> = [] // 用来存放检测日志 const testLogList = reactive([{type: 'info', log: '暂无数据,等待检测开始'}]) @@ -303,6 +304,28 @@ watch(testStatus, function (newValue, oldValue) { watch(webMsgSend, function (newValue, oldValue) { if (activeIndex <= checkTotal) { switch (newValue.requestId) { + case 'Test_PreTest_Fail': + ElMessageBox.alert('预检测失败,请检查设备连接情况', '预检测失败', { + confirmButtonText: '确定', + type: 'error', + }).then(() => { + emit('update:testStatus', 'success') + }) + break; + case 'Test_Pause_Success': + ElMessage.success('暂停成功') + emit('update:testStatus','paused') + break; + case 'Test_Pause_Fail': + ElMessage.error('暂停失败') + break; + case 'Test_Resume_Success': + ElMessage.success('开始继续检测') + emit('update:testStatus','process') + break; + case 'Test_Resume_Fail': + ElMessage.error('无法继续检测') + break; case 'Test_VOL_Start': updateCheckResultView("VOL", true) updateLog(true) @@ -312,7 +335,7 @@ watch(webMsgSend, function (newValue, oldValue) { updateLog(false) updatePercentage() if (testStatus.value != 'paused') { - activeIndex++; + activeIndex++ startTimer() } break; @@ -838,7 +861,6 @@ const handlePauseOrContinue = () => { type: 'info', log: currentTime.value + ':暂停检测', }) - //pauseTimer() console.log('暂停中') } if (testStatus.value == "process") { @@ -847,7 +869,6 @@ const handlePauseOrContinue = () => { type: 'info', log: currentTime.value + ':继续检测', }) - //resumeTimer() startTimer() console.log('开始继续检测') } @@ -1016,20 +1037,15 @@ const startTimer = () => { } }; -// const pauseTimer = () => { -// if (timer.value) { -// clearInterval(timer.value); -// timer.value = null; -// } -// console.log('暂停中') -// }; +const handlePauseTest = () => { + // 发送暂停指令 + emit('sendPause') +}; -// const resumeTimer = () => { -// if (!timer.value) { -// startTimer(); -// } -// console.log('开始继续检测') -// }; +const handleResumeTest = () => { + // 发送继续检测指令 + emit('sendResume') +}; //完成检测 const handleFinishTest = () => { diff --git a/frontend/src/views/home/components/testPopup.vue b/frontend/src/views/home/components/testPopup.vue index bb1c968..90d9f7e 100644 --- a/frontend/src/views/home/components/testPopup.vue +++ b/frontend/src/views/home/components/testPopup.vue @@ -17,7 +17,7 @@ - +