This commit is contained in:
caozehui
2024-12-25 18:04:16 +08:00
parent e4025e39cb
commit 6b76d89507
6 changed files with 404 additions and 66 deletions

View File

@@ -42,9 +42,10 @@ export namespace CheckData {
// 用来描述检测脚本类型
export interface ScriptItem {
id: string,
code: string,
scriptItemName: string,
//children?: ScriptItem[]
code?: string,
scriptName: string,
pid?: string,
children?: ScriptItem[]
}
// 用来描述 通道检测结果
@@ -57,7 +58,7 @@ export namespace CheckData {
//用来描述 某个脚本测试项对所有通道的检测结果
export interface ScriptChnItem {
scriptId: string
scriptItemName?: string //可以不要该属性,有点多余
scriptName?: string //可以不要该属性,有点多余
// 设备
devices: Array<{
@@ -80,7 +81,7 @@ export namespace CheckData {
*/
export interface ScriptChnViewItem {
scriptId: string,
scriptItemName?: string //脚本项名称,可以不要该属性,有点多余
scriptName?: string //脚本项名称,可以不要该属性,有点多余
// 设备
devices: Array<{

View File

@@ -16,10 +16,10 @@
<script lang="tsx" setup>
import type {RawDataItem} from "@/api/check/interface";
import{CheckData} from "@/api/check/interface";
const {tableData} = defineProps<{
tableData: RawDataItem[]
tableData: CheckData.RawDataItem[]
}>()

View File

@@ -50,10 +50,10 @@
<script lang="tsx" setup>
import {defineProps, reactive} from 'vue';
import type {CheckResult} from "@/api/check/interface";
import {CheckData} from "@/api/check/interface";
const {tableData}=defineProps<{
tableData:CheckResult[],
tableData:CheckData.CheckResult[],
}>();

View File

@@ -18,7 +18,7 @@
</el-form-item>
<el-form-item label='通道号'>
<el-select v-model="formContent.monitorIdx" @change="handleChnNumChange">
<el-option v-for="item in monitorIdxList" :key="item.value" :label="item.value"
<el-option v-for="item in chnList" :key="item.value" :label="item.value"
:value="item.value"/>
</el-select>
</el-form-item>
@@ -28,13 +28,13 @@
<div class="data-check-body">
<div class="content-left-tree">
<div>
<el-radio-group v-model="checkItemSwitch" @change="handleCheckItemSwitch">
<el-radio-group v-model="switchItem">
<el-radio-button label="不符合测试项" :value="0"/>
<el-radio-button label="全部测试项" :value="1"/>
</el-radio-group>
</div>
<div class="content-tree">
<el-tree :default-expanded-keys="['1-1-1']" node-key="id" :data="treeData"
<el-tree :default-expanded-keys="defaultExpandedKeys" node-key="id" :data="treeData"
:props="defaultProps" @node-click="handleNodeClick"/>
</div>
</div>
@@ -45,7 +45,7 @@
<span>{{ currentScriptDsc }}</span>
</div>
<div class="content-right-Tabs">
<el-tabs type="border-card" v-model="activeName">
<el-tabs type="border-card" v-model="activeTab">
<el-tab-pane label="检测结果" name="resultTab">
<DataCheckResultTable :tableData="checkResultTableData" ref="resultTableRef"/>
</el-tab-pane>
@@ -66,12 +66,17 @@ import {reactive, ref} from 'vue'
import DataCheckResultTable from './dataCheckResultTable.vue'
import DataCheckRawDataTable from './dataCheckRawDataTable.vue'
import {CheckData} from "@/api/check/interface";
import {data as treeData} from "@/api/plan/autoTest.json";
const {appendToBody} = withDefaults(defineProps<{
appendToBody: boolean
}>(), {appendToBody: false})
const defaultProps = {
label: "scriptName",
children: "children",
};
// 表单数据
const formContent = reactive<CheckData.DataCheck>({
scriptName: '',
errorSysName: '',
@@ -79,23 +84,24 @@ const formContent = reactive<CheckData.DataCheck>({
deviceName: '',
monitorIdx: '',
})
// 通道下拉列表
let chnList: number[] = []
const activeName = ref('resultTab')
// 不符合测试项、全部测试项切换
const switchItem = ref<number>(-1)
// 左侧树数据(仅用于展示)
const treeData=reactive<CheckData.ScriptItem[]>([])
// 左侧树数据-不符合测试项
let treeDataUnQualified: CheckData.ScriptItem[] = []
// 左侧树数据-全部测试项
let treeDataAll: CheckData.ScriptItem[] = []
// 左侧树被选中的叶子节点id
const checkedScriptId = ref('')
const checkedScriptId = ref<string>('')
const checkItemSwitch = ref(0)
const currentScriptDsc = ref('电压准确度检测频率42.5Hz Ua=46.192V 0° Ub=46.192V -120° Uc=46.192V 120° Ia=1A 0° Ib=1A -120° Ic=1A 120°');
const defaultProps = {
children: "children",
label: "name",
pid: "pid",
};
let monitorIdxList: any[] = []
// 右侧Tab选中项
const activeTab = ref<string>('resultTab')
// 检测结果表格数据
const checkResultTableData = reactive<CheckData.CheckResult[]>([
{
@@ -235,20 +241,14 @@ const rawTableData = reactive<CheckData.RawDataItem[]>([
}
])
const resultTableRef = ref()
const rawDataTableRef = ref()
// 左侧树默认展开节点id
const defaultExpandedKeys = computed(() => {
return [getDefaultId(treeData)]
})
// 切换不合格测试项、全部测试项 触发事件
const handleCheckItemSwitch = (data: any) => {
// 0 不合格测试项、1 全部测试项
if (data === 0) {
} else {
}
}
// 改变通道号下拉框触发事件
const handleChnNumChange = (data: any) => {
formContent.monitorIdx = data.value
@@ -256,6 +256,11 @@ const handleChnNumChange = (data: any) => {
watch(() => formContent.monitorIdx, (newVal, oldVal) => {
if (newVal) {
console.log("通道号下拉框", newVal, oldVal);
// 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询)
// treeDataUnQualified=[]
// treeDataAll=[]
}
})
@@ -265,6 +270,7 @@ const handleNodeClick = (data: any) => {
checkedScriptId.value = data.id
}
};
watch(checkedScriptId, (newVal, oldVal) => {
if (newVal) {
console.log("左侧树被选中的叶子节点id", newVal, oldVal);
@@ -272,9 +278,23 @@ watch(checkedScriptId, (newVal, oldVal) => {
}
})
// 切换不合格测试项、全部测试项 触发事件
// const handleSwitch = (data: any) => {
// if (data === 0) {
// //Object.assign(treeData, treeDataUnQualified)
// } else {
// //Object.assign(treeData, treeDataAll)
// }
// }
watch(switchItem, (newVal, oldVal) => {
if (switchItem.value === 0) {
Object.assign(treeData, treeDataUnQualified)
}
if (switchItem.value === 1) {
Object.assign(treeData, treeDataAll)
}
},{immediate:true})
const resultTableRef = ref()
const rawDataTableRef = ref()
const visible = ref(false)
@@ -288,12 +308,13 @@ const close = () => {
monitorIdx: '',
})
checkedScriptId.value = ''
activeName.value = 'rawDataTab'
activeTab.value = 'rawDataTab'
visible.value = false;
};
const open = async (deviceId: string, chnNum: number, checkItemId?: string) => {
switchItem.value = 0
// 发起后端请求,查询详细信息
// 当checkItemId为空时默认显示全部测试项、全部不合格测试项
// 当checkItemId不为空时默认显示当前checkItemId的测试项、属于当前checkItemId的不合格测试项
@@ -303,7 +324,7 @@ const open = async (deviceId: string, chnNum: number, checkItemId?: string) => {
// 数据处理
monitorIdxList = [
chnList = [
{value: '1',},
{
value: '2 (不合格)',
@@ -319,20 +340,336 @@ const open = async (deviceId: string, chnNum: number, checkItemId?: string) => {
errorSysName: 'Q/GDW 10650.2-2021',
dataRule: '所有值',
deviceName: '被检设备1',
monitorIdx: monitorIdxList[0].value,
monitorIdx: chnList[0].value,
})
checkedScriptId.value = treeData[0].children[0].children[0].id
// checkResultTableData=[];
treeDataAll=[{
"id": "1",
"pid": "0",
"scriptName": "频率准确度检测",
"children": [
{
"id": "1-1",
"pid": "1",
"scriptName": "额定工作条件下的检测",
"children": [
{
"id": "1-1-1",
"pid": "1-1",
"scriptName": "输入:频率 42.5Hz..."
},
{
"id": "1-1-2",
"pid": "1-1",
"scriptName": "输入:频率 50.0Hz..."
},
{
"id": "1-1-3",
"pid": "1-1",
"scriptName": "输入:频率 50.05Hz...."
}
]
},
{
"id": "1-2",
"pid": "1",
"scriptName": "电压对频率测量的影响",
"children": [
{
"id": "1-2-1",
"pid": "1-2",
"scriptName": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"id": "1-2-1",
"pid": "1-2",
"scriptName": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"id": "1-2-2",
"pid": "1-2",
"scriptName": "输入:频率 52.05Hz Ua =10%Un..."
}
]
},
{
"id": "1-3",
"pid": "1",
"scriptName": "谐波对频率测量的影响",
"children": [
{
"id": "1-3-1",
"pid": "1-3",
"scriptName": "输入:频率 50.05Hz Ua =100%Un..."
}
]
}
]
}]
treeDataUnQualified=[{
"id": "1",
"pid": "0",
"scriptName": "频率准确度检测",
"children": [
{
"id": "1-1",
"pid": "1",
"scriptName": "额定工作条件下的检测",
"children": [
{
"id": "1-1-1",
"pid": "1-1",
"scriptName": "输入:频率 42.5Hz..."
},
{
"id": "1-1-2",
"pid": "1-1",
"scriptName": "输入:频率 50.0Hz..."
},
{
"id": "1-1-3",
"pid": "1-1",
"scriptName": "输入:频率 50.05Hz...."
}
]
},
{
"id": "1-2",
"pid": "1",
"scriptName": "电压对频率测量的影响",
"children": [
{
"id": "1-2-1",
"pid": "1-2",
"scriptName": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"id": "1-2-1",
"pid": "1-2",
"scriptName": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"id": "1-2-2",
"pid": "1-2",
"scriptName": "输入:频率 52.05Hz Ua =10%Un..."
}
]
}
]
}]
// Object.assign(treeData, [
// {
// "id": "1",
// "pid": "0",
// "scriptName": "频率准确度检测",
// "children": [
// {
// "id": "1-1",
// "pid": "1",
// "scriptName": "额定工作条件下的检测",
// "children": [
// {
// "id": "1-1-1",
// "pid": "1-1",
// "scriptName": "输入:频率 42.5Hz..."
// },
// {
// "id": "1-1-2",
// "pid": "1-1",
// "scriptName": "输入:频率 50.0Hz..."
// },
// {
// "id": "1-1-3",
// "pid": "1-1",
// "scriptName": "输入:频率 50.05Hz...."
// }
// ]
// },
// {
// "id": "1-2",
// "pid": "1",
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "id": "1-2-1",
// "pid": "1-2",
// "scriptName": "输入:频率 50.05Hz Ua =10%Un..."
// },
// {
// "id": "1-2-1",
// "pid": "1-2",
// "scriptName": "输入:频率 51.05Hz Ua =10%Un..."
// },
// {
// "id": "1-2-2",
// "pid": "1-2",
// "scriptName": "输入:频率 52.05Hz Ua =10%Un..."
// }
// ]
// },
// {
// "id": "1-3",
// "pid": "1",
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "id": "1-3-1",
// "pid": "1-3",
// "scriptName": "输入:频率 50.05Hz Ua =100%Un..."
// }
// ]
// }
// ]
// },
// {
// "id": "2",
// "pid": "0",
// "scriptName": "电压准确度检测",
// "children": [
// {
// "pid": "2",
// "id": "2-1",
// "scriptName": "额定工作条件下的检测",
// "children": [
// {
// "id": "2-1-1",
// "pid": "2-1",
// "scriptName": "输入:频率 42.5Hz..."
// },
// {
// "id": "2-1-2",
// "pid": "2-1",
// "scriptName": "输入:频率 50.0Hz..."
// },
// {
// "id": "2-1-3",
// "pid": "2-1",
// "scriptName": "输入:频率 50.05Hz..."
// }
// ]
// },
// {
// "pid": "2",
// "id": "2-2",
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "id": "2-2-1",
// "pid": "2-2",
// "scriptName": "输入:频率 50.05Hz Ua =10%Un..."
// },
// {
// "id": "2-2-1",
// "pid": "2-2",
// "scriptName": "输入:频率 51.05Hz Ua =10%Un..."
// },
// {
// "id": "2-2-2",
// "pid": "2-2",
// "scriptName": "输入:频率 52.05Hz Ua =10%Un..."
// }
// ]
// },
// {
// "pid": "2",
// "id": "2-3",
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "id": "2-3-1",
// "pid": "2-3",
// "scriptName": "输入:频率 50.05Hz Ua =100%Un..."
// }
// ]
// }
// ]
// },
// {
// "id": "3",
// "pid": "0",
// "scriptName": "谐波准确度检测",
// "children": [
// {
// "id": "3-1",
// "pid": "3",
// "scriptName": "额定工作条件下的检测",
// "children": [
// {
// "id": "3-1-1",
// "pid": "3-1",
// "scriptName": "输入:频率 42.5Hz..."
// },
// {
// "id": "3-1-2",
// "pid": "3-1",
// "scriptName": "输入:频率 50.0Hz..."
// },
// {
// "id": "3-1-3",
// "pid": "3-1",
// "scriptName": "输入:频率 50.05Hz..."
// }
// ]
// },
// {
// "id": "3-2",
// "pid": "3",
// "scriptName": "电压对频率测量的影响",
// "children": [
// {
// "id": "3-2-1",
// "pid": "3-2",
// "scriptName": "输入:频率 50.05Hz Ua =10%Un..."
// },
// {
// "id": "3-2-1",
// "pid": "3-2",
// "scriptName": "输入:频率 51.05Hz Ua =10%Un..."
// },
// {
// "id": "3-2-2",
// "pid": "3-2",
// "scriptName": "输入:频率 52.05Hz Ua =10%Un..."
// }
// ]
// },
// {
// "id": "3-3",
// "pid": "3",
// "scriptName": "谐波对频率测量的影响",
// "children": [
// {
// "id": "3-3-1",
// "pid": "3-3",
// "name": "输入:频率 50.05Hz Ua =100%Un..."
// }
// ]
// }
// ]
// }
// ])
checkedScriptId.value = defaultExpandedKeys.value[0] ?? ''
visible.value = true;
}
const getDefaultLeafNodeId = (treeData: any[]): string => {
let leafNodeId = ''
if (treeData.length > 0) {
const firstNode = treeData[0]
const findFirstLeafNode = (node: any): string => {
if (!node.children || node.children.length === 0) {
return node.id;
}
return leafNodeId
return findFirstLeafNode(node.children[0]);
}
const getDefaultId = (data: any[]): string | null => {
if (!data || data.length === 0) {
return null;
}
const firstElement = data[0];
return findFirstLeafNode(firstElement);
}
defineExpose({

View File

@@ -41,7 +41,7 @@
<el-table :data="checkResultView" :cell-class-name="tableCell" row-key="scriptId" height="450px"
:header-cell-style="{ background: '#003078', color: '#eee', textAlign: 'center' } " style="width: 100%"
border>
<el-table-column fixed prop="scriptItemName" label="检测项目" width="140px" align="center">
<el-table-column fixed prop="scriptName" label="检测项目" width="140px" align="center">
</el-table-column>
<template v-if="chnSum<=MAX_CHN_SUM">
@@ -190,7 +190,7 @@ const checkResultView = computed(() => {
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
let temp: CheckData.ScriptChnViewItem = {
scriptId: item.scriptId,
scriptItemName: item.scriptItemName,
scriptName: item.scriptName,
devices: []
}
@@ -344,24 +344,24 @@ const initScriptData = () => {
.set('Flicker', '短时闪变')
let response: CheckData.ScriptItem[] = [
{id: '1', code: 'Freq', scriptItemName: '频率准确度检测'},
{id: '2', code: 'VOL', scriptItemName: '电压准确度检测'},
{id: '3', code: 'Harm_V', scriptItemName: '谐波电压准确度检测'},
{id: '4', code: 'Harm_I', scriptItemName: '谐波电流准确度检测'},
{id: '5', code: 'Harm_P', scriptItemName: '谐波有功功率准确度检测'},
{id: '6', code: 'InHarm_V', scriptItemName: '间谐波电压准确度检测'},
{id: '7', code: 'InHarm_I', scriptItemName: '间谐波电流准确度检测'},
{id: '8', code: 'Dip', scriptItemName: '暂态准确度检测'},
{id: '9', code: 'CUR', scriptItemName: '电流准确度检测'},
{id: '10', code: 'MSQI_U', scriptItemName: '三相电压不平衡度检测'},
{id: '11', code: 'MSQI_I', scriptItemName: '三相电流不平衡度检测'},
{id: '12', code: 'Flicker', scriptItemName: '闪变准确度检测'}
{id: '1', code: 'Freq', scriptName: '频率准确度检测'},
{id: '2', code: 'VOL', scriptName: '电压准确度检测'},
{id: '3', code: 'Harm_V', scriptName: '谐波电压准确度检测'},
{id: '4', code: 'Harm_I', scriptName: '谐波电流准确度检测'},
{id: '5', code: 'Harm_P', scriptName: '谐波有功功率准确度检测'},
{id: '6', code: 'InHarm_V', scriptName: '间谐波电压准确度检测'},
{id: '7', code: 'InHarm_I', scriptName: '间谐波电流准确度检测'},
{id: '8', code: 'Dip', scriptName: '暂态准确度检测'},
{id: '9', code: 'CUR', scriptName: '电流准确度检测'},
{id: '10', code: 'MSQI_U', scriptName: '三相电压不平衡度检测'},
{id: '11', code: 'MSQI_I', scriptName: '三相电流不平衡度检测'},
{id: '12', code: 'Flicker', scriptName: '闪变准确度检测'}
]
let temp = response.map(item => {
return {
...item,
scriptItemName: map.get(item.code) || item.scriptItemName
scriptName: map.get(item.code) || item.scriptName
}
})
@@ -385,7 +385,7 @@ const initCheckResult = () => {
// 处理当前节点的数据
let temp: CheckData.ScriptChnItem = {
scriptId: item.id,
scriptItemName: item.scriptItemName,
scriptName: item.scriptName,
devices: []
}
for (let i = 0; i < deviceList?.length; i++) {