组件改动
This commit is contained in:
1 parent
1dd21a5061
commit
69b54f260b
13 files changed
+110
-207
No files matched your search
@@ -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"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,6 +101,7 @@ const props = withDefaults(
|
||||
showExpand?: boolean // 折叠控制
|
||||
query?: (searchName?: string) => Promise<any> // 查询函数
|
||||
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 = ""
|
||||
|
||||
Reference in new issue
Block a user