@ebiz/designer-components 0.0.18-tj.1 → 0.0.19-beta.1
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 +66100 -52710
- package/package.json +1 -1
- package/src/apiService/mockDataService.js +116 -0
- package/src/apiService/simpleDataService.js +186 -80
- package/src/components/Button.vue +72 -22
- package/src/components/EbizAvatar.vue +116 -0
- package/src/components/EbizCheckbox.vue +94 -0
- package/src/components/EbizCheckboxGroup.vue +70 -0
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +249 -0
- package/src/components/EbizEmployeeInfo.vue +139 -0
- package/src/components/EbizPageHeader.vue +96 -0
- package/src/components/EbizPagination.vue +163 -0
- package/src/components/EbizRadio.vue +87 -0
- package/src/components/EbizRadioGroup.vue +84 -0
- package/src/components/EbizRemoteSelect.vue +107 -41
- package/src/components/EbizStatistic.vue +150 -0
- package/src/components/EbizSwiper.vue +3 -3
- package/src/components/EbizSwitch.vue +86 -0
- package/src/components/EbizTabHeader.vue +6 -10
- package/src/components/EbizTabPanel.vue +23 -0
- package/src/components/EbizTable.vue +466 -0
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTabs.vue +143 -0
- package/src/components/EbizTimePicker.vue +144 -0
- package/src/components/EbizTitle.vue +36 -37
- package/src/components/EbizTree.vue +153 -0
- package/src/components/EbizTreeSelector.vue +418 -0
- package/src/components/TdesignAlert.vue +116 -0
- package/src/components/TdesignCalendar/index.vue +6 -3
- package/src/components/TdesignCol.vue +102 -0
- package/src/components/TdesignDialog.vue +226 -0
- package/src/components/TdesignGrid.vue +56 -0
- package/src/components/TdesignInput.vue +23 -23
- package/src/components/TdesignTextarea.vue +143 -0
- package/src/components/TdesignTimeline.vue +58 -0
- package/src/components/TdesignTimelineItem.vue +72 -0
- package/src/components/TdesignUpload.vue +757 -0
- package/src/components/TdesignWatermark.vue +108 -0
- package/src/index.js +85 -0
- package/src/main.js +2 -2
- package/src/router/index.js +160 -5
- package/src/views/Button.vue +7 -3
- package/src/views/CheckboxDemo.vue +105 -0
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizAvatar.vue +224 -0
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/EbizEmployeeInfo.vue +250 -0
- package/src/views/EbizRadioDemo.vue +152 -0
- package/src/views/GridDemo.vue +239 -0
- package/src/views/Home.vue +49 -2
- package/src/views/PageHeaderDemo.vue +105 -0
- package/src/views/PaginationDemo.vue +97 -0
- package/src/views/RemoteSelect.vue +336 -5
- package/src/views/StatisticDemo.vue +191 -0
- package/src/views/SwitchDemo.vue +80 -0
- package/src/views/TableDemo.vue +335 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TabsDemo.vue +283 -0
- package/src/views/TdesignAlert.vue +99 -0
- package/src/views/TextareaDemo.vue +94 -0
- package/src/views/TimePickerDemo.vue +147 -0
- package/src/views/TimelineDemo.vue +161 -0
- package/src/views/TreeDemo.vue +255 -0
- package/src/views/TreeSelectorDemo.vue +246 -0
- package/src/views/UploadDemo.vue +122 -0
- package/src/views/WatermarkDemo.vue +86 -0
@@ -0,0 +1,161 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="timeline-demo">
|
3
|
+
<h1>TDesign Timeline 组件示例</h1>
|
4
|
+
|
5
|
+
<h2>基础时间轴</h2>
|
6
|
+
<div class="demo-section">
|
7
|
+
<EbizTimeline>
|
8
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
9
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
10
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
11
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
12
|
+
</EbizTimeline>
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<h2>时间轴方向</h2>
|
16
|
+
<div class="demo-section">
|
17
|
+
<h3>水平方向</h3>
|
18
|
+
<EbizTimeline layout="horizontal">
|
19
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
20
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
21
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
22
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
23
|
+
</EbizTimeline>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<h2>时间轴主题</h2>
|
27
|
+
<div class="demo-section">
|
28
|
+
<h3>点状主题</h3>
|
29
|
+
<EbizTimeline theme="dot">
|
30
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
31
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
32
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
33
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
34
|
+
</EbizTimeline>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<h2>不同的展示方式</h2>
|
38
|
+
<div class="demo-section">
|
39
|
+
<h3>左侧展示</h3>
|
40
|
+
<EbizTimeline mode="left">
|
41
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
42
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
43
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
44
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
45
|
+
</EbizTimeline>
|
46
|
+
|
47
|
+
<h3>右侧展示</h3>
|
48
|
+
<EbizTimeline mode="right">
|
49
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
50
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
51
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
52
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
53
|
+
</EbizTimeline>
|
54
|
+
|
55
|
+
<h3>同侧展示</h3>
|
56
|
+
<EbizTimeline mode="same">
|
57
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
58
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
59
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
60
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
61
|
+
</EbizTimeline>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<h2>标签位置</h2>
|
65
|
+
<div class="demo-section">
|
66
|
+
<h3>标签在左侧</h3>
|
67
|
+
<EbizTimeline labelAlign="left">
|
68
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
69
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
70
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
71
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
72
|
+
</EbizTimeline>
|
73
|
+
|
74
|
+
<h3>标签在顶部</h3>
|
75
|
+
<EbizTimeline labelAlign="top">
|
76
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" />
|
77
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" />
|
78
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" />
|
79
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" />
|
80
|
+
</EbizTimeline>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<h2>自定义节点颜色</h2>
|
84
|
+
<div class="demo-section">
|
85
|
+
<EbizTimeline>
|
86
|
+
<EbizTimelineItem label="2022-01-01" content="事件一" dotColor="primary" />
|
87
|
+
<EbizTimelineItem label="2022-02-01" content="事件二" dotColor="warning" />
|
88
|
+
<EbizTimelineItem label="2022-03-01" content="事件三" dotColor="error" />
|
89
|
+
<EbizTimelineItem label="2022-04-01" content="事件四" dotColor="success" />
|
90
|
+
</EbizTimeline>
|
91
|
+
</div>
|
92
|
+
|
93
|
+
<h2>使用插槽自定义内容</h2>
|
94
|
+
<div class="demo-section">
|
95
|
+
<EbizTimeline>
|
96
|
+
<EbizTimelineItem label="2022-01-01">
|
97
|
+
<div class="custom-content">
|
98
|
+
<h4>自定义内容一</h4>
|
99
|
+
<p>这是一个自定义内容示例</p>
|
100
|
+
</div>
|
101
|
+
</EbizTimelineItem>
|
102
|
+
<EbizTimelineItem label="2022-02-01">
|
103
|
+
<div class="custom-content">
|
104
|
+
<h4>自定义内容二</h4>
|
105
|
+
<p>这是一个自定义内容示例</p>
|
106
|
+
</div>
|
107
|
+
</EbizTimelineItem>
|
108
|
+
</EbizTimeline>
|
109
|
+
</div>
|
110
|
+
|
111
|
+
<h2>加载状态</h2>
|
112
|
+
<div class="demo-section">
|
113
|
+
<EbizTimeline>
|
114
|
+
<EbizTimelineItem label="2022-01-01" content="已完成" />
|
115
|
+
<EbizTimelineItem label="2022-02-01" content="进行中" loading />
|
116
|
+
<EbizTimelineItem label="2022-03-01" content="未开始" />
|
117
|
+
<EbizTimelineItem label="2022-04-01" content="未开始" />
|
118
|
+
</EbizTimeline>
|
119
|
+
</div>
|
120
|
+
</div>
|
121
|
+
</template>
|
122
|
+
|
123
|
+
<script setup>
|
124
|
+
import { EbizTimeline, EbizTimelineItem } from '../index.js';
|
125
|
+
</script>
|
126
|
+
|
127
|
+
<style scoped>
|
128
|
+
.timeline-demo {
|
129
|
+
padding: 20px;
|
130
|
+
}
|
131
|
+
|
132
|
+
.demo-section {
|
133
|
+
margin-bottom: 40px;
|
134
|
+
}
|
135
|
+
|
136
|
+
h1 {
|
137
|
+
margin-bottom: 30px;
|
138
|
+
}
|
139
|
+
|
140
|
+
h2 {
|
141
|
+
margin: 20px 0;
|
142
|
+
}
|
143
|
+
|
144
|
+
h3 {
|
145
|
+
margin: 15px 0;
|
146
|
+
}
|
147
|
+
|
148
|
+
.custom-content {
|
149
|
+
padding: 10px;
|
150
|
+
border: 1px solid #eee;
|
151
|
+
border-radius: 4px;
|
152
|
+
}
|
153
|
+
|
154
|
+
.custom-content h4 {
|
155
|
+
margin: 0 0 10px 0;
|
156
|
+
}
|
157
|
+
|
158
|
+
.custom-content p {
|
159
|
+
margin: 0;
|
160
|
+
}
|
161
|
+
</style>
|
@@ -0,0 +1,255 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="tree-demo">
|
3
|
+
<h1>树组件示例</h1>
|
4
|
+
|
5
|
+
<h2>基础树</h2>
|
6
|
+
<div class="demo-section">
|
7
|
+
<EbizTree :items="treeData" />
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<h2>可选择的树</h2>
|
11
|
+
<div class="demo-section">
|
12
|
+
<EbizTree :items="treeData" checkable v-model="checkedValue" @change="handleChange" />
|
13
|
+
<div class="result-panel">
|
14
|
+
<p>当前选中值: {{ checkedValue.join(', ') }}</p>
|
15
|
+
</div>
|
16
|
+
</div>
|
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
|
+
|
26
|
+
<h2>带连接线的树</h2>
|
27
|
+
<div class="demo-section">
|
28
|
+
<EbizTree :items="treeData" line v-model:expanded="expandedNodes" />
|
29
|
+
</div>
|
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
|
+
|
39
|
+
<h2>可拖拽的树</h2>
|
40
|
+
<div class="demo-section">
|
41
|
+
<EbizTree
|
42
|
+
:items="treeData"
|
43
|
+
draggable
|
44
|
+
@drag-drop="handleDragDrop"
|
45
|
+
/>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<h2>自定义图标的树</h2>
|
49
|
+
<div class="demo-section">
|
50
|
+
<EbizTree :items="treeData" line>
|
51
|
+
<template #icon="{ node }">
|
52
|
+
<span v-if="node.children && node.children.length">📁</span>
|
53
|
+
<span v-else>📄</span>
|
54
|
+
</template>
|
55
|
+
</EbizTree>
|
56
|
+
</div>
|
57
|
+
|
58
|
+
<h2>节点操作</h2>
|
59
|
+
<div class="demo-section">
|
60
|
+
<EbizTree :items="operableTreeData" line>
|
61
|
+
<template #operations="{ node }">
|
62
|
+
<div class="node-operations">
|
63
|
+
<button @click.stop="addChildNode(node)">添加</button>
|
64
|
+
<button @click.stop="removeNode(node)">删除</button>
|
65
|
+
</div>
|
66
|
+
</template>
|
67
|
+
</EbizTree>
|
68
|
+
</div>
|
69
|
+
</div>
|
70
|
+
</template>
|
71
|
+
|
72
|
+
<script setup>
|
73
|
+
import { ref } from 'vue';
|
74
|
+
import { EbizTree } from '../index.js';
|
75
|
+
|
76
|
+
// 树的数据
|
77
|
+
const treeData = ref([
|
78
|
+
{
|
79
|
+
label: '节点1',
|
80
|
+
value: '1',
|
81
|
+
children: [
|
82
|
+
{
|
83
|
+
label: '节点1.1',
|
84
|
+
value: '1.1',
|
85
|
+
children: [
|
86
|
+
{
|
87
|
+
label: '节点1.1.1',
|
88
|
+
value: '1.1.1'
|
89
|
+
},
|
90
|
+
{
|
91
|
+
label: '节点1.1.2',
|
92
|
+
value: '1.1.2'
|
93
|
+
}
|
94
|
+
]
|
95
|
+
},
|
96
|
+
{
|
97
|
+
label: '节点1.2',
|
98
|
+
value: '1.2'
|
99
|
+
}
|
100
|
+
]
|
101
|
+
},
|
102
|
+
{
|
103
|
+
label: '节点2',
|
104
|
+
value: '2',
|
105
|
+
children: [
|
106
|
+
{
|
107
|
+
label: '节点2.1',
|
108
|
+
value: '2.1'
|
109
|
+
},
|
110
|
+
{
|
111
|
+
label: '节点2.2',
|
112
|
+
value: '2.2'
|
113
|
+
}
|
114
|
+
]
|
115
|
+
}
|
116
|
+
]);
|
117
|
+
|
118
|
+
// 禁用特定节点选择的函数
|
119
|
+
const disableTreeNode = (node) => {
|
120
|
+
return node.value === '1.1';
|
121
|
+
};
|
122
|
+
|
123
|
+
// 可操作的树数据
|
124
|
+
const operableTreeData = ref([
|
125
|
+
{
|
126
|
+
label: '节点1',
|
127
|
+
value: '1',
|
128
|
+
children: [
|
129
|
+
{
|
130
|
+
label: '节点1.1',
|
131
|
+
value: '1.1'
|
132
|
+
}
|
133
|
+
]
|
134
|
+
},
|
135
|
+
{
|
136
|
+
label: '节点2',
|
137
|
+
value: '2',
|
138
|
+
children: []
|
139
|
+
}
|
140
|
+
]);
|
141
|
+
|
142
|
+
// 选中的值
|
143
|
+
const checkedValue = ref([]);
|
144
|
+
|
145
|
+
// 展开的节点
|
146
|
+
const expandedNodes = ref(['1', '1.1']);
|
147
|
+
|
148
|
+
// 选中值变化处理
|
149
|
+
const handleChange = (values, context) => {
|
150
|
+
console.log('选中值变化:', values);
|
151
|
+
console.log('选中上下文:', context);
|
152
|
+
};
|
153
|
+
|
154
|
+
// 拖拽处理
|
155
|
+
const handleDragDrop = (context) => {
|
156
|
+
console.log('拖拽结束:', context);
|
157
|
+
};
|
158
|
+
|
159
|
+
// 添加子节点
|
160
|
+
const addChildNode = (node) => {
|
161
|
+
const newNodeId = `${node.value}-${Date.now()}`;
|
162
|
+
const newNode = {
|
163
|
+
label: `节点${newNodeId}`,
|
164
|
+
value: newNodeId,
|
165
|
+
children: []
|
166
|
+
};
|
167
|
+
|
168
|
+
if (!node.children) {
|
169
|
+
node.children = [];
|
170
|
+
}
|
171
|
+
|
172
|
+
node.children.push(newNode);
|
173
|
+
};
|
174
|
+
|
175
|
+
// 删除节点
|
176
|
+
const removeNode = (node) => {
|
177
|
+
// 找到父节点,从父节点的children中删除当前节点
|
178
|
+
operableTreeData.value = removeNodeByValue(operableTreeData.value, node.value);
|
179
|
+
};
|
180
|
+
|
181
|
+
// 根据值递归删除节点
|
182
|
+
const removeNodeByValue = (nodes, value) => {
|
183
|
+
return nodes.filter(node => {
|
184
|
+
if (node.value === value) {
|
185
|
+
return false;
|
186
|
+
}
|
187
|
+
|
188
|
+
if (node.children && node.children.length) {
|
189
|
+
node.children = removeNodeByValue(node.children, value);
|
190
|
+
}
|
191
|
+
|
192
|
+
return true;
|
193
|
+
});
|
194
|
+
};
|
195
|
+
</script>
|
196
|
+
|
197
|
+
<style scoped>
|
198
|
+
.tree-demo {
|
199
|
+
padding: 20px;
|
200
|
+
|
201
|
+
h1 {
|
202
|
+
margin-bottom: 20px;
|
203
|
+
font-size: 24px;
|
204
|
+
}
|
205
|
+
|
206
|
+
h2 {
|
207
|
+
margin-top: 30px;
|
208
|
+
margin-bottom: 15px;
|
209
|
+
font-size: 20px;
|
210
|
+
}
|
211
|
+
|
212
|
+
.demo-section {
|
213
|
+
margin-bottom: 30px;
|
214
|
+
padding: 20px;
|
215
|
+
border: 1px solid #eee;
|
216
|
+
border-radius: 4px;
|
217
|
+
}
|
218
|
+
|
219
|
+
.result-panel {
|
220
|
+
margin-top: 16px;
|
221
|
+
padding: 10px;
|
222
|
+
background-color: #f5f5f5;
|
223
|
+
border-radius: 4px;
|
224
|
+
|
225
|
+
p {
|
226
|
+
margin: 0;
|
227
|
+
}
|
228
|
+
}
|
229
|
+
|
230
|
+
.node-operations {
|
231
|
+
display: inline-flex;
|
232
|
+
margin-left: 8px;
|
233
|
+
|
234
|
+
button {
|
235
|
+
margin-left: 4px;
|
236
|
+
padding: 2px 6px;
|
237
|
+
font-size: 12px;
|
238
|
+
background-color: #f0f0f0;
|
239
|
+
border: 1px solid #ddd;
|
240
|
+
border-radius: 3px;
|
241
|
+
cursor: pointer;
|
242
|
+
|
243
|
+
&:hover {
|
244
|
+
background-color: #e0e0e0;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
}
|
248
|
+
|
249
|
+
.description {
|
250
|
+
margin-top: 10px;
|
251
|
+
color: #666;
|
252
|
+
font-size: 14px;
|
253
|
+
}
|
254
|
+
}
|
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>
|