From 780a446aedf1c505db0ec9fec49cf5a1e18ef3a5 Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Tue, 9 Sep 2025 20:54:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E6=A3=80=E6=B5=8B=E5=BD=95?= =?UTF-8?q?=E6=B3=A2=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/check/test/index.ts | 5 +- frontend/src/api/device/interface/devType.ts | 1 + ...eDataCheckSingleChannelSingleTestPopup.vue | 135 ++++++-- .../src/views/home/components/compareTest.vue | 313 ++++++++---------- .../devType/components/devTypePopup.vue | 7 + .../plan/planList/components/planPopup.vue | 1 + 6 files changed, 253 insertions(+), 209 deletions(-) diff --git a/frontend/src/api/check/test/index.ts b/frontend/src/api/check/test/index.ts index 6df8cd5..017a566 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' @@ -88,8 +89,7 @@ export const getContrastFormContent = (params: { deviceId: string chnNum: string num: number | null - // waveNum: number | null - // isWave: boolean + patternId: string }) => { return http.post('/result/getContrastFormContent', params, {loading: false}) } @@ -105,6 +105,7 @@ export const getContrastResult = (params: { num: number | string | null waveNum: number | null isWave: boolean + patternId: string }) => { return http.post('/result/getContrastResult', params, {loading: true}) } diff --git a/frontend/src/api/device/interface/devType.ts b/frontend/src/api/device/interface/devType.ts index ce9f635..ed5584e 100644 --- a/frontend/src/api/device/interface/devType.ts +++ b/frontend/src/api/device/interface/devType.ts @@ -25,6 +25,7 @@ export namespace DevType { devChns: number; //设备通道数 reportName: string| null;//报告模版名称 state: number; + waveCmd:string| null;//录波指令 createBy?: string| null; //创建用户 createTime?: string| null; //创建时间 updateBy?: string| null; //更新用户 diff --git a/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue b/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue index 527730b..7737ef2 100644 --- a/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/compareDataCheckSingleChannelSingleTestPopup.vue @@ -75,7 +75,7 @@ @@ -94,12 +94,12 @@ label="录波次数" v-if="isWaveData" > - + @@ -181,21 +181,13 @@ const defaultProps = { const chnMapList: any = ref({}) const waveNumCount = ref(0) -const waveNumber = ref(0) +const waveNumber = ref(1) +const selectedScriptName = ref('') +const pattern = ref('') // 添加以下内容 const isWaveData = ref(false) const scriptNameOptions = ref<{label: string, value: string}[]>([]) -// 添加处理scriptName变化的方法 -const handleScriptNameChange = (value: string) => { - rowList.value.scriptName = value - // 查找选中项的scriptType - const selectedItem = scriptData.value.find(item => item.scriptName === value) - if (selectedItem) { - rowList.value.scriptType = selectedItem.id - getResults('wave_data') - } -} // 表单数据 const formContent = reactive({ scriptName: '', @@ -231,22 +223,28 @@ const currentRawTableData = computed(() => { }) const open = async (row: any, chnNum: string, deviceId: string | null, source: number) => { + isWaveData.value = false + pattern.value = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id rowList.value = {} formContent.deviceId = deviceId || '' formContent.chnNum = chnNum sourceKey.value = source if (source == 1) { - // 正式检测进入页面 - rowList.value = row + // 正式检测进入页面 - 创建新的对象避免引用共享 + rowList.value = { + scriptName: row.scriptName, + scriptType: row.scriptType, + // 复制其他需要的属性 + devices: row.devices ? [...row.devices] : [] + } } else if (source == 2) { // 检测数据查询进入 await initScriptData(row) } visible.value = true - scriptType = null - formContent.errorSysId = checkStore.plan.errorSysId + pqErrorList.length = 0 // 获取误差体系 let { data: resPqErrorList } = await getPqErrSysList() @@ -255,15 +253,14 @@ const open = async (row: any, chnNum: string, deviceId: string | null, source: n await getBasicInformation() } // 查询大项树 -const initScriptData = async (row: any) => { - const pattern = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id ?? '' - +const initScriptData = async (row?: any) => { let response: any = await getBigTestItem({ reCheckType: checkStore.reCheckType, planId: checkStore.plan.id, devIds: checkStore.devices.map(item => item.deviceId), - patternId: pattern + patternId: pattern.value }) + // 格式化脚本数据 let temp = response.data.map((item: any) => { return { @@ -271,30 +268,45 @@ const initScriptData = async (row: any) => { scriptName: item.scriptName } }) - rowList.value.scriptName = temp[0].scriptName - rowList.value.scriptType = temp[0].id - // 保存脚本数据并设置总数 + + // 保存脚本数据 scriptData.value = temp - setTimeout(() => { - treeRef.value?.setCurrentKey(temp[0].id) - }, 0) + + // 只有在sourceKey == 2时才设置rowList和tree相关属性 + if (sourceKey.value === 2 && temp.length > 0) { + rowList.value.scriptName = temp[0].scriptName + rowList.value.scriptType = temp[0].id + selectedScriptName.value = temp[0].scriptName + setTimeout(() => { + treeRef.value?.setCurrentKey(temp[0].id) + }, 0) + } } + //获取基本信息 const getBasicInformation = async () => { checkResultData.value = [] rawTableData.value = [] + + // 确保scriptData已初始化 + if (scriptData.value.length === 0) { + await initScriptData() + } + getContrastFormContent({ planId: checkStore.plan.id, scriptType: rowList.value.scriptType, deviceId: formContent.deviceId, chnNum: formContent.chnNum, num: formContent.num == '' ? null : parseInt(formContent.num), + patternId: pattern.value }).then((res: any) => { formContent.dataRule = res.data.dataRule formContent.deviceName = res.data.deviceName formContent.errorSysId = res.data.errorSysId chnMapList.value = res.data.chnMap formContent.num = res.data.checkNum + let chnMap: string[] = [] for (let key in res.data.chnMap) { chnMap.push(key) @@ -302,14 +314,37 @@ const getBasicInformation = async () => { chnList.value = chnMap formContent.chnNum = formContent.chnNum == null ? chnList.value[0] : formContent.chnNum waveNumCount.value = res.data.waveNumTotal + // 查询表格数据 - getResults('') + if(sourceKey.value == 1 && rowList.value.scriptName == "录波"){ + isWaveData.value = true + // 设置录波数据相关的选项,与选中左侧录波树时保持一致 + scriptNameOptions.value = scriptData.value + .filter(item => item.code !== 'wave_data' && item.code !== 'FREQ') + .map(item => ({ + label: item.scriptName, + value: item.scriptName + })) + + // 默认选中第一个选项 + if (scriptNameOptions.value.length > 0) { + selectedScriptName.value = scriptNameOptions.value[0].value + // 更新rowList以匹配选中的script + const selectedItem = scriptData.value.find(item => item.scriptName === selectedScriptName.value) + if (selectedItem) { + rowList.value.scriptName = selectedScriptName.value + rowList.value.scriptType = selectedItem.id + } + } + getResults('wave_data') + }else{ + getResults('') + } }) } // 左边树变化 const handleNodeClick = (data: any) => { - console.log('data', data) rowList.value.scriptName = data.scriptName rowList.value.scriptType = data.id @@ -318,11 +353,23 @@ const handleNodeClick = (data: any) => { isWaveData.value = true // 过滤掉"录波"选项,设置下拉框数据 scriptNameOptions.value = scriptData.value - .filter(item => item.code !== 'wave_data') + .filter(item => item.code !== 'wave_data' && item.code !== 'FREQ') .map(item => ({ label: item.scriptName, value: item.scriptName })) + + // 每次选中录波数据时都重置为第一个选项并触发getResults + if (scriptNameOptions.value.length > 0) { + selectedScriptName.value = scriptNameOptions.value[0].value + // 更新rowList并触发getResults + rowList.value.scriptName = selectedScriptName.value + const selectedItem = scriptData.value.find(item => item.scriptName === selectedScriptName.value) + if (selectedItem) { + rowList.value.scriptType = selectedItem.id + getResults('wave_data') + } + } } else { isWaveData.value = false getResults(data.code) @@ -339,8 +386,9 @@ const getResults = async (code: any) => { deviceId: formContent.deviceId, chnNum: formContent.chnNum, num: formContent.num == '' ? null : formContent.num, - waveNum: code == 'wave_data' ? null : 0 , - isWave: code == 'wave_data' ? true : false + waveNum: code == 'wave_data' ? waveNumber.value : null, + isWave: code == 'wave_data' ? true : false , + patternId: pattern.value }).then((res: any) => { let list: string[] = [] for (let key in res.data.resultMap) { @@ -353,6 +401,25 @@ const getResults = async (code: any) => { }) } +// 添加处理scriptName变化的方法 +const handleScriptNameChange = (value: string) => { + selectedScriptName.value = value + rowList.value.scriptName = value + // 查找选中项的scriptType + const selectedItem = scriptData.value.find(item => item.scriptName === value) + if (selectedItem) { + rowList.value.scriptType = selectedItem.id + getResults('wave_data') + } +} + +// 添加处理waveNumber变化的方法 +const handleWaveNumberChange = (value: number) => { + waveNumber.value = value + // 当录波次数改变时,重新获取结果 + getResults('wave_data') +} + const close = () => { visible.value = false formContent.num = '' diff --git a/frontend/src/views/home/components/compareTest.vue b/frontend/src/views/home/components/compareTest.vue index 6f90ea5..dbc2bdf 100644 --- a/frontend/src/views/home/components/compareTest.vue +++ b/frontend/src/views/home/components/compareTest.vue @@ -193,7 +193,6 @@ let errorCheckItem: Array<{ scriptType: string; type: CheckData.ChnCheckResultEn const testLogList = reactive([{type: 'info', log: '暂无数据,等待检测开始'}]) // 添加一个响应式变量来跟踪是否需要显示录波项目 const showWaveItem = ref(false) - const testStatus = toRef(props, 'testStatus') const webMsgSend = toRef(props, 'webMsgSend') @@ -212,7 +211,6 @@ const chnSum = computed(() => { // 用来展示的检测结果 const checkResultView: ComputedRef = computed(() => { - let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => { let temp: CheckData.ScriptChnViewItem = { scriptType: item.scriptType, @@ -257,6 +255,7 @@ const checkResultView: ComputedRef = computed(() } } } + temp.devices.push({ deviceId: device.deviceId, deviceName: device.deviceName, @@ -293,111 +292,12 @@ watch(testStatus, function (newValue, oldValue) { } }) -// 次数 -let count = 0 - watch( webMsgSend, function (newValue, oldValue) { - if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') { - if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') { - testLogList.shift() - setLogList('info', '初始化开始!') - } - let str = - newValue.requestId == 'yjc_sbtxjy' - ? '设备通讯校验' - : newValue.requestId == 'yjc_mxyzxjy' - ? '模型一致性检验' - : newValue.requestId == 'yjc_align' - ? '实时数据对齐检验' - : newValue.requestId == 'YJC_xujy' - ? '相序校验' - : '' - // 预检测处理 - switch (newValue.code) { - case 25001: - // 成功 - if (newValue.data != undefined) return - setLogList('info', str + '成功!') - if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化成功!') - break - case 25003: - // 失败 - if (newValue.data != undefined) return - setLogList('error', str + '失败!') - emit('update:testStatus', 'error') - stopTimeCount() - if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化失败!') - break - } - } - // 预监测 正式检测 - else if (newValue.requestId == 'formal_real') { - if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') { - testLogList.shift() - } - switch (newValue.code) { - case 25001: - case 25005: - let result: CheckData.ScriptChnItem[] = [] - let message = JSON.parse(newValue.data) - - // 当收到 25005 消息时,显示录波项目 - if (newValue.code == 25005) { - showWaveItem.value = true - // 添加录波项目到 scriptData - addWaveScriptItem() - } - - scriptData.forEach(item => { - // 处理当前节点的数据 - const temp: CheckData.ScriptChnItem = { - scriptType: item.id, - scriptName: item.scriptName, - devices: [] - } - // 找到message中所有scriptName与当前item.code匹配的项 - const matchedDevices = message - .filter((msg: any) => msg.scriptName === item.code) - .map((msg: any) => ({ - deviceId: msg.deviceId, - deviceName: msg.deviceName, // 如果有的话 - chnResult: msg.chnResult - })) - - // 添加匹配到的设备 - temp.devices.push(...matchedDevices) - result.push(temp) - }) - Object.assign(checkResult, result) - - if (newValue.code == 25001) { - setLogList('info', '检测完成!') - stopTimeCount() - updatePercentage() - } - if(newValue.code == 25005){ - setLogList("error", '实时数据校验失败!开始录波校验...') - } - break - case 25003: - setLogList('error', '检测失败!') - stopTimeCount() - updatePercentage() - break - default: - if (newValue.code != 10201) { - setLogList(newValue.code == 10200 ? 'info' : 'error', newValue.data) - } - - break - } - } - switch (newValue.requestId) { + switch (newValue.requestId) { case 'record_wave_step2': switch (newValue.code) { - case 10200: setLogList('info', newValue.data) break @@ -411,12 +311,26 @@ watch( }) stopTimeCount() break - case 25001: - console.log('newValue.code', newValue.code) + case 25001: { // 当录波校验完成时,更新录波项目的按钮状态 - setLogList('info', newValue.data) - updateWaveItemStatus(CheckData.ChnCheckResultEnum.SUCCESS) // 或根据实际结果设置状态 - break + setLogList('info', '录波对齐完成!') + // 找到录波项目并更新其状态 + const waveResultItem = checkResult.find(item => item.scriptType === 'wave_data') + console.log('waveResultItem1111111:', waveResultItem) + if (waveResultItem) { + // 将录波项目状态设置为SUCCESS + waveResultItem.devices.forEach(device => { + device.chnResult.fill(CheckData.ChnCheckResultEnum.SUCCESS) + }) + } + console.log('waveResultItem2222222:', waveResultItem) + // 触发响应式更新 + // 由于Vue可能无法检测到深层嵌套属性的更改,我们手动触发更新 + checkResult.splice(0, 0) // 这会触发响应式更新 + console.log('waveResultItem3333333:', checkResult) + stopTimeCount() + break + } } break case 'connect': @@ -462,6 +376,116 @@ watch( stopTimeCount() break } + if (checkStore.selectTestItems.preTest == false && newValue.requestId != 'formal_real') { + if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') { + testLogList.shift() + setLogList('info', '初始化开始!') + } + let str = + newValue.requestId == 'yjc_sbtxjy' + ? '设备通讯校验' + : newValue.requestId == 'yjc_mxyzxjy' + ? '模型一致性检验' + : newValue.requestId == 'yjc_align' + ? '实时数据对齐检验' + : newValue.requestId == 'YJC_xujy' + ? '相序校验' + : '' + // 预检测处理 + switch (newValue.code) { + case 25001: + // 成功 + if (newValue.data != undefined) return + setLogList('info', str + '成功!') + if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化成功!') + break + case 25003: + // 失败 + if (newValue.data != undefined) return + setLogList('error', str + '失败!') + emit('update:testStatus', 'error') + stopTimeCount() + if (newValue.requestId == 'YJC_xujy') setLogList('info', '初始化失败!') + break + } + } + // 预监测 正式检测 + else if (newValue.requestId == 'formal_real') { + if (testLogList[0].log == '正在检测,请稍等...' || testLogList[0].log == '暂无数据,等待检测开始') { + testLogList.shift() + } + switch (newValue.code) { + case 25001: + case 25005: + { + let result: CheckData.ScriptChnItem[] = [] + let message = JSON.parse(newValue.data) + // 当收到 25005 消息时,录波项目开始loading + if (newValue.code == 25005) { + // 设置录波项目为LOADING状态 + const waveResultItem = checkResult.find(item => item.code === 'wave_data') + + if (waveResultItem) { + waveResultItem.devices.forEach(device => { + device.chnResult.fill(CheckData.ChnCheckResultEnum.LOADING) + }) + } + + } + scriptData.forEach(item => { + // 处理当前节点的数据 + const temp: CheckData.ScriptChnItem = { + scriptType: item.id, + scriptName: item.scriptName, + devices: [] + } + // 特殊处理录波项目 - 如果是25005消息且当前项目是录波项目,则使用已设置的状态 + if (newValue.code == 25005 && item.code === 'wave_data') { + const existingWaveItem = checkResult.find(checkItem => checkItem.scriptType === 'wave_data') + if (existingWaveItem) { + temp.devices = [...existingWaveItem.devices] // 保留已设置的devices + } + } else { + // 找到message中所有scriptName与当前item.code匹配的项 + const matchedDevices = message + .filter((msg: any) => msg.scriptName === item.code) + .map((msg: any) => ({ + deviceId: msg.deviceId, + deviceName: msg.deviceName, + chnResult: msg.chnResult + })) + + // 添加匹配到的设备 + temp.devices.push(...matchedDevices) + } + result.push(temp) + }) + Object.assign(checkResult, result) + + if (newValue.code == 25001) { + setLogList('info', '检测完成!') + stopTimeCount() + updatePercentage() + } + if(newValue.code == 25005){ + setLogList("error", '实时数据校验失败!开始录波校验...') + } + break + } + + case 25003: + setLogList('error', '检测失败!') + stopTimeCount() + updatePercentage() + break + default: + if (newValue.code != 10201) { + setLogList(newValue.code == 10200 ? 'info' : 'error', newValue.data) + } + + break + } + } }, {deep: true} ) @@ -472,67 +496,6 @@ const setLogList = (state: 'error' | 'info' | 'warning', text: string) => { }) } -// 添加录波项目到 scriptData 的函数 -const addWaveScriptItem = () => { - // 检查是否已经添加过录波项目 - if (!scriptData.some(item => item.code === 'wave_data')) { - // 从原始数据中找到录波项目 - // 这里需要根据实际情况获取录波项目的原始数据 - const waveItem = scriptData.find(item => item.code === 'wave_data') - const waveItem2 = { - id: 'wave_data_id', // 需要替换为实际的ID - code: 'wave_data', - scriptName: '录波', - // 添加其他必要的属性 - } - - scriptData.push(waveItem2 as any) - checkTotal = scriptData.length - - // 初始化录波项目的检查结果为LOADING状态 - initWaveCheckResult() - } -} - -// 初始化录波项目的检查结果 -const initWaveCheckResult = () => { - const waveItem = scriptData.find(item => item.code === 'wave_data') - if (waveItem) { - let temp: CheckData.ScriptChnItem = { - scriptType: waveItem.id, - code: waveItem.code, - scriptName: waveItem.scriptName, - devices: [] - } - - for (let i = 0; i < deviceList?.length; i++) { - let tempChnResult: CheckData.ChnCheckResultEnum[] = [] - for (let j = 0; j < checkStore.chnNumList.length; j++) { - tempChnResult.push(CheckData.ChnCheckResultEnum.LOADING) // 设置为LOADING状态 - } - temp.devices.push({ - deviceId: deviceList[i].deviceId, - deviceName: deviceList[i].deviceName, - chnResult: tempChnResult - }) - } - - // 添加到checkResult中 - checkResult.push(temp) - } -} - -// 更新录波项目状态的函数 -const updateWaveItemStatus = (status: CheckData.ChnCheckResultEnum) => { - const waveResultItem = checkResult.find(item => item.code === 'wave_data') - if (waveResultItem) { - // 更新所有通道的状态 - waveResultItem.devices.forEach(device => { - device.chnResult.fill(status) - }) - } -} - // 更新进度条 const updatePercentage = async () => { if (testLogList.length - 1 < checkStore.chnNumList.length) { @@ -622,10 +585,8 @@ const initScriptData = async () => { devIds: checkStore.devices.map(item => item.deviceId), patternId: pattern }) - // 格式化脚本数据,初始化时排除录波项目 let temp = response.data - .filter((item: any) => item.code !== 'wave_data') // 排除录波项目 .map((item: any) => { return { ...item, @@ -643,10 +604,8 @@ const initDeviceList = () => { } // 初始化检测结果 (详细到通道) -// 修改函数定义 const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => { let result: CheckData.ScriptChnItem[] = [] - console.log('🚀 ~ initCheckResult ~ scriptData:', scriptData) scriptData.forEach(item => { let temp: CheckData.ScriptChnItem = { @@ -659,7 +618,12 @@ const initCheckResult = (defaultValue: CheckData.ChnCheckResultEnum) => { for (let i = 0; i < deviceList?.length; i++) { let tempChnResult: CheckData.ChnCheckResultEnum[] = [] for (let j = 0; j < checkStore.chnNumList.length; j++) { - tempChnResult.push(defaultValue) + // 录波项目初始化为UNKNOWN状态,其他项目使用传入的默认值 + if (item.code === 'wave_data') { + tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN) + } else { + tempChnResult.push(defaultValue) + } } temp.devices.push({ deviceId: deviceList[i].deviceId, @@ -690,6 +654,7 @@ watch( // 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道 const handleClick = (item: any, chnNum: number, scriptType: string) => { let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType) + let flag = -1 if (checkResultItem) { let device = checkResultItem.devices.find(obj => obj.deviceId === item.deviceId) @@ -748,7 +713,9 @@ const initializeParameters = async () => { // onMounted(() => { + if (!checkStore.selectTestItems.preTest) { + console.log(222222) // 判断是否预检测 initializeParameters() } diff --git a/frontend/src/views/machine/devType/components/devTypePopup.vue b/frontend/src/views/machine/devType/components/devTypePopup.vue index b324bc8..9211038 100644 --- a/frontend/src/views/machine/devType/components/devTypePopup.vue +++ b/frontend/src/views/machine/devType/components/devTypePopup.vue @@ -66,6 +66,9 @@ /> + + +