qtsk-vue3 0.0.45 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package/component.js
CHANGED
@@ -28,6 +28,7 @@ import Skeleton from './components/Skeleton/index.vue'
|
|
28
28
|
import Alert from './components/Alert/index.vue'
|
29
29
|
import PopConfirm from './components/PopConfirm/index.vue'
|
30
30
|
import Drawer from './components/Drawer/index.vue'
|
31
|
+
import TreeSelect from './components/TreeSelect/index.vue'
|
31
32
|
const components =
|
32
33
|
[
|
33
34
|
CommonButton,
|
@@ -59,6 +60,7 @@ const components =
|
|
59
60
|
Alert,
|
60
61
|
PopConfirm,
|
61
62
|
SelectGroup,
|
62
|
-
Drawer
|
63
|
+
Drawer,
|
64
|
+
TreeSelect
|
63
65
|
]
|
64
66
|
export default components
|
@@ -11,6 +11,7 @@
|
|
11
11
|
:default-checked-keys="checkedKeys"
|
12
12
|
@node-click="handleNodeClick"
|
13
13
|
@check-change="checkChange"
|
14
|
+
@check="handleCheck"
|
14
15
|
>
|
15
16
|
<template #default="{ node, data }" v-if="editable">
|
16
17
|
<span class="custom-tree-node">
|
@@ -59,6 +60,13 @@ const props = defineProps({
|
|
59
60
|
labelName: {
|
60
61
|
type: String,
|
61
62
|
default: 'name'
|
63
|
+
},
|
64
|
+
defaultProps : {
|
65
|
+
type: Object,
|
66
|
+
default: () => ({
|
67
|
+
children: 'children',
|
68
|
+
label: 'name'
|
69
|
+
})
|
62
70
|
}
|
63
71
|
})
|
64
72
|
|
@@ -69,11 +77,6 @@ const handleNodeClick = (data) => {
|
|
69
77
|
emits('handleNode', data)
|
70
78
|
}
|
71
79
|
|
72
|
-
const defaultProps = {
|
73
|
-
children: 'children',
|
74
|
-
label: props.labelName
|
75
|
-
}
|
76
|
-
|
77
80
|
// 获取选中的节点
|
78
81
|
const getCheckedKeys = () => {
|
79
82
|
return treeRef.value.getCheckedKeys(false)
|
@@ -81,9 +84,21 @@ const getCheckedKeys = () => {
|
|
81
84
|
|
82
85
|
//当复选框被点击的时候触发, 用于获取所有的选中数据
|
83
86
|
const checkChange = () => {
|
84
|
-
modelValue.value = treeRef.value.getCheckedKeys(
|
87
|
+
// modelValue.value = treeRef.value.getCheckedKeys()
|
88
|
+
}
|
89
|
+
const handleCheck = (currentNode, {checkedKeys}) => {
|
90
|
+
console.log('currentNode', currentNode)
|
91
|
+
let keys = []
|
92
|
+
if (checkedKeys.length) {
|
93
|
+
// 选中时,将当前节点设为唯一选中
|
94
|
+
keys = [currentNode[props.nodeKey]];
|
95
|
+
} else {
|
96
|
+
// 取消选中时,清空所有选中(可选,根据需求决定是否允许取消)
|
97
|
+
keys = [];
|
98
|
+
}
|
99
|
+
modelValue.value = keys
|
100
|
+
treeRef.value.setCheckedKeys(keys);
|
85
101
|
}
|
86
|
-
|
87
102
|
const handleOperations = (data, type) => {
|
88
103
|
emits('handleTree', data, type)
|
89
104
|
}
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<el-tree-select
|
4
|
+
v-model="modelValue"
|
5
|
+
v-bind="$attrs"
|
6
|
+
:data="options"
|
7
|
+
:multiple="multiple"
|
8
|
+
:render-after-expand="false"
|
9
|
+
:show-checkbox="showCheckbox"
|
10
|
+
/>
|
11
|
+
</div>
|
12
|
+
</template>
|
13
|
+
|
14
|
+
<script setup>
|
15
|
+
import { ElTreeSelect } from 'element-plus'
|
16
|
+
|
17
|
+
defineOptions({
|
18
|
+
name: 'TreeSelect',
|
19
|
+
})
|
20
|
+
defineProps({
|
21
|
+
options: {
|
22
|
+
type: Array,
|
23
|
+
default: () => ([])
|
24
|
+
},
|
25
|
+
// 是否多选
|
26
|
+
multiple: {
|
27
|
+
type: Boolean,
|
28
|
+
default: false
|
29
|
+
},
|
30
|
+
// 是否显示复选框
|
31
|
+
showCheckbox: {
|
32
|
+
type: Boolean,
|
33
|
+
default: false
|
34
|
+
},
|
35
|
+
})
|
36
|
+
|
37
|
+
const modelValue = defineModel('modelValue')
|
38
|
+
</script>
|
39
|
+
|
40
|
+
<style lang="less" scoped>
|
41
|
+
</style>
|