From 61b87304e62d377faa931bfca428cb141e67d4e7 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Fri, 15 Aug 2025 08:37:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=A8=A1=E6=B2=A1=E6=9C=89=E6=A0=87?= =?UTF-8?q?=E5=87=86=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/check/interface/index.ts | 1 + frontend/src/api/check/test/index.ts | 2 + frontend/src/stores/modules/check.ts | 8 +- .../src/views/home/components/compareTest.vue | 223 +++--------------- .../home/components/compareTestPopup.vue | 16 +- .../home/components/selectTestItemPopup.vue | 2 - frontend/src/views/home/components/table.vue | 23 -- frontend/src/views/home/components/test.vue | 8 +- .../plan/planList/components/planPopup.vue | 3 +- 9 files changed, 56 insertions(+), 230 deletions(-) diff --git a/frontend/src/api/check/interface/index.ts b/frontend/src/api/check/interface/index.ts index ca1cfdc..1e87c74 100644 --- a/frontend/src/api/check/interface/index.ts +++ b/frontend/src/api/check/interface/index.ts @@ -203,6 +203,7 @@ export namespace CheckData { //描述比对式检测项描述 export interface CompareTestItem { id: string, + code: string, name: string, } } diff --git a/frontend/src/api/check/test/index.ts b/frontend/src/api/check/test/index.ts index 7075848..d5a8639 100644 --- a/frontend/src/api/check/test/index.ts +++ b/frontend/src/api/check/test/index.ts @@ -1,3 +1,4 @@ +import { pa } from 'element-plus/es/locale/index.mjs'; import http from "@/api"; import {CheckData} from "@/api/check/interface"; @@ -5,6 +6,7 @@ export const getBigTestItem = (params: { reCheckType: number, planId: string, devIds: string[], + patternId: string }) => { return http.post(`/adPlan/getBigTestItem`, params, {loading: false}); } diff --git a/frontend/src/stores/modules/check.ts b/frontend/src/stores/modules/check.ts index 0fa4ec5..a10c1a0 100644 --- a/frontend/src/stores/modules/check.ts +++ b/frontend/src/stores/modules/check.ts @@ -14,7 +14,6 @@ export const useCheckStore = defineStore(CHECK_STORE_KEY, { showDetailType: 0, // 0:数据查询 1:误差体系跟换 2:正式检测 temperature: 0, humidity: 0, - compareTestItem: [] as CheckData.CompareTestItem[], }), getters: {}, actions: { @@ -55,11 +54,6 @@ export const useCheckStore = defineStore(CHECK_STORE_KEY, { setHumidity(humidity: number) { this.humidity = humidity }, - setCompareTestItem(testItem: CheckData.CompareTestItem[]) { - this.compareTestItem.push(...testItem); - }, - clearCompareTestItem() { - this.compareTestItem = []; - }, + } }); \ No newline at end of file diff --git a/frontend/src/views/home/components/compareTest.vue b/frontend/src/views/home/components/compareTest.vue index 2560823..0abe557 100644 --- a/frontend/src/views/home/components/compareTest.vue +++ b/frontend/src/views/home/components/compareTest.vue @@ -35,9 +35,9 @@ : row.devices[index1].chnResult[index2].icon==='WarnTriangleFilled' ? '数据异常' : row.devices[index1].chnResult[index2].icon==='Loading'? '检测中':'连接中断'" placement="right"> - + { // 用来展示的检测结果 const checkResultView: ComputedRef = computed(() => { - let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => { let temp: CheckData.ScriptChnViewItem = { scriptType: item.scriptType, @@ -238,95 +239,8 @@ let count = 0 watch(webMsgSend, function (newValue, oldValue) { console.log('webMsgSend', newValue) if (testStatus.value !== 'waiting') { + handleStartItem('V', 'newValue.desc') if (props.stepsActive === 4) { - if (newValue.code == 10520) { - ElMessageBox.alert('报文解析异常!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:报文解析异常!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10521) { - ElMessageBox.alert('程控源參数有误!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:程控源參数有误!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10522) { - ElMessageBox.alert('测试项解析有误!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:测试项解析有误!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10523) { - if (count === 0) { - ElMessageBox.alert('源连接失败!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源连接失败!`}) - emit('update:testStatus', 'test_init_fail') - count++ - } - } else if (newValue.code == 10524) { - ElMessageBox.alert('获取源控制权失败!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:获取源控制权失败!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10525) { - ElMessageBox.alert('重置源失败!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:重置源失败!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10527) { - ElMessageBox.alert('源未进行初始化!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源未进行初始化!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10528) { - ElMessageBox.alert('目标源有误(该用户已控制其他源,在关闭前无法操作新的源)!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:目标源有误(该用户已控制其他源,在关闭前无法操作新的源)!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10529) { - ElMessageBox.alert('源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)!', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:源状态有误,无法响应报文(例如源处于输出状态,无法响应初始化报文)!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10550) { - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:${newValue.data}设备连接异常!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10551) { - ElMessageBox.alert(`${newValue.data}设备触发报告异常!`, '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:${newValue.data}设备触发报告异常!`}) - emit('update:testStatus', 'test_init_fail') - } else if (newValue.code == 10552) { //todo 10552之后还会发送消息吗? - ElMessageBox.alert('存在已经初始化步骤,执行自动关闭,请重新发起检测', '初始化失败', { - confirmButtonText: '确定', - type: 'error', - }) - testLogList.push({ - type: 'error', - log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!` - }) - // emit('update:testStatus', 'recheck') - emit('update:testStatus', 'test_init_fail') - } else { switch (newValue.requestId) { case 'server_error': if (newValue.operateCode === 'server_error' && count === 0) { @@ -473,17 +387,11 @@ watch(webMsgSend, function (newValue, oldValue) { pauseSuccessCallback() } break; - // case 'Pause_Fail': - // ElMessage.error('暂停失败') - // break; case 'Resume_Success': ElMessage.success('开始继续检测') emit('update:testStatus', 'process') handleResumeTest() break; - // case 'Resume_Fail': - // ElMessage.error('无法继续检测') - // break; case 'FREQ_Start': handleStartItem('FREQ', newValue.desc) break; @@ -561,12 +469,17 @@ watch(webMsgSend, function (newValue, oldValue) { break; } } - } } }, {deep: true}) const handleStartItem = (code: string, desc: string | undefined) => { - +if (desc === undefined) { + console.log('开始检测项:', code) + updateCheckResultView(code, true) // 更新界面为加载状态 + } else { + // 子测试项开始 + testLogList.push({ type: 'info', log: `${new Date().toLocaleString()}:${desc}准确度检测:开始` }) + } } const handleEndItem = (code: string, desc: string | undefined, devices: CheckData.DeviceCheckResult[] = []) => { @@ -639,15 +552,26 @@ const showTestLog = () => { // 初始化检测脚本数据 const initScriptData = async () => { - let temp = checkStore.compareTestItem.map(item => { + const pattern = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''; + let response: any = await getBigTestItem({ + reCheckType: checkStore.reCheckType, + planId: checkStore.plan.id, + devIds: checkStore.devices.map(item => item.deviceId), + patternId: pattern + }) + + // 格式化脚本数据 + let temp = response.data.map((item: any) => { return { - id: item.id, - code: '', - scriptName: item.name + ...item, + scriptName: item.scriptName, } }) - scriptData.push(...temp) - checkTotal = scriptData.length + + // 保存脚本数据并设置总数 + scriptData.push(...temp) + checkTotal = scriptData.length + } // 初始化设备列表 const initDeviceList = () => { @@ -861,86 +785,6 @@ const pauseSuccessCallback = () => { console.log('暂停中') }; -const todoItem = (code: string) => { - emit('update:webMsgSend', { - requestId: `${code}_Start` - }) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_Start`, - desc: '输入:频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' - }) - } - }, 1000) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_End`, - desc: '输入:频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', - data: [{ - chnResult: [1, 1, 1, 1], - deviceId: "e90c09c0905248ad912e19e17a8672aa", - deviceName: "250226001" - }] - }) - } - }, 2000) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_Start`, - desc: '输入:频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' - }) - } - }, 3000) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_End`, - desc: '输入:频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', - data: [{ - chnResult: [1, 1, 1, 1], - deviceId: "e90c09c0905248ad912e19e17a8672aa", - deviceName: "250226001" - }] - }) - } - }, 5000) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_Start`, - desc: '输入:频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' - }) - } - }, 6000) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_End`, - desc: '输入:频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0°,Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', - data: [{ - chnResult: [1, 1, 1, 1], - deviceId: "e90c09c0905248ad912e19e17a8672aa", - deviceName: "250226001" - }] - }) - } - }, 8000) - setTimeout(() => { - if (testStatus.value !== 'paused') { - emit('update:webMsgSend', { - requestId: `${code}_End`, - data: [{ - chnResult: [1, 2, 1, 1], - deviceId: "e90c09c0905248ad912e19e17a8672aa", - deviceName: "250226001" - }] - }) - } - }, 9000) -} const handleResumeTest = () => { //activeIndex++ @@ -951,11 +795,6 @@ const handleResumeTest = () => { console.log('开始继续检测') }; - - - - - defineExpose({ handlePause }) diff --git a/frontend/src/views/home/components/compareTestPopup.vue b/frontend/src/views/home/components/compareTestPopup.vue index 1d3b954..bdb07e2 100644 --- a/frontend/src/views/home/components/compareTestPopup.vue +++ b/frontend/src/views/home/components/compareTestPopup.vue @@ -172,6 +172,7 @@ const open = async (title: string,mapping:any,plan: string,login: string,devIdsA socketClient.Instance.connect(); dataSocket.socketServe = socketClient.Instance; dataSocket.socketServe.registerCallBack('aaa', (res: { code: number; }) => { + console.log('Received message:', res) // 处理来自服务器的消息 if (res.code === 20000) { //ElMessage.error(message.message) @@ -228,7 +229,6 @@ const handleSubmitFast = async () => { const checkNum = await mapValue() - switch (stepsActive.value) { case 1: if (preTestStatus.value == 'waiting') { @@ -242,14 +242,24 @@ const handleSubmitFast = async () => { testItemList:[checkStore.selectTestItems.preTest,false,checkStore.selectTestItems.test], num: checkNum }) - preTestStatus.value = 'start' } } break; case 2: if (TestStatus.value == "waiting") { - + // 如果没有预检测,直接进行正式检测需要先初始化 + if (!checkStore.selectTestItems.preTest && checkStore.selectTestItems.test) { + await contrastTest({ + planId: planId.value, + loginName: loginName.value, + devIds: devIds.value, + standardDevIds: standardDevIds.value, + pairs:pairs.value, + testItemList:[checkStore.selectTestItems.preTest,false,checkStore.selectTestItems.test], + num: checkNum + }) + } TestStatus.value = 'start' } else if (TestStatus.value == 'paused') { // 发送继续指令 diff --git a/frontend/src/views/home/components/selectTestItemPopup.vue b/frontend/src/views/home/components/selectTestItemPopup.vue index 4c3418d..081a196 100644 --- a/frontend/src/views/home/components/selectTestItemPopup.vue +++ b/frontend/src/views/home/components/selectTestItemPopup.vue @@ -50,8 +50,6 @@ const open = async () => { checkStore.setSelectTestItems(formContent) dialogVisible.value = true if(modeStore.currentMode === '比对式'){ - - channelsTestShow.value = false }else{ if(AppSceneStore.currentScene === '1'){ diff --git a/frontend/src/views/home/components/table.vue b/frontend/src/views/home/components/table.vue index c5bf5c8..bd10434 100644 --- a/frontend/src/views/home/components/table.vue +++ b/frontend/src/views/home/components/table.vue @@ -729,29 +729,6 @@ const handleTest2 = () => { return } - // 获取选中计划的数据源配置 - const dataSources = ref([]) - - const matchedItem = props.planTable.data.find(item => item.name === props.plan.name) - if (matchedItem) { - dataSources.value = matchedItem.datasourceIds - } - // 获取选中计划的测试项配置 - const compareTestItem = ref([]) - const names = matchedItem.testItemNameStr ? matchedItem.testItemNameStr.split(',') : [] - const ids = matchedItem.testItems || [] - - // 构造 compareTestItem 数组 - compareTestItem.value = ids.map((id: string, index: number) => { - return { - id: id, - name: names[index] || '' - } - }) - checkStore.clearCompareTestItem() - checkStore.setCompareTestItem(compareTestItem.value) - - deviceConnectionPopupRef.value?.open(channelsSelection.value, pqStandardDevList.value,props.id) } diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index c42c3c7..d3037bc 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -118,11 +118,13 @@ import { ElMessage, ElMessageBox } from 'element-plus' import { getBigTestItem } from '@/api/check/test' import { getAutoGenerate } from '@/api/user/login' import { generateDevReport } from '@/api/plan/plan' - +import { useModeStore } from '@/stores/modules/mode' // 引入模式 store +import { useDictStore } from '@/stores/modules/dict' // 获取检测状态管理实例 const checkStore = useCheckStore() - +const modeStore = useModeStore() +const dictStore = useDictStore() // 最大通道数限制,超过此数量将使用汇总显示 const MAX_CHN_SUM = 12 @@ -733,11 +735,13 @@ const showTestLog = () => { // ========== 数据初始化函数 ========== // 从服务器获取检测脚本配置数据 const initScriptData = async () => { + const pattern = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''; // 根据复检类型、计划ID、设备ID列表获取测试项 let response: any = await getBigTestItem({ reCheckType: checkStore.reCheckType, planId: checkStore.plan.id, devIds: checkStore.devices.map(item => item.deviceId), + patternId: pattern }) // 格式化脚本数据 diff --git a/frontend/src/views/plan/planList/components/planPopup.vue b/frontend/src/views/plan/planList/components/planPopup.vue index 50323a9..40a787a 100644 --- a/frontend/src/views/plan/planList/components/planPopup.vue +++ b/frontend/src/views/plan/planList/components/planPopup.vue @@ -20,7 +20,7 @@ show-word-limit /> - +