From 5e8dda0b75f36011b693b4e07f8139e5e01754b3 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Tue, 31 Dec 2024 19:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/api/check/test/index.ts | 23 +- frontend/src/stores/modules/check.ts | 5 + .../home/components/dataCheckRawDataTable.vue | 1 - .../home/components/dataCheckResultTable.vue | 1 - .../dataCheckSingleChannelSingleTestPopup.vue | 632 ++++++++---------- frontend/src/views/home/components/tree.vue | 4 + 6 files changed, 306 insertions(+), 360 deletions(-) diff --git a/frontend/src/api/check/test/index.ts b/frontend/src/api/check/test/index.ts index ad9e0c0..3c6cc0d 100644 --- a/frontend/src/api/check/test/index.ts +++ b/frontend/src/api/check/test/index.ts @@ -1,5 +1,4 @@ import http from "@/api"; -import {CheckData} from "@/api/check/interface"; export const getBigTestItem = (planId: string) => { return http.get(`/adPlan/getBigTestItem?planId=${planId}`, {loading: false}); @@ -9,7 +8,12 @@ export const getBigTestItem = (planId: string) => { * 获取弹出框表单数据 * @param params 当为scriptType为null时,表示查询所有脚本类型,否则只查询指定脚本类型。当为chnNum为-1时,表示查询所有通道,否则只查询指定通道。 */ -export const getFormData = (params: { planId: string, deviceId: string, chnNum: string, scriptType: string|null }) => { +export const getFormData = (params: { + scriptId: string, + deviceId: string, + chnNum: string, + scriptType: string | null +}) => { return http.post("/result/formContent/", params, {loading: false}); } @@ -17,7 +21,13 @@ export const getFormData = (params: { planId: string, deviceId: string, chnNum: * 获取树形结构数据 * @param params */ -export const getTreeData = (params: { deviceId: string, chnNum: string, checkItemId: string }) => { +export const getTreeData = (params: { + scriptId: string, + deviceId: string, + chnNum: string, + scriptType: string | null, + flag: number +}) => { return http.post("/result/treeData/", params, {loading: false}); } @@ -25,6 +35,11 @@ export const getTreeData = (params: { deviceId: string, chnNum: string, checkIte * 获取检查数据 * @param params */ -export const getTableData = (params: { deviceId: string, chnNum: string, checkItemId: string }) => { +export const getTableData = (params: { + scriptId: string, + deviceId: string, + chnNum: string, + scriptType: string | null +}) => { return http.post("/result/tableData/", params, {loading: false}); } \ No newline at end of file diff --git a/frontend/src/stores/modules/check.ts b/frontend/src/stores/modules/check.ts index c399b9c..f7ea995 100644 --- a/frontend/src/stores/modules/check.ts +++ b/frontend/src/stores/modules/check.ts @@ -9,6 +9,7 @@ export const useCheckStore = defineStore("check", { state: () => ({ devices: Array(), planId: String(""), + scriptId: String(""), }), getters: {}, @@ -24,6 +25,10 @@ export const useCheckStore = defineStore("check", { setPlanId(planId: string) { this.planId = planId + }, + + setScriptId(scriptId: string) { + this.scriptId = scriptId } } }); \ No newline at end of file diff --git a/frontend/src/views/home/components/dataCheckRawDataTable.vue b/frontend/src/views/home/components/dataCheckRawDataTable.vue index ec5300c..f8f42d8 100644 --- a/frontend/src/views/home/components/dataCheckRawDataTable.vue +++ b/frontend/src/views/home/components/dataCheckRawDataTable.vue @@ -37,7 +37,6 @@ const phaseFlag = computed(() => { if (tableData.length > 0) { result = !tableData[0].T ? 0 : 1; } - console.log(result); return result; }) diff --git a/frontend/src/views/home/components/dataCheckResultTable.vue b/frontend/src/views/home/components/dataCheckResultTable.vue index 79fb5b3..927b176 100644 --- a/frontend/src/views/home/components/dataCheckResultTable.vue +++ b/frontend/src/views/home/components/dataCheckResultTable.vue @@ -90,7 +90,6 @@ const phaseFlag = computed(() => { if (tableData.length > 0) { result = !tableData[0].T ? 0:1; } - console.log(result); return result; }) diff --git a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue index 9b6910d..fbb201b 100644 --- a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue @@ -17,7 +17,7 @@ - + @@ -28,14 +28,14 @@
- +
+ :data="treeDataUnqualified" :props="defaultProps" @node-click="handleNodeClick"/>
@@ -68,7 +68,6 @@ import {reactive, ref} from 'vue' import DataCheckResultTable from './dataCheckResultTable.vue' import DataCheckRawDataTable from './dataCheckRawDataTable.vue' import {CheckData} from "@/api/check/interface"; -import {getFormData, getTreeData, getTableData} from "@/api/check/test"; import {useDictStore} from "@/stores/modules/dict"; import {useCheckStore} from "@/stores/modules/check"; @@ -92,7 +91,7 @@ const formContent = reactive({ errorSysName: '', dataRule: '', deviceName: '', - monitorIdx: '', + chnNum: '', }) let deviceId: string = '' let scriptType: string | null = null @@ -101,22 +100,21 @@ let scriptType: string | null = null let chnList: any[] = [] // 不符合测试项、全部测试项切换 -const switchItem = ref(-1) -// 左侧树数据-不符合测试项 -let treeDataUnQualified: CheckData.ScriptItem[] = [] -// 左侧树数据-全部测试项 +const switchItem = ref(0) +// 左侧树数据 +let treeDataUnqualified: CheckData.ScriptItem[] = [] let treeDataAll: CheckData.ScriptItem[] = [] + // 左侧树被选中的叶子节点id const checkedScriptId = ref('') - const currentScriptDsc = ref(''); // 右侧Tab选中项 const activeTab = ref('resultTab') // 检测结果表格数据 -const checkResultTableData = reactive([]) +let checkResultTableData: CheckData.CheckResult = [] // 原始数据表格数据 -const rawTableData = reactive([]) +let rawTableData: CheckData.RawDataItem[] = [] const resultTableRef = ref() const rawDataTableRef = ref() @@ -124,285 +122,289 @@ const rawDataTableRef = ref() // 左侧树默认展开节点id let defaultExpandedKeys: string[] = [] -// 监控通道号下拉框 -const handleChnChange = (data: any) => { - - console.log("通道号下拉框", data); - - // 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询) - // const result = await getTreeData({deviceId, formContent.monitorIdx, scriptType}) - // treeDataUnQualified=[] - // treeDataAll=[] - - switchItem.value = 0 - -} - // 点击左侧树节点触发事件 -const handleNodeClick = (data: any) => { +const handleNodeClick = async (data: any) => { if (!data.children) { checkedScriptId.value = data.id currentScriptDsc.value = data.scriptName + + if (checkedScriptId.value) { + await updateTableData() + } } }; -watch(checkedScriptId, (newVal, oldVal) => { - if (newVal) { - console.log("左侧树被选中的叶子节点id", newVal); - // 发起请求,查询该测试项的检测结果 - // const result = await getTableData({deviceId, formContent.monitorIdx, scriptType}) +watch(() => formContent.chnNum, async (newVal, oldVal) => { + console.log("通道号", newVal); - Object.assign(checkResultTableData, [{ - chnNum: '1', - standardValue: 57.74, - A: 57.73, - A_errValue: 0.01, - B: 57.73, - B_errValue: 0.01, - C: 57.73, - C_errValue: 0.01, - maxErrVaule: 0.05774, - result: '合格', - }]) - // Object.assign(checkResultTableData, [{ - // chnNum: '1', - // standardValue: 57.74, - // T: 57.73, - // T_errValue: 0.01, - // maxErrVaule: 0.05774, - // result: '合格', - // }]) - - Object.assign(rawTableData, [ - { - updateTime: "2024-10-10 09:30:00", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:03", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:06", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:09", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:12", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:15", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:18", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:21", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:24", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:27", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:30", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:33", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:36", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:39", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:42", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:45", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:48", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:51", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:54", - A: 57.73, - B: 57.73, - C: 57.73, - }, - { - updateTime: "2024-10-10 09:30:57", - A: 57.73, - B: 57.73, - C: 57.73, - } - ]) - - // Object.assign(rawTableData, [ - // { - // updateTime: "2024-10-10 09:30:00", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:03", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:06", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:09", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:12", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:15", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:18", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:21", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:24", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:27", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:30", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:33", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:36", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:39", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:42", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:45", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:48", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:51", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:54", - // T: 57.73, - // }, - // { - // updateTime: "2024-10-10 09:30:57", - // T: 57.73, - // } - // ]) - } + switchItem.value = 0 + await handleSwitchChange(0) }) -// 切换不合格测试项、全部测试项 触发事件 -watch(switchItem, (newVal, oldVal) => { - let node = null - if (newVal === 0) { - node = getDefaultNode(treeDataUnQualified) - } - if (newVal === 1) { - node = getDefaultNode(treeDataAll) +const handleSwitchChange = async (data: any) => { + console.log("切换不合格测试项、全部测试项", data); + + if (data === 0) { + // 发起请求,查询该测试项的检测结果 + // const result = await getTreeData({checkStore.scriptId,deviceId, formContent.chnNum+'', scriptType,0}) + treeDataUnqualified = [{ + "id": "1", + "scriptName": "频率准确度检测", + "children": [ + { + "id": "1-2", + "scriptName": "电压对频率测量的影响", + "children": [ + { + "id": "1-2-1", + "scriptName": "输入:频率 50.05Hz Ua =10%Un..." + }, + { + "id": "1-2-2", + "scriptName": "输入:频率 51.05Hz Ua =10%Un..." + }, + { + "id": "1-2-3", + "scriptName": "输入:频率 52.05Hz Ua =10%Un..." + } + ] + }, + { + "id": "1-3", + "scriptName": "谐波对频率测量的影响", + "children": [ + { + "id": "1-3-1", + "scriptName": "输入:频率 50.05Hz Ua =100%Un..." + } + ] + } + ] + }] + } else { + // 发起请求,查询该测试项的检测结果 + // const result = await getTreeData({checkStore.scriptId,deviceId, formContent.chnNum+'', scriptType,1}) + treeDataAll = [{ + "id": "1", + "scriptName": "频率准确度检测", + "children": [ + { + "id": "1-1", + "scriptName": "额定工作条件下的检测", + "children": [ + { + "id": "1-1-1", + "scriptName": "输入:频率 42.5Hz..." + }, + { + "id": "1-1-2", + "scriptName": "输入:频率 50.0Hz..." + }, + { + "id": "1-1-3", + "scriptName": "输入:频率 50.05Hz...." + } + ] + }, + { + "id": "1-2", + "scriptName": "电压对频率测量的影响", + "children": [ + { + "id": "1-2-1", + "scriptName": "输入:频率 50.05Hz Ua =10%Un..." + }, + { + "id": "1-2-2", + "scriptName": "输入:频率 51.05Hz Ua =10%Un..." + }, + { + "id": "1-2-3", + "scriptName": "输入:频率 52.05Hz Ua =10%Un..." + } + ] + }, + { + "id": "1-3", + "scriptName": "谐波对频率测量的影响", + "children": [ + { + "id": "1-3-1", + "scriptName": "输入:频率 50.05Hz Ua =100%Un..." + } + ] + } + ] + }] + } + defaultOperate() + await updateTableData() +} + +// 默认操作 +const defaultOperate = () => { + let node = null + if (switchItem.value === 0) { + node = getDefaultNode(treeDataUnqualified) + } else { + node = getDefaultNode(treeDataAll) + } currentScriptDsc.value = node?.scriptName checkedScriptId.value = node?.id defaultExpandedKeys = [node?.id] -}) +} -const open = async (_deviceId: string, chnNum: string, _scriptType: string | null) => { - console.log(_deviceId, chnNum, _scriptType); +const updateTableData = async () => { + console.log("左侧树被选中的叶子节点id", checkedScriptId.value); + // 发起请求,查询该测试项的检测结果 + // const result = await getTableData({checkStore.scriptId,deviceId, formContent.chnNum, scriptType}) + + checkResultTableData = [{ + chnNum: '1', + standardValue: 57.74, + A: 57.73, + A_errValue: 0.01, + B: 57.73, + B_errValue: 0.01, + C: 57.73, + C_errValue: 0.01, + maxErrVaule: 0.05774, + result: '合格', + }] + + rawTableData = [ + { + updateTime: "2024-10-10 09:30:00", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:03", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:06", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:09", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:12", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:15", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:18", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:21", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:24", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:27", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:30", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:33", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:36", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:39", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:42", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:45", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:48", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:51", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:54", + A: 57.73, + B: 57.73, + C: 57.73, + }, + { + updateTime: "2024-10-10 09:30:57", + A: 57.73, + B: 57.73, + C: 57.73, + } + ] +} + +const open = (_deviceId: string, chnNum: string, _scriptType: string | null) => { + console.log(checkStore.scriptId, _deviceId, chnNum, _scriptType); deviceId = _deviceId scriptType = _scriptType - switchItem.value = 0 + // 发起后端请求,查询详细信息 当chnNum为-1时,查询所有通道号 - //const resFormContent = await getFormData({checkStore.planId,deviceId, chnNum,scriptType}) + //const resFormContent = await getFormData({checkStore.scriptId,deviceId, chnNum,scriptType}) // 数据处理 let resFormContent = { @@ -423,87 +425,9 @@ const open = async (_deviceId: string, chnNum: string, _scriptType: string | nul let dataRuleName = dictStore.getDictData('Data_Rule').find(item => item.id == resFormContent.dataRule)?.name - Object.assign(formContent, {...resFormContent, dataRule: dataRuleName, monitorIdx: chnList[0].value}) + Object.assign(formContent, {...resFormContent, dataRule: dataRuleName, chnNum: chnList[0].value}) - // const result2 = await getTreeData({deviceId, formContent.monitorIdx, checkItemId}) - treeDataAll = [{ - "id": "1", - "scriptName": "频率准确度检测", - "children": [ - { - "id": "1-1", - "scriptName": "额定工作条件下的检测", - "children": [ - { - "id": "1-1-1", - "scriptName": "输入:频率 42.5Hz..." - }, - { - "id": "1-1-2", - "scriptName": "输入:频率 50.0Hz..." - }, - { - "id": "1-1-3", - "scriptName": "输入:频率 50.05Hz...." - } - ] - }, - { - "id": "1-2", - "scriptName": "电压对频率测量的影响", - "children": [ - { - "id": "1-2-1", - "scriptName": "输入:频率 50.05Hz Ua =10%Un..." - }, - { - "id": "1-2-1", - "scriptName": "输入:频率 51.05Hz Ua =10%Un..." - }, - { - "id": "1-2-2", - "scriptName": "输入:频率 52.05Hz Ua =10%Un..." - } - ] - }, - { - "id": "1-3", - "scriptName": "谐波对频率测量的影响", - "children": [ - { - "id": "1-3-1", - "scriptName": "输入:频率 50.05Hz Ua =100%Un..." - } - ] - } - ] - }] - treeDataUnQualified = [{ - "id": "1", - "scriptName": "频率准确度检测", - "children": [ - { - "id": "1-2", - "scriptName": "电压对频率测量的影响", - "children": [ - { - "id": "1-2-1", - "scriptName": "输入:频率 50.05Hz Ua =10%Un..." - }, - { - "id": "1-2-1", - "scriptName": "输入:频率 51.05Hz Ua =10%Un..." - }, - { - "id": "1-2-2", - "scriptName": "输入:频率 52.05Hz Ua =10%Un..." - } - ] - } - ] - }] - visible.value = true; } @@ -514,14 +438,14 @@ const close = () => { errorSysName: '', dataRule: '', deviceName: '', - monitorIdx: '', + chnNum: '', }) + treeDataUnqualified = [] treeDataAll = [] - treeDataUnQualified = [] checkedScriptId.value = '' activeTab.value = 'rawDataTab' currentScriptDsc.value = '' - switchItem.value = -1 + switchItem.value = 0 visible.value = false; }; diff --git a/frontend/src/views/home/components/tree.vue b/frontend/src/views/home/components/tree.vue index 79ab2df..846830b 100644 --- a/frontend/src/views/home/components/tree.vue +++ b/frontend/src/views/home/components/tree.vue @@ -37,8 +37,11 @@ import { type Plan } from '@/api/plan/interface'; import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue' import { onMounted, ref, watch } from 'vue'; import { useRouter } from 'vue-router' +import {useCheckStore} from "@/stores/modules/check"; const router = useRouter() +const checkStore = useCheckStore() + const data: any = ref([]) const defaultProps = { children: 'children', @@ -71,6 +74,7 @@ watch( }, ) const handleNodeClick = (data: Plan.ResPlan) => { + checkStore.setScriptId(data.scriptId) updateSelectedTreeNode(data.id) } const filterNode = (value: string, data: any) => {