This commit is contained in:
caozehui
2025-01-06 14:50:36 +08:00
parent 9eac101794
commit 336ee843cc
4 changed files with 178 additions and 281 deletions

View File

@@ -34,9 +34,9 @@ export namespace CheckData {
// 第几次谐波 // 第几次谐波
//num: number | null, //num: number | null,
//符合、不符合 //符合、不符合
isData: number, isData?: number,
//最大误差值 //最大误差值
radius: string, radius?: string,
} }
/** /**
@@ -45,16 +45,16 @@ export namespace CheckData {
export interface CheckResult { export interface CheckResult {
aStd?: number, aStd?: number,
aData?: number, aData?: number,
aError?: number, aError?: string,
bStd?: number, bStd?: number,
bData?: number, bData?: number,
bError?: number, bError?: string,
cStd?: number, cStd?: number,
cData?: number, cData?: number,
cError?: number, cError?: string,
tStd?: number, tStd?: number,
tData?: number, tData?: number,
tError?: number, tError?: string,
//最大误差值 //最大误差值
maxError?: string, maxError?: string,

View File

@@ -42,5 +42,5 @@ export const getTableData = (params: {
chnNum: string, chnNum: string,
scriptType: string | null scriptType: string | null
}) => { }) => {
return http.post("/result/tableData/", params, {loading: false}); return http.post("/result/resultData/", params, {loading: false});
} }

View File

@@ -1,7 +1,7 @@
<template> <template>
<div class="table-main"> <div class="table-main">
<el-table v-if="info.length <= 0" :data="tableData" height="335px" :header-cell-style="{ textAlign: 'center' } " <el-table :data="tableData" height="335px" :header-cell-style="{ textAlign: 'center' } "
:cell-style="{ textAlign: 'center' }"> :cell-style="{ textAlign: 'center' }">
<!-- <el-table-column prop="chnNum" label="通道号" width="80">--> <!-- <el-table-column prop="chnNum" label="通道号" width="80">-->
<!-- <template #default="{row}">--> <!-- <template #default="{row}">-->
@@ -27,8 +27,9 @@
<el-table-column prop="maxError" :label="`最大误差(${unit}`"/> <el-table-column prop="maxError" :label="`最大误差(${unit}`"/>
<el-table-column prop="result" label="检测结果" width="70"> <el-table-column prop="result" label="检测结果" width="70">
<template #default="scope"> <template #default="scope">
<el-tag type="danger" v-if="scope.row.result === '不符合'">{{ scope.row.result }}</el-tag> <el-tag type="danger" v-if="scope.row.result === 2">不符合</el-tag>
<span v-if="scope.row.result != '不符合'">{{ scope.row.result }}</span> <span v-if="scope.row.result === 1">符合</span>
<span v-if="scope.row.result === 4">/</span>
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
@@ -42,32 +43,14 @@
<el-table-column prop="maxError" label="最大误差V"/> <el-table-column prop="maxError" label="最大误差V"/>
<el-table-column prop="result" label="检测结果"> <el-table-column prop="result" label="检测结果">
<template #default="scope"> <template #default="scope">
<el-tag type="danger" v-if="scope.row.result === '不符合'">{{ scope.row.result }}</el-tag> <el-tag type="danger" v-if="scope.row.result === 2">不符合</el-tag>
<span v-if="scope.row.result != '不符合'">{{ scope.row.result }}</span> <span v-if="scope.row.result === 1">符合</span>
<span v-if="scope.row.result === 4">/</span>
</template> </template>
</el-table-column> </el-table-column>
</template> </template>
</el-table>
<el-collapse v-else v-model="activeNames">
<el-collapse-item v-for="(item, index) in info" :key="index" :title="item.title" :name="item.name">
<el-table :data="[tableData[index]]" :header-cell-style="{ textAlign: 'center' } "
:cell-style="{ textAlign: 'center' }">
<el-table-column :label="`T${unit}`">
<el-table-column prop="tStd" label="标准值V"/>
<el-table-column prop="tData" label="被检值"/>
<el-table-column prop="tError" label="误差值"/>
</el-table-column>
<el-table-column prop="maxError" label="最大误差V"/>
<el-table-column prop="result" label="检测结果">
<template #default="scope">
<el-tag type="danger" v-if="scope.row.result === '不符合'">{{ scope.row.result }}</el-tag>
<span v-if="scope.row.result != '不符合'">{{ scope.row.result }}</span>
</template>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
</el-table>
</div> </div>
</template> </template>
@@ -77,11 +60,9 @@ import {defineProps} from 'vue';
import {CheckData} from "@/api/check/interface"; import {CheckData} from "@/api/check/interface";
const {tableData} = defineProps<{ const {tableData} = defineProps<{
info: { title: string, name: string }[],
tableData: CheckData.CheckResult[], tableData: CheckData.CheckResult[],
}>(); }>();
const activeNames = ref(["Voltage"])
const unit = computed(() => { const unit = computed(() => {
return "V" return "V"

View File

@@ -22,12 +22,6 @@
:value="item.value"/> :value="item.value"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="harmNumList.length" label='谐波次数'>
<el-select v-model="currentHarmNum">
<el-option v-for="item in harmNumList" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
</el-form> </el-form>
</div> </div>
@@ -58,24 +52,32 @@
<div class="content-right"> <div class="content-right">
<div class="content-right-title"> <div class="content-right-title">
<span class="content-right-title-text">当前检测项目</span> <div style="width: 680px;">
<el-popover trigger="hover" :content="currentDesc? currentDesc : '无'" popper-class="popover-class" <span class="content-right-title-text">当前检测项目
width="32%" placement="right-start"> <el-popover trigger="hover" :content="currentDesc? currentDesc : '无'" :width="popoverWidth" placement="right">
<template #reference> <template #reference>
<el-button type="text" style="font-size: 16px;"> <el-button type="text" style="font-size: 16px;">
{{ currentScriptTypeName ? currentScriptTypeName : '无' }} {{ currentScriptTypeName ? currentScriptTypeName : '无' }}
</el-button> </el-button>
</template> </template>
</el-popover> </el-popover>
<!-- <el-divider>当前检测项目</el-divider>--> </span>
<!-- <div class="content-right-title-desc">--> </div>
<!-- {{ currentDesc ? currentDesc : "无" }}--> <el-form-item style="margin-left: 0px;margin-bottom:0px !important;width: 210px;" v-if="harmNumList.length" label='谐波次数'>
<!-- </div>--> <el-select v-model="currentHarmNum">
<el-option v-for="item in harmNumList" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
<el-form-item style="margin-left: 0px;margin-bottom:0px !important;width: 210px;" v-if="checkList.length" label='测试项'>
<el-select v-model="currentCheckItem">
<el-option v-for="item in checkList" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
</div> </div>
<div class="content-right-Tabs"> <div class="content-right-Tabs">
<el-tabs type="border-card" v-model="activeTab"> <el-tabs type="border-card" v-model="activeTab">
<el-tab-pane label="检测结果" name="resultTab"> <el-tab-pane label="检测结果" name="resultTab">
<DataCheckResultTable :tableData="checkResultData" :info="infoMsg"/> <DataCheckResultTable :tableData="checkResultData"/>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="原始数据" name="rawDataTab"> <el-tab-pane label="原始数据" name="rawDataTab">
<DataCheckRawDataTable :tableData="rawTableData"/> <DataCheckRawDataTable :tableData="rawTableData"/>
@@ -113,7 +115,7 @@ const checkStore = useCheckStore()
const visible = ref(false) const visible = ref(false)
// 格式化数字 // 格式化数字
const fixed = 4; const fixed = 6;
// 表单数据 // 表单数据
const formContent = reactive<CheckData.DataCheck>({ const formContent = reactive<CheckData.DataCheck>({
@@ -126,7 +128,11 @@ const formContent = reactive<CheckData.DataCheck>({
// 当前选中的谐波次数 // 当前选中的谐波次数
const currentHarmNum = ref<string>("-1") const currentHarmNum = ref<string>("-1")
// 谐波次数列表 // 谐波次数列表
const harmNumList = reactive([]) const harmNumList = reactive<{ value: string, label: string }[]>([])
// 当前选中的检测项
const currentCheckItem = ref<string>("")
// 检测项列表
const checkList = reactive<{ value: string, label: string }[]>([])
let deviceId: string = '' let deviceId: string = ''
let scriptType: string | null = null let scriptType: string | null = null
@@ -141,7 +147,6 @@ let switchItem = 0
let treeDataUnqualified: CheckData.TreeItem[] = [] let treeDataUnqualified: CheckData.TreeItem[] = []
let treeDataAll: CheckData.TreeItem[] = [] let treeDataAll: CheckData.TreeItem[] = []
// 左侧树被选中的叶子节点id // 左侧树被选中的叶子节点id
const checkIndex = ref<string>('') const checkIndex = ref<string>('')
@@ -153,12 +158,14 @@ const currentDesc = ref('');
const activeTab = ref<string>('resultTab') const activeTab = ref<string>('resultTab')
//存放相应的表格数据 //存放相应的表格数据
let resTableData: { resultData: Map<string, any>, rawData: Map<string, any> } = {} let resTableData: { resultData: Map<string, any>, rawData: Map<string, any> } = {resultData: new Map(), rawData: new Map()}
// 检测结果表格数据 // 检测结果表格数据
const checkResultData = reactive<CheckData.CheckResult[]>([]) const checkResultData = reactive<CheckData.CheckResult[]>([])
const infoMsg = reactive<{ title: string, name: string }[]>([]) const popoverWidth: ComputedRef<string> = computed(() => {
return `${680 - currentScriptTypeName.value.length * 16 - (harmNumList.length || checkList.length ? 120 : 0)}px`
})
// 原始数据表格数据 // 原始数据表格数据
const rawTableData = reactive<CheckData.RawDataItem[]>([]) const rawTableData = reactive<CheckData.RawDataItem[]>([])
@@ -192,101 +199,6 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
code: checkStore.planCode code: checkStore.planCode
}) })
treeDataAll = resTreeDataTemp treeDataAll = resTreeDataTemp
// treeDataAll = [
// {
// scriptTypeName: "频率准确度检测",
// sourceDesc: null,
// harmNum: null,
// index: null,
// fly: null,
// children: [
// {
// scriptTypeName: "额定条件下频率准确度测试",
// sourceDesc: null,
// harmNum: null,
// index: null,
// fly: null,
// children: [
// {
// scriptTypeName: "频率=42.5Hz",
// sourceDesc: "频率=42.5Hz",
// harmNum: null,
// index: 11,
// fly: 1,
// children: null
// },
// {
// scriptTypeName: "频率=50Hz",
// sourceDesc: "频率=50Hz",
// harmNum: null,
// index: 12,
// fly: 1,
// children: null
// },
// {
// scriptTypeName: "频率=50.05Hz",
// sourceDesc: "频率=50.05Hz",
// harmNum: null,
// index: 13,
// fly: 1,
// children: null
// },
// {
// scriptTypeName: "频率=57.5Hz",
// sourceDesc: "频率=57.5Hz",
// harmNum: null,
// index: 14,
// fly: 1,
// children: null
// }
// ]
// },
// {
// scriptTypeName: "单影响量下频率准确度测试",
// sourceDesc: null,
// harmNum: null,
// index: null,
// fly: null,
// children: [
// {
// scriptTypeName: "电压幅值对频率测量的影响",
// sourceDesc: null,
// harmNum: null,
// index: null,
// fly: null,
// children: [
// {
// scriptTypeName: "10%Un对频率=50.05Hz的影响",
// sourceDesc: "10%Un对频率=50.05Hz的影响",
// harmNum: null,
// index: 15,
// fly: 2,
// children: null
// }
// ]
// },
// {
// scriptTypeName: "谐波对频率测量的影响",
// sourceDesc: null,
// harmNum: null,
// index: null,
// fly: null,
// children: [
// {
// scriptTypeName: "叠加多次谐波对频率=50.05Hz的影响",
// sourceDesc: "叠加多次谐波对频率=50.05Hz的影响",
// harmNum: null,
// index: 16,
// fly: 1,
// children: null
// }
// ]
// }
// ]
// },
// ]
// }
// ]
let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll)) let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll))
filterTree(treeDataTemp, 2) filterTree(treeDataTemp, 2)
@@ -297,14 +209,23 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
} }
}) })
watch(currentHarmNum, (newVal, oldVal) => { watch(currentHarmNum, (newVal, oldVal) => {
console.log("谐波次数", newVal); console.log("谐波次数", newVal);
if(newVal !== '-1'){ if (newVal !== '-1') {
let resCheckResult: CheckData.ResCheckResult = resTableData.resultData.get(newVal.toString()) let resCheckResult: CheckData.ResCheckResult = resTableData.resultData.get(newVal.toString())
setCheckResultData(resCheckResult) setCheckResultData(resCheckResult)
} }
}) })
watch(currentCheckItem, (newVal, oldVal) => {
console.log("当前检测项", newVal);
if (newVal) {
let resCheckResult: CheckData.ResCheckResult = resTableData.resultData.get(newVal.toString() === 'Voltage' ? '电压幅值' : '持续时间')
setCheckResultData(resCheckResult)
}
})
const handleSwitchChange = async (data: any) => { const handleSwitchChange = async (data: any) => {
console.log("切换不合格测试项、全部测试项", data); console.log("切换不合格测试项、全部测试项", data);
@@ -342,98 +263,97 @@ const updateTableData = async () => {
// resTableData =data // resTableData =data
let resultData = new Map() let resultData = new Map()
// resultData.set("频率", [{ // resultData.set("频率", {
// dataT: { // dataT: {
// data: 57.7401, // data: 57.740001,
// resultData: 57.7301, // resultData: 57.730001,
// }, // },
// dataB: { // dataB: {
// data: 57.7401, // data: 57.740001,
// resultData: 57.7301, // resultData: 57.730001,
// }, // },
// dataC: { // dataC: {
// data: 57.7401, // data: 57.740001,
// resultData: 57.7301, // resultData: 57.730001,
// }, // },
// radius: 0.05774, // radius: 0.05774,
// isData: '符合', // isData: 1,
// }]) // })
// resultData.set('3', [{ resultData.set('3', {
// dataA: { dataA: {
// data: 57.7401, data: 57.740001,
// resultData: 57.7301, resultData: 57.730001,
// }, },
// dataB: { dataB: {
// data: 57.7401, data: 57.740001,
// resultData: 57.7301, resultData: 57.730001,
// }, },
// dataC: { dataC: {
// data: 57.7401, data: 57.740001,
// resultData: 57.7301, resultData: 57.730001,
// },
// radius: 0.05774,
// isData: '符合',
// }])
// resultData.set('5', [{
// dataA: {
// data: 57.7402,
// resultData: 57.7301,
// },
// dataB: {
// data: 57.7402,
// resultData: 57.7301,
// },
// dataC: {
// data: 57.7402,
// resultData: 57.7301,
// },
// radius: 0.05774,
// isData: '符合',
// }])
// resultData.set('7', [{
// dataA: {
// data: 57.7403,
// resultData: 57.7301,
// },
// dataB: {
// data: 57.7403,
// resultData: 57.7301,
// },
// dataC: {
// data: 57.7403,
// resultData: 57.7301,
// },
// radius: 0.05774,
// isData: '符合',
// }])
resultData.set("电压幅值", [{
dataT: {
data: 57.7401,
resultData: 57.7301,
}, },
radius: 0.05774, radius: 0.05774,
isData: '符合', isData: 1,
}]) })
resultData.set("持续时间", [{ resultData.set('5', {
dataT: { dataA: {
data: 57.7402, data: 57.740002,
resultData: 57.7302, resultData: 57.730001,
},
dataB: {
data: 57.740002,
resultData: 57.730001,
},
dataC: {
data: 57.740002,
resultData: 57.730001,
}, },
radius: 0.05774, radius: 0.05774,
isData: '符合', isData: 1,
}]) })
resultData.set('7', {
dataA: {
data: 57.740003,
resultData: 57.730001,
},
dataB: {
data: 57.740003,
resultData: 57.730001,
},
dataC: {
data: 57.740003,
resultData: 57.730001,
},
radius: 0.05774,
isData: 4,
})
// resultData.set("电压幅值", {
// dataT: {
// data: 57.740001,
// resultData: 57.730001,
// },
// radius: 0.05774,
// isData: 1,
// })
// resultData.set("持续时间", {
// dataT: {
// data: 57.740002,
// resultData: 57.730002,
// },
// radius: 0.05774,
// isData: 2,
// })
let rawData = new Map() let rawData = new Map()
resTableData = { resTableData = {
resultData: resultData, resultData,
rawData: rawData rawData
} }
let resCheckResult: CheckData.ResCheckResult = [] let resCheckResult: CheckData.ResCheckResult = {}
let tempInfoMsg: { title: string, name: string } = []
if (resTableData.resultData.size === 1) { if (resTableData.resultData.size === 1) {
resCheckResult = resTableData.resultData.values().next().value resCheckResult = resTableData.resultData.values().next().value
@@ -443,35 +363,35 @@ const updateTableData = async () => {
setCheckResultData(resCheckResult) setCheckResultData(resCheckResult)
} else { } else {
if (resTableData.resultData.get('电压幅值') || resTableData.resultData.get('持续时间')) { if (resTableData.resultData.get('电压幅值') || resTableData.resultData.get('持续时间')) {
let tempCheckList = []
if (resTableData.resultData.get('电压幅值')) { if (resTableData.resultData.get('电压幅值')) {
tempInfoMsg.push({title: '电压幅值', name: 'Voltage'}) tempCheckList.push({value: 'Voltage', label: '电压幅值'})
resCheckResult.push(...resTableData.resultData.get('电压幅值')) resCheckResult = resTableData.resultData.get('电压幅值')
} }
if (resTableData.resultData.get('持续时间')) { if (resTableData.resultData.get('持续时间')) {
tempInfoMsg.push({title: '持续时间', name: 'Duration'}) tempCheckList.push({value: 'Duration', label: '持续时间'})
resCheckResult.push(...resTableData.resultData.get('持续时间')) resCheckResult = resTableData.resultData.get('持续时间')
} }
Object.assign(checkList, tempCheckList)
currentCheckItem.value = checkList[0].value
Object.assign(harmNumList, []) Object.assign(harmNumList, [])
currentHarmNum.value = '-1' currentHarmNum.value = '-1'
Object.assign(infoMsg, tempInfoMsg) //setCheckResultData(resCheckResult)
setCheckResultData(resCheckResult)
} else { } else {
let tempHarmNumList = [] let tempHarmNumList: { value: string, label: string }[] = []
resTableData.resultData.forEach((value, key) => { for (let [key, value] of resTableData.resultData) {
tempHarmNumList.push({ tempHarmNumList.push({value: key, label: key})
value: key, }
label: key
})
})
Object.assign(harmNumList, tempHarmNumList) Object.assign(harmNumList, tempHarmNumList)
currentHarmNum.value = harmNumList[0].value currentHarmNum.value = harmNumList[0].value
} }
} }
// setCheckResultData(resCheckResult) // setCheckResultData(resCheckResult)
Object.assign(rawTableData, [ Object.assign(rawTableData, [
{ {
updateTime: "2024-10-10 09:30:00", updateTime: "2024-10-10 09:30:00",
@@ -610,19 +530,6 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul
scriptType scriptType
}) })
// 数据处理
// let resFormContent = {
// scriptName: 'Q/GDW 10650.4-2021 模拟式',
// errorSysName: 'Q/GDW 10650.2-2021',
// dataRule: '505f063f9f91ab108d895a9fe96b5dce',
// deviceName: '被检设备1',
// chnList: [
// {value: '1', label: '1'},
// {value: '2', label: '0'},
// {value: '3', label: '1'},
// {value: '4', label: '0'}],
// }
chnList = resFormContent.chnList.map((item: { value: string, label: string }) => ({ chnList = resFormContent.chnList.map((item: { value: string, label: string }) => ({
value: item.value, value: item.value,
label: item.label == '1' ? `${item.value}` : `${item.value}(不符合)` label: item.label == '1' ? `${item.value}` : `${item.value}(不符合)`
@@ -656,7 +563,6 @@ const close = () => {
Object.assign(harmNumList, []) Object.assign(harmNumList, [])
currentHarmNum.value = '-1' currentHarmNum.value = '-1'
Object.assign(checkResultData, []) Object.assign(checkResultData, [])
Object.assign(infoMsg, [])
Object.assign(rawTableData, []) Object.assign(rawTableData, [])
defaultExpandedKeys = [] defaultExpandedKeys = []
checkIndex.value = '' checkIndex.value = ''
@@ -668,34 +574,42 @@ const close = () => {
visible.value = false; visible.value = false;
}; };
const setCheckResultData = (data: CheckData.ResCheckResult[]) => { const setCheckResultData = (data: CheckData.ResCheckResult) => {
// debugger
let result: CheckData.CheckResult[] = [] let result: CheckData.CheckResult[] = []
data.forEach((item: CheckData.ResCheckResult) => { if (data.dataA && data.dataB && data.dataC) {
let temp: CheckData.CheckResult = { result.push({
aStd: item.dataA?.resultData, aStd: data.dataA?.resultData,
aData: item.dataA?.data, aData: data.dataA?.data,
aError: Math.abs(item.dataA?.data - item.dataA?.resultData).toFixed(fixed), aError: getError(data.dataA?.resultData, data.dataA?.data),
bStd: item.dataB?.resultData, bStd: data.dataB?.resultData,
bData: item.dataB?.data, bData: data.dataB?.data,
bError: Math.abs(item.dataB?.data - item.dataB?.resultData).toFixed(fixed), bError: getError(data.dataA?.resultData, data.dataA?.data),
cStd: item.dataC?.resultData, cStd: data.dataC?.resultData,
cData: item.dataC?.data, cData: data.dataC?.data,
cError: Math.abs(item.dataC?.data - item.dataC?.resultData).toFixed(fixed), cError: getError(data.dataA?.resultData, data.dataA?.data),
tStd: item.dataT?.resultData,
tData: item.dataT?.data, maxError: data.radius,
tError: Math.abs(item.dataT?.data - item.dataT?.resultData).toFixed(fixed), result: data.isData,
})
}
if (data.dataT) {
result.push({
tStd: data.dataT?.resultData,
tData: data.dataT?.data,
tError: getError(data.dataT?.resultData, data.dataT?.data),
maxError: data.radius,
result: data.isData,
})
}
maxError: item.radius,
result: item.isData,
}
result.push(temp)
})
Object.assign(checkResultData, result) Object.assign(checkResultData, result)
} }
// const toFixed = (num: number, pow: number): string => { const getError = (num1: number, num2: number): string => {
// return Math.floor(num * Math.pow(10, pow)) / Math.pow(10, pow) return Math.abs(num1 - num2).toFixed(fixed)
// } }
const findFirstLeafNode = (node: any): any => { const findFirstLeafNode = (node: any): any => {
if (!node.children || node.children.length === 0) { if (!node.children || node.children.length === 0) {
return node; return node;
@@ -801,6 +715,8 @@ defineExpose({
flex: 1; flex: 1;
.content-right-title { .content-right-title {
display: flex;
padding: 10px 0;
margin-top: 10px; margin-top: 10px;
line-height: 1.5; line-height: 1.5;