@ebiz/designer-components 0.0.18-kzy.2 → 0.0.18-kzy.3
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 +14854 -14552
- package/package.json +1 -1
- package/src/apiService/simpleDataService.js +4 -2
- package/src/components/Button copy.vue +104 -0
- package/src/components/EbizRemoteSelect.vue +17 -8
- package/src/components/EbizRouteBreadcrumb.vue +3 -1
- package/src/components/EbizTable.vue +113 -133
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/index.js +5 -0
- package/src/router/index.js +20 -5
- package/src/views/Home.vue +3 -1
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
@@ -0,0 +1,181 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-table-sort">
|
3
|
+
<t-popup :visible="sortVisible" trigger="click" placement="bottom-right" :overlay-style="{ width: '450px' }"
|
4
|
+
@visible-change="handleVisibleChange" :destroy-on-close="false">
|
5
|
+
<template #content>
|
6
|
+
<t-card :title="popupTitle" size="small" :bordered="false">
|
7
|
+
<div class="sort-content">
|
8
|
+
<div class="sort-item" v-for="(item, index) in sortItems" :key="index">
|
9
|
+
<div class="sort-item-content" style="display: flex; margin-bottom: 12px;">
|
10
|
+
<t-select v-model="item.type" :placeholder="fieldPlaceholder" :options="fieldOptions" :clearable="false"
|
11
|
+
:style="{ width: '170px' }" @change="handleSortChange" />
|
12
|
+
<t-select v-model="item.sort" :placeholder="orderPlaceholder" :options="orderOptions" :clearable="false"
|
13
|
+
:style="{ width: '170px', marginLeft: '8px' }" @change="handleSortChange" />
|
14
|
+
<t-button theme="default" variant="text" shape="circle" @click="removeSortItem(index)"
|
15
|
+
v-if="sortItems.length > 1" :style="{ marginLeft: '8px', flexShrink: 0 }">
|
16
|
+
<template #icon>
|
17
|
+
<t-icon name="close" />
|
18
|
+
</template>
|
19
|
+
</t-button>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div class="sort-footer">
|
23
|
+
<t-button theme="default" variant="outline" @click="addSortItem"
|
24
|
+
v-if="sortItems.length < maxSortItems">
|
25
|
+
<template #icon>
|
26
|
+
<t-icon name="add" />
|
27
|
+
</template>
|
28
|
+
{{ addConditionText }}
|
29
|
+
</t-button>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</t-card>
|
33
|
+
</template>
|
34
|
+
<t-button block variant="outline" :title="title">
|
35
|
+
<template #icon>
|
36
|
+
<t-icon :name="icon" />
|
37
|
+
</template>
|
38
|
+
<div v-if="buttonText">
|
39
|
+
{{ buttonText }}
|
40
|
+
</div>
|
41
|
+
</t-button>
|
42
|
+
</t-popup>
|
43
|
+
</div>
|
44
|
+
</template>
|
45
|
+
|
46
|
+
<script>
|
47
|
+
export default {
|
48
|
+
name: "EbizTableSort"
|
49
|
+
}
|
50
|
+
</script>
|
51
|
+
|
52
|
+
<script setup>
|
53
|
+
import { ref, computed, defineProps, defineEmits, watch } from 'vue';
|
54
|
+
import { Button as TButton, Popup as TPopup, Card as TCard, Select as TSelect, Icon as TIcon } from 'tdesign-vue-next';
|
55
|
+
|
56
|
+
const props = defineProps({
|
57
|
+
// v-model绑定值
|
58
|
+
modelValue: {
|
59
|
+
type: Array,
|
60
|
+
default: () => []
|
61
|
+
},
|
62
|
+
// 按钮图标
|
63
|
+
icon: {
|
64
|
+
type: String,
|
65
|
+
default: 'sort'
|
66
|
+
},
|
67
|
+
// 按钮文本
|
68
|
+
buttonText: {
|
69
|
+
type: String,
|
70
|
+
default: ''
|
71
|
+
},
|
72
|
+
// 按钮标题
|
73
|
+
title: {
|
74
|
+
type: String,
|
75
|
+
default: '排序'
|
76
|
+
},
|
77
|
+
// 弹出层标题
|
78
|
+
popupTitle: {
|
79
|
+
type: String,
|
80
|
+
default: '排序'
|
81
|
+
},
|
82
|
+
// 字段选项
|
83
|
+
fieldOptions: {
|
84
|
+
type: Array,
|
85
|
+
default: () => []
|
86
|
+
},
|
87
|
+
// 字段占位符
|
88
|
+
fieldPlaceholder: {
|
89
|
+
type: String,
|
90
|
+
default: '选择字段'
|
91
|
+
},
|
92
|
+
// 排序选项
|
93
|
+
orderOptions: {
|
94
|
+
type: Array,
|
95
|
+
default: () => [
|
96
|
+
{ value: 'asc', label: '升序 ↑' },
|
97
|
+
{ value: 'desc', label: '降序 ↓' }
|
98
|
+
]
|
99
|
+
},
|
100
|
+
// 排序占位符
|
101
|
+
orderPlaceholder: {
|
102
|
+
type: String,
|
103
|
+
default: '选择排序'
|
104
|
+
},
|
105
|
+
// 最大排序条件数量
|
106
|
+
maxSortItems: {
|
107
|
+
type: Number,
|
108
|
+
default: 5
|
109
|
+
},
|
110
|
+
// 添加条件文本
|
111
|
+
addConditionText: {
|
112
|
+
type: String,
|
113
|
+
default: '添加排序条件'
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
const emit = defineEmits(['update:modelValue', 'sort', 'visible-change']);
|
118
|
+
|
119
|
+
// 排序弹出层显示状态
|
120
|
+
const sortVisible = ref(false);
|
121
|
+
|
122
|
+
// 排序条件列表
|
123
|
+
const sortItems = ref([]);
|
124
|
+
|
125
|
+
// 监听modelValue变化
|
126
|
+
watch(() => props.modelValue, (newVal) => {
|
127
|
+
if (newVal && newVal.length > 0) {
|
128
|
+
sortItems.value = JSON.parse(JSON.stringify(newVal));
|
129
|
+
} else {
|
130
|
+
// 默认添加一个空的排序条件
|
131
|
+
sortItems.value = [{ type: '', sort: 'desc' }];
|
132
|
+
}
|
133
|
+
}, { immediate: true });
|
134
|
+
|
135
|
+
// 添加排序条件
|
136
|
+
const addSortItem = () => {
|
137
|
+
if (sortItems.value.length < props.maxSortItems) {
|
138
|
+
sortItems.value.push({ type: '', sort: 'desc' });
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
// 移除排序条件
|
143
|
+
const removeSortItem = (index) => {
|
144
|
+
sortItems.value.splice(index, 1);
|
145
|
+
handleSortChange();
|
146
|
+
};
|
147
|
+
|
148
|
+
// 处理排序变更
|
149
|
+
const handleSortChange = () => {
|
150
|
+
// 过滤有效的排序条件(字段和排序方向都不为空)
|
151
|
+
const validSortItems = sortItems.value.filter(item => item.type && item.sort);
|
152
|
+
emit('update:modelValue', validSortItems);
|
153
|
+
emit('sort', validSortItems);
|
154
|
+
};
|
155
|
+
|
156
|
+
// 弹出层可见性变化
|
157
|
+
const handleVisibleChange = (visible) => {
|
158
|
+
sortVisible.value = visible;
|
159
|
+
emit('visible-change', visible);
|
160
|
+
};
|
161
|
+
</script>
|
162
|
+
|
163
|
+
<style lang="less" scoped>
|
164
|
+
.ebiz-table-sort {
|
165
|
+
display: inline-block;
|
166
|
+
|
167
|
+
.sort-content {
|
168
|
+
min-width: 400px;
|
169
|
+
width: 100%;
|
170
|
+
}
|
171
|
+
|
172
|
+
.sort-footer {
|
173
|
+
margin-top: 16px;
|
174
|
+
}
|
175
|
+
|
176
|
+
.sort-actions {
|
177
|
+
display: flex;
|
178
|
+
justify-content: flex-end;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
</style>
|
package/src/index.js
CHANGED
@@ -49,6 +49,8 @@ import EbizEmployeeInfo from "./components/EbizEmployeeInfo.vue";
|
|
49
49
|
import EbizAlert from "./components/TdesignAlert.vue";
|
50
50
|
import EbizDialog from "./components/TdesignDialog.vue";
|
51
51
|
import EbizTable from "./components/EbizTable.vue";
|
52
|
+
import EbizTableColumn from './components/EbizTableColumn.vue';
|
53
|
+
import EbizTableSort from './components/EbizTableSort.vue';
|
52
54
|
import EbizStatusBadge from "./components/EbizStatusBadge.vue";
|
53
55
|
import { MessagePlugin as EbizMessage } from 'tdesign-vue-next';
|
54
56
|
|
@@ -150,6 +152,9 @@ export {
|
|
150
152
|
EbizDialog,
|
151
153
|
// 表格组件
|
152
154
|
EbizTable,
|
155
|
+
EbizTableColumn,
|
156
|
+
// 表格排序组件
|
157
|
+
EbizTableSort,
|
153
158
|
// 状态标记组件
|
154
159
|
EbizStatusBadge
|
155
160
|
};
|
package/src/router/index.js
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
import { createRouter, createWebHistory } from 'vue-router'
|
2
|
+
import Home from '../views/Home.vue'
|
3
|
+
import ButtonView from '../views/Button.vue'
|
4
|
+
import TableView from '../views/TableView.vue'
|
2
5
|
|
3
6
|
const routes = [
|
4
7
|
{
|
5
8
|
path: '/',
|
6
9
|
name: 'Home',
|
7
|
-
component:
|
10
|
+
component: Home,
|
8
11
|
meta: { title: '首页' }
|
9
12
|
},
|
10
13
|
{
|
@@ -15,10 +18,16 @@ const routes = [
|
|
15
18
|
},
|
16
19
|
{
|
17
20
|
path: '/table',
|
18
|
-
name: '
|
19
|
-
component:
|
21
|
+
name: 'table',
|
22
|
+
component: TableView,
|
20
23
|
meta: { title: '表格组件示例' }
|
21
24
|
},
|
25
|
+
{
|
26
|
+
path: '/table-column',
|
27
|
+
name: 'table-column',
|
28
|
+
component: TableView,
|
29
|
+
meta: { title: '表格列组件示例' }
|
30
|
+
},
|
22
31
|
{
|
23
32
|
path: '/form',
|
24
33
|
name: 'Form',
|
@@ -27,8 +36,8 @@ const routes = [
|
|
27
36
|
},
|
28
37
|
{
|
29
38
|
path: '/button',
|
30
|
-
name: '
|
31
|
-
component:
|
39
|
+
name: 'button',
|
40
|
+
component: ButtonView,
|
32
41
|
meta: { title: '按钮组件示例' }
|
33
42
|
},
|
34
43
|
{
|
@@ -246,6 +255,12 @@ const routes = [
|
|
246
255
|
name: 'StatusBadge',
|
247
256
|
component: () => import('../views/StatusBadgeExample.vue'),
|
248
257
|
meta: { title: 'Ebiz状态标记组件示例' }
|
258
|
+
},
|
259
|
+
{
|
260
|
+
path: '/table-sort',
|
261
|
+
name: 'TableSort',
|
262
|
+
component: () => import('../views/TableSortDemo.vue'),
|
263
|
+
meta: { title: 'Ebiz表格排序组件示例' }
|
249
264
|
}
|
250
265
|
]
|
251
266
|
|
package/src/views/Home.vue
CHANGED
@@ -55,7 +55,9 @@ export default {
|
|
55
55
|
{ path: '/tdesign-alert', title: 'TDesign提示组件示例' },
|
56
56
|
{ path: '/tdesign-dialog', title: 'TDesign对话框组件示例' },
|
57
57
|
{ path: '/table-demo', title: 'Ebiz表格组件示例' },
|
58
|
-
{ path: '/status-badge', title: 'Ebiz状态标记组件示例' }
|
58
|
+
{ path: '/status-badge', title: 'Ebiz状态标记组件示例' },
|
59
|
+
{ path: '/table-column', title: 'Ebiz表格列组件示例' },
|
60
|
+
{ path: '/table-sort', title: 'Ebiz表格排序组件示例' }
|
59
61
|
]
|
60
62
|
|
61
63
|
return {
|
@@ -0,0 +1,144 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="container">
|
3
|
+
<h1>表格排序组件演示</h1>
|
4
|
+
|
5
|
+
<div class="demo-section">
|
6
|
+
<h2>基础用法</h2>
|
7
|
+
<div class="demo-item">
|
8
|
+
<EbizTableSort icon="filter-sort" :field-options="fieldOptions" @sort="handleSort"
|
9
|
+
@reset="handleReset" />
|
10
|
+
</div>
|
11
|
+
<div class="result" v-if="sortResult.length > 0">
|
12
|
+
<h3>排序结果:</h3>
|
13
|
+
<pre>{{ JSON.stringify(sortResult, null, 2) }}</pre>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<div class="demo-section">
|
18
|
+
<h2>自定义按钮</h2>
|
19
|
+
<div class="demo-item">
|
20
|
+
<EbizTableSort icon="filter" button-text="自定义排序" :field-options="fieldOptions" @sort="handleSort2" />
|
21
|
+
</div>
|
22
|
+
<div class="result" v-if="sortResult2.length > 0">
|
23
|
+
<h3>排序结果:</h3>
|
24
|
+
<pre>{{ JSON.stringify(sortResult2, null, 2) }}</pre>
|
25
|
+
</div>
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<div class="demo-section">
|
29
|
+
<h2>预设排序条件</h2>
|
30
|
+
<div class="demo-item">
|
31
|
+
<EbizTableSort :field-options="fieldOptions" :default-sort="defaultSort" @sort="handleSort3" />
|
32
|
+
</div>
|
33
|
+
<div class="result" v-if="sortResult3.length > 0">
|
34
|
+
<h3>排序结果:</h3>
|
35
|
+
<pre>{{ JSON.stringify(sortResult3, null, 2) }}</pre>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div class="demo-section">
|
40
|
+
<h2>多条件排序</h2>
|
41
|
+
<div class="demo-item">
|
42
|
+
<EbizTableSort :field-options="fieldOptions" :max-sort-items="3" @sort="handleSort4" />
|
43
|
+
</div>
|
44
|
+
<div class="result" v-if="sortResult4.length > 0">
|
45
|
+
<h3>排序结果:</h3>
|
46
|
+
<pre>{{ JSON.stringify(sortResult4, null, 2) }}</pre>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
</div>
|
50
|
+
</template>
|
51
|
+
|
52
|
+
<script setup>
|
53
|
+
import { ref } from 'vue';
|
54
|
+
import { EbizTableSort } from '../index.js';
|
55
|
+
|
56
|
+
// 字段选项
|
57
|
+
const fieldOptions = [
|
58
|
+
{ value: 'name', label: '姓名' },
|
59
|
+
{ value: 'age', label: '年龄' },
|
60
|
+
{ value: 'address', label: '地址' },
|
61
|
+
{ value: 'createTime', label: '创建时间' },
|
62
|
+
{ value: 'status', label: '状态' }
|
63
|
+
];
|
64
|
+
|
65
|
+
// 默认排序条件
|
66
|
+
const defaultSort = [
|
67
|
+
{ field: 'age', order: 'desc' }
|
68
|
+
];
|
69
|
+
|
70
|
+
// 排序结果
|
71
|
+
const sortResult = ref([]);
|
72
|
+
const sortResult2 = ref([]);
|
73
|
+
const sortResult3 = ref([]);
|
74
|
+
const sortResult4 = ref([]);
|
75
|
+
|
76
|
+
// 处理排序
|
77
|
+
const handleSort = (sort) => {
|
78
|
+
sortResult.value = sort;
|
79
|
+
console.log('排序条件:', sort);
|
80
|
+
};
|
81
|
+
|
82
|
+
const handleSort2 = (sort) => {
|
83
|
+
sortResult2.value = sort;
|
84
|
+
console.log('排序条件2:', sort);
|
85
|
+
};
|
86
|
+
|
87
|
+
const handleSort3 = (sort) => {
|
88
|
+
sortResult3.value = sort;
|
89
|
+
console.log('排序条件3:', sort);
|
90
|
+
};
|
91
|
+
|
92
|
+
const handleSort4 = (sort) => {
|
93
|
+
sortResult4.value = sort;
|
94
|
+
console.log('排序条件4:', sort);
|
95
|
+
};
|
96
|
+
|
97
|
+
// 处理重置
|
98
|
+
const handleReset = () => {
|
99
|
+
sortResult.value = [];
|
100
|
+
console.log('重置排序');
|
101
|
+
};
|
102
|
+
</script>
|
103
|
+
|
104
|
+
<style lang="less" scoped>
|
105
|
+
.container {
|
106
|
+
padding: 20px;
|
107
|
+
|
108
|
+
h1 {
|
109
|
+
margin-bottom: 20px;
|
110
|
+
}
|
111
|
+
|
112
|
+
.demo-section {
|
113
|
+
margin-bottom: 30px;
|
114
|
+
padding: 20px;
|
115
|
+
border: 1px solid #eee;
|
116
|
+
border-radius: 6px;
|
117
|
+
|
118
|
+
h2 {
|
119
|
+
margin-bottom: 16px;
|
120
|
+
font-size: 18px;
|
121
|
+
}
|
122
|
+
|
123
|
+
.demo-item {
|
124
|
+
margin-bottom: 16px;
|
125
|
+
}
|
126
|
+
|
127
|
+
.result {
|
128
|
+
margin-top: 20px;
|
129
|
+
padding: 16px;
|
130
|
+
background-color: #f9f9f9;
|
131
|
+
border-radius: 4px;
|
132
|
+
|
133
|
+
h3 {
|
134
|
+
margin-bottom: 8px;
|
135
|
+
font-size: 16px;
|
136
|
+
}
|
137
|
+
|
138
|
+
pre {
|
139
|
+
font-family: monospace;
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
}
|
144
|
+
</style>
|
@@ -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>
|