@ebiz/designer-components 0.0.18-beta.26 → 0.0.18-beta.28
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/dist/designer-components.css +1 -1
- package/dist/index.mjs +17956 -17673
- package/package.json +1 -1
- package/src/apiService/simpleDataService.js +0 -1
- package/src/components/EbizTree.vue +12 -0
- package/src/components/EbizTreeSelector.vue +517 -0
- package/src/index.js +160 -158
- package/src/router/index.js +285 -271
- package/src/views/Home.vue +121 -97
- package/src/views/TreeDemo.vue +37 -25
- package/src/views/TreeSelectorDemo.vue +246 -0
package/src/views/Home.vue
CHANGED
@@ -1,98 +1,122 @@
|
|
1
|
-
<template>
|
2
|
-
<div class="home">
|
3
|
-
<h1
|
4
|
-
<div class="component-list">
|
5
|
-
<div v-for="(item, index) in components" :key="index" class="component-item">
|
6
|
-
<router-link :to="item.path" class="component-link">
|
7
|
-
{{ item.title }}
|
8
|
-
</router-link>
|
9
|
-
</div>
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
{ path: '/
|
30
|
-
{ path: '/
|
31
|
-
{ path: '/
|
32
|
-
{ path: '/
|
33
|
-
{ path: '/
|
34
|
-
{ path: '/
|
35
|
-
{ path: '/
|
36
|
-
{ path: '/
|
37
|
-
{ path: '/tdesign-
|
38
|
-
{ path: '/tdesign-
|
39
|
-
{ path: '/tdesign-
|
40
|
-
{ path: '/
|
41
|
-
{ path: '/
|
42
|
-
{ path: '/
|
43
|
-
{ path: '/
|
44
|
-
{ path: '/
|
45
|
-
{ path: '/
|
46
|
-
{ path: '/
|
47
|
-
{ path: '/
|
48
|
-
{ path: '/
|
49
|
-
{ path: '/
|
50
|
-
{ path: '/
|
51
|
-
{ path: '/
|
52
|
-
{ path: '/
|
53
|
-
{ path: '/
|
54
|
-
{ path: '/
|
55
|
-
{ path: '/
|
56
|
-
{ path: '/
|
57
|
-
{ path: '/
|
58
|
-
{ path: '/
|
59
|
-
{ path: '/
|
60
|
-
{ path: '/
|
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
|
-
}
|
1
|
+
<template>
|
2
|
+
<div class="home">
|
3
|
+
<h1>Ebiz 组件库</h1>
|
4
|
+
<div class="component-list">
|
5
|
+
<div v-for="(item, index) in components" :key="index" class="component-item">
|
6
|
+
<router-link :to="item.path" class="component-link">
|
7
|
+
{{ item.title }}
|
8
|
+
</router-link>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<router-link to="/tree-demo" class="component-item">
|
12
|
+
<div class="component-title">树组件</div>
|
13
|
+
<div class="component-desc">用于展示层级结构和操作的组件</div>
|
14
|
+
</router-link>
|
15
|
+
|
16
|
+
<router-link to="/tree-selector-demo" class="component-item">
|
17
|
+
<div class="component-title">树形选择器</div>
|
18
|
+
<div class="component-desc">基于树组件的选择器,支持搜索和多选</div>
|
19
|
+
</router-link>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<script>
|
25
|
+
export default {
|
26
|
+
name: 'Home',
|
27
|
+
setup() {
|
28
|
+
const components = [
|
29
|
+
{ path: '/my-component', title: '基础组件示例' },
|
30
|
+
{ path: '/table', title: '表格组件示例' },
|
31
|
+
{ path: '/form', title: '表单组件示例' },
|
32
|
+
{ path: '/button', title: '按钮组件示例' },
|
33
|
+
{ path: '/tdesign-button', title: 'TDesign按钮组件示例' },
|
34
|
+
{ path: '/tdesign-icon', title: 'TDesign图标组件示例' },
|
35
|
+
{ path: '/tdesign-input', title: 'TDesign输入框组件示例' },
|
36
|
+
{ path: '/tdesign-select', title: 'TDesign选择器组件示例' },
|
37
|
+
{ path: '/tdesign-form', title: 'TDesign表单组件示例' },
|
38
|
+
{ path: '/tdesign-card', title: 'TDesign卡片组件示例' },
|
39
|
+
{ path: '/tdesign-date-picker', title: 'TDesign日期选择器示例' },
|
40
|
+
{ path: '/tdesign-image', title: 'TDesign图片组件示例' },
|
41
|
+
{ path: '/tdesign-image-viewer', title: 'TDesign图片查看器组件示例' },
|
42
|
+
{ path: '/data-container', title: '数据容器示例' },
|
43
|
+
{ path: '/title', title: '标题组件示例' },
|
44
|
+
{ path: '/okr-tree', title: 'OKR树形图示例' },
|
45
|
+
{ path: '/remote-select', title: '远程选择器示例' },
|
46
|
+
{ path: '/mindmap', title: '思维导图示例' },
|
47
|
+
{ path: '/tdesign-calendar', title: 'TDesign日历组件示例' },
|
48
|
+
{ path: '/tdesign-collapse', title: 'TDesign折叠面板组件示例' },
|
49
|
+
{ path: '/tdesign-tag', title: 'TDesign标签组件示例' },
|
50
|
+
{ path: '/ebiz-swiper', title: 'Ebiz轮播框组件示例' },
|
51
|
+
{ path: '/ebiz-space', title: 'Ebiz间距组件示例' },
|
52
|
+
{ path: '/pagination', title: 'EbizPagination分页组件示例' },
|
53
|
+
{ path: '/checkbox', title: 'Ebiz多选框组件示例' },
|
54
|
+
{ path: '/radio', title: 'Ebiz单选框组件示例' },
|
55
|
+
{ path: '/switch', title: 'Ebiz开关组件示例' },
|
56
|
+
{ path: '/textarea', title: 'Ebiz多行文本框组件示例' },
|
57
|
+
{ path: '/upload', title: 'TDesign上传组件示例' },
|
58
|
+
{ path: '/grid', title: 'TDesign栅格组件示例' },
|
59
|
+
{ path: '/tabs', title: 'Ebiz选项卡组件示例' },
|
60
|
+
{ path: '/statistic', title: 'Ebiz统计数值组件示例' },
|
61
|
+
{ path: '/timeline', title: 'Ebiz时间轴组件示例' },
|
62
|
+
{ path: '/watermark', title: 'TDesign水印组件示例' },
|
63
|
+
{ path: '/ebiz-avatar', title: 'Ebiz头像组件示例' },
|
64
|
+
{ path: '/ebiz-employee-info', title: 'Ebiz员工信息组件示例' },
|
65
|
+
{ path: '/tdesign-alert', title: 'TDesign提示组件示例' },
|
66
|
+
{ path: '/tdesign-dialog', title: 'TDesign对话框组件示例' },
|
67
|
+
{ path: '/table-demo', title: 'Ebiz表格组件示例' },
|
68
|
+
{ path: '/table-column', title: 'Ebiz表格列组件示例' },
|
69
|
+
{ path: '/table-sort', title: 'Ebiz表格排序组件示例' },
|
70
|
+
{ path: '/tree', title: 'Ebiz树组件示例' }
|
71
|
+
]
|
72
|
+
|
73
|
+
return {
|
74
|
+
components
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
</script>
|
79
|
+
|
80
|
+
<style scoped>
|
81
|
+
.home {
|
82
|
+
padding: 20px;
|
83
|
+
}
|
84
|
+
|
85
|
+
.component-list {
|
86
|
+
display: grid;
|
87
|
+
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
88
|
+
gap: 20px;
|
89
|
+
margin-top: 20px;
|
90
|
+
}
|
91
|
+
|
92
|
+
.component-item {
|
93
|
+
background: #f5f5f5;
|
94
|
+
padding: 20px;
|
95
|
+
border-radius: 8px;
|
96
|
+
text-align: center;
|
97
|
+
}
|
98
|
+
|
99
|
+
.component-link {
|
100
|
+
color: #333;
|
101
|
+
text-decoration: none;
|
102
|
+
font-size: 16px;
|
103
|
+
}
|
104
|
+
|
105
|
+
.component-link:hover {
|
106
|
+
color: #1890ff;
|
107
|
+
}
|
108
|
+
|
109
|
+
.component-title {
|
110
|
+
font-size: 16px;
|
111
|
+
font-weight: bold;
|
112
|
+
margin-bottom: 10px;
|
113
|
+
}
|
114
|
+
|
115
|
+
.component-desc {
|
116
|
+
font-size: 14px;
|
117
|
+
}
|
118
|
+
|
119
|
+
.component-item:hover {
|
120
|
+
background-color: #e6e6e6;
|
121
|
+
}
|
98
122
|
</style>
|
package/src/views/TreeDemo.vue
CHANGED
@@ -1,62 +1,63 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="tree-demo">
|
3
3
|
<h1>树组件示例</h1>
|
4
|
-
|
4
|
+
|
5
5
|
<h2>基础树</h2>
|
6
6
|
<div class="demo-section">
|
7
7
|
<EbizTree :items="treeData" />
|
8
8
|
</div>
|
9
|
-
|
9
|
+
|
10
10
|
<h2>可选择的树</h2>
|
11
11
|
<div class="demo-section">
|
12
|
-
<EbizTree
|
13
|
-
:items="treeData"
|
14
|
-
checkable
|
15
|
-
v-model="checkedValue"
|
16
|
-
@change="handleChange"
|
17
|
-
/>
|
12
|
+
<EbizTree :items="treeData" checkable v-model="checkedValue" @change="handleChange" />
|
18
13
|
<div class="result-panel">
|
19
14
|
<p>当前选中值: {{ checkedValue.join(', ') }}</p>
|
20
15
|
</div>
|
21
16
|
</div>
|
22
|
-
|
17
|
+
|
18
|
+
<h2>带禁用节点的树</h2>
|
19
|
+
<div class="demo-section">
|
20
|
+
<EbizTree :items="treeData" checkable :disable-check="disableTreeNode" />
|
21
|
+
<div class="description">
|
22
|
+
<p>通过 disableCheck 函数自定义禁用节点,所有值为"1.1"的节点无法被勾选</p>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
23
26
|
<h2>带连接线的树</h2>
|
24
27
|
<div class="demo-section">
|
25
|
-
<EbizTree
|
26
|
-
:items="treeData"
|
27
|
-
line
|
28
|
-
v-model:expanded="expandedNodes"
|
29
|
-
/>
|
28
|
+
<EbizTree :items="treeData" line v-model:expanded="expandedNodes" />
|
30
29
|
</div>
|
31
|
-
|
30
|
+
|
31
|
+
<h2>启用动画效果的树</h2>
|
32
|
+
<div class="demo-section">
|
33
|
+
<EbizTree :items="treeData" line :transition="true" />
|
34
|
+
<div class="description">
|
35
|
+
<p>启用节点展开/收起的过渡动画效果</p>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
32
39
|
<h2>可拖拽的树</h2>
|
33
40
|
<div class="demo-section">
|
34
41
|
<EbizTree
|
35
42
|
:items="treeData"
|
36
|
-
draggable
|
43
|
+
draggable
|
37
44
|
@drag-drop="handleDragDrop"
|
38
45
|
/>
|
39
46
|
</div>
|
40
47
|
|
41
48
|
<h2>自定义图标的树</h2>
|
42
49
|
<div class="demo-section">
|
43
|
-
<EbizTree
|
44
|
-
:items="treeData"
|
45
|
-
line
|
46
|
-
>
|
50
|
+
<EbizTree :items="treeData" line>
|
47
51
|
<template #icon="{ node }">
|
48
52
|
<span v-if="node.children && node.children.length">📁</span>
|
49
53
|
<span v-else>📄</span>
|
50
54
|
</template>
|
51
55
|
</EbizTree>
|
52
56
|
</div>
|
53
|
-
|
57
|
+
|
54
58
|
<h2>节点操作</h2>
|
55
59
|
<div class="demo-section">
|
56
|
-
<EbizTree
|
57
|
-
:items="operableTreeData"
|
58
|
-
line
|
59
|
-
>
|
60
|
+
<EbizTree :items="operableTreeData" line>
|
60
61
|
<template #operations="{ node }">
|
61
62
|
<div class="node-operations">
|
62
63
|
<button @click.stop="addChildNode(node)">添加</button>
|
@@ -114,6 +115,11 @@ const treeData = ref([
|
|
114
115
|
}
|
115
116
|
]);
|
116
117
|
|
118
|
+
// 禁用特定节点选择的函数
|
119
|
+
const disableTreeNode = (node) => {
|
120
|
+
return node.value === '1.1';
|
121
|
+
};
|
122
|
+
|
117
123
|
// 可操作的树数据
|
118
124
|
const operableTreeData = ref([
|
119
125
|
{
|
@@ -239,5 +245,11 @@ const removeNodeByValue = (nodes, value) => {
|
|
239
245
|
}
|
240
246
|
}
|
241
247
|
}
|
248
|
+
|
249
|
+
.description {
|
250
|
+
margin-top: 10px;
|
251
|
+
color: #666;
|
252
|
+
font-size: 14px;
|
253
|
+
}
|
242
254
|
}
|
243
255
|
</style>
|
@@ -0,0 +1,246 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="tree-selector-demo">
|
3
|
+
<h2>树选择器组件演示</h2>
|
4
|
+
|
5
|
+
<div class="demo-section">
|
6
|
+
<h3>基础用法</h3>
|
7
|
+
<t-button @click="showBasicSelector">打开基础树选择器</t-button>
|
8
|
+
<div class="selected-data">
|
9
|
+
已选择: {{ selectedBasicData.length }} 项
|
10
|
+
<t-tag v-for="item in selectedBasicData" :key="item.value" class="selected-tag" closable @close="removeItem(item, 'basic')">
|
11
|
+
{{ item.label }}
|
12
|
+
</t-tag>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="demo-section">
|
17
|
+
<h3>预选中用法</h3>
|
18
|
+
<t-button @click="showPreselectedSelector">打开预选中树选择器</t-button>
|
19
|
+
<div class="selected-data">
|
20
|
+
已选择: {{ selectedPreData.length }} 项
|
21
|
+
<t-tag v-for="item in selectedPreData" :key="item.value" class="selected-tag" closable @close="removeItem(item, 'pre')">
|
22
|
+
{{ item.label }}
|
23
|
+
</t-tag>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class="demo-section">
|
28
|
+
<h3>自定义禁用规则</h3>
|
29
|
+
<t-button @click="showCustomDisabledSelector">打开禁用员工选择树选择器</t-button>
|
30
|
+
<div class="selected-data">
|
31
|
+
已选择: {{ selectedDisabledData.length }} 项
|
32
|
+
<t-tag v-for="item in selectedDisabledData" :key="item.value" class="selected-tag" closable @close="removeItem(item, 'disabled')">
|
33
|
+
{{ item.label }}
|
34
|
+
</t-tag>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<!-- 基础树选择器 -->
|
39
|
+
<EbizTreeSelector
|
40
|
+
v-model="selectedBasicData"
|
41
|
+
:data="treeData"
|
42
|
+
title="选择人员/部门"
|
43
|
+
@change="handleChange"
|
44
|
+
/>
|
45
|
+
|
46
|
+
<!-- 预选中树选择器 -->
|
47
|
+
<EbizTreeSelector
|
48
|
+
v-model="selectedPreData"
|
49
|
+
:data="treeData"
|
50
|
+
title="预选中的树选择器"
|
51
|
+
/>
|
52
|
+
|
53
|
+
<!-- 自定义禁用规则树选择器 -->
|
54
|
+
<EbizTreeSelector
|
55
|
+
v-model="selectedDisabledData"
|
56
|
+
:data="treeData"
|
57
|
+
title="仅选择部门和岗位"
|
58
|
+
:disable-check="disableEmployeeCheck"
|
59
|
+
/>
|
60
|
+
</div>
|
61
|
+
</template>
|
62
|
+
|
63
|
+
<script setup>
|
64
|
+
import { ref } from 'vue';
|
65
|
+
import { MessagePlugin } from 'tdesign-vue-next';
|
66
|
+
import EbizTreeSelector from '../components/EbizTreeSelector.vue';
|
67
|
+
|
68
|
+
// 树形数据
|
69
|
+
const treeData = {
|
70
|
+
organization: [
|
71
|
+
{
|
72
|
+
label: "强瑞科技",
|
73
|
+
value: "1",
|
74
|
+
children: [
|
75
|
+
{
|
76
|
+
label: "总经办",
|
77
|
+
value: "1.1",
|
78
|
+
type: "department"
|
79
|
+
},
|
80
|
+
{
|
81
|
+
label: "研发部",
|
82
|
+
value: "1.2",
|
83
|
+
type: "department",
|
84
|
+
children: [
|
85
|
+
{
|
86
|
+
label: "前端组",
|
87
|
+
value: "1.2.1",
|
88
|
+
type: "department"
|
89
|
+
},
|
90
|
+
{
|
91
|
+
label: "后端组",
|
92
|
+
value: "1.2.2",
|
93
|
+
type: "department"
|
94
|
+
}
|
95
|
+
]
|
96
|
+
}
|
97
|
+
]
|
98
|
+
}
|
99
|
+
],
|
100
|
+
department: [
|
101
|
+
{
|
102
|
+
label: "总经办",
|
103
|
+
value: "1.1",
|
104
|
+
type: "department"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
label: "研发部",
|
108
|
+
value: "1.2",
|
109
|
+
type: "department",
|
110
|
+
children: [
|
111
|
+
{
|
112
|
+
label: "前端组",
|
113
|
+
value: "1.2.1",
|
114
|
+
type: "department"
|
115
|
+
},
|
116
|
+
{
|
117
|
+
label: "后端组",
|
118
|
+
value: "1.2.2",
|
119
|
+
type: "department"
|
120
|
+
}
|
121
|
+
]
|
122
|
+
},
|
123
|
+
{
|
124
|
+
label: "人事部",
|
125
|
+
value: "1.3",
|
126
|
+
type: "department"
|
127
|
+
}
|
128
|
+
],
|
129
|
+
position: [
|
130
|
+
{
|
131
|
+
label: "工程师",
|
132
|
+
value: "pos1",
|
133
|
+
type: "position",
|
134
|
+
children: [
|
135
|
+
{
|
136
|
+
label: "前端工程师",
|
137
|
+
value: "pos1.1",
|
138
|
+
type: "position"
|
139
|
+
},
|
140
|
+
{
|
141
|
+
label: "后端工程师",
|
142
|
+
value: "pos1.2",
|
143
|
+
type: "position"
|
144
|
+
}
|
145
|
+
]
|
146
|
+
},
|
147
|
+
{
|
148
|
+
label: "设计师",
|
149
|
+
value: "pos2",
|
150
|
+
type: "position"
|
151
|
+
}
|
152
|
+
],
|
153
|
+
employee: [
|
154
|
+
{
|
155
|
+
label: "张三",
|
156
|
+
value: "emp1",
|
157
|
+
type: "employee"
|
158
|
+
},
|
159
|
+
{
|
160
|
+
label: "李四",
|
161
|
+
value: "emp2",
|
162
|
+
type: "employee"
|
163
|
+
},
|
164
|
+
{
|
165
|
+
label: "王五",
|
166
|
+
value: "emp3",
|
167
|
+
type: "employee"
|
168
|
+
}
|
169
|
+
]
|
170
|
+
};
|
171
|
+
|
172
|
+
// 已选择数据
|
173
|
+
const selectedBasicData = ref([]);
|
174
|
+
const selectedPreData = ref([
|
175
|
+
{
|
176
|
+
label: "研发部",
|
177
|
+
value: "1.2",
|
178
|
+
type: "department"
|
179
|
+
},
|
180
|
+
{
|
181
|
+
label: "张三",
|
182
|
+
value: "emp1",
|
183
|
+
type: "employee"
|
184
|
+
}
|
185
|
+
]);
|
186
|
+
const selectedDisabledData = ref([]);
|
187
|
+
|
188
|
+
// 打开选择器
|
189
|
+
const showBasicSelector = () => {
|
190
|
+
document.querySelectorAll('.t-dialog')[0]?.classList.add('show-dialog');
|
191
|
+
};
|
192
|
+
|
193
|
+
const showPreselectedSelector = () => {
|
194
|
+
document.querySelectorAll('.t-dialog')[1]?.classList.add('show-dialog');
|
195
|
+
};
|
196
|
+
|
197
|
+
const showCustomDisabledSelector = () => {
|
198
|
+
document.querySelectorAll('.t-dialog')[2]?.classList.add('show-dialog');
|
199
|
+
};
|
200
|
+
|
201
|
+
// 自定义禁用检查(禁用员工选择)
|
202
|
+
const disableEmployeeCheck = (node) => {
|
203
|
+
return node.type === 'employee';
|
204
|
+
};
|
205
|
+
|
206
|
+
// 移除已选项
|
207
|
+
const removeItem = (item, type) => {
|
208
|
+
if (type === 'basic') {
|
209
|
+
selectedBasicData.value = selectedBasicData.value.filter(i => i.value !== item.value);
|
210
|
+
} else if (type === 'pre') {
|
211
|
+
selectedPreData.value = selectedPreData.value.filter(i => i.value !== item.value);
|
212
|
+
} else if (type === 'disabled') {
|
213
|
+
selectedDisabledData.value = selectedDisabledData.value.filter(i => i.value !== item.value);
|
214
|
+
}
|
215
|
+
};
|
216
|
+
|
217
|
+
// 监听变更
|
218
|
+
const handleChange = (value) => {
|
219
|
+
MessagePlugin.success(`选择变更,已选择 ${value.length} 项`);
|
220
|
+
};
|
221
|
+
</script>
|
222
|
+
|
223
|
+
<style scoped>
|
224
|
+
.tree-selector-demo {
|
225
|
+
padding: 20px;
|
226
|
+
}
|
227
|
+
|
228
|
+
.demo-section {
|
229
|
+
margin-bottom: 30px;
|
230
|
+
padding: 20px;
|
231
|
+
border: 1px solid #e0e0e0;
|
232
|
+
border-radius: 4px;
|
233
|
+
}
|
234
|
+
|
235
|
+
.selected-data {
|
236
|
+
margin-top: 16px;
|
237
|
+
padding: 10px;
|
238
|
+
background-color: #f5f5f5;
|
239
|
+
border-radius: 4px;
|
240
|
+
min-height: 40px;
|
241
|
+
}
|
242
|
+
|
243
|
+
.selected-tag {
|
244
|
+
margin: 4px;
|
245
|
+
}
|
246
|
+
</style>
|