diff --git a/frontend/src/api/check/test/index.ts b/frontend/src/api/check/test/index.ts index b3cd167..23ece4c 100644 --- a/frontend/src/api/check/test/index.ts +++ b/frontend/src/api/check/test/index.ts @@ -1,5 +1,5 @@ import http from "@/api"; -export const getCheckItemDetail = (params: { checkItemId: string, deviceId: string, chnNum: number }) => { +export const getCheckItemDetail = (params: { deviceId: string, chnNum: number, checkItemId?: string }) => { return http.post("/check/test/detail/", params, {loading: false}); } \ 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 f26fd7f..9708690 100644 --- a/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue +++ b/frontend/src/views/home/components/dataCheckSingleChannelSingleTestPopup.vue @@ -67,6 +67,7 @@ import DataCheckResultTable from './dataCheckResultTable.vue' import DataCheckRawDataTable from './dataCheckRawDataTable.vue' import {CheckData} from "@/api/check/interface"; import {data as treeData} from "@/api/plan/autoTest.json"; +import {getCheckItemDetail} from "@/api/check/test"; const {appendToBody} = withDefaults(defineProps<{ appendToBody: boolean @@ -279,10 +280,14 @@ const close = () => { visible.value = false; }; -const open = (checkItemId: string, deviceId: string, chnNum?: number) => { - console.log(checkItemId, deviceId, chnNum); +const open = async (deviceId: string, chnNum: number, checkItemId?: string) => { // 发起后端请求,查询详细信息 - //const result = await getCheckItemDetail({checkItemId,deviceId, chnNum}) + // 当checkItemId为空时,默认显示全部测试项、全部不合格测试项 + // 当checkItemId不为空时,默认显示当前checkItemId的测试项、属于当前checkItemId的不合格测试项 + checkItemId = checkItemId ?? '' + console.log(deviceId, chnNum, checkItemId); + //const result = await getCheckItemDetail({deviceId, chnNum, checkItemId}) + // 数据处理 // checkResultTableData=[]; @@ -330,6 +335,7 @@ defineExpose({ padding: 10px 0; border: 1px solid #ccc; overflow: auto; + .content-tree { min-width: 100%; height: 100%; diff --git a/frontend/src/views/home/components/table.vue b/frontend/src/views/home/components/table.vue index 2d44615..0be9536 100644 --- a/frontend/src/views/home/components/table.vue +++ b/frontend/src/views/home/components/table.vue @@ -875,8 +875,7 @@ const openDrawer = (title: string, row: any) => { if(title === '检测数据查询') { - let device={} - dataCheckPopupRef.value?.open(device) + dataCheckPopupRef.value?.open(row.id,-1) } if (title === '误差体系更换') { diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index 3550a22..ffbf556 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -8,17 +8,17 @@ 停止检测 - 检测完成 + 检测完成 继续检测 @@ -26,7 +26,7 @@ 检测项进度 + + +
+

+ {{ item.log }}
+

+
+ + ([]) // 用来保存被检设备 const deviceList = reactive([]) // 用来保存定时器 @@ -152,6 +160,8 @@ const startData = ref(new Date()) //测试项检测结束时间(或暂停时的时间) const endData = ref(new Date()) const timeDifference = ref(0) +// 真正的检测结果(详细到通道) +const checkResult = reactive([]) // 用来存放检测出现失败的测试项id。只要有一个通道检测不合格,则该检测项的id会被加入该数组。 const errorCheckItem = reactive([]); // 用来存放检测日志 @@ -161,7 +171,9 @@ const testStatus = toRef(props, 'testStatus') const webMsgSend = toRef(props, 'webMsgSend') const resultDialogVisible = ref(false) -const dataCheckSingleChannelSingleTestPopupRef = ref() +const scrollContainer = ref(null); +const dataCheckSingleChannelSingleTestPopupRef = ref>() + // 总通道数 const chnSum = computed(() => { @@ -172,265 +184,6 @@ const chnSum = computed(() => { return sum }) - -watch(testStatus, function (newValue, oldValue) { - if (newValue == 'start') { - emit('update:testStatus', 'process') - startTimer() - } - if (newValue == 'paused' && oldValue == 'process') { - handlePauseOrContinue() - } - if (newValue === 'process' && oldValue == 'paused') { - handlePauseOrContinue() - } -}) - -watch(webMsgSend, function (newValue, oldValue) { - if (activeIndex.value <= TEST_TOTAL) { - console.log('检测开始') - switch (newValue.requestId) { - case 'Test_Freq': - updateCheckResultView("Freq") - break; - case 'Test_VOL': - updateCheckResultView("VOL") - break; - case 'Test_Harm_V': - updateCheckResultView("Harm_V") - break; - case 'Test_Harm_I': - updateCheckResultView("Harm_I") - break; - case 'Test_Harm_P': - updateCheckResultView("Harm_P") - break; - case 'Test_InHarm_V': - updateCheckResultView("InHarm_V") - break; - case 'Test_InHarm_I': - updateCheckResultView("InHarm_I") - break; - case 'Test_Dip': - updateCheckResultView("Dip") - break; - case 'Test_CUR': - updateCheckResultView("CUR") - break; - case 'Test_MSQI_U': - updateCheckResultView("MSQI_U") - break; - case 'Test_MSQI_I': - updateCheckResultView("MSQI_I") - break; - case 'Test_Flicker': - updateCheckResultView("Flicker") - break; - case 'Test_Quit': - console.log('检测结束') - break; - } - - updateLog() - activeIndex.value++; - - if (percentage.value < 100) { - percentage.value = Math.trunc(activeIndex.value / TEST_TOTAL * 100); - } else { - percentage.value = 100; - clearInterval(timer.value) - timer.value = null; - emit('update:testStatus', 'success') - - ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', { - // if you want to disable its autofocus - // autofocus: false, - confirmButtonText: '确定', - }) - clear(); - } - } else { - clearInterval(timer.value) - timer.value = null; - emit('update:testStatus', 'success') - scrollToBottom(); - } -}, {deep: true}) - -onBeforeMount(() => { - initScriptData() - initDeviceList() - initCheckResult() -}) - -const showTestLog = () => { - drawer.value = true -} - -// const currentRow = ref<{ -// id: number; -// scriptItemName: string; -// name: string; -// address: string; -// hasChildren?: boolean; -// children?: User[] -// } | null>(null); -// const currentRow = ref(null); // 用于存储当前选中的行 - - -// 检测脚本数据 -const scriptData = reactive([]) -// 初始化检测脚本数据 -const initScriptData = () => { - let map = new Map() - map.set('Freq', '频率') - .set('VOL', '电压') - .set('Harm_V', '谐波电压') - .set('Harm_I', '谐波电流') - .set('Harm_P', '谐波有功功率') - .set('InHarm_V', '间谐波电压') - .set('InHarm_I', '间谐波电流') - .set('Dip', '暂态') - .set('CUR', '电流') - .set('MSQI_U', '电压不平衡度') - .set('MSQI_I', '电流不平衡度') - .set('Flicker', '短时闪变') - - - let response: CheckData.ScriptItem[] = [ - {id: '1', code: 'Freq', scriptItemName: '频率准确度检测'}, - {id: '2', code: 'VOL', scriptItemName: '电压准确度检测'}, - {id: '3', code: 'Harm_V', scriptItemName: '谐波电压准确度检测'}, - {id: '4', code: 'Harm_I', scriptItemName: '谐波电流准确度检测'}, - {id: '5', code: 'Harm_P', scriptItemName: '谐波有功功率准确度检测'}, - {id: '6', code: 'InHarm_V', scriptItemName: '间谐波电压准确度检测'}, - {id: '7', code: 'InHarm_I', scriptItemName: '间谐波电流准确度检测'}, - {id: '8', code: 'Dip', scriptItemName: '暂态准确度检测'}, - {id: '9', code: 'CUR', scriptItemName: '电流准确度检测'}, - {id: '10', code: 'MSQI_U', scriptItemName: '三相电压不平衡度检测'}, - {id: '11', code: 'MSQI_I', scriptItemName: '三相电流不平衡度检测'}, - {id: '12', code: 'Flicker', scriptItemName: '闪变准确度检测'} - ] - // Object.assign(scriptData, [ - // { - // id: '1', - // code: 'Freq', - // scriptItemName: '频率' - // }, - // { - // id: '2', - // code: 'VOL', - // scriptItemName: '电压' - // }, - // { - // id: '3', - // code: 'Harm_V', - // scriptItemName: '谐波电压' - // }, - // { - // id: '4', - // code: 'Harm_I', - // scriptItemName: '谐波电流' - // }, - // { - // id: '5', - // code: 'Harm_P', - // scriptItemName: '谐波有功功率' - // }, - // { - // id: '6', - // code: 'InHarm_V', - // scriptItemName: '间谐波电压' - // }, - // { - // id: '7', - // code: 'InHarm_I', - // scriptItemName: '间谐波电流' - // }, - // { - // id: '8', - // code: 'Dip', - // scriptItemName: '暂态' - // }, - // { - // id: '9', - // code: 'CUR', - // scriptItemName: '电流' - // }, - // { - // id: '10', - // code: 'MSQI_U', - // scriptItemName: '电压不平衡度' - // }, - // { - // id: '11', - // code: 'MSQI_I', - // scriptItemName: '电流不平衡度' - // }, - // { - // id: '12', - // code: 'Flicker', - // scriptItemName: '短时闪变' - // }, - // ]) - - let temp = response.map(item => { - return { - ...item, - scriptItemName: map.get(item.code) || item.scriptItemName - } - }) - - scriptData.push(...temp) -} -// 初始化设备列表 -const initDeviceList = () => { - checkStore.devices.forEach(item => { - deviceList.push({ - deviceId: item.deviceId, - deviceName: item.deviceName, - chnNum: item.chnNum, - }) - }) -} -// 真正的检测结果(详细到通道) -const checkResult = reactive([]) -// 初始化检测结果 (详细到通道) -const initCheckResult = () => { - scriptData.forEach(item => { - // 处理当前节点的数据 - let temp: CheckData.ScriptChnItem = { - scriptId: item.id, - scriptItemName: item.scriptItemName, - devices: [] - } - for (let i = 0; i < deviceList?.length; i++) { - let tempChnResult: CheckData.ChnCheckResultEnum[] = [] - for (let j = 0; j < deviceList[i].chnNum; j++) { - tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN) - } - temp.devices.push({ - deviceId: deviceList[i].deviceId, - deviceName: deviceList[i].deviceName, - chnResult: tempChnResult - }) - } - checkResult.push(temp) - }) -} -// 更新检测结果(详细到通道) -const updateCheckResult = (data: CheckData.ScriptChnItem) => { - const {scriptId} = {...data} - - checkResult.forEach(item => { - if (item.scriptId == scriptId) { - item.devices.forEach((device, index) => { - device.chnResult = [...data.devices[index].chnResult] - }) - } - }) -} - // 用来展示的检测结果 const checkResultView = computed(() => { @@ -480,7 +233,188 @@ const checkResultView = computed(() => { return result }) -const scrollContainer = ref(null); // 声明 scrollContainer +watch(testStatus, function (newValue, oldValue) { + if (newValue == 'start') { + emit('update:testStatus', 'process') + startTimer() + } + if (newValue == 'paused' && oldValue == 'process') { + handlePauseOrContinue() + } + if (newValue === 'process' && oldValue == 'paused') { + handlePauseOrContinue() + } +}) + +watch(webMsgSend, function (newValue, oldValue) { + if (activeIndex.value <= checkTotal.value) { + console.log('检测开始') + switch (newValue.requestId) { + case 'Test_Freq': + updateCheckResultView("Freq") + break; + case 'Test_VOL': + updateCheckResultView("VOL") + break; + case 'Test_Harm_V': + updateCheckResultView("Harm_V") + break; + case 'Test_Harm_I': + updateCheckResultView("Harm_I") + break; + case 'Test_Harm_P': + updateCheckResultView("Harm_P") + break; + case 'Test_InHarm_V': + updateCheckResultView("InHarm_V") + break; + case 'Test_InHarm_I': + updateCheckResultView("InHarm_I") + break; + case 'Test_Dip': + updateCheckResultView("Dip") + break; + case 'Test_CUR': + updateCheckResultView("CUR") + break; + case 'Test_MSQI_U': + updateCheckResultView("MSQI_U") + break; + case 'Test_MSQI_I': + updateCheckResultView("MSQI_I") + break; + case 'Test_Flicker': + updateCheckResultView("Flicker") + break; + case 'Test_Quit': + console.log('检测结束') + break; + } + + updateLog() + activeIndex.value++; + + if (percentage.value < 100) { + percentage.value = Math.trunc(activeIndex.value / checkTotal.value * 100); + } else { + percentage.value = 100; + clearInterval(timer.value) + timer.value = null; + emit('update:testStatus', 'success') + + ElMessageBox.alert('检测全部结束,你可以停留在此页面查看检测结果,或返回首页进行复检、报告生成和归档等操作', '检测完成', { + // if you want to disable its autofocus + // autofocus: false, + confirmButtonText: '确定', + }) + clear(); + } + } else { + clearInterval(timer.value) + timer.value = null; + emit('update:testStatus', 'success') + scrollToBottom(); + } +}, {deep: true}) + +onBeforeMount(() => { + initScriptData() + initDeviceList() + initCheckResult() +}) + +const showTestLog = () => { + drawer.value = true +} + +// 初始化检测脚本数据 +const initScriptData = () => { + let map = new Map() + map.set('Freq', '频率') + .set('VOL', '电压') + .set('Harm_V', '谐波电压') + .set('Harm_I', '谐波电流') + .set('Harm_P', '谐波有功功率') + .set('InHarm_V', '间谐波电压') + .set('InHarm_I', '间谐波电流') + .set('Dip', '暂态') + .set('CUR', '电流') + .set('MSQI_U', '电压不平衡度') + .set('MSQI_I', '电流不平衡度') + .set('Flicker', '短时闪变') + + let response: CheckData.ScriptItem[] = [ + {id: '1', code: 'Freq', scriptItemName: '频率准确度检测'}, + {id: '2', code: 'VOL', scriptItemName: '电压准确度检测'}, + {id: '3', code: 'Harm_V', scriptItemName: '谐波电压准确度检测'}, + {id: '4', code: 'Harm_I', scriptItemName: '谐波电流准确度检测'}, + {id: '5', code: 'Harm_P', scriptItemName: '谐波有功功率准确度检测'}, + {id: '6', code: 'InHarm_V', scriptItemName: '间谐波电压准确度检测'}, + {id: '7', code: 'InHarm_I', scriptItemName: '间谐波电流准确度检测'}, + {id: '8', code: 'Dip', scriptItemName: '暂态准确度检测'}, + {id: '9', code: 'CUR', scriptItemName: '电流准确度检测'}, + {id: '10', code: 'MSQI_U', scriptItemName: '三相电压不平衡度检测'}, + {id: '11', code: 'MSQI_I', scriptItemName: '三相电流不平衡度检测'}, + {id: '12', code: 'Flicker', scriptItemName: '闪变准确度检测'} + ] + + let temp = response.map(item => { + return { + ...item, + scriptItemName: map.get(item.code) || item.scriptItemName + } + }) + + scriptData.push(...temp) + checkTotal.value = scriptData.length + 1 +} +// 初始化设备列表 +const initDeviceList = () => { + checkStore.devices.forEach(item => { + deviceList.push({ + deviceId: item.deviceId, + deviceName: item.deviceName, + chnNum: item.chnNum, + }) + }) +} + +// 初始化检测结果 (详细到通道) +const initCheckResult = () => { + scriptData.forEach(item => { + // 处理当前节点的数据 + let temp: CheckData.ScriptChnItem = { + scriptId: item.id, + scriptItemName: item.scriptItemName, + devices: [] + } + for (let i = 0; i < deviceList?.length; i++) { + let tempChnResult: CheckData.ChnCheckResultEnum[] = [] + for (let j = 0; j < deviceList[i].chnNum; j++) { + tempChnResult.push(CheckData.ChnCheckResultEnum.UNKNOWN) + } + temp.devices.push({ + deviceId: deviceList[i].deviceId, + deviceName: deviceList[i].deviceName, + chnResult: tempChnResult + }) + } + checkResult.push(temp) + }) +} +// 更新检测结果(详细到通道) +const updateCheckResult = (data: CheckData.ScriptChnItem) => { + const {scriptId} = {...data} + + checkResult.forEach(item => { + if (item.scriptId == scriptId) { + item.devices.forEach((device, index) => { + device.chnResult = [...data.devices[index].chnResult] + }) + } + }) +} + const scrollToBottom = () => { if (scrollContainer.value) { scrollContainer.value.scrollTop = scrollContainer.value.scrollHeight; @@ -828,14 +762,16 @@ const handlePauseOrContinue = () => { // 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道 const handleClick = (scriptId: string, deviceId: any, chnNum: number) => { - dataCheckSingleChannelSingleTestPopupRef.value?.open(scriptId, deviceId, chnNum); + dataCheckSingleChannelSingleTestPopupRef.value?.open(deviceId, chnNum, scriptId); }; const startTimer = () => { - activeIndex.value++; + if (activeIndex.value === 0) { + activeIndex.value++; + } //if (timer.value !== null) return; // 如果定时器已经启动,则不再重复启动 timer.value = setInterval(() => { - if (activeIndex.value <= TEST_TOTAL) { + if (activeIndex.value <= checkTotal.value) { switch (activeIndex.value) { case 1: emit('update:webMsgSend', { @@ -1022,6 +958,24 @@ function clear() { font-size: 14px; } } +.drawer-container{ + :deep(header.el-drawer__header){ + color: #fff !important; + background-color: #003078 !important; + + .el-drawer__close-btn svg:hover { + color: #ccc !important; + } + + .el-drawer__title{ + color: #fff !important; + } + } +} + +//:deep(.el-drawer .el-drawer__title){ +// background-color: #003078 !important; +//} @@ -1035,4 +989,5 @@ function clear() { padding: 5px 0 !important; } + diff --git a/frontend/src/views/home/tabs/dashboard.vue b/frontend/src/views/home/tabs/dashboard.vue index 2502cf2..9ca1d23 100644 --- a/frontend/src/views/home/tabs/dashboard.vue +++ b/frontend/src/views/home/tabs/dashboard.vue @@ -399,9 +399,9 @@ const resizeObserver = new ResizeObserver(entries => { chartsWidth.value = entry.contentRect.width; //console.log('Charts Info Width:', chartsWidth.value); - pieRef1.value.reSize(chartsWidth.value * 0.95, 180, true); - pieRef2.value.reSize(chartsWidth.value * 0.95, 180, true); - pieRef3.value.reSize(chartsWidth.value * 0.95, 180, true); + pieRef1.value?.reSize(chartsWidth.value * 0.95, 180, true); + pieRef2.value?.reSize(chartsWidth.value * 0.95, 180, true); + pieRef3.value?.reSize(chartsWidth.value * 0.95, 180, true); } }); diff --git a/frontend/src/views/machine/errorSystem/components/errorSystemDetailTable.vue b/frontend/src/views/machine/errorSystem/components/errorSystemDetailTable.vue index 216c915..adb7ebf 100644 --- a/frontend/src/views/machine/errorSystem/components/errorSystemDetailTable.vue +++ b/frontend/src/views/machine/errorSystem/components/errorSystemDetailTable.vue @@ -33,8 +33,7 @@ - + @@ -50,7 +49,7 @@ - +