diff --git a/frontend/src/api/check/interface/index.ts b/frontend/src/api/check/interface/index.ts index d75db35..7c1b305 100644 --- a/frontend/src/api/check/interface/index.ts +++ b/frontend/src/api/check/interface/index.ts @@ -13,12 +13,14 @@ export namespace CheckData { export interface CheckResult { chnNum: string, standardValue: number, - L1: number, - L1_errValue: number, - L2: number, - L2_errValue: number, - L3: number, - L3_errValue: number, + A?: number, + A_errValue?: number, + B?: number, + B_errValue?: number, + C?: number, + C_errValue?: number, + T?: number, + T_errValue?: number, maxErrVaule: number, result: string, } @@ -28,9 +30,10 @@ export namespace CheckData { */ export interface RawDataItem { updateTime: string, - L1: number, - L2: number, - L3: number + A?: number, + B?: number, + C?: number + T?: number } export interface Device { @@ -44,7 +47,6 @@ export namespace CheckData { id: string, code?: string, scriptName: string, - pid?: string, children?: ScriptItem[] } @@ -75,7 +77,7 @@ export namespace CheckData { INFO = '#909399', LOADING = '#607eab', SUCCESS = '#67c23a', - WARNING ='#e6a23c', + WARNING = '#e6a23c', DANGER = '#f56c6c', } diff --git a/frontend/src/api/check/test/index.ts b/frontend/src/api/check/test/index.ts index c8b4c9f..3c6cc0d 100644 --- a/frontend/src/api/check/test/index.ts +++ b/frontend/src/api/check/test/index.ts @@ -1,13 +1,45 @@ import http from "@/api"; -export const getFormData = (params: { deviceId: string, chnNum: number}) => { - return http.post("/check/detail/", params, {loading: false}); +export const getBigTestItem = (planId: string) => { + return http.get(`/adPlan/getBigTestItem?planId=${planId}`, {loading: false}); } -export const getTreeData = (params: { deviceId: string, chnNum: number, checkItemId: string }) => { - return http.post("/check/treeData/", params, {loading: false}); +/** + * 获取弹出框表单数据 + * @param params 当为scriptType为null时,表示查询所有脚本类型,否则只查询指定脚本类型。当为chnNum为-1时,表示查询所有通道,否则只查询指定通道。 + */ +export const getFormData = (params: { + scriptId: string, + deviceId: string, + chnNum: string, + scriptType: string | null +}) => { + return http.post("/result/formContent/", params, {loading: false}); } -export const getCheckData = (params: { deviceId: string, chnNum: number, checkItemId: string }) => { - return http.post("/check/data/", params, {loading: false}); +/** + * 获取树形结构数据 + * @param params + */ +export const getTreeData = (params: { + scriptId: string, + deviceId: string, + chnNum: string, + scriptType: string | null, + flag: number +}) => { + return http.post("/result/treeData/", params, {loading: false}); +} + +/** + * 获取检查数据 + * @param params + */ +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/api/socket/socket.ts b/frontend/src/api/socket/socket.ts index 2ba2729..0236aaa 100644 --- a/frontend/src/api/socket/socket.ts +++ b/frontend/src/api/socket/socket.ts @@ -13,15 +13,15 @@ export const closePreTest = (params) => { * 开始正式检测 * @param params */ -export const startTest = (params: { deviceIds: string[] }) => { - return http.post(`/test/startTest`, params, {loading: false}) +export const startTest = (params) => { + return http.post(`/prepare/startTest`, params, {loading: false}) } /** * 暂停正式检测 * @param params */ -export const pauseTest = (params: { deviceIds: string[] }) => { +export const pauseTest = (params) => { return http.post(`/test/pauseTest`, params, {loading: false}) } @@ -29,6 +29,6 @@ export const pauseTest = (params: { deviceIds: string[] }) => { * 继续正式检测 * @param params */ -export const resumeTest = (params: { deviceIds: string[] }) => { +export const resumeTest = (params) => { return http.post(`/test/resumeTest`, params, {loading: false}) } 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 2b254c0..f8f42d8 100644 --- a/frontend/src/views/home/components/dataCheckRawDataTable.vue +++ b/frontend/src/views/home/components/dataCheckRawDataTable.vue @@ -6,9 +6,14 @@ style="width: 100%;"> - - - + + @@ -16,13 +21,25 @@ \ No newline at end of file diff --git a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue index c683141..0ba81a5 100644 --- a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue @@ -17,7 +17,7 @@ - + @@ -28,16 +28,25 @@
- +
+ :data="treeDataUnqualified" :props="defaultProps" @node-click="handleNodeClick" + class="custom-tree"> + + + :data="treeDataAll" :props="defaultProps" @node-click="handleNodeClick" class="custom-tree"> + +
@@ -68,8 +77,8 @@ import {reactive, ref} from 'vue' import DataCheckResultTable from './dataCheckResultTable.vue' import DataCheckRawDataTable from './dataCheckRawDataTable.vue' import {CheckData} from "@/api/check/interface"; -import {getFormData, getTreeData, getCheckData} from "@/api/check/test"; import {useDictStore} from "@/stores/modules/dict"; +import {useCheckStore} from "@/stores/modules/check"; const {appendToBody} = withDefaults(defineProps<{ appendToBody: boolean @@ -81,6 +90,7 @@ const defaultProps = { }; const dictStore = useDictStore() +const checkStore = useCheckStore() const visible = ref(false) @@ -90,31 +100,30 @@ const formContent = reactive({ errorSysName: '', dataRule: '', deviceName: '', - monitorIdx: '', + chnNum: '', }) let deviceId: string = '' -let scriptType: string = '' +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() @@ -122,202 +131,291 @@ const rawDataTableRef = ref() // 左侧树默认展开节点id let defaultExpandedKeys: string[] = [] -// 监控通道号下拉框 -const handleChnChange = (data: any) => { - - console.log("通道号下拉框", data); - - // 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询) - // const result = await getTreeData({deviceId, formContent.monitorIdx, scriptType}) - // treeDataUnQualified=[] - // treeDataAll=[] - - -} -// watch(() => formContent.monitorIdx, (newVal, oldVal) => { -// if (newVal) { -// console.log("通道号下拉框", newVal, oldVal); -// -// // 后端请求,查询该通道号下的测试项(可以只查询不合格测试项,也可以全部测试项、不合格测试项都查询) -// // const result = await getTreeData({deviceId, formContent.monitorIdx, scriptType}) -// // treeDataUnQualified=[] -// // treeDataAll=[] -// -// } -// }) - // 点击左侧树节点触发事件 -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 getCheckData({deviceId, formContent.monitorIdx, scriptType}) - Object.assign(checkResultTableData, [{ - chnNum: '1', - standardValue: 57.74, - L1: 57.73, - L1_errValue: 0.01, - L2: 57.73, - L2_errValue: 0.01, - L3: 57.73, - L3_errValue: 0.01, - maxErrVaule: 0.05774, - result: '合格', - }]) - Object.assign(rawTableData, [ - { - updateTime: "2024-10-10 09:30:00", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:03", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:06", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:09", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:12", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:15", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:18", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:21", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:24", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:27", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:30", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:33", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:36", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:39", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:42", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:45", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:48", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:51", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:54", - L1: 57.73, - L2: 57.73, - L3: 57.73, - }, - { - updateTime: "2024-10-10 09:30:57", - L1: 57.73, - L2: 57.73, - L3: 57.73, - } - ]) - } +watch(() => formContent.chnNum, async (newVal, oldVal) => { + console.log("通道号", newVal); + + 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: number, _scriptType?: string) => { - 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 + scriptType = _scriptType + // 发起后端请求,查询详细信息 当chnNum为-1时,查询所有通道号 - //const result1 = await getFormData({deviceId, chnNum}) + //const resFormContent = await getFormData({checkStore.scriptId,deviceId, chnNum,scriptType}) // 数据处理 let resFormContent = { @@ -325,7 +423,7 @@ const open = async (_deviceId: string, chnNum: number, _scriptType?: string) => errorSysName: 'Q/GDW 10650.2-2021', dataRule: '505f063f9f91ab108d895a9fe96b5dce', deviceName: '被检设备1', - chnList:[ + chnList: [ {value: '1', label: '1'}, {value: '2', label: '0'}, {value: '3', label: '1'}, @@ -336,105 +434,11 @@ const open = async (_deviceId: string, chnNum: number, _scriptType?: string) => label: item.label == '1' ? `${item.value}` : `${item.value}(不符合)` })) - let dataRuleName = dictStore.getDictData('Data_Rule').find(item=>item.id==resFormContent.dataRule)?.name + 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", - "pid": "0", - "scriptName": "频率准确度检测", - "children": [ - { - "id": "1-1", - "pid": "1", - "scriptName": "额定工作条件下的检测", - "children": [ - { - "id": "1-1-1", - "pid": "1-1", - "scriptName": "输入:频率 42.5Hz..." - }, - { - "id": "1-1-2", - "pid": "1-1", - "scriptName": "输入:频率 50.0Hz..." - }, - { - "id": "1-1-3", - "pid": "1-1", - "scriptName": "输入:频率 50.05Hz...." - } - ] - }, - { - "id": "1-2", - "pid": "1", - "scriptName": "电压对频率测量的影响", - "children": [ - { - "id": "1-2-1", - "pid": "1-2", - "scriptName": "输入:频率 50.05Hz Ua =10%Un..." - }, - { - "id": "1-2-1", - "pid": "1-2", - "scriptName": "输入:频率 51.05Hz Ua =10%Un..." - }, - { - "id": "1-2-2", - "pid": "1-2", - "scriptName": "输入:频率 52.05Hz Ua =10%Un..." - } - ] - }, - { - "id": "1-3", - "pid": "1", - "scriptName": "谐波对频率测量的影响", - "children": [ - { - "id": "1-3-1", - "pid": "1-3", - "scriptName": "输入:频率 50.05Hz Ua =100%Un..." - } - ] - } - ] - }] - treeDataUnQualified = [{ - "id": "1", - "pid": "0", - "scriptName": "频率准确度检测", - "children": [ - { - "id": "1-2", - "pid": "1", - "scriptName": "电压对频率测量的影响", - "children": [ - { - "id": "1-2-1", - "pid": "1-2", - "scriptName": "输入:频率 50.05Hz Ua =10%Un..." - }, - { - "id": "1-2-1", - "pid": "1-2", - "scriptName": "输入:频率 51.05Hz Ua =10%Un..." - }, - { - "id": "1-2-2", - "pid": "1-2", - "scriptName": "输入:频率 52.05Hz Ua =10%Un..." - } - ] - } - ] - }] - visible.value = true; } @@ -445,14 +449,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; }; @@ -512,13 +516,19 @@ defineExpose({ padding: 10px 0; border: 1px solid #ccc; - overflow: auto; + overflow-y: auto; .content-tree { - min-width: 100%; + width: 100%; height: 100%; max-height: 100%; margin-top: 10px; + + .custom-tree-node { + overflow-x: hidden !important; // 溢出部分隐藏 + white-space: nowrap !important; //禁止自动换行 + text-overflow: ellipsis !important; // 使溢出部分以省略号显示 + } } } diff --git a/frontend/src/views/home/components/table.vue b/frontend/src/views/home/components/table.vue index 492d01d..4da79e7 100644 --- a/frontend/src/views/home/components/table.vue +++ b/frontend/src/views/home/components/table.vue @@ -918,7 +918,7 @@ const openDrawer = (title: string, row: any) => { if(title === '检测数据查询') { - dataCheckPopupRef.value?.open(row.id,-1) + dataCheckPopupRef.value?.open(row.id,'-1',null) } if (title === '误差体系更换') { diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index c360edd..e6095ca 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -41,7 +41,7 @@ - +