This commit is contained in:
sjl
2025-03-11 11:30:52 +08:00
parent e2559ffa65
commit 7470f697bd
2 changed files with 23 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
<template> <template>
<el-tree <el-tree
node-key="id" node-key="scriptName"
default-expand-all default-expand-all
:data="props.treeData" :data="props.treeData"
:props="defaultProps" :props="defaultProps"
@@ -8,8 +8,10 @@
:expand-on-click-node="false" :expand-on-click-node="false"
:highlight-current="true" :highlight-current="true"
@node-click="handleNodeClick" @node-click="handleNodeClick"
show-checkbox show-checkbox
:check-strictly="true"
@check-change="handleCheckChange" @check-change="handleCheckChange"
ref="treeRef"
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<el-tooltip effect="dark" :content="data.sourceDesc || data.scriptTypeName" placement="top" :hide-after="0"> <el-tooltip effect="dark" :content="data.sourceDesc || data.scriptTypeName" placement="top" :hide-after="0">
@@ -40,6 +42,7 @@ const defaultProps = {
const activeName = ref('') const activeName = ref('')
const childActiveName = ref('') const childActiveName = ref('')
const activeIndex = ref() const activeIndex = ref()
const treeRef = ref()
const handleNodeClick = (data, node) => { const handleNodeClick = (data, node) => {
console.log('handleNodeClick', props.treeData) console.log('handleNodeClick', props.treeData)
if(data.index!= null){ if(data.index!= null){
@@ -99,16 +102,12 @@ function findTargetCodes(data: any[], targetCodes: string[]) {
// return result // return result
} }
function handleCheckChange(data, checked) { function handleCheckChange(data,isChecked) {
if (checked) { console.log('handleCheckChange', data,isChecked)
// Uncheck all other nodes if(isChecked){
console.log('handleCheckChange', data.id) const checked = [data.scriptName]; // id为tree的node-key属性
props.treeData.forEach((node) => { treeRef.value?.setCheckedKeys(checked);
if (node.id !== data.id) { }
node.checked = false;
}
});
}
} }
// // 对外映射 // // 对外映射
// defineExpose({ init }) // defineExpose({ init })

View File

@@ -18,7 +18,7 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label='检测脚本' prop='scriptId'> <el-form-item label='检测脚本' prop='scriptId'>
<el-select v-model="controlContent.scriptId" collapse-tags placeholder="请选择检测脚本"> <el-select v-model="controlContent.scriptId" collapse-tags placeholder="请选择检测脚本" @change="handleScriptChange">
<el-option <el-option
v-for="(option, index) in scriptArray" v-for="(option, index) in scriptArray"
:key="index" :key="index"
@@ -293,7 +293,18 @@ const handleActiveIndexChange = (newActiveIndex: number) => {
scriptIndex.value = newActiveIndex scriptIndex.value = newActiveIndex
} }
// 定义 handleScriptChange 方法
const handleScriptChange = (value: string) => {
// 根据业务需求实现具体逻辑
console.log('检测脚本变更:', value);
router.push({
path: '/machine/controlSource',
state: { title: '新增检测脚本', row: '', mode: modeStore.currentMode }
})
}
const start = async () => { const start = async () => {
controlContent.value.userPageId = 'cdf' controlContent.value.userPageId = 'cdf'
controlContent.value.scriptIndex = scriptIndex.value controlContent.value.scriptIndex = scriptIndex.value
await checkSimulate(controlContent.value) await checkSimulate(controlContent.value)