|
@@ -2,8 +2,9 @@
|
|
<div>
|
|
<div>
|
|
<el-dialog v-model="dialogVisible" draggable title="选择装置" width="30%" @close="sureclose"
|
|
<el-dialog v-model="dialogVisible" draggable title="选择装置" width="30%" @close="sureclose"
|
|
:close-on-click-modal="false">
|
|
:close-on-click-modal="false">
|
|
- <el-tree :data="treeList" :props="treeProps" @check-change="handleNodeClick" show-checkbox
|
|
|
|
- style="height: 300px;overflow-y: auto;" />
|
|
|
|
|
|
+ <el-input v-model="filterText" style="width: 480px;margin-left: 23px;" placeholder="输入关键词查找,区分大小写" />
|
|
|
|
+ <el-tree ref="treeRef" :data="treeList" :props="treeProps" :filter-node-method="filterNode"
|
|
|
|
+ @check-change="handleNodeClick" show-checkbox style="height: 300px;overflow-y: auto;" />
|
|
<template #footer>
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<span class="dialog-footer">
|
|
<el-button @click="cleanBox">取消</el-button>
|
|
<el-button @click="cleanBox">取消</el-button>
|
|
@@ -39,9 +40,14 @@ export default {
|
|
label: "label",
|
|
label: "label",
|
|
id: "id",
|
|
id: "id",
|
|
})
|
|
})
|
|
|
|
+ let filterText = ref("")//树形节点过滤
|
|
|
|
+ let treeRef = ref()//树形节点的ref
|
|
watch(() => props.loadScdId, (newVal) => {
|
|
watch(() => props.loadScdId, (newVal) => {
|
|
resultId.value = newVal
|
|
resultId.value = newVal
|
|
})
|
|
})
|
|
|
|
+ watch(filterText, (val) => {
|
|
|
|
+ treeRef.value?.filter(val)
|
|
|
|
+ })
|
|
function reload() {
|
|
function reload() {
|
|
dialogVisible.value = props.iedModal
|
|
dialogVisible.value = props.iedModal
|
|
resultId.value = props.loadScdId
|
|
resultId.value = props.loadScdId
|
|
@@ -49,7 +55,7 @@ export default {
|
|
if (res.data != null) {
|
|
if (res.data != null) {
|
|
treeList.value = res.data.map(item => {
|
|
treeList.value = res.data.map(item => {
|
|
return {
|
|
return {
|
|
- label: "["+item.ied_name + "] " + item.attr_desc,
|
|
|
|
|
|
+ label: "[" + item.ied_name + "] " + item.attr_desc,
|
|
id: item.ied_id,
|
|
id: item.ied_id,
|
|
ied_name: item.ied_name,
|
|
ied_name: item.ied_name,
|
|
attr_desc: item.attr_desc
|
|
attr_desc: item.attr_desc
|
|
@@ -72,14 +78,18 @@ export default {
|
|
if (existingIndex === -1) {
|
|
if (existingIndex === -1) {
|
|
// 如果 e.id 不在 checkArr 中,则将 e 添加到 checkArr
|
|
// 如果 e.id 不在 checkArr 中,则将 e 添加到 checkArr
|
|
checkArr.value.push(e);
|
|
checkArr.value.push(e);
|
|
- console.log(checkArr.value,'添加');
|
|
|
|
|
|
+ console.log(checkArr.value, '添加');
|
|
} else {
|
|
} else {
|
|
// 如果 e.id 已经在 checkArr 中,则从 checkArr 中删除
|
|
// 如果 e.id 已经在 checkArr 中,则从 checkArr 中删除
|
|
checkArr.value.splice(existingIndex, 1);
|
|
checkArr.value.splice(existingIndex, 1);
|
|
- console.log(checkArr.value,'删除');
|
|
|
|
|
|
+ console.log(checkArr.value, '删除');
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+ const filterNode = (value, data) => {
|
|
|
|
+ if (!value) return true
|
|
|
|
+ return data.label.includes(value)
|
|
|
|
+ }
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
reload()
|
|
reload()
|
|
@@ -94,6 +104,9 @@ export default {
|
|
treeProps,
|
|
treeProps,
|
|
handleNodeClick,
|
|
handleNodeClick,
|
|
checkArr,
|
|
checkArr,
|
|
|
|
+ filterText,//树形节点过滤
|
|
|
|
+ treeRef,//树形节点的ref
|
|
|
|
+ filterNode,//筛选树形节点数据方法
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|