From 60145ec4f769bab13330f3c86ce3926f5a37bfb0 Mon Sep 17 00:00:00 2001 From: GGJ <357021191@qq.com> Date: Thu, 27 Mar 2025 18:34:40 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=82=E8=80=83=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A=E5=80=BC=E6=B7=BB=E5=8A=A0=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/controlSourceDetail.vue | 364 +++++++++--------- .../testScript/components/setValueTable.vue | 113 +++++- .../components/testProjectPopup.vue | 1 + .../components/testScriptDetail.vue | 2 +- 4 files changed, 299 insertions(+), 181 deletions(-) diff --git a/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue b/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue index 7152b1e..81e3c03 100644 --- a/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue +++ b/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue @@ -6,7 +6,7 @@
- +
@@ -14,11 +14,11 @@
- + @@ -126,46 +126,52 @@
- - - - - - - - -
-
-
-
Loading...
+ + + + + + + + +
+
+
+
Loading...
+
+
- -
-
-
-
-
Loading
+
+
+
+
Loading
+
+
- -
-
- 标准源加量输出:{{hour}}时{{minute}}分{{second}}秒 -
-
- 启动 - 停止 -
+
+ 标准源加量输出:{{ hour }}时{{ minute }}分{{ second }}秒 +
+
+ + 启动 + + + 停止 + +
@@ -187,12 +193,13 @@ v-if="showDialog" /> - +
@@ -200,9 +207,19 @@ import { type PropType, ref, nextTick, onMounted, watch } from 'vue' import Tree from './tree.vue' import Commun from '@/views/machine/testScript/components//communication.vue' -import {type CascaderOption, ElMessage} from 'element-plus' +import { type CascaderOption, ElMessage } from 'element-plus' import { getTreeData } from '@/api/check/test' -import {CirclePlus, Delete, Check, CopyDocument, View, EditPen, VideoPlay, VideoPause, Loading} from '@element-plus/icons-vue' +import { + CirclePlus, + Delete, + Check, + CopyDocument, + View, + EditPen, + VideoPlay, + VideoPause, + Loading +} from '@element-plus/icons-vue' import type { TestScript } from '@/api/device/interface/testScript' import TestProjectPopup from '@/views/machine/testScript/components/testProjectPopup.vue' import { CheckData } from '@/api/check/interface' @@ -211,7 +228,7 @@ import { useDictStore } from '@/stores/modules/dict' import { useHandleData } from '@/hooks/useHandleData' import { scriptDtlsCheckDataList } from '@/api/device/testScript/index' import ViewRow from '@/views/machine/testScript/components/viewRow.vue' -import { startSimulateTest,closeSimulateTest } from '@/api/device/controlSource/index.ts' +import { startSimulateTest, closeSimulateTest } from '@/api/device/controlSource/index.ts' import { controlSource } from '@/api/device/interface/controlSource' interface TabOption { label?: string @@ -238,17 +255,16 @@ const props = defineProps({ type: Object, required: true }, - startDisabeld: { - type:Boolean, - required:true - }, - pauseDisabled: { - type: Boolean, - required: true - } + startDisabeld: { + type: Boolean, + required: true + }, + pauseDisabled: { + type: Boolean, + required: true + } }) - const showDialog = ref(false) const viewDialog = ref(false) const dictStore = useDictStore() @@ -285,47 +301,47 @@ const hour = ref(0) const minute = ref(0) const second = ref(0) -const emit = defineEmits(['update:activeName','update:activeIndex','update:startDisabeld','update:pauseDisabled']) +const emit = defineEmits(['update:activeName', 'update:activeIndex', 'update:startDisabeld', 'update:pauseDisabled']) -watch(()=>props.formControl.scriptId,async ()=>{ - if(props.formControl.scriptId!=''){ - - nextTick(async () => { - await getTree() - console.log('props.formControl.scriptId') - treeRef.value.checkTree() - }) - - - } -}) +watch( + () => props.formControl.scriptId, + async () => { + if (props.formControl.scriptId != '') { + nextTick(async () => { + await getTree() + console.log('props.formControl.scriptId') + treeRef.value.checkTree() + }) + } + } +) const controlContent = ref({ - userPageId: '', - scriptId: '', - scriptIndex: 0, - sourceId: '', + userPageId: '', + scriptId: '', + scriptIndex: 0, + sourceId: '' }) // 获取树 const getTree = () => { getTreeData({ - scriptId: props.formControl.scriptId, + scriptId: props.formControl.scriptId }).then(res => { if (res.code === 'A0000') { treeData.value = res.data //console.log('tree',res.data) // 为 treeData 及其子节点添加 id - let idCounter = 0; + let idCounter = 0 const addIdToTree = (nodes: any[]) => { nodes.forEach(node => { - node.id = idCounter++; // 为每个节点添加唯一的 id + node.id = idCounter++ // 为每个节点添加唯一的 id if (node.children && node.children.length > 0) { node.disabled = true - addIdToTree(node.children); // 递归为子节点添加 id + addIdToTree(node.children) // 递归为子节点添加 id } - }); - }; + }) + } - addIdToTree(treeData.value); + addIdToTree(treeData.value) // 添加tab子项 props.options.forEach((k: any, i: number) => { @@ -335,7 +351,6 @@ const getTree = () => { item.children.forEach((s: any) => { k.children.forEach((P: any) => { if (P.code == s.scriptTypeCode) { - tabData.value[i].children.push({ label: P.label, value: P.code, @@ -357,17 +372,15 @@ const getTree = () => { } }) }) - + //console.log('2222',treeData.value) tabChange() } }) //console.log('获取树') - } - // 设置树点击tab const setTab = row => { activeName.value = row.activeName @@ -396,8 +409,6 @@ const tabChange = () => { childActiveName.value = tabData.value.filter((item: any) => item.value == activeName.value)[0]?.children[0]?.value || '' } - - } inquireTable() } @@ -425,13 +436,11 @@ const inquireTable = () => { //console.log('treeData',treeData.value) } - // 查看 const view = (row: Partial = {}) => { - getCommunication() //当前点击的一级tab - const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称'; + const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称' //当前点击的二级tab const childrenTabName = ref('') tabData.value.forEach((item: any) => { @@ -445,25 +454,23 @@ const view = (row: Partial = {}) => { }) viewDialog.value = true setTimeout(() => { - viewRowRef.value?.open(row, communicationList.value, parentTabName, childrenTabName.value) }, 0) - } // 定义 startLoading 方法 const startLoading = async () => { - emit('update:startDisabeld', true) - emit('update:pauseDisabled', true) - ElMessage.success({message:'启动中...',duration:6000}) + emit('update:startDisabeld', true) + emit('update:pauseDisabled', true) + ElMessage.success({ message: '启动中...', duration: 6000 }) // 启动加载逻辑 controlContent.value.userPageId = 'cdf' controlContent.value.scriptId = props.formControl.scriptId controlContent.value.scriptIndex = childActiveIndex.value - controlContent.value.sourceId = props.formControl.sourceId - setTimeout(async () => { - await startSimulateTest(controlContent.value) - },3000) + controlContent.value.sourceId = props.formControl.sourceId + setTimeout(async () => { + await startSimulateTest(controlContent.value) + }, 3000) } // 定义 startLoading 方法 @@ -472,44 +479,43 @@ const stopLoading = async () => { controlContent.value.userPageId = 'cdf' controlContent.value.scriptId = props.formControl.scriptId controlContent.value.scriptIndex = childActiveIndex.value - controlContent.value.sourceId = props.formControl.sourceId + controlContent.value.sourceId = props.formControl.sourceId await closeSimulateTest(controlContent.value) emit('update:pauseDisabled', true) emit('update:startDisabeld', true) - ElMessage.success({message:'停止中...',duration:5000}) + ElMessage.success({ message: '停止中...', duration: 5000 }) } - const startTimeCount = () => { - // Loading效果展示 - showLoading.value = true + // Loading效果展示 + showLoading.value = true - if (!timer) { - hour.value = 0 - minute.value = 0 - second.value = 0 - timeCount.value = 0 - timer = setInterval(() => { - timeCount.value = timeCount.value + 1 - secondToTime(timeCount.value) - }, 1000) - } + if (!timer) { + hour.value = 0 + minute.value = 0 + second.value = 0 + timeCount.value = 0 + timer = setInterval(() => { + timeCount.value = timeCount.value + 1 + secondToTime(timeCount.value) + }, 1000) + } } const secondToTime = (secd: number) => { - //将秒数转换成时分秒 - hour.value = Math.floor(secd / 3600) - minute.value = Math.floor((secd - hour.value * 3600) / 60) - second.value = Math.floor(secd % 60); + //将秒数转换成时分秒 + hour.value = Math.floor(secd / 3600) + minute.value = Math.floor((secd - hour.value * 3600) / 60) + second.value = Math.floor(secd % 60) } const stopTimeCount = () => { - if (timer) { - clearInterval(timer) - timer = null - } - //Loading效果关闭 - showLoading.value = false + if (timer) { + clearInterval(timer) + timer = null + } + //Loading效果关闭 + showLoading.value = false } // 获取左边树数据 @@ -519,7 +525,6 @@ const addTab = (row: any) => { } onMounted(() => { - getTree() props.options.forEach((item: any) => { tabData.value.push({ @@ -537,8 +542,8 @@ onMounted(() => { }) defineExpose({ - startTimeCount, - stopTimeCount + startTimeCount, + stopTimeCount })