修改检测结果弹窗框
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user