diff --git a/src/components/DraggableDepTree/index.vue b/src/components/DraggableDepTree/index.vue index 1102d22..6259ff7 100644 --- a/src/components/DraggableDepTree/index.vue +++ b/src/components/DraggableDepTree/index.vue @@ -45,7 +45,7 @@ :data="state.treeDataList" :expand-on-click-node="false" node-key="id" - highlight-current + :highlight-current="nodeClickable ? true : false" default-expand-all show-checkbox @node-click="handleNodeClick" @@ -63,7 +63,7 @@ @change="handleSwitchChange" :inactive-text="switchInactiveText" :active-text="switchActiveText" - :disabled="state.checkedTreeNodes.length > 0" + :disabled="nodeClickable && state.checkedTreeNodes.length > 0" /> @@ -101,6 +101,7 @@ const props = withDefaults( showExpand?: boolean // 折叠控制 query?: (searchName?: string) => Promise // 查询函数 props?: object + nodeClickable?: boolean switchInactiveText?: string | undefined switchActiveText?: string | undefined defaultTreeWidth?: number | string @@ -116,6 +117,7 @@ const props = withDefaults( value: "id", } }, + nodeClickable: true, switchInactiveText: "当前级", switchActiveText: "当前级及子级", defaultTreeWidth: 20, @@ -177,6 +179,7 @@ const handleSearchInputChange = () => { // 点击树形结构节点 const handleNodeClick = (nodeData: any) => { + if (!props.nodeClickable) return state.curClickedNode = nodeData emit("getSelectNode", state.curClickedNode, state.checkedTreeNodes, state.switch) } @@ -186,7 +189,7 @@ const handleCheck = (data: any, checkStatus: any) => { const { checkedNodes } = checkStatus console.log("checkedNodes", checkedNodes) state.checkedTreeNodes = checkedNodes - if (state.checkedTreeNodes.length > 0) { + if (props.nodeClickable && state.checkedTreeNodes.length > 0) { state.switch = false } emit("getSelectNode", state.curClickedNode, state.checkedTreeNodes, state.switch) @@ -204,16 +207,6 @@ const toggleRowExpansionAll = (status: boolean) => { } } -// 勾选树节点时关闭switch -watch( - () => state.checkedTreeNodes, - (val) => { - if (state.checkedTreeNodes.length > 0) { - state.switch = false - } - }, -) - // 重置数据 const resetData = () => { state.searchName = "" diff --git a/src/views/hard/hard-dept-total/index.vue b/src/views/hard/hard-dept-total/index.vue index 0be3693..883fc14 100644 --- a/src/views/hard/hard-dept-total/index.vue +++ b/src/views/hard/hard-dept-total/index.vue @@ -6,9 +6,10 @@ placeholder="请输入部门名称" :show-expand="true" @getSelectNode="handleGetSelectNode" - switch-inactive-text="当前部门" - switch-active-text="当前部门及子部门" + switch-inactive-text="包含" + switch-active-text="不包含" :defaultTreeWidth="20" + :nodeClickable="false" >