diff --git a/frontend/src/layouts/components/Main/index.vue b/frontend/src/layouts/components/Main/index.vue index 6e99a56..cf3ef5f 100644 --- a/frontend/src/layouts/components/Main/index.vue +++ b/frontend/src/layouts/components/Main/index.vue @@ -5,7 +5,7 @@ - + @@ -26,11 +26,12 @@ import Maximize from "./components/Maximize.vue"; import Tabs from "@/layouts/components/Tabs/index.vue"; import Footer from "@/layouts/components/Footer/index.vue"; import { useAuthStore } from "@/stores/modules/auth"; -import { useRoute, type RouteLocationNormalized } from 'vue-router' +import { useTabsStore } from '@/stores/modules/tabs' +const tabStore = useTabsStore() const globalStore = useGlobalStore(); +const tabsMenuList = computed(() => tabStore.tabsMenuList.map(item => item.name)) const authStore = useAuthStore(); const { maximize, isCollapse, layout, tabs, footer } = storeToRefs(globalStore); -const route = useRoute() const keepAliveStore = useKeepAliveStore(); const { keepAliveName } = storeToRefs(keepAliveStore); // console.log("🚀 ~ keepAliveName:", keepAliveName) @@ -61,14 +62,7 @@ watch( }, { immediate: true } ); -watch( - () => route.path, - () => { - console.log(123, route.path); - }, - -); // 监听窗口大小变化,折叠侧边栏 const screenWidth = ref(0); diff --git a/frontend/src/layouts/components/Tabs/index.vue b/frontend/src/layouts/components/Tabs/index.vue index cc8c64d..ca8f9fb 100644 --- a/frontend/src/layouts/components/Tabs/index.vue +++ b/frontend/src/layouts/components/Tabs/index.vue @@ -77,6 +77,7 @@ const initTabs = () => { name: item.name, close: !item.meta.isAffix, isKeepAlive: item.meta.isKeepAlive, + unshift:true } tabStore.addTabs(tabsParams) } @@ -100,6 +101,7 @@ const tabsDrop = () => { // Tab Click const tabClick = (tabItem: TabsPaneContext) => { const fullPath = tabItem.props.name as string + console.log("🚀 ~ tabClick ~ fullPath:", tabItem) router.push(fullPath) } diff --git a/frontend/src/stores/interface/index.ts b/frontend/src/stores/interface/index.ts index 1fa337a..7f7d416 100644 --- a/frontend/src/stores/interface/index.ts +++ b/frontend/src/stores/interface/index.ts @@ -39,6 +39,7 @@ export interface TabsMenuProps { name: string; close: boolean; isKeepAlive: boolean; + unshift?: boolean; } /* TabsState */ diff --git a/frontend/src/stores/modules/tabs.ts b/frontend/src/stores/modules/tabs.ts index 2b78d2e..120b622 100644 --- a/frontend/src/stores/modules/tabs.ts +++ b/frontend/src/stores/modules/tabs.ts @@ -16,8 +16,14 @@ export const useTabsStore = defineStore({ actions: { // Add Tabs async addTabs(tabItem: TabsMenuProps) { + if (this.tabsMenuList.every(item => item.path !== tabItem.path)) { - this.tabsMenuList.push(tabItem); + if (tabItem?.unshift) { + this.tabsMenuList.unshift(tabItem); + }else{ + this.tabsMenuList.push(tabItem); + + } } if (!keepAliveStore.keepAliveName.includes(tabItem.name) && tabItem.isKeepAlive) { keepAliveStore.addKeepAliveName(tabItem.name); diff --git a/frontend/src/views/home/components/preTest.vue b/frontend/src/views/home/components/preTest.vue index e552a1e..0a3e8ec 100644 --- a/frontend/src/views/home/components/preTest.vue +++ b/frontend/src/views/home/components/preTest.vue @@ -481,7 +481,14 @@ watch(webMsgSend, function (newValue, oldValue) { type: 'wait', log: '获取数据相序校验数据!', }]; - } else if (newValue.code == 25001) { + } else if (newValue.code == 25003) { + step4.value = 'error' + step4InitLog.value.push({ + type: 'error', + log: '相序校验未通过!', + }) + ts.value = 'error' + }else if (newValue.code == 25001) { step4.value = 'success' step5.value = 'success' step4InitLog.value.push({ diff --git a/frontend/src/views/home/components/test.vue b/frontend/src/views/home/components/test.vue index 38caea4..3b0a71b 100644 --- a/frontend/src/views/home/components/test.vue +++ b/frontend/src/views/home/components/test.vue @@ -13,7 +13,7 @@ @click="handlePause()">停止检测 - + 暂停中 @@ -303,7 +303,6 @@ watch(testStatus, function (newValue, oldValue) { if (newValue == 'start') { ElMessage.success('初始化开始!') - startData.value = new Date(); showTestLog() if (oldValue == 'error') { @@ -315,6 +314,8 @@ watch(testStatus, function (newValue, oldValue) { } emit('update:testStatus', 'test_init') //startTimer() // todo 可移除 + startData.value = new Date(); + timeDifference.value = 0; testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化开始!`}) } }) @@ -343,7 +344,7 @@ watch(webMsgSend, function (newValue, oldValue) { type: 'error', log: `${new Date().toLocaleString()}:存在已经初始化步骤,执行自动关闭,请重新发起检测!` }) - emit('update:testStatus', 'error') + emit('update:testStatus', 'test_recheck') } else { switch (newValue.requestId) { case 'error_flow_end': @@ -418,9 +419,11 @@ watch(webMsgSend, function (newValue, oldValue) { if (newValue.code == 25001) { ElMessage.success('初始化成功!') testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:协议校验成功!`}) + timeDifference.value = + new Date().getTime() - startData.value.getTime(); testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:初始化成功!`}) percentage.value = 3 + activeIndex = getNextActiveIndex() + 2 //startTimer() @@ -448,172 +451,76 @@ watch(webMsgSend, function (newValue, oldValue) { // ElMessage.error('无法继续检测') // break; case 'FREQ_Start': - activeIndex = getActiveIndex('FREQ') - updateCheckResultView("FREQ", true) - updateLog(true) + handleStartItem('FREQ', newValue.desc) break; case 'FREQ_End': - updatePercentage() - updateCheckResultView("FREQ", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('FREQ') - //startTimer() - } + handleEndItem('FREQ', newValue.desc, newValue.data) break; case 'V_Start': - activeIndex = getActiveIndex('V') - updateCheckResultView("V", true) - updateLog(true) + handleStartItem('V', newValue.desc) break; case 'V_End': - updatePercentage() - updateCheckResultView("V", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('V') - //startTimer() - } + handleEndItem('V', newValue.desc, newValue.data) break; case 'HV_Start': - activeIndex = getActiveIndex('HV') - updateCheckResultView("HV", true) - updateLog(true) + handleStartItem('HV', newValue.desc) break; case 'HV_End': - updatePercentage() - updateCheckResultView("HV", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('HV') - //startTimer() - } + handleEndItem('HV', newValue.desc, newValue.data) break; case 'HI_Start': - activeIndex = getActiveIndex('HI') - updateCheckResultView("HI", true) - updateLog(true) + handleStartItem('HI', newValue.desc) break; case 'HI_End': - updatePercentage() - updateCheckResultView("HI", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('HI') - //startTimer() - } + handleEndItem('HI', newValue.desc, newValue.data) break; case 'HP_Start': - activeIndex = getActiveIndex('HP') - updateCheckResultView("HP", true) - updateLog(true) + handleStartItem('HP', newValue.desc) break; case 'HP_End': - updatePercentage() - updateCheckResultView("HP", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('HP') - //startTimer() - } + handleEndItem('HP', newValue.desc, newValue.data) break; case 'HSV_Start': - activeIndex = getActiveIndex('HSV') - updateCheckResultView("HSV", true) - updateLog(true) + handleStartItem('HSV', newValue.desc) break; case 'HSV_End': - updatePercentage() - updateCheckResultView("HSV", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('HSV') - //startTimer() - } + handleEndItem('HSV', newValue.desc, newValue.data) break; case 'HSI_Start': - activeIndex = getActiveIndex('HSI') - updateCheckResultView("HSI", true) - updateLog(true) + handleStartItem('HSI', newValue.desc) break; case 'HSI_End': - updatePercentage() - updateCheckResultView("HSI", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('HSI') - //startTimer() - } + handleEndItem('HSI', newValue.desc, newValue.data) break; case 'VOLTAGE_Start': - activeIndex = getActiveIndex('VOLTAGE') - updateCheckResultView("VOLTAGE", true) - updateLog(true) + handleStartItem('VOLTAGE', newValue.desc) break; case 'VOLTAGE_End': - updatePercentage() - updateCheckResultView("VOLTAGE", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('VOLTAGE') - //startTimer() - } + handleEndItem('VOLTAGE', newValue.desc, newValue.data) break; case 'I_Start': - activeIndex = getActiveIndex('I') - updateCheckResultView("I", true) - updateLog(true) + handleStartItem('I', newValue.desc) break; case 'I_End': - updatePercentage() - updateCheckResultView("I", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('I') - //startTimer() - } + handleEndItem('I', newValue.desc, newValue.data) break; case 'IMBV_Start': - activeIndex = getActiveIndex('IMBV') - updateCheckResultView("IMBV", true) - updateLog(true) + handleStartItem('IMBV', newValue.desc) break; case 'IMBV_End': - updatePercentage() - updateCheckResultView("IMBV", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('IMBV') - //startTimer() - } + handleEndItem('IMBV', newValue.desc, newValue.data) break; case 'IMBA_Start': - activeIndex = getActiveIndex('IMBA') - updateCheckResultView("IMBA", true) - updateLog(true) + handleStartItem('IMBA', newValue.desc) break; case 'IMBA_End': - updatePercentage() - updateCheckResultView("IMBA", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('IMBA') - //startTimer() - } + handleEndItem('IMBA', newValue.desc, newValue.data) break; case 'F_Start': - activeIndex = getActiveIndex('F') - updateCheckResultView("F", true) - updateLog(true) + handleStartItem('F', newValue.desc) break; case 'F_End': - updatePercentage() - updateCheckResultView("F", false, newValue.data) - updateLog(false) - if (testStatus.value != 'paused') { - activeIndex = getNextActiveIndex('F') - //startTimer() - } + handleEndItem('F', newValue.desc, newValue.data) break; case 'Quit': console.log('检测结束') @@ -623,6 +530,44 @@ watch(webMsgSend, function (newValue, oldValue) { }, {deep: true}) +const handleStartItem = (code: string, desc: string|undefined) => { + if (desc === undefined) { + activeIndex = getActiveIndex(code) + updateCheckResultView(code, true) + updateLog(true) + } else { + if(desc.length>60){ + desc = desc.substring(0,60) + '...' + } + testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:${desc}准确度检测:开始`}) + } +} + +const handleEndItem = (code: string, desc: string|undefined, devices: CheckData.DeviceCheckResult[] = []) => { + if (desc === undefined) { + updatePercentage() + updateCheckResultView(code, false, devices) + updateLog(false) + if (testStatus.value != 'paused') { + activeIndex = getNextActiveIndex(code) + //startTimer() + } + } else { + let result = getResult(devices) + if(desc.length>60){ + desc = desc.substring(0,60) + '...' + } + if(result === 1){ + testLogList.push({type: 'info', log: `${new Date().toLocaleString()}:${desc}检测结束:符合`}) + } + if(result === 2){ + testLogList.push({type: 'error', log: `${new Date().toLocaleString()}:${desc}检测结束:不符合`}) + } + if(result === 4){ + testLogList.push({type: 'warning', log: `${new Date().toLocaleString()}:${desc}检测结束:数据异常`}) + } + } +} // 更新进度条 const updatePercentage = () => { @@ -716,16 +661,20 @@ const updateCheckResult = (data: CheckData.ScriptChnItem) => { checkResult.forEach(item => { if (item.scriptType == scriptType) { - item.devices.forEach((device, index) => { - let targetDevice = data.devices.find(dev => dev.deviceId === device.deviceId) + for (let i = 0; i < item.devices.length; i++) { + let targetDevice = data.devices.find(dev => dev.deviceId === item.devices[i].deviceId) if (targetDevice !== undefined) { - device.chnResult = [...targetDevice.chnResult] + item.devices[i].chnResult = [...targetDevice.chnResult] } - }) + } + // item.devices.forEach((device, index) => { + // let targetDevice = data.devices.find(dev => dev.deviceId === device.deviceId) + // if (targetDevice !== undefined) { + // device.chnResult = [...targetDevice.chnResult] + // } + // }) } }) - - } const scrollToBottom = () => { @@ -768,12 +717,13 @@ const updateLog = (isStart: boolean) => { let timeDifferenceItem = 0 if (activeIndex === 1 && isStart) { - timeDifference.value = 0; + // timeDifference.value = 0; //testLogList.length = 0; // 清空数组 } // debugger if (activeIndex <= checkTotal) { if (isStart) { + startData.value = new Date(); testLogList.push({ type: 'info', log: currentTime.value + ` :${scriptData[activeIndex - 1].scriptName}准确度检测:开始`, @@ -891,8 +841,8 @@ const updateCheckResultView = (scriptCode: string, isStart: boolean, devices: Ch // } // { // chnResult: [1, 1, 1, 1], - // deviceId: "2957b271f39d4240a1c5e275c453676c", - // deviceName: "测试003" + // deviceId: "461813a4f30f4a34a1a273ecd0379458", + // deviceName: "25011407" // } // ] let temp = null @@ -995,6 +945,23 @@ const getCheckResult = (scriptType: string) => { return tempScriptChnItem } +const getResult=(devices: CheckData.DeviceCheckResult[] = [])=>{ + let type = 1 + let tempChnResult: CheckData.ChnCheckResultEnum[] = [] + for (let i = 0; i < devices.length; i++) { + tempChnResult.push(...devices[i].chnResult) + } + + if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.ERRORDATA)) { + type = CheckData.ChnCheckResultEnum.ERRORDATA + } + if (tempChnResult.some(item => item === CheckData.ChnCheckResultEnum.FAIL)) { + type = CheckData.ChnCheckResultEnum.FAIL + } + return type +} + + // 点击查看(设备)通道检测详情。参数1:设备信息,参数2:通道号,-1:代表查看全部通道 const handleClick = (item: any, chnNum: number, scriptType: string) => { let checkResultItem = checkResult.find(obj => obj.scriptType === scriptType) @@ -1082,14 +1049,7 @@ const startTimer = () => { }, 6000) break; case 1: - emit('update:webMsgSend', { - requestId: 'V_Start' - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'V_End' - }) - }, 2000); + todoItem('V') // setTimeout(() => { // emit('update:webMsgSend', { // requestId: 'FREQ_Start' @@ -1102,14 +1062,7 @@ const startTimer = () => { // }, 2000); break; case 2: - emit('update:webMsgSend', { - requestId: 'I_Start' - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'I_End' - }) - }, 2000) + todoItem('I') // emit('update:webMsgSend', { // requestId: 'V_Start' // }) @@ -1120,14 +1073,7 @@ const startTimer = () => { // }, 2000); break; case 3: - emit('update:webMsgSend', { - requestId: 'IMBV_Start' - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'IMBV_End' - }) - }, 2000) + todoItem('IMBV') // emit('update:webMsgSend', { // requestId: 'HV_Start', // }) @@ -1138,16 +1084,7 @@ const startTimer = () => { // }, 2000) break; case 4: - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'FREQ_Start' - }) - }, 1000) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'FREQ_End' - }) - }, 2000); + todoItem('FREQ') // emit('update:webMsgSend', { // requestId: 'HI_Start' // }) @@ -1158,14 +1095,7 @@ const startTimer = () => { // }, 2000) break; case 5: - emit('update:webMsgSend', { - requestId: 'HV_Start', - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'HV_End' - }) - }, 2000) + todoItem('HV') // emit('update:webMsgSend', { // requestId: 'HP_Start', // }) @@ -1176,14 +1106,7 @@ const startTimer = () => { // }, 2000) break; case 6: - emit('update:webMsgSend', { - requestId: 'HI_Start' - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'HI_End' - }) - }, 2000) + todoItem('HI') // emit('update:webMsgSend', { // requestId: 'HSV_Start' // }) @@ -1194,14 +1117,7 @@ const startTimer = () => { // }, 2000) break; case 7: - emit('update:webMsgSend', { - requestId: 'HSV_Start' - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'HSV_End' - }) - }, 2000) + todoItem('HSV') // emit('update:webMsgSend', { // requestId: 'HSI_Start' // }) @@ -1212,14 +1128,7 @@ const startTimer = () => { // }, 2000) break; case 8: - emit('update:webMsgSend', { - requestId: 'HSI_Start' - }) - setTimeout(() => { - emit('update:webMsgSend', { - requestId: 'HSI_End' - }) - }, 2000) + todoItem('HSI') // emit('update:webMsgSend', { // requestId: 'VOLTAGE_Start' // }) @@ -1269,7 +1178,7 @@ const startTimer = () => { // }) // }, 2000) // break; - case 13: + case 9: emit('update:webMsgSend', { requestId: 'Quit' }) @@ -1293,6 +1202,87 @@ const pauseSuccessCallback = () => { console.log('暂停中') }; +const todoItem = (code:string) => { + emit('update:webMsgSend', { + requestId: `${code}_Start` + }) + setTimeout(() => { + if(testStatus.value !== 'paused'){ + emit('update:webMsgSend', { + requestId: `${code}_Start`, + desc: '输入:频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' + }) + } + }, 1000) + setTimeout(() => { + if (testStatus.value !== 'paused') { + emit('update:webMsgSend', { + requestId: `${code}_End`, + desc: '输入:频率t=42.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', + data: [{ + chnResult: [1, 1, 1, 1], + deviceId: "461813a4f30f4a34a1a273ecd0379458", + deviceName: "25011407" + }] + }) + } + }, 2000) + setTimeout(() => { + if (testStatus.value !== 'paused') { + emit('update:webMsgSend', { + requestId: `${code}_Start`, + desc: '输入:频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' + }) + } + }, 3000) + setTimeout(() => { + if (testStatus.value !== 'paused') { + emit('update:webMsgSend', { + requestId: `${code}_End`, + desc: '输入:频率t=45.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', + data: [{ + chnResult: [1, 1, 1, 1], + deviceId: "461813a4f30f4a34a1a273ecd0379458", + deviceName: "25011407" + }] + }) + } + }, 5000) + setTimeout(() => { + if(testStatus.value !== 'paused'){ + emit('update:webMsgSend', { + requestId: `${code}_Start`, + desc: '输入:频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ' + }) + } + }, 6000) + setTimeout(() => { + if(testStatus.value !== 'paused'){ + emit('update:webMsgSend', { + requestId: `${code}_End`, + desc: '输入:频率t=50.5Hz Ua=57.74%Un,相角=0.0° Ub=57.74%Un,相角=-120.0° Uc=57.74%Un,相角=120.0° Ia=0.0%In,相角=0.0° Ib=0.0%In,相角=0.0° Ic=0.0%In,相角=0.0° ', + data: [{ + chnResult: [1, 2, 1, 1], + deviceId: "461813a4f30f4a34a1a273ecd0379458", + deviceName: "25011407" + }] + }) + } + }, 8000) + setTimeout(() => { + if(testStatus.value !== 'paused'){ + emit('update:webMsgSend', { + requestId: `${code}_End`, + data: [{ + chnResult: [1, 2, 1, 1], + deviceId: "461813a4f30f4a34a1a273ecd0379458", + deviceName: "25011407" + }] + }) + } + }, 9000) +} + const handleResumeTest = () => { //activeIndex++ startData.value = new Date();