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

@@ -44,9 +44,18 @@ export namespace CheckData {
// 用来描述检测脚本类型
export interface ScriptItem{
id: string,
code: string,
scriptName: string,
scriptType?: string,
children?: ScriptItem[]
}
// 用来描述 检测数据-左侧树结构
export interface TreeItem{
scriptTypeName: string|null,
sourceDesc: string|null,
index:number|null,
fly:number|null,
children?: TreeItem[]
}
// 用来描述 通道检测结果
export enum ChnCheckResultEnum {

View File

@@ -29,7 +29,7 @@ export const getTreeData = (params: {
scriptType: string | null,
code: string
}) => {
return http.post<CheckData.ScriptItem[]>("/result/treeData/", params, {loading: true});
return http.post<CheckData.TreeItem[]>("/result/treeData/", params, {loading: true});
}
/**

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

View File

@@ -9,7 +9,6 @@
<el-button
type="primary"
v-if="testStatus=='process' && activeIndex < checkTotal"
:disabled="activeIndex===0"
:icon="VideoPause"
@click="emit('sendPause')">停止检测
</el-button>
@@ -180,7 +179,7 @@ let scriptData: CheckData.ScriptItem[] = []
// 用来保存被检设备
const deviceList = reactive<CheckData.Device[]>([])
// 当前进行的测试项索引
let activeIndex = 1
let activeIndex = 0
// 百分比
const percentage = ref(0);
//测试项开始检测时间(或继续检测时间)
@@ -213,7 +212,7 @@ const chnSum = computed(() => {
})
// 用来展示的检测结果
const checkResultView: any[] = computed(() => {
const checkResultView: ComputedRef<CheckData.ScriptChnViewItem[]> = computed(() => {
let result: CheckData.ScriptChnViewItem[] = checkResult.map(item => {
let temp: CheckData.ScriptChnViewItem = {
@@ -381,6 +380,10 @@ watch(webMsgSend, function (newValue, oldValue) {
case 'DATA_REQUEST$02':
ElMessage.success('预检测成功!')
testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:预检测成功!`})
activeIndex = getNextActiveIndex()+2
startTimer()
emit('update:testStatus', 'process')
break
}
@@ -406,11 +409,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'FREQ_End':
updatePercentage()
updateCheckResultView("FREQ", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('FREQ')
startTimer()
}
break;
@@ -419,11 +422,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'V_End':
updatePercentage()
updateCheckResultView("V", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++
activeIndex = getNextActiveIndex('V')
startTimer()
}
break;
@@ -432,11 +435,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'HV_End':
updatePercentage()
updateCheckResultView("HV", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('HV')
startTimer()
}
break;
@@ -445,11 +448,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'HI_End':
updatePercentage()
updateCheckResultView("HI", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('HI')
startTimer()
}
break;
@@ -458,11 +461,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'HP_End':
updatePercentage()
updateCheckResultView("HP", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('HP')
startTimer()
}
break;
@@ -471,11 +474,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'HSV_End':
updatePercentage()
updateCheckResultView("HSV", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('HSV')
startTimer()
}
break;
@@ -484,11 +487,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'HSI_End':
updatePercentage()
updateCheckResultView("HSI", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('HSI')
startTimer()
}
break;
@@ -497,11 +500,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'VOLTAGE_End':
updatePercentage()
updateCheckResultView("VOLTAGE", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('VOLTAGE')
startTimer()
}
break;
@@ -510,11 +513,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'I_End':
updatePercentage()
updateCheckResultView("I", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('I')
startTimer()
}
break;
@@ -523,11 +526,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'IMBV_End':
updatePercentage()
updateCheckResultView("IMBV", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('IMBV')
startTimer()
}
break;
@@ -536,11 +539,11 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'IMBA_End':
updatePercentage()
updateCheckResultView("IMBA", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('IMBA')
startTimer()
}
break;
@@ -549,17 +552,17 @@ watch(webMsgSend, function (newValue, oldValue) {
updateLog(true)
break;
case 'F_End':
updatePercentage()
updateCheckResultView("F", false)
updateLog(false)
updatePercentage()
if (testStatus.value != 'paused') {
activeIndex++;
activeIndex = getNextActiveIndex('F')
startTimer()
}
break;
case 'Quit':
updateLog(false)
updatePercentage()
updateLog(false)
console.log('检测结束')
break;
}
@@ -905,7 +908,7 @@ const handleClick = (item: any, chnNum: string, scriptType: string) => {
const startTimer = () => {
console.log('开始检测第' + activeIndex + '项')
switch (activeIndex) {
case 1:
case 0:
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'yjc_ytxjy',
@@ -927,18 +930,20 @@ const startTimer = () => {
operateCode: "DATA_REQUEST$02"
})
}, 6000)
break;
case 1:
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'FREQ_Start',
params: {}
})
}, 9000)
}, 1000)
setTimeout(() => {
emit('update:webMsgSend', {
requestId: 'FREQ_End',
params: {}
})
}, 12000);
}, 2000);
break;
case 2:
emit('update:webMsgSend', {
@@ -1057,7 +1062,7 @@ const startTimer = () => {
emit('update:webMsgSend', {
requestId: 'IMBA_End',
params: {}
}, 2000)
}, 4000)
})
break;
case 12:
@@ -1111,13 +1116,26 @@ const handleFinishTest = () => {
};
const handleReCheck = () => {
activeIndex = 1;
activeIndex = 0;
percentage.value = 0;
testLogList.length = 0;
errorCheckItem.length = 0;
// resumeTimer()
};
// 获取当前执行的大测试项序 的 下一个大测试项序号
const getNextActiveIndex = (code: string = ''): number => {
if (code === '') {
return -1
}
for (let i = 0; i < scriptData.length; i++) {
if (scriptData[i].code === code) {
return i + 2
}
}
return -1
}
function clear() {
errorCheckItem.length = 0;
}