优化项目
This commit is contained in:
@@ -52,6 +52,7 @@ import useCurrentInstance from '@/utils/useCurrentInstance'
|
||||
import { ElMessage, ElTree } from 'element-plus'
|
||||
import { ref, watch } from 'vue'
|
||||
import { createTreeFilterNode } from './govern/treeFilterUtils'
|
||||
import { isLineTreeLeaf } from './govern/lineTreeUtils'
|
||||
|
||||
defineOptions({ name: 'govern/select', inheritAttrs: false })
|
||||
|
||||
@@ -75,7 +76,8 @@ const filterNode = createTreeFilterNode()
|
||||
const checkedNodes = ref<any[]>([])
|
||||
const defaultCheckedKeys = ref<string[]>([])
|
||||
const MAX_CHECK = 5
|
||||
const MONITOR_LEVEL = 3
|
||||
|
||||
const isMonitorLeaf = (node: any) => isLineTreeLeaf(node)
|
||||
|
||||
watch(filterText, val => treeRef.value?.filter(val))
|
||||
|
||||
@@ -85,7 +87,7 @@ const onMenuCollapse = () => {
|
||||
}
|
||||
|
||||
const handleCheckChange = (_data: any, checkInfo: any) => {
|
||||
const monitoringPointNodes = (checkInfo.checkedNodes as any[]).filter(node => node.level === MONITOR_LEVEL)
|
||||
const monitoringPointNodes = (checkInfo.checkedNodes as any[]).filter(isMonitorLeaf)
|
||||
|
||||
if (monitoringPointNodes.length > MAX_CHECK) {
|
||||
const previousCheckedNodes = checkedNodes.value
|
||||
@@ -122,7 +124,7 @@ const updateNodeCheckStatus = (currentCount: number) => {
|
||||
if (!treeRef.value) return
|
||||
const isMaxSelected = currentCount >= MAX_CHECK
|
||||
treeRef.value.store._getAllNodes().forEach((node: any) => {
|
||||
if (node.level === MONITOR_LEVEL) {
|
||||
if (isMonitorLeaf(node.data)) {
|
||||
node.data.disabled = isMaxSelected && !node.checked
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user