From d3a74e830f3891a82c57b66985c2fdec107a7d4c Mon Sep 17 00:00:00 2001 From: sjl <1716605279@qq.com> Date: Fri, 7 Mar 2025 14:00:20 +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 --- .../src/api/device/interface/controlSource.ts | 2 +- .../components/controlSourceDetail.vue | 37 +++++++++++++++++++ .../machine/controlSource/components/tree.vue | 9 +++-- .../src/views/machine/controlSource/index.vue | 24 +++++++++--- 4 files changed, 62 insertions(+), 10 deletions(-) diff --git a/frontend/src/api/device/interface/controlSource.ts b/frontend/src/api/device/interface/controlSource.ts index 91cb255..7557244 100644 --- a/frontend/src/api/device/interface/controlSource.ts +++ b/frontend/src/api/device/interface/controlSource.ts @@ -9,7 +9,7 @@ export namespace controlSource { export interface ResControl { userPageId: string; scriptId: string; - scriptIndex: string; + scriptIndex: number; sourceId: string; } } \ No newline at end of file diff --git a/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue b/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue index f60a12f..8b9aee7 100644 --- a/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue +++ b/frontend/src/views/machine/controlSource/components/controlSourceDetail.vue @@ -179,6 +179,8 @@ 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 { controlSource } from '@/api/device/interface/controlSource' interface TabOption { label?: string name?: string @@ -197,6 +199,10 @@ const props = defineProps({ formContent: { type: Object, required: true + }, + formControl: { + type: Object, + required: true } }) const showDialog = ref(false) @@ -204,6 +210,7 @@ const viewDialog = ref(false) const dictStore = useDictStore() const activeName = ref('') const childActiveName = ref('') +const childActiveIndex = ref(0) const firstName = 'first' const viewRowRef = ref() const communicationList = ref([]) @@ -226,6 +233,14 @@ const column = ref([ num: 4 } ]) + +const emit = defineEmits(['update:activeName','update:activeIndex']) +const controlContent = ref({ + userPageId: '', + scriptId: '', + scriptIndex: 0, + sourceId: '', +}) // 获取树 const getTree = () => { getTreeData({ @@ -273,7 +288,10 @@ const getTree = () => { const setTab = row => { activeName.value = row.activeName childActiveName.value = row.childActiveName + childActiveIndex.value = row.activeIndex getTree() + emit('update:activeName', activeName.value) // 触发事件并传递 activeName.value + emit('update:activeIndex', row.activeIndex) // 触发事件并传递 activeName.value } const copyActiveName = ref('') // 获取通讯脚本点击 @@ -353,6 +371,25 @@ const view = (row: Partial = {}) => { } +// 定义 startLoading 方法 +const startLoading = async () => { + // 启动加载逻辑 + controlContent.value.userPageId = 'cdf' + controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57' + controlContent.value.scriptIndex = props.formControl.scriptIndex + controlContent.value.sourceId = props.formControl.sourceId + await startSimulateTest(controlContent.value) +} + +// 定义 startLoading 方法 +const stopLoading = async () => { + // 启动加载逻辑 + controlContent.value.userPageId = 'cdf' + controlContent.value.scriptId = '9ff96807cf8c7524587982ed8baa8b57' + controlContent.value.scriptIndex = childActiveIndex.value + controlContent.value.sourceId = props.formControl.sourceId + await closeSimulateTest(controlContent.value) +} // 获取左边树数据 // 新增保存 diff --git a/frontend/src/views/machine/controlSource/components/tree.vue b/frontend/src/views/machine/controlSource/components/tree.vue index add0298..a764034 100644 --- a/frontend/src/views/machine/controlSource/components/tree.vue +++ b/frontend/src/views/machine/controlSource/components/tree.vue @@ -9,7 +9,7 @@ :highlight-current="true" @node-click="handleNodeClick" show-checkbox - @check-change="handleCheckChange" + @check-change="handleCheckChange" >