This commit is contained in:
caozehui
2025-01-03 18:57:35 +08:00
parent 938b9054d3
commit d10a7a4884
4 changed files with 179 additions and 248 deletions

View File

@@ -34,17 +34,17 @@
</el-radio-group>
</div>
<div class="content-tree">
<el-tree v-if="switchItem === 0" :default-expanded-keys="defaultExpandedKeys" node-key="scriptType"
<el-tree v-if="switchItem === 0" :default-expanded-keys="defaultExpandedKeys" node-key="index"
:data="treeDataUnqualified" :props="defaultProps" @node-click="handleNodeClick"
class="custom-tree">
<template #default="{ node, data }">
<span class="custom-tree-node">{{ data.scriptName }}</span>
<span class="custom-tree-node">{{ data.scriptTypeName }}</span>
</template>
</el-tree>
<el-tree v-if="switchItem === 1" :default-expanded-keys="defaultExpandedKeys" node-key="scriptType"
<el-tree v-if="switchItem === 1" :default-expanded-keys="defaultExpandedKeys" node-key="index"
:data="treeDataAll" :props="defaultProps" @node-click="handleNodeClick" class="custom-tree">
<template #default="{ node, data }">
<span class="custom-tree-node">{{ data.scriptName }}</span>
<span class="custom-tree-node">{{ data.scriptTypeName }}</span>
</template>
</el-tree>
</div>
@@ -53,15 +53,15 @@
<div class="content-right">
<div class="content-right-title">
<el-divider>当前检测项目</el-divider>
<span>{{ currentScriptDsc }}</span>
<span>{{ currentDesc }}</span>
</div>
<div class="content-right-Tabs">
<el-tabs type="border-card" v-model="activeTab">
<el-tab-pane label="检测结果" name="resultTab">
<DataCheckResultTable :tableData="checkResultTableData" ref="resultTableRef"/>
<DataCheckResultTable :tableData="checkResultTableData"/>
</el-tab-pane>
<el-tab-pane label="原始数据" name="rawDataTab">
<DataCheckRawDataTable :tableData="rawTableData" ref="rawDataTableRef"/>
<DataCheckRawDataTable :tableData="rawTableData"/>
</el-tab-pane>
</el-tabs>
</div>
@@ -86,7 +86,7 @@ const {appendToBody} = withDefaults(defineProps<{
}>(), {appendToBody: true})
const defaultProps = {
label: "scriptName",
label: "scriptTypeName",
children: "children",
};
@@ -112,23 +112,21 @@ let chnList: any[] = []
// 不符合测试项、全部测试项切换
const switchItem = ref<number>(0)
// 左侧树数据
let treeDataUnqualified: CheckData.ScriptItem[] = []
let treeDataAll: CheckData.ScriptItem[] = []
let treeDataUnqualified: CheckData.TreeItem[] = []
let treeDataAll: CheckData.TreeItem[] = []
// 左侧树被选中的叶子节点id
const checkedScriptType = ref<string>('')
const checkIndex = ref<string>('')
const currentScriptDsc = ref('');
const currentDesc = ref('');
// 右侧Tab选中项
const activeTab = ref<string>('resultTab')
// 检测结果表格数据
let checkResultTableData: CheckData.CheckResult[] = []
const checkResultTableData = reactive<CheckData.CheckResult[]>([])
// 原始数据表格数据
let rawTableData: CheckData.RawDataItem[] = []
const rawTableData = reactive<CheckData.RawDataItem[]>([])
const resultTableRef = ref()
const rawDataTableRef = ref()
// 左侧树默认展开节点id
let defaultExpandedKeys: string[] = []
@@ -136,10 +134,10 @@ let defaultExpandedKeys: string[] = []
// 点击左侧树节点触发事件
const handleNodeClick = async (data: any) => {
if (!data.children) {
checkedScriptType.value = data.scriptType
currentScriptDsc.value = data.scriptName
checkIndex.value = data.index
currentDesc.value = data.sourceDesc
if (checkedScriptType.value) {
if (checkIndex.value) {
await updateTableData()
}
}
@@ -150,7 +148,7 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
if (newVal) {
// 发起请求,查询该测试项的检测结果
const {data: resTreeDataTemp}: { data: CheckData.ScriptItem[] } = await getTreeData({
const {data: resTreeDataTemp}: { data: CheckData.TreeItem[] } = await getTreeData({
scriptId: checkStore.scriptId,
deviceId,
devNum: formContent.chnNum + '',
@@ -159,92 +157,89 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
})
treeDataAll = resTreeDataTemp
treeDataAll = [
{
scriptTypeName: "频率准确度检测",
sourceDesc: null,
index: null,
fly: null,
children: [
{
scriptTypeName: "额定条件下频率准确度测试",
sourceDesc: null,
index: null,
fly: null,
children: [
{
scriptTypeName: "频率=42.5Hz",
sourceDesc: "频率=42.5Hz",
index: 11,
fly: 1,
},
{
scriptTypeName: "频率=50Hz",
sourceDesc: "频率=50Hz",
index: 12,
fly: 2,
},
{
scriptTypeName: "频率=50.05Hz",
sourceDesc: "频率=50.05Hz",
index: 13,
fly: 1,
},
{
scriptTypeName: "频率=57.5Hz",
sourceDesc: "频率=57.5Hz",
index: 14,
fly: 2,
}
]
},
{
scriptTypeName: "单影响量下频率准确度测试",
sourceDesc: null,
index: null,
fly: null,
children: [
{
scriptTypeName: "电压幅值对频率测量的影响",
sourceDesc: null,
index: null,
fly: null,
children: [
{
scriptTypeName: "10%Un对频率=50.05Hz的影响",
sourceDesc: "10%Un对频率=50.05Hz的影响",
index: null,
fly: 1,
}
]
},
{
scriptTypeName: "谐波对频率测量的影响",
sourceDesc: null,
index: null,
fly: null,
children: [
{
scriptTypeName: "叠加多次谐波对频率=50.05Hz的影响",
sourceDesc: "叠加多次谐波对频率=50.05Hz的影响",
index: null,
fly: 2,
}
]
}
]
},
]
}
]
let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll))
filterTree(treeDataTemp, 2)
treeDataUnqualified = treeDataTemp
// 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'
// }
// ]
// }
// ]
// }
// ]
// 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'
// }
// ]
// }
// ]
// }]
switchItem.value = 0
await handleSwitchChange(0)
}
@@ -253,100 +248,6 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
const handleSwitchChange = async (data: any) => {
console.log("切换不合格测试项、全部测试项", data);
// let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll))
// if (data === 0) {
// filterTree(treeDataTemp, 2)
// treeDataUnqualified = treeDataTemp
// treeDataUnqualified=[]
//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 {
// treeDataAll = treeDataTemp
// 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()
await updateTableData()
}
@@ -360,23 +261,23 @@ const defaultOperate = () => {
node = getDefaultNode(treeDataAll)
}
if (node) {
currentScriptDsc.value = node.scriptName
checkedScriptType.value = node.scriptType
defaultExpandedKeys = [node.scriptType]
currentDesc.value = node.sourceDesc
checkIndex.value = node.index
defaultExpandedKeys = [node.index]
} else {
currentScriptDsc.value = ''
checkedScriptType.value = ''
currentDesc.value = ''
checkIndex.value = ''
defaultExpandedKeys = []
}
}
const updateTableData = async () => {
console.log("左侧树被选中的叶子节点scriptType", checkedScriptType.value);
if (checkedScriptType.value) {
console.log("左侧树被选中的叶子节点checkIndex", checkIndex.value);
if (checkIndex.value) {
// 发起请求,查询该测试项的检测结果
// const result = await getTableData({checkStore.scriptId,deviceId, formContent.chnNum, scriptType})
// const result = await getTableData({checkStore.scriptId,deviceId, formContent.chnNum, scriptType,checkIndex})
checkResultTableData = [{
Object.assign(checkResultTableData, [{
chnNum: '1',
standardValue: 57.74,
A: 57.73,
@@ -387,9 +288,8 @@ const updateTableData = async () => {
C_errValue: 0.01,
maxErrVaule: 0.05774,
result: '合格',
}]
rawTableData = [
}])
Object.assign(rawTableData, [
{
updateTime: "2024-10-10 09:30:00",
A: 57.73,
@@ -510,7 +410,7 @@ const updateTableData = async () => {
B: 57.73,
C: 57.73,
}
]
])
}
}
@@ -568,9 +468,9 @@ const close = () => {
})
treeDataUnqualified = []
treeDataAll = []
checkedScriptType.value = ''
activeTab.value = 'rawDataTab'
currentScriptDsc.value = ''
checkIndex.value = ''
activeTab.value = 'resultTab'
currentDesc.value = ''
switchItem.value = 0
visible.value = false;
@@ -654,6 +554,10 @@ const filter = (treeData: any[], fly: number) => {
if (node && node.fly !== fly) {
if (node.children && node.children.length > 0) {
filter(node.children, fly)
// 检查 children 是否被全部移除
if (node.children.length === 0) {
treeData.splice(i, 1);
}
} else {
treeData.splice(i, 1)
}