diff --git a/frontend/src/api/check/test/index.ts b/frontend/src/api/check/test/index.ts index 1bb3622..d245897 100644 --- a/frontend/src/api/check/test/index.ts +++ b/frontend/src/api/check/test/index.ts @@ -24,9 +24,9 @@ export const getFormData = (params: { export const getTreeData = (params: { scriptId: string, deviceId: string, - chnNum: string, + devNum: string, scriptType: string | null, - flag: number + code: string }) => { return http.post("/result/treeData/", params, {loading: false}); } diff --git a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue index 098f501..e912df1 100644 --- a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue @@ -79,7 +79,7 @@ import DataCheckRawDataTable from './dataCheckRawDataTable.vue' import {CheckData} from "@/api/check/interface"; import {useDictStore} from "@/stores/modules/dict"; import {useCheckStore} from "@/stores/modules/check"; -import {getFormData, getTreeData, getTableData} from "@/api/check/test"; +import {getFormData, getTreeData} from "@/api/check/test"; const {appendToBody} = withDefaults(defineProps<{ appendToBody: boolean @@ -156,92 +156,101 @@ const handleSwitchChange = async (data: any) => { if (data === 0) { // 发起请求,查询该测试项的检测结果 - // const result = await getTreeData({scriptId:checkStore.scriptId,deviceId, chnNum: formContent.chnNum+'', scriptType,0}) - treeDataUnqualified = [{ - "scriptName": "频率准确度检测", - "children": [ - { - "scriptName": "电压对频率测量的影响", - "children": [ - { - "scriptName": "输入:频率 50.05Hz Ua =10%Un...", - "scriptType": '2346adafdf' - }, - { - "scriptName": "输入:频率 51.05Hz Ua =10%Un...", - "scriptType": '1246adaafdf' - }, - { - "scriptName": "输入:频率 52.05Hz Ua =10%Un...", - "scriptType": '2136ada3fdf' - } - ] - }, - { - "scriptName": "谐波对频率测量的影响", - "children": [ - { - "scriptName": "输入:频率 50.05Hz Ua =100%Un...", - "scriptType": '234246adafdf' - } - ] - } - ] - }] + const {data: treeDataTemp} = await getTreeData({ + scriptId: checkStore.scriptId, + deviceId, + devNum: formContent.chnNum + '', + scriptType, + code: checkStore.planCode + }) + treeDataUnqualified = [] + //filterTree(treeDataTemp,2) + //treeDataUnqualified=treeDataTemp + // treeDataUnqualified = [{ + // "scriptName": "频率准确度检测", + // "children": [ + // { + // "scriptName": "电压对频率测量的影响", + // "children": [ + // { + // "scriptName": "输入:频率 50.05Hz Ua =10%Un...", + // "scriptType": '2346adafdf' + // }, + // { + // "scriptName": "输入:频率 51.05Hz Ua =10%Un...", + // "scriptType": '1246adaafdf' + // }, + // { + // "scriptName": "输入:频率 52.05Hz Ua =10%Un...", + // "scriptType": '2136ada3fdf' + // } + // ] + // }, + // { + // "scriptName": "谐波对频率测量的影响", + // "children": [ + // { + // "scriptName": "输入:频率 50.05Hz Ua =100%Un...", + // "scriptType": '234246adafdf' + // } + // ] + // } + // ] + // }] } else { // 发起请求,查询该测试项的检测结果 - // const result = await getTreeData({scriptId:checkStore.scriptId,deviceId, chnNum: formContent.chnNum+'', scriptType,1}) - treeDataAll = [ - { - "scriptName": "频率准确度检测", - "children": [ - { - "scriptName": "额定工作条件下的检测", - "children": [ - { - "scriptName": "输入:频率 42.5Hz...", - "scriptType": '2246ada2fdf' - }, - { - "scriptName": "输入:频率 50.0Hz...", - "scriptType": '2246a3dafdf' - }, - { - "scriptName": "输入:频率 50.05Hz....", - "scriptType": '22246adafdf' - } - ] - }, - { - "scriptName": "电压对频率测量的影响", - "children": [ - { - "scriptName": "输入:频率 50.05Hz Ua =10%Un...", - "scriptType": '224a6adafdf' - }, - { - "scriptName": "输入:频率 51.05Hz Ua =10%Un...", - "scriptType": '2246aadafdf' - }, - { - "scriptName": "输入:频率 52.05Hz Ua =10%Un...", - "scriptType": '2246adaffdf' - } - ] - }, - { - "scriptName": "谐波对频率测量的影响", - "children": [ - { - "scriptName": "输入:频率 50.05Hz Ua =100%Un...", - "scriptType": '2246aadafdf' - } - ] - } - ] - } - ] - + // const {data:treeDataAll} = await getTreeData({scriptId:checkStore.scriptId,deviceId, devNum: formContent.chnNum+'', scriptType,code:checkStore.planCode}) + treeDataAll = [] + // treeDataAll = [ + // { + // "scriptName": "频率准确度检测", + // "children": [ + // { + // "scriptName": "额定工作条件下的检测", + // "children": [ + // { + // "scriptName": "输入:频率 42.5Hz...", + // "scriptType": '2246ada2fdf' + // }, + // { + // "scriptName": "输入:频率 50.0Hz...", + // "scriptType": '2246a3dafdf' + // }, + // { + // "scriptName": "输入:频率 50.05Hz....", + // "scriptType": '22246adafdf' + // } + // ] + // }, + // { + // "scriptName": "电压对频率测量的影响", + // "children": [ + // { + // "scriptName": "输入:频率 50.05Hz Ua =10%Un...", + // "scriptType": '224a6adafdf' + // }, + // { + // "scriptName": "输入:频率 51.05Hz Ua =10%Un...", + // "scriptType": '2246aadafdf' + // }, + // { + // "scriptName": "输入:频率 52.05Hz Ua =10%Un...", + // "scriptType": '2246adaffdf' + // } + // ] + // }, + // { + // "scriptName": "谐波对频率测量的影响", + // "children": [ + // { + // "scriptName": "输入:频率 50.05Hz Ua =100%Un...", + // "scriptType": '2246aadafdf' + // } + // ] + // } + // ] + // } + // ] } defaultOperate() @@ -256,9 +265,15 @@ const defaultOperate = () => { } else { node = getDefaultNode(treeDataAll) } - currentScriptDsc.value = node?.scriptName - checkedScriptType.value = node?.scriptType - defaultExpandedKeys = [node?.scriptType] + if (node) { + currentScriptDsc.value = node.scriptName + checkedScriptType.value = node.scriptType + defaultExpandedKeys = [node.scriptType] + } else { + currentScriptDsc.value = '' + checkedScriptType.value = '' + defaultExpandedKeys = [] + } } const updateTableData = async () => { @@ -423,6 +438,7 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul // {value: '3', label: '1'}, // {value: '4', label: '0'}], // } + chnList = resFormContent.chnList.map(item => ({ value: item.value, label: item.label == '1' ? `${item.value}` : `${item.value}(不符合)` @@ -438,6 +454,8 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul visible.value = true; + + // console.log(filterTree(treeD, 1)) } const close = () => { @@ -476,6 +494,74 @@ const getDefaultNode = (data: any[]) => { return findFirstLeafNode(firstElement); } +// let treeD: any = [{ +// "scriptTypeName": "暂态", +// "sort": null, +// "fly": null, +// "children": [ +// { +// "scriptTypeName": "额定工作条件下的测量1", +// "sort": null, +// "fly": null, +// "children": [ +// { +// "scriptTypeName": "输入:频率=50.0Hz Ua=100.0%Un Ub=100.0%Un Uc=100.0%Un Ia=100.0%In Ib=100.0%In Ic=100.0%In 暂态 A相(暂态深度=null% 暂态持续时间=null%) B相(暂态深度=null% 暂态持续时间=null%) C相(暂态深度=null% 暂态持续时间=null%) ", +// "sort": 81, +// "fly": 1, +// "children": null +// }, +// { +// "scriptTypeName": "输入:频率=45.0Hz Ua=100.0%Un Ub=100.0%Un Uc=100.0%Un Ia=100.0%In Ib=100.0%In Ic=100.0%In 暂态 A相(暂态深度=null% 暂态持续时间=null%) B相(暂态深度=null% 暂态持续时间=null%) C相(暂态深度=null% 暂态持续时间=null%) ", +// "sort": 81, +// "fly": 0, +// "children": null +// } +// ] +// }, +// { +// "scriptTypeName": "额定工作条件下的测量2", +// "sort": null, +// "fly": null, +// "children": [ +// { +// "scriptTypeName": "输入:频率=50.0Hz Ua=100.0%Un Ub=100.0%Un Uc=100.0%Un Ia=100.0%In Ib=100.0%In Ic=100.0%In 暂态 A相(暂态深度=null% 暂态持续时间=null%) B相(暂态深度=null% 暂态持续时间=null%) C相(暂态深度=null% 暂态持续时间=null%) ", +// "sort": 81, +// "fly": 1, +// "children": null +// }, +// { +// "scriptTypeName": "输入:频率=45.0Hz Ua=100.0%Un Ub=100.0%Un Uc=100.0%Un Ia=100.0%In Ib=100.0%In Ic=100.0%In 暂态 A相(暂态深度=null% 暂态持续时间=null%) B相(暂态深度=null% 暂态持续时间=null%) C相(暂态深度=null% 暂态持续时间=null%) ", +// "sort": 81, +// "fly": 0, +// "children": null +// } +// ] +// } +// ] +// }] + +// fly: 1合格 2不合格 4数据错误 +const filterTree = (treeData: any[], fly: number): any[] => { + if (!treeData || treeData.length === 0) { + return [] + } + filter(treeData, fly) + return treeData +} + +const filter = (treeData: any[], fly: number) => { + for (let i = 0; i < treeData.length; i++) { + let node = treeData[i] + if (node && node.fly !== fly) { + if (node.children && node.children.length > 0) { + filter(node.children, fly) + } else { + treeData.splice(i, 1) + } + } + } +} + defineExpose({ open }) diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index 35f0557..b561a3c 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -412,11 +412,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'VOL_Start': + case 'V_Start': updateCheckResultView("V", true) updateLog(true) break; - case 'VOL_End': + case 'V_End': updateCheckResultView("V", false) updateLog(false) updatePercentage() @@ -425,11 +425,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'Harm_V_Start': + case 'HV_Start': updateCheckResultView("HV", true) updateLog(true) break; - case 'Harm_V_End': + case 'HV_End': updateCheckResultView("HV", false) updateLog(false) updatePercentage() @@ -438,11 +438,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'Harm_I_Start': + case 'HI_Start': updateCheckResultView("HI", true) updateLog(true) break; - case 'Harm_I_End': + case 'HI_End': updateCheckResultView("HI", false) updateLog(false) updatePercentage() @@ -451,11 +451,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'Harm_P_Start': + case 'HP_Start': updateCheckResultView("HP", true) updateLog(true) break; - case 'Harm_P_End': + case 'HP_End': updateCheckResultView("HP", false) updateLog(false) updatePercentage() @@ -464,11 +464,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'InHarm_V_Start': + case 'HSV_Start': updateCheckResultView("HSV", true) updateLog(true) break; - case 'InHarm_V_End': + case 'HSV_End': updateCheckResultView("HSV", false) updateLog(false) updatePercentage() @@ -477,11 +477,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'InHarm_I_Start': + case 'HSI_Start': updateCheckResultView("HSI", true) updateLog(true) break; - case 'InHarm_I_End': + case 'HSI_End': updateCheckResultView("HSI", false) updateLog(false) updatePercentage() @@ -490,11 +490,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'Dip_Start': + case 'VOLTAGE_Start': updateCheckResultView("VOLTAGE", true) updateLog(true) break; - case 'Dip_End': + case 'VOLTAGE_End': updateCheckResultView("VOLTAGE", false) updateLog(false) updatePercentage() @@ -503,11 +503,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'CUR_Start': + case 'I_Start': updateCheckResultView("I", true) updateLog(true) break; - case 'CUR_End': + case 'I_End': updateCheckResultView("I", false) updateLog(false) updatePercentage() @@ -516,11 +516,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'MSQI_U_Start': + case 'IMBV_Start': updateCheckResultView("IMBV", true) updateLog(true) break; - case 'MSQI_U_End': + case 'IMBV_End': updateCheckResultView("IMBV", false) updateLog(false) updatePercentage() @@ -529,11 +529,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'MSQI_I_Start': + case 'IMBA_Start': updateCheckResultView("IMBA", true) updateLog(true) break; - case 'MSQI_I_End': + case 'IMBA_End': updateCheckResultView("IMBA", false) updateLog(false) updatePercentage() @@ -542,11 +542,11 @@ watch(webMsgSend, function (newValue, oldValue) { startTimer() } break; - case 'Flicker_Start': + case 'F_Start': updateCheckResultView("F", true) updateLog(true) break; - case 'Flicker_End': + case 'F_End': updateCheckResultView("F", false) updateLog(false) updatePercentage() @@ -969,132 +969,132 @@ const startTimer = () => { break; case 2: emit('update:webMsgSend', { - requestId: 'VOL_Start', + requestId: 'V_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'VOL_End', + requestId: 'V_End', params: {} }) }, 2000); break; case 3: emit('update:webMsgSend', { - requestId: 'Harm_V_Start', + requestId: 'HV_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'Harm_V_End', + requestId: 'HV_End', params: {} }) }, 2000) break; case 4: emit('update:webMsgSend', { - requestId: 'Harm_I_Start', + requestId: 'HI_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'Harm_I_End', + requestId: 'HI_End', params: {} }) }, 2000) break; case 5: emit('update:webMsgSend', { - requestId: 'Harm_P_Start', + requestId: 'HP_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'Harm_P_End', + requestId: 'HP_End', params: {} }) }, 2000) break; case 6: emit('update:webMsgSend', { - requestId: 'InHarm_V_Start', + requestId: 'HSV_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'InHarm_V_End', + requestId: 'HSV_End', params: {} }) }, 2000) break; case 7: emit('update:webMsgSend', { - requestId: 'InHarm_I_Start', + requestId: 'HSI_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'InHarm_I_End', + requestId: 'HSI_End', params: {} }) }, 2000) break; case 8: emit('update:webMsgSend', { - requestId: 'Dip_Start', + requestId: 'VOLTAGE_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'Dip_End', + requestId: 'VOLTAGE_End', params: {} }) }, 2000) break; case 9: emit('update:webMsgSend', { - requestId: 'CUR_Start', + requestId: 'I_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'CUR_End', + requestId: 'I_End', params: {} }) }, 2000) break; case 10: emit('update:webMsgSend', { - requestId: 'MSQI_U_Start', + requestId: 'IMBV_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'MSQI_U_End', + requestId: 'IMBV_End', params: {} }) }, 2000) break; case 11: emit('update:webMsgSend', { - requestId: 'MSQI_I_Start', + requestId: 'IMBA_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'MSQI_I_End', + requestId: 'IMBA_End', params: {} }, 2000) }) break; case 12: emit('update:webMsgSend', { - requestId: 'Flicker_Start', + requestId: 'F_Start', params: {} }) setTimeout(() => { emit('update:webMsgSend', { - requestId: 'Flicker_End', + requestId: 'F_End', params: {} }) }, 2000)