修改检测结果弹窗框

This commit is contained in:
caozehui
2025-01-07 11:19:33 +08:00
parent a629907196
commit ba0c577514
5 changed files with 186 additions and 120 deletions

View File

@@ -48,15 +48,19 @@ export namespace CheckData {
aStd?: string,
aData?: string,
aError?: string,
isDataA?: number,
bStd?: string,
bData?: string,
bError?: string,
isDataB?: number,
cStd?: string,
cData?: string,
cError?: string,
isDataC?: number,
tStd?: string,
tData?: string,
tError?: string,
isDataT?: number,
//最大误差值
maxError?: string,

View File

@@ -6,12 +6,12 @@
style="width: 100%;">
<el-table-column type="index" label="序号" width="70" fixed="left"/>
<el-table-column prop="time" label="数据时间"/>
<template v-if="phaseFlag === 0">
<template v-if="phaseT === 0">
<el-table-column prop="dataA" :label="`A${unit}`"/>
<el-table-column prop="dataB" :label="`B${unit}`"/>
<el-table-column prop="dataC" :label="`C${unit}`"/>
</template>
<template v-if="phaseFlag === 1">
<template v-if="phaseT === 1">
<el-table-column prop="dataT" :label="`T${unit}`"/>
</template>
</el-table>
@@ -31,7 +31,7 @@ const unit = computed(() => {
return tableData.length > 0 ? tableData[0].unit : '';
})
const phaseFlag = computed(() => {
const phaseT = computed(() => {
let result = 0;
if (tableData.length > 0) {
result = !tableData[0].dataT ? 0 : 1;

View File

@@ -8,24 +8,42 @@
<!-- {{ '通道' + row.chnNum }}-->
<!-- </template>-->
<!-- </el-table-column>-->
<template v-if="phaseFlag === 0">
<template v-if="phaseT === 0">
<el-table-column :label="`A${unit}`">
<el-table-column prop="aStd" width="74" label="标准值"/>
<el-table-column prop="aData" width="74" label="被检值"/>
<el-table-column prop="aError" width="74" label="误差值"/>
<el-table-column prop="aStd" width="72" label="标准值"/>
<el-table-column prop="aData" width="72" label="被检值"/>
<el-table-column prop="aError" width="85" label="误差值">
<template #default="scope">
<span v-if="scope.row.isDataA === 1">{{scope.row.aError}}</span>
<el-tag type="danger" v-if="scope.row.isDataA === 2">{{scope.row.aError}}</el-tag>
<span v-if="scope.row.isDataA === 4">/</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column :label="`B${unit}`">
<el-table-column prop="bStd" width="74" label="标准值"/>
<el-table-column prop="bData" width="74" label="被检值"/>
<el-table-column prop="bError" width="74" label="误差值"/>
<el-table-column prop="bStd" width="72" label="标准值"/>
<el-table-column prop="bData" width="72" label="被检值"/>
<el-table-column prop="bError" width="85" label="误差值">
<template #default="scope">
<span v-if="scope.row.isDataB === 1">{{scope.row.bError}}</span>
<el-tag type="danger" v-if="scope.row.isDataB === 2">{{scope.row.bError}}</el-tag>
<span v-if="scope.row.isDataB === 4">/</span>
</template>
</el-table-column>
</el-table-column>
<el-table-column :label="`C${unit}`">
<el-table-column prop="cStd" width="74" label="标准值"/>
<el-table-column prop="cData" width="74" label="被检值"/>
<el-table-column prop="cError" width="74" label="误差值"/>
<el-table-column prop="cStd" width="72" label="标准值"/>
<el-table-column prop="cData" width="72" label="被检值"/>
<el-table-column prop="cError" width="85" label="误差值">
<template #default="scope">
<span v-if="scope.row.isDataC === 1">{{scope.row.cError}}</span>
<el-tag type="danger" v-if="scope.row.isDataC === 2">{{scope.row.cError}}</el-tag>
<span v-if="scope.row.isDataC === 4">/</span>
</template>
</el-table-column>
<el-table-column prop="maxError" :label="`最大误差`"/>
<el-table-column prop="result" label="检测结果" width="95">
</el-table-column>
<el-table-column prop="maxError" :label="`最大误差(${unit}`"/>
<el-table-column prop="result" label="检测结果" width="88">
<template #default="scope">
<el-tag type="danger" v-if="scope.row.result === 2">不符合</el-tag>
<span v-if="scope.row.result === 1">符合</span>
@@ -34,7 +52,7 @@
</el-table-column>
</template>
<template v-if="phaseFlag === 1">
<template v-if="phaseT === 1">
<el-table-column :label="`T${unit}`">
<el-table-column prop="tStd" label="标准值"/>
<el-table-column prop="tData" label="被检值"/>
@@ -43,8 +61,8 @@
<el-table-column prop="maxError" label="最大误差"/>
<el-table-column prop="result" label="检测结果">
<template #default="scope">
<el-tag type="danger" v-if="scope.row.result === 2">不符合</el-tag>
<span v-if="scope.row.result === 1">符合</span>
<el-tag type="danger" v-if="scope.row.result === 2">不符合</el-tag>
<span v-if="scope.row.result === 4">/</span>
</template>
</el-table-column>
@@ -68,7 +86,7 @@ const unit = computed(() => {
return tableData.length > 0 ? tableData[0].unit : '';
})
const phaseFlag = computed(() => {
const phaseT = computed(() => {
let result = 0;
if (tableData.length > 0) {
result = !tableData[0].tData ? 0 : 1;

View File

@@ -26,24 +26,21 @@
<div class="data-check-body">
<div class="content-left-tree">
<div>
<el-radio-group v-model="switchItem" @change="handleSwitchChange">
<el-radio-button label="不符合测试项" :value="0"/>
<el-radio-button label="全部测试项" :value="1"/>
</el-radio-group>
<div style="width: 190px;">
<el-input
placeholder='请输入测试项名称'
clearable
v-model='searchValue'
></el-input>
</div>
<div class="content-tree">
<el-tree v-if="switchItem === 0" :default-expanded-keys="defaultExpandedKeys" node-key="index"
:data="treeDataUnqualified" :props="defaultProps" @node-click="handleNodeClick"
class="custom-tree">
<el-tree :filter-node-method='filterNode' :highlight-current="true" :default-expanded-keys="defaultExpandedKeys"
node-key="index"
:data="treeDataAll"
:props="defaultProps"
@node-click="handleNodeClick" class="custom-tree" ref="treeRef">
<template #default="{ node, data }">
<span class="custom-tree-node">{{ data.scriptTypeName }}</span>
</template>
</el-tree>
<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.scriptTypeName }}</span>
<span class="custom-tree-node" :style="data.fly===2? 'color: red;':''">{{ data.scriptTypeName }}</span>
</template>
</el-tree>
</div>
@@ -55,7 +52,7 @@
<span class="content-right-title-text">当前检测项目
<el-popover trigger="hover" :content="currentDesc? currentDesc : '无'" :width="popoverWidth" placement="right">
<template #reference>
<el-button type="text" style="font-size: 16px;">
<el-button type="text" style="font-size: 14px;">
{{ currentScriptTypeName ? currentScriptTypeName : '无' }}
</el-button>
</template>
@@ -91,7 +88,7 @@
</template>
<script setup lang='ts'>
import {dialogBig} from '@/utils/elementBind'
import {reactive, ref} from 'vue'
import {reactive, ref, watch} from 'vue'
import DataCheckResultTable from './dataCheckResultTable.vue'
import DataCheckRawDataTable from './dataCheckRawDataTable.vue'
import {CheckData} from "@/api/check/interface";
@@ -112,6 +109,11 @@ const dictStore = useDictStore()
const checkStore = useCheckStore()
const visible = ref(false)
const treeRef = ref()
const searchValue = ref<string>('')
watch(searchValue, (val) => {
treeRef.value!.filter(val)
})
// 格式化数字
const fixed = 4;
@@ -139,12 +141,9 @@ let scriptType: string | null = null
// 通道下拉列表
let chnList: any[] = []
// 不符合测试项、全部测试项切换
let switchItem = ref(0)
// 左侧树数据
let treeDataUnqualified: CheckData.TreeItem[] = []
let treeDataAll: CheckData.TreeItem[] = []
const treeDataAll = reactive<CheckData.TreeItem[]>([])
// 左侧树被选中的叶子节点id
const checkIndex = ref<string>('')
@@ -163,7 +162,7 @@ let resTableData: { resultData: Map<string, any>, rawData: Map<string, any> } =
const checkResultData = reactive<CheckData.CheckResult[]>([])
const popoverWidth: ComputedRef<string> = computed(() => {
return `${680 - currentScriptTypeName.value.length * 16 - (harmNumList.length || checkList.length ? 120 : 0)}px`
return `${940 - (currentScriptTypeName.value.length + 7) * 14 - (harmNumList.length || checkList.length ? 140 : 0)}px`
})
// 原始数据表格数据
@@ -172,6 +171,11 @@ const rawTableData = reactive<CheckData.RawDataItem[]>([])
// 左侧树默认展开节点id
let defaultExpandedKeys: string[] = []
const filterNode = (value: string, data: any) => {
if (!value) return true
return data.scriptTypeName.includes(value)
}
// 点击左侧树节点触发事件
const handleNodeClick = async (data: any) => {
if (!data.children) {
@@ -197,18 +201,17 @@ watch(() => formContent.chnNum, async (newVal, oldVal) => {
scriptType: scriptType,
code: parseInt(checkStore.planCode)
})
treeDataAll = resTreeDataTemp
updateTreeFly(resTreeDataTemp, 2)
let treeDataTemp = JSON.parse(JSON.stringify(treeDataAll))
filterTree(treeDataTemp, 2)
treeDataUnqualified = treeDataTemp
Object.assign(treeDataAll, resTreeDataTemp)
console.log("树数据", treeDataAll)
switchItem.value = 0
await handleSwitchChange(0)
// await handleSwitchChange(0)
defaultOperate()
await updateTableData()
}
})
watch(currentHarmNum, (newVal, oldVal) => {
console.log("谐波次数", newVal);
if (newVal !== '-1') {
@@ -228,21 +231,17 @@ watch(currentCheckItem, (newVal, oldVal) => {
}
})
const handleSwitchChange = async (data: any) => {
console.log("切换不合格测试项、全部测试项", data);
defaultOperate()
await updateTableData()
}
// const handleSwitchChange = async (data: any) => {
// console.log("切换不合格测试项、全部测试项", data);
//
// defaultOperate()
// await updateTableData()
// }
// 默认操作
const defaultOperate = () => {
let node = null
if (switchItem.value === 0) {
node = getDefaultNode(treeDataUnqualified)
} else {
node = getDefaultNode(treeDataAll)
}
let node = getDefaultNode(treeDataAll)
if (node) {
currentScriptTypeName.value = node.scriptTypeName
currentDesc.value = node.sourceDesc
@@ -374,9 +373,6 @@ const close = () => {
deviceName: '',
chnNum: '',
})
treeDataUnqualified = []
treeDataAll = []
treeDataUnqualified.length = 0
treeDataAll.length = 0
harmNumList.length = 0
currentHarmNum.value = '-1'
@@ -387,7 +383,6 @@ const close = () => {
activeTab.value = 'resultTab'
currentScriptTypeName.value = ''
currentDesc.value = ''
switchItem.value = 0
visible.value = false;
};
@@ -396,15 +391,18 @@ const setCheckResultData = (data: CheckData.ResCheckResult) => {
let result: CheckData.CheckResult[] = []
if (data.dataA && data.dataB && data.dataC) {
result.push({
aStd: data.dataA?.resultData.toFixed(fixed),
aData: data.dataA?.data?.toFixed(fixed),
aStd: numberToFixed(data.dataA?.resultData),
aData: numberToFixed(data.dataA?.data),
aError: getError(data.dataA?.resultData, data.dataA?.data),
bStd: data.dataB?.resultData?.toFixed(fixed),
bData: data.dataB?.data?.toFixed(fixed),
isDataA: data.dataA?.isData,
bStd: numberToFixed(data.dataB?.resultData),
bData: numberToFixed(data.dataB?.data),
bError: getError(data.dataB?.resultData, data.dataB?.data),
cStd: data.dataC?.resultData?.toFixed(fixed),
cData: data.dataC?.data?.toFixed(fixed),
isDataB: data.dataB?.isData,
cStd: numberToFixed(data.dataC?.resultData),
cData: numberToFixed(data.dataC?.data),
cError: getError(data.dataC?.resultData, data.dataC?.data),
isDataC: data.dataC?.isData,
maxError: data.radius,
unit: data.unit,
@@ -414,33 +412,43 @@ const setCheckResultData = (data: CheckData.ResCheckResult) => {
if (data.dataT) {
result.push({
tStd: data.dataT?.resultData?.toFixed(fixed),
tData: data.dataT?.data?.toFixed(fixed),
tStd: numberToFixed(data.dataT?.resultData),
tData: numberToFixed(data.dataT?.data),
tError: getError(data.dataT?.resultData, data.dataT?.data),
isDataT: data.dataT?.isData,
maxError: data.radius,
unit: data.unit,
result: data.isData,
})
}
console.log("检测结果", result);
Object.assign(checkResultData, result)
}
const setRawData = (data: CheckData.RawDataItem[]) => {
data.forEach((item: CheckData.RawDataItem) => {
item.dataA = item.dataA == null || item.dataA == undefined ? '' : Number(item.dataA).toFixed(fixed)
item.dataB = item.dataB == null || item.dataB == undefined ? '' : Number(item.dataB).toFixed(fixed)
item.dataC = item.dataC == null || item.dataC == undefined ? '' : Number(item.dataC).toFixed(fixed)
item.dataT = item.dataT == null || item.dataT == undefined ? '' : Number(item.dataT).toFixed(fixed)
item.dataA = item.dataA == null || item.dataA == undefined ? '' : Number(item.dataA).toFixed(fixed).replace(/-/g, "")
item.dataB = item.dataB == null || item.dataB == undefined ? '' : Number(item.dataB).toFixed(fixed).replace(/-/g, "")
item.dataC = item.dataC == null || item.dataC == undefined ? '' : Number(item.dataC).toFixed(fixed).replace(/-/g, "")
item.dataT = item.dataT == null || item.dataT == undefined ? '' : Number(item.dataT).toFixed(fixed).replace(/-/g, "")
})
console.log("原始数据", data)
Object.assign(rawTableData, data)
}
const numberToFixed = (num: number): string => {
if (num == null || num == undefined) {
return ''
} else {
return num.toFixed(fixed).replace(/-/g, "")
}
}
const getError = (num1: number, num2: number): string => {
if (num1 == null || num1 == undefined || num2 == null || num2 == undefined) {
return ''
}
return Math.abs(Number(num1.toFixed(fixed)) - Number(num2.toFixed(fixed))).toFixed(fixed)
return Math.abs(Number(numberToFixed(num1)) - Number(numberToFixed(num2))).toFixed(fixed)
}
const findFirstLeafNode = (node: any): any => {
@@ -486,6 +494,42 @@ const filter = (treeData: any[], fly: number) => {
}
}
const updateTreeFly = (treeData: any[], fly: number) => {
// 递归函数
function recursiveUpdate(node: any, targetFly: number) {
//if (!node) return false; // 如果节点不存在,返回 false
// 如果当前节点是叶子节点且 fly 字段等于 targetFly
if (!node.children || node.children.length === 0) {
if (node.fly === targetFly) {
node.fly = targetFly; // 确保叶子节点的 fly 字段被设置为 targetFly
return true; // 返回 true 表示找到并更新了
}
return false; // 否则返回 false
}
// 递归更新子节点
let updated = false;
for (let child of node.children) {
if (recursiveUpdate(child, targetFly)) {
updated = true;
}
}
// 如果有子节点被更新了,则更新当前节点的 fly 字段
if (updated) {
node.fly = targetFly;
}
return updated;
}
for (let i = 0; i < treeData.length; i++) {
// 调用递归函数从根节点开始更新
recursiveUpdate(treeData[i], fly);
}
}
defineExpose({
open
})
@@ -518,7 +562,7 @@ defineExpose({
flex-direction: row;
.content-left-tree {
width: 20%;
width: 18%;
display: flex;
flex-direction: column;
align-items: center;
@@ -543,7 +587,7 @@ defineExpose({
}
.content-right {
width: 80%;
width: 82%;
margin-left: 10px;
flex: 1;
@@ -554,7 +598,7 @@ defineExpose({
line-height: 1.5;
.content-right-title-text {
font-size: 16px;
font-size: 14px;
font-weight: bold;
}
}

View File

@@ -564,9 +564,9 @@ const updatePercentage = () => {
}
// todo 可移除start
let randomUnConnectedRaw = -1
let randomUnConnectedDeviceId = -1
let randomErrorDataRaw = -1
// let randomUnConnectedRaw = -1
// let randomUnConnectedDeviceId = -1
// let randomErrorDataRaw = -1
// todo 可移除end
onBeforeMount(async () => {
@@ -575,13 +575,13 @@ onBeforeMount(async () => {
initCheckResult()
// todo 可移除start
let a = getRandomInt(scriptData.length) + 4
randomUnConnectedRaw = a < scriptData.length ? a : scriptData.length
randomUnConnectedDeviceId = deviceList[getRandomInt(deviceList.length)].deviceId
randomErrorDataRaw = getRandomInt(scriptData.length) + 1
while (randomErrorDataRaw === randomUnConnectedRaw) {
randomErrorDataRaw = getRandomInt(scriptData.length) + 1
}
// let a = getRandomInt(scriptData.length) + 4
// randomUnConnectedRaw = a < scriptData.length ? a : scriptData.length
// randomUnConnectedDeviceId = deviceList[getRandomInt(deviceList.length)].deviceId
// randomErrorDataRaw = getRandomInt(scriptData.length) + 1
// while (randomErrorDataRaw === randomUnConnectedRaw) {
// randomErrorDataRaw = getRandomInt(scriptData.length) + 1
// }
// todo 可移除end
})
@@ -794,36 +794,36 @@ const getCheckResult = (scriptType: string) => {
// debugger
let devices = []
if (activeIndex === randomErrorDataRaw) {
// if (activeIndex === randomErrorDataRaw) {
// devices = deviceList.map(item => {
// let tempChnResult: CheckData.ChnCheckResultEnum[] = []
// if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
// for (let i = 0; i < item.chnNum; i++) {
// tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
// //errorCheckItem.push({scriptType,type:'warning'})
// }
// } else {
// for (let i = 0; i < item.chnNum; i++) {
// tempChnResult.push(CheckData.ChnCheckResultEnum.ERRORDATA)
// //errorCheckItem.push({scriptType,type:'warning'})
// }
// }
//
// return {
// deviceId: item.deviceId,
// deviceName: item.deviceName,
// chnResult: tempChnResult,
// }
// })
// } else {
devices = deviceList.map(item => {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
//errorCheckItem.push({scriptType,type:'warning'})
}
} else {
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.ERRORDATA)
//errorCheckItem.push({scriptType,type:'warning'})
}
}
return {
deviceId: item.deviceId,
deviceName: item.deviceName,
chnResult: tempChnResult,
}
})
} else {
devices = deviceList.map(item => {
let tempChnResult: CheckData.ChnCheckResultEnum[] = []
if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
//errorCheckItem.push({scriptType,type:'warning'})
}
} else {
// if (item.deviceId === randomUnConnectedDeviceId && activeIndex >= randomUnConnectedRaw) {
// for (let i = 0; i < item.chnNum; i++) {
// tempChnResult.push(CheckData.ChnCheckResultEnum.UNCONNECTED)
// //errorCheckItem.push({scriptType,type:'warning'})
// }
// } else {
for (let i = 0; i < item.chnNum; i++) {
tempChnResult.push(CheckData.ChnCheckResultEnum.SUCCESS)
}
@@ -832,7 +832,7 @@ const getCheckResult = (scriptType: string) => {
tempChnResult[randomNum] = CheckData.ChnCheckResultEnum.FAIL
errorCheckItem.push({scriptType, type: 'error'})
}
}
// }
return {
deviceId: item.deviceId,
@@ -840,7 +840,7 @@ const getCheckResult = (scriptType: string) => {
chnResult: tempChnResult,
}
})
}
// }
let tempScriptChnItem: CheckData.ScriptChnItem = {
scriptType,