qtsk-vue3 0.0.46 → 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.
@@ -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(false)
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qtsk-vue3",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "description": "vue3版组件库",
5
5
  "main": "./package/index.js",
6
6
  "scripts": {