This commit is contained in:
caozehui
2025-01-02 20:27:36 +08:00
parent 410cd53e51
commit 8a5bcca901
3 changed files with 220 additions and 134 deletions

View File

@@ -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
})