wujingjing
2025-02-17 0f01c4bbce19fa8489a4e835c83cb9415549f681
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
import type { AllowDropType, NodeDropType } from 'element-plus/es/components/tree/src/tree.type';
import { buildProps, definePropType } from 'element-plus/es/utils/vue/props/runtime';
import type { ExtractPropTypes, PropType } from 'vue';
import type Node from 'element-plus/es/components/tree/src/model/node';
 
export const leftTreeProps = buildProps({
    /**树数据 */
    treedata: {
        type: Array,
        default: () => {
            return [];
        },
    },
    
    /**下拉选择数据 */
    selectData: {
        type: Array,
        default: () => {
            return [];
        },
    },
 
    /**下拉选择是否显示 */
    selectIsShow: {
        type: Boolean,
        default: false,
    },
    expandOnClickNode: {
        type: Boolean,
        default: false,
    },
    /**树 默认属性配置 */
    defaultProps: {
        type: Object,
        default: () => {
            return {
                children: 'children',
                label: 'title',
                id: 'id',
            };
        },
    },
    /**下拉树 默认属性配置 */
    selectProps: {
        type: Object,
        default: () => {
            return {
                children: 'children',
                label: 'title',
                id: 'id',
            };
        },
    },
    /**树 默认选中节点key */
    currentNodeKey: {
        type: String,
        default: '',
    },
    /**下拉 默认选中值 */
    defaultSelectValue: {
        type: [String, Number],
        default: '',
    },
    /**树 默认展开节点keys */
    defaultExpandedKeys: {
        type: Array<any>,
        default: () => {
            return [];
        },
    },
    /**左侧树 标题名称 */
    titleName: {
        type: String,
        default: '功能位置',
    },
    /**是否显示右侧更多操作图标,默认为编辑和删除 */
    showMoreOperate: {
        type: [Boolean, Function],
        default: false,
    },
 
    /**是否可以清空选项 */
    clearable: {
        type: Boolean,
        default: false,
    },
    /**是否可以收起 */
    accordion: {
        type: Boolean,
        default: false,
    },
    /**是否点击叶子才关闭下拉框 */
    isleafclose: {
        type: Boolean,
        default: false,
    },
    /**是否默认展开全部 */
    defaultExpandAll: {
        type: Boolean,
        default: false,
    },
    /**选择是否默认展开全部 */
    selectDefaultExpandAll: {
        type: Boolean,
        default: true,
    },
    /**需要先开启 showMoreOperate,自定义一个在更多操作中的dropwDownMenu,自己加入操作 */
    customDropdown: {
        type: Boolean,
        default: false,
    },
    /**树是否存在添加数据操作 */
    showAdd: {
        type: Boolean,
        default: false,
    },
    /**是否展示顶部标题 */
    showTitle: {
        type: Boolean,
        default: true,
    },
    /** 树列表是否展示 checkbox */
    showCheckbox: {
        type: Boolean,
        default: false,
    },
    //树列表是否默认勾选中第一个
    checkBoxCurrentIDs: {
        type: Array<any>,
        default: () => {
            return [];
        },
    },
    /** 树列表是否有 checkStrictly */
    checkStrictly: {
        type: Boolean,
        default: false,
    },
    /**自定义展示 Folder 图标时机,返回为 true 的展示 folder,否则展示为 document。
     * 默认只在最大层 level 展示 Document,其余层 node 均展示 Folder
     */
    folderIcon: {
        type: Function as PropType<(node, data) => Boolean>,
        default: null,
    },
    /**
     * 自定义带 tooltip 的label
     */
    tooltip:{
        type:definePropType<(node,data)=>string>(Function),
 
    },
    /**
     * 自定义节点 icon
     */
    nodeIcon: {
        type: Function as PropType<(node, data) => String>,
        default: null,
    },
 
    /**
     * 是否展示树搜索框,默认展示
     */
    searchIsShow: {
        type: Boolean,
        default: true,
    },
    /**
     * 节点是否带 icon
     */
    showNodeIcon: {
        type: Boolean,
        default: true,
    },
    /**
     * 是否展示排序按钮
     */
    showSorter: {
        type: Boolean,
        Default: false,
    },
    /**
     * 自定义拖拽可释放节点区域(已禁用跨级拖拽)
     */
    allowDropNode: {
        type: Function as PropType<(draggingNode: Node, dropNode: Node, type: AllowDropType) => Boolean>,
        default: () => true,
    },
    /**
     * 自定义可拖拽节点
     */
    allowDragNode: {
        type: Function as PropType<(node: Node) => Boolean>,
        default: () => true,
    },
    /**
     * 是否可拖拽(showSorter 为 true 时,不需要设置改属性)
     */
    draggable: {
        type: Boolean,
        default: () => false,
    },
    /**
     * 是否高亮当前点击的树节点
     */
    highlightCurrent: {
        type: Boolean,
        default: () => true,
    },
    /**
     * 是否展示选择节点图标
     */
    showSelectNodeIcon: {
        type: Boolean,
        default: false,
    },
    /**
     * 选择自定义节点 icon
     */
    selectNodeIcon: {
        type: Function as PropType<(node, data) => String>,
        default: null,
    },
    /**
     * 选择节点文件夹图标显示自定义
     */
    selectFolderIcon: {
        type: Function as PropType<(node, data) => Boolean>,
        default: null,
    },
    /** @description 列表树节点,图标后缀 */
    suffixIcon: {
        type: Function as PropType<(node, data) => string | { name: string; color: string }>,
    },
} as const);
 
export const leftTreeEmits = {
    treeEdit: (data: any, node: any) => true,
    treeDelete: (data: any, node: any) => true,
    treeAdd: () => true,
    selectchange: (node: any) => true,
    nodeDragEnd: (draggingNode: Node, dropNode: Node, dropType: NodeDropType, ev: DragEvent, originTreeData: any[]) => true,
    nodeDragStart: (draggingNode: Node, ev: DragEvent) => true,
    click: (data: any) => true,
    check: (data: any, obj) => true,
    treeSearchClear: () => true,
};
export type LeftTreeProps = ExtractPropTypes<typeof leftTreeProps>;
 
export type LeftTreeEmits = typeof leftTreeEmits;