This commit is contained in:
sjl
2025-03-12 11:17:12 +08:00
parent 05948aebf5
commit d7cfcc7855
3 changed files with 20 additions and 10 deletions

View File

@@ -287,9 +287,15 @@ 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,()=>{ watch(()=>props.formControl.scriptId,async ()=>{
if(props.formControl.scriptId!=''){ if(props.formControl.scriptId!=''){
getTree()
nextTick(async () => {
await getTree()
console.log('props.formControl.scriptId')
treeRef.value.checkTree()
})
} }
}) })
@@ -357,8 +363,8 @@ const getTree = () => {
tabChange() tabChange()
} }
}) })
//console.log('获取树')
treeRef.value.checkTree()
} }

View File

@@ -23,7 +23,7 @@
</el-tree> </el-tree>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted, watch } from 'vue' import { ref, reactive, onMounted, watch, nextTick } from 'vue'
import { CheckData } from '@/api/check/interface' import { CheckData } from '@/api/check/interface'
import { da } from 'element-plus/es/locale' import { da } from 'element-plus/es/locale'
@@ -130,20 +130,24 @@ function findFirstLeafNode(node: any): any {
} }
const checkTree = () => { const checkTree = () => {
console.log('checkTree11')
console.log('checkTree22',props.treeData.length)
console.log('checkTree33',treeRef.value)
if (props.treeData.length > 0 && treeRef.value) { if (props.treeData.length > 0 && treeRef.value) {
console.log('checkTree44')
const firstNode = props.treeData[0]; const firstNode = props.treeData[0];
const firstLeafNode = findFirstLeafNode(firstNode); const firstLeafNode = findFirstLeafNode(firstNode);
const firstLeafNodeId = firstLeafNode.id; const firstLeafNodeId = firstLeafNode.id;
treeRef.value.setCheckedKeys([firstLeafNodeId]); treeRef.value.setCheckedKeys([firstLeafNodeId]);
} }
} }
// 确保在组件挂载后也执行一次 // 确保在组件挂载后也执行一次
onMounted(() => { onMounted(() => {
console.log('onMounted',props.treeData);
checkTree() nextTick(() => {
checkTree()
});
}); });

View File

@@ -314,7 +314,7 @@ const handleActiveIndexChange = (newActiveIndex: number) => {
// 定义 handleScriptChange 方法 // 定义 handleScriptChange 方法
const handleScriptChange = (value: string) => { const handleScriptChange = (value: string) => {
// 根据业务需求实现具体逻辑 // 根据业务需求实现具体逻辑
console.log('检测脚本变更:', value); //console.log('检测脚本变更:', value);
router.push({ router.push({
path: '/machine/controlSource', path: '/machine/controlSource',
state: { title: '新增检测脚本', row: '', mode: modeStore.currentMode } state: { title: '新增检测脚本', row: '', mode: modeStore.currentMode }