@ebiz/designer-components 0.0.18-beta.24 → 0.0.18-beta.26

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.
@@ -0,0 +1,69 @@
1
+ <template>
2
+ <div class="table-demo-container">
3
+ <h2>基础表格</h2>
4
+ <ebiz-table :data="tableData" :bordered="true" :hover="true">
5
+ <ebiz-table-column col-key="id" title="ID" width="80" />
6
+ <ebiz-table-column col-key="name" title="姓名" width="120" />
7
+ <ebiz-table-column col-key="age" title="年龄" width="80" :sorter="true" align="center" />
8
+ <ebiz-table-column col-key="address" title="地址" :ellipsis="true" />
9
+ </ebiz-table>
10
+
11
+ <h2>列类型演示</h2>
12
+ <ebiz-table :data="tableData" :bordered="true" :stripe="true" row-key="id">
13
+ <ebiz-table-column type="multiple" width="60" />
14
+ <ebiz-table-column type="index" title="序号" width="80" />
15
+ <ebiz-table-column col-key="name" title="姓名" width="120" />
16
+ <ebiz-table-column col-key="age" title="年龄" width="80" />
17
+ <ebiz-table-column col-key="address" title="地址" :ellipsis="true" />
18
+ </ebiz-table>
19
+
20
+ <h2>插槽用法</h2>
21
+ <ebiz-table :data="tableData" :bordered="true">
22
+ <ebiz-table-column col-key="id" title="ID" width="80" />
23
+ <ebiz-table-column col-key="name" title="姓名" width="120">
24
+ <template #default="{ row }">
25
+ <strong style="color: #0052d9">{{ row.name }}</strong>
26
+ </template>
27
+ </ebiz-table-column>
28
+ <ebiz-table-column col-key="age" title="年龄" width="80" />
29
+ <ebiz-table-column col-key="operation" title="操作" width="160">
30
+ <template #default="{ row }">
31
+ <button @click="handleEdit(row)" style="margin-right: 8px">编辑</button>
32
+ <button @click="handleDelete(row)">删除</button>
33
+ </template>
34
+ </ebiz-table-column>
35
+ </ebiz-table>
36
+ </div>
37
+ </template>
38
+
39
+ <script setup>
40
+ import { ref } from 'vue';
41
+ import { EbizTable, EbizTableColumn } from '../index.js';
42
+
43
+ const tableData = ref([
44
+ { id: 1, name: '张三', age: 28, address: '北京市朝阳区' },
45
+ { id: 2, name: '李四', age: 35, address: '上海市浦东新区' },
46
+ { id: 3, name: '王五', age: 42, address: '广州市天河区' },
47
+ { id: 4, name: '赵六', age: 31, address: '深圳市南山区科技园' },
48
+ { id: 5, name: '钱七', age: 27, address: '杭州市西湖区' }
49
+ ]);
50
+
51
+ const handleEdit = (row) => {
52
+ alert(`编辑: ${row.name}`);
53
+ };
54
+
55
+ const handleDelete = (row) => {
56
+ alert(`删除: ${row.name}`);
57
+ };
58
+ </script>
59
+
60
+ <style scoped>
61
+ .table-demo-container {
62
+ padding: 20px;
63
+ }
64
+
65
+ .table-demo-container h2 {
66
+ margin: 30px 0 15px;
67
+ font-size: 18px;
68
+ }
69
+ </style>
@@ -0,0 +1,243 @@
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
13
+ :items="treeData"
14
+ checkable
15
+ v-model="checkedValue"
16
+ @change="handleChange"
17
+ />
18
+ <div class="result-panel">
19
+ <p>当前选中值: {{ checkedValue.join(', ') }}</p>
20
+ </div>
21
+ </div>
22
+
23
+ <h2>带连接线的树</h2>
24
+ <div class="demo-section">
25
+ <EbizTree
26
+ :items="treeData"
27
+ line
28
+ v-model:expanded="expandedNodes"
29
+ />
30
+ </div>
31
+
32
+ <h2>可拖拽的树</h2>
33
+ <div class="demo-section">
34
+ <EbizTree
35
+ :items="treeData"
36
+ draggable
37
+ @drag-drop="handleDragDrop"
38
+ />
39
+ </div>
40
+
41
+ <h2>自定义图标的树</h2>
42
+ <div class="demo-section">
43
+ <EbizTree
44
+ :items="treeData"
45
+ line
46
+ >
47
+ <template #icon="{ node }">
48
+ <span v-if="node.children && node.children.length">📁</span>
49
+ <span v-else>📄</span>
50
+ </template>
51
+ </EbizTree>
52
+ </div>
53
+
54
+ <h2>节点操作</h2>
55
+ <div class="demo-section">
56
+ <EbizTree
57
+ :items="operableTreeData"
58
+ line
59
+ >
60
+ <template #operations="{ node }">
61
+ <div class="node-operations">
62
+ <button @click.stop="addChildNode(node)">添加</button>
63
+ <button @click.stop="removeNode(node)">删除</button>
64
+ </div>
65
+ </template>
66
+ </EbizTree>
67
+ </div>
68
+ </div>
69
+ </template>
70
+
71
+ <script setup>
72
+ import { ref } from 'vue';
73
+ import { EbizTree } from '../index.js';
74
+
75
+ // 树的数据
76
+ const treeData = ref([
77
+ {
78
+ label: '节点1',
79
+ value: '1',
80
+ children: [
81
+ {
82
+ label: '节点1.1',
83
+ value: '1.1',
84
+ children: [
85
+ {
86
+ label: '节点1.1.1',
87
+ value: '1.1.1'
88
+ },
89
+ {
90
+ label: '节点1.1.2',
91
+ value: '1.1.2'
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ label: '节点1.2',
97
+ value: '1.2'
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ label: '节点2',
103
+ value: '2',
104
+ children: [
105
+ {
106
+ label: '节点2.1',
107
+ value: '2.1'
108
+ },
109
+ {
110
+ label: '节点2.2',
111
+ value: '2.2'
112
+ }
113
+ ]
114
+ }
115
+ ]);
116
+
117
+ // 可操作的树数据
118
+ const operableTreeData = ref([
119
+ {
120
+ label: '节点1',
121
+ value: '1',
122
+ children: [
123
+ {
124
+ label: '节点1.1',
125
+ value: '1.1'
126
+ }
127
+ ]
128
+ },
129
+ {
130
+ label: '节点2',
131
+ value: '2',
132
+ children: []
133
+ }
134
+ ]);
135
+
136
+ // 选中的值
137
+ const checkedValue = ref([]);
138
+
139
+ // 展开的节点
140
+ const expandedNodes = ref(['1', '1.1']);
141
+
142
+ // 选中值变化处理
143
+ const handleChange = (values, context) => {
144
+ console.log('选中值变化:', values);
145
+ console.log('选中上下文:', context);
146
+ };
147
+
148
+ // 拖拽处理
149
+ const handleDragDrop = (context) => {
150
+ console.log('拖拽结束:', context);
151
+ };
152
+
153
+ // 添加子节点
154
+ const addChildNode = (node) => {
155
+ const newNodeId = `${node.value}-${Date.now()}`;
156
+ const newNode = {
157
+ label: `节点${newNodeId}`,
158
+ value: newNodeId,
159
+ children: []
160
+ };
161
+
162
+ if (!node.children) {
163
+ node.children = [];
164
+ }
165
+
166
+ node.children.push(newNode);
167
+ };
168
+
169
+ // 删除节点
170
+ const removeNode = (node) => {
171
+ // 找到父节点,从父节点的children中删除当前节点
172
+ operableTreeData.value = removeNodeByValue(operableTreeData.value, node.value);
173
+ };
174
+
175
+ // 根据值递归删除节点
176
+ const removeNodeByValue = (nodes, value) => {
177
+ return nodes.filter(node => {
178
+ if (node.value === value) {
179
+ return false;
180
+ }
181
+
182
+ if (node.children && node.children.length) {
183
+ node.children = removeNodeByValue(node.children, value);
184
+ }
185
+
186
+ return true;
187
+ });
188
+ };
189
+ </script>
190
+
191
+ <style scoped>
192
+ .tree-demo {
193
+ padding: 20px;
194
+
195
+ h1 {
196
+ margin-bottom: 20px;
197
+ font-size: 24px;
198
+ }
199
+
200
+ h2 {
201
+ margin-top: 30px;
202
+ margin-bottom: 15px;
203
+ font-size: 20px;
204
+ }
205
+
206
+ .demo-section {
207
+ margin-bottom: 30px;
208
+ padding: 20px;
209
+ border: 1px solid #eee;
210
+ border-radius: 4px;
211
+ }
212
+
213
+ .result-panel {
214
+ margin-top: 16px;
215
+ padding: 10px;
216
+ background-color: #f5f5f5;
217
+ border-radius: 4px;
218
+
219
+ p {
220
+ margin: 0;
221
+ }
222
+ }
223
+
224
+ .node-operations {
225
+ display: inline-flex;
226
+ margin-left: 8px;
227
+
228
+ button {
229
+ margin-left: 4px;
230
+ padding: 2px 6px;
231
+ font-size: 12px;
232
+ background-color: #f0f0f0;
233
+ border: 1px solid #ddd;
234
+ border-radius: 3px;
235
+ cursor: pointer;
236
+
237
+ &:hover {
238
+ background-color: #e0e0e0;
239
+ }
240
+ }
241
+ }
242
+ }
243
+ </style>