@ebiz/designer-components 0.0.18-beta.25 → 0.0.18-beta.27
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/package.json +1 -1
- package/src/components/EbizDialog.vue +249 -0
- package/src/components/EbizRemoteSelect.vue +4 -1
- package/src/components/EbizTable.vue +113 -133
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTree.vue +125 -0
- package/src/index.js +10 -2
- package/src/router/index.js +26 -5
- package/src/views/Home.vue +4 -1
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TreeDemo.vue +243 -0
package/package.json
CHANGED
@@ -0,0 +1,249 @@
|
|
1
|
+
<template>
|
2
|
+
<t-dialog
|
3
|
+
v-model:visible="dialogVisible"
|
4
|
+
:attach="attach"
|
5
|
+
:body-class="bodyClass"
|
6
|
+
:body-scroll-lock="bodyScrollLock"
|
7
|
+
:cancel-btn="cancelBtn"
|
8
|
+
:class-prefix="classPrefix"
|
9
|
+
:close-btn="closeBtn"
|
10
|
+
:close-on-esc-keydown="closeOnEscKeydown"
|
11
|
+
:close-on-overlay-click="closeOnOverlayClick"
|
12
|
+
:confirm-btn="confirmBtn"
|
13
|
+
:content="content"
|
14
|
+
:default-visible="defaultVisible"
|
15
|
+
:destroy-on-close="destroyOnClose"
|
16
|
+
:dialog-class="dialogClass"
|
17
|
+
:draggable="draggable"
|
18
|
+
:footer="footer"
|
19
|
+
:header="header"
|
20
|
+
:mode="mode"
|
21
|
+
:placement="placement"
|
22
|
+
:prevent-scroll-through="preventScrollThrough"
|
23
|
+
:show-overlay="showOverlay"
|
24
|
+
:top="top"
|
25
|
+
:width="width"
|
26
|
+
:zIndex="zIndex"
|
27
|
+
@cancel="handleCancel"
|
28
|
+
@close="handleClose"
|
29
|
+
@closed="handleClosed"
|
30
|
+
@confirm="handleConfirm"
|
31
|
+
@opened="handleOpened"
|
32
|
+
@overlay-click="handleOverlayClick"
|
33
|
+
@update:visible="handleUpdateVisible"
|
34
|
+
>
|
35
|
+
<!-- 默认插槽 -->
|
36
|
+
<slot></slot>
|
37
|
+
|
38
|
+
<!-- 页脚插槽 -->
|
39
|
+
<template v-if="$slots.footer" #footer>
|
40
|
+
<slot name="footer"></slot>
|
41
|
+
</template>
|
42
|
+
|
43
|
+
<!-- 头部插槽 -->
|
44
|
+
<template #header>
|
45
|
+
<slot name="header">{{ title }}</slot>
|
46
|
+
</template>
|
47
|
+
</t-dialog>
|
48
|
+
</template>
|
49
|
+
|
50
|
+
<script>
|
51
|
+
export default {
|
52
|
+
name: "EbizDialog"
|
53
|
+
}
|
54
|
+
</script>
|
55
|
+
|
56
|
+
<script setup>
|
57
|
+
import { ref, defineProps, defineEmits, watch } from 'vue';
|
58
|
+
import { Dialog as TDialog } from 'tdesign-vue-next';
|
59
|
+
|
60
|
+
// 定义组件接收的属性
|
61
|
+
const props = defineProps({
|
62
|
+
// 对话框挂载的节点
|
63
|
+
attach: {
|
64
|
+
type: [String, Function, Element],
|
65
|
+
default: 'body'
|
66
|
+
},
|
67
|
+
// 对话框内容的类名
|
68
|
+
bodyClass: {
|
69
|
+
type: String,
|
70
|
+
default: ''
|
71
|
+
},
|
72
|
+
// 是否锁定body滚动
|
73
|
+
bodyScrollLock: {
|
74
|
+
type: Boolean,
|
75
|
+
default: true
|
76
|
+
},
|
77
|
+
// 取消按钮配置
|
78
|
+
cancelBtn: {
|
79
|
+
type: [String, Object, Boolean],
|
80
|
+
default: null
|
81
|
+
},
|
82
|
+
// 类名前缀
|
83
|
+
classPrefix: {
|
84
|
+
type: String,
|
85
|
+
default: 't'
|
86
|
+
},
|
87
|
+
// 关闭按钮配置
|
88
|
+
closeBtn: {
|
89
|
+
type: [String, Object, Boolean],
|
90
|
+
default: true
|
91
|
+
},
|
92
|
+
// 是否支持按ESC键关闭对话框
|
93
|
+
closeOnEscKeydown: {
|
94
|
+
type: Boolean,
|
95
|
+
default: true
|
96
|
+
},
|
97
|
+
// 点击蒙层是否关闭
|
98
|
+
closeOnOverlayClick: {
|
99
|
+
type: Boolean,
|
100
|
+
default: true
|
101
|
+
},
|
102
|
+
// 确认按钮配置
|
103
|
+
confirmBtn: {
|
104
|
+
type: [String, Object, Boolean],
|
105
|
+
default: '确认'
|
106
|
+
},
|
107
|
+
// 对话框内容
|
108
|
+
content: {
|
109
|
+
type: [String, Function],
|
110
|
+
default: ''
|
111
|
+
},
|
112
|
+
// 默认是否显示对话框
|
113
|
+
defaultVisible: {
|
114
|
+
type: Boolean,
|
115
|
+
default: false
|
116
|
+
},
|
117
|
+
// 关闭时是否销毁对话框
|
118
|
+
destroyOnClose: {
|
119
|
+
type: Boolean,
|
120
|
+
default: false
|
121
|
+
},
|
122
|
+
// 对话框样式类
|
123
|
+
dialogClass: {
|
124
|
+
type: String,
|
125
|
+
default: ''
|
126
|
+
},
|
127
|
+
// 是否可拖拽
|
128
|
+
draggable: {
|
129
|
+
type: Boolean,
|
130
|
+
default: false
|
131
|
+
},
|
132
|
+
// 底部内容
|
133
|
+
footer: {
|
134
|
+
type: [Boolean, Function],
|
135
|
+
default: true
|
136
|
+
},
|
137
|
+
// 头部内容
|
138
|
+
header: {
|
139
|
+
type: [Boolean, Function],
|
140
|
+
default: true
|
141
|
+
},
|
142
|
+
// 对话框类型
|
143
|
+
mode: {
|
144
|
+
type: String,
|
145
|
+
default: 'modal',
|
146
|
+
validator: (val) => ['modal', 'modeless', 'full-screen'].includes(val)
|
147
|
+
},
|
148
|
+
// 对话框位置
|
149
|
+
placement: {
|
150
|
+
type: String,
|
151
|
+
default: 'top',
|
152
|
+
validator: (val) => ['top', 'center'].includes(val)
|
153
|
+
},
|
154
|
+
// 防止滚动穿透
|
155
|
+
preventScrollThrough: {
|
156
|
+
type: Boolean,
|
157
|
+
default: true
|
158
|
+
},
|
159
|
+
// 是否显示遮罩层
|
160
|
+
showOverlay: {
|
161
|
+
type: Boolean,
|
162
|
+
default: true
|
163
|
+
},
|
164
|
+
// 对话框标题
|
165
|
+
title: {
|
166
|
+
type: [String, Function],
|
167
|
+
default: ''
|
168
|
+
},
|
169
|
+
// 距离顶部的位置
|
170
|
+
top: {
|
171
|
+
type: [String, Number],
|
172
|
+
default: '15%'
|
173
|
+
},
|
174
|
+
// 对话框可见性
|
175
|
+
visible: {
|
176
|
+
type: Boolean,
|
177
|
+
default: undefined
|
178
|
+
},
|
179
|
+
// 对话框宽度
|
180
|
+
width: {
|
181
|
+
type: [String, Number],
|
182
|
+
default: '500px'
|
183
|
+
},
|
184
|
+
// 对话框层级
|
185
|
+
zIndex: {
|
186
|
+
type: Number,
|
187
|
+
default: 2500
|
188
|
+
}
|
189
|
+
});
|
190
|
+
|
191
|
+
// 定义组件的事件
|
192
|
+
const emit = defineEmits([
|
193
|
+
'cancel',
|
194
|
+
'close',
|
195
|
+
'closed',
|
196
|
+
'confirm',
|
197
|
+
'opened',
|
198
|
+
'overlay-click',
|
199
|
+
'update:visible'
|
200
|
+
]);
|
201
|
+
|
202
|
+
// 内部维护的可见性状态
|
203
|
+
const dialogVisible = ref(props.visible !== undefined ? props.visible : props.defaultVisible);
|
204
|
+
|
205
|
+
// 监听visible属性变化
|
206
|
+
watch(() => props.visible, (newValue) => {
|
207
|
+
dialogVisible.value = newValue;
|
208
|
+
});
|
209
|
+
|
210
|
+
// 取消按钮点击事件
|
211
|
+
const handleCancel = (e) => {
|
212
|
+
emit('cancel', e);
|
213
|
+
};
|
214
|
+
|
215
|
+
// 关闭事件
|
216
|
+
const handleClose = (e) => {
|
217
|
+
emit('close', e);
|
218
|
+
};
|
219
|
+
|
220
|
+
// 关闭动画结束后触发
|
221
|
+
const handleClosed = () => {
|
222
|
+
emit('closed');
|
223
|
+
};
|
224
|
+
|
225
|
+
// 确认按钮点击事件
|
226
|
+
const handleConfirm = (e) => {
|
227
|
+
emit('confirm', e);
|
228
|
+
};
|
229
|
+
|
230
|
+
// 对话框打开动画结束后触发
|
231
|
+
const handleOpened = () => {
|
232
|
+
emit('opened');
|
233
|
+
};
|
234
|
+
|
235
|
+
// 点击遮罩层触发
|
236
|
+
const handleOverlayClick = (context) => {
|
237
|
+
emit('overlay-click', context);
|
238
|
+
};
|
239
|
+
|
240
|
+
// 可见性变化事件
|
241
|
+
const handleUpdateVisible = (visible) => {
|
242
|
+
dialogVisible.value = visible;
|
243
|
+
emit('update:visible', visible);
|
244
|
+
};
|
245
|
+
</script>
|
246
|
+
|
247
|
+
<style lang="less" scoped>
|
248
|
+
/* 自定义样式 */
|
249
|
+
</style>
|
@@ -142,7 +142,8 @@ const focus = () => {
|
|
142
142
|
|
143
143
|
defineExpose({
|
144
144
|
focus,
|
145
|
-
selectRef
|
145
|
+
selectRef,
|
146
|
+
options
|
146
147
|
});
|
147
148
|
|
148
149
|
// 远程搜索处理函数
|
@@ -163,6 +164,7 @@ const handleRemoteSearch = async (keyword) => {
|
|
163
164
|
const { labelField, valueField } = props.optionsConfig;
|
164
165
|
|
165
166
|
options.value = res.data.map(item => ({
|
167
|
+
...item,
|
166
168
|
label: labelField ? item[labelField] : (item.label || item.name),
|
167
169
|
value: valueField ? item[valueField] : (item.value || item.id)
|
168
170
|
}));
|
@@ -211,6 +213,7 @@ onMounted(async () => {
|
|
211
213
|
const { labelField, valueField } = props.optionsConfig;
|
212
214
|
|
213
215
|
options.value = res.data.map(item => ({
|
216
|
+
...item,
|
214
217
|
label: labelField ? item[labelField] : (item.label || item.name),
|
215
218
|
value: valueField ? item[valueField] : (item.value || item.id)
|
216
219
|
}));
|
@@ -1,130 +1,90 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
3
|
-
:data="data"
|
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
|
-
</template>
|
89
|
-
|
90
|
-
<!-- 表头插槽 -->
|
91
|
-
<template v-if="$slots.header" #header>
|
92
|
-
<slot name="header"></slot>
|
93
|
-
</template>
|
94
|
-
|
95
|
-
<!-- 表尾插槽 -->
|
96
|
-
<template v-if="$slots.footer" #footer>
|
97
|
-
<slot name="footer"></slot>
|
98
|
-
</template>
|
99
|
-
|
100
|
-
<!-- 自定义单元格插槽 -->
|
101
|
-
<template v-if="$slots.cell" #cell="slotProps">
|
102
|
-
<slot name="cell" v-bind="slotProps"></slot>
|
103
|
-
</template>
|
104
|
-
|
105
|
-
<!-- 展开行插槽 -->
|
106
|
-
<template v-if="$slots.expandedRow" #expandedRow="slotProps">
|
107
|
-
<slot name="expandedRow" v-bind="slotProps"></slot>
|
108
|
-
</template>
|
109
|
-
|
110
|
-
<!-- 过滤图标插槽 -->
|
111
|
-
<template v-if="$slots.filterIcon" #filterIcon="slotProps">
|
112
|
-
<slot name="filterIcon" v-bind="slotProps"></slot>
|
113
|
-
</template>
|
114
|
-
|
115
|
-
<!-- 自定义列配置按钮插槽 -->
|
116
|
-
<template v-if="$slots.columnController" #columnController="slotProps">
|
117
|
-
<slot name="columnController" v-bind="slotProps"></slot>
|
118
|
-
</template>
|
119
|
-
|
120
|
-
<!-- 自定义分页器插槽 -->
|
121
|
-
<template v-if="$slots.pagination" #pagination="slotProps">
|
122
|
-
<slot name="pagination" v-bind="slotProps"></slot>
|
123
|
-
</template>
|
124
|
-
|
125
|
-
<!-- 默认插槽 -->
|
126
|
-
<slot></slot>
|
127
|
-
</t-table>
|
2
|
+
<div>
|
3
|
+
<t-table :data="data" :columns="mergedColumns" :row-key="rowKey" :vertical-align="verticalAlign"
|
4
|
+
:horizontal-align="horizontalAlign" :size="size" :bordered="bordered" :stripe="stripe" :hover="hover"
|
5
|
+
:height="height" :max-height="maxHeight" :loading="loading" :loading-props="loadingProps" :load-more="loadMore"
|
6
|
+
:empty="empty" :table-layout="tableLayout" :cell-empty-content="cellEmptyContent" :pagination="pagination"
|
7
|
+
:show-header="showHeader" :header-affixed-top="headerAffixedTop" :footer-affixed-bottom="footerAffixedBottom"
|
8
|
+
:top-content="topContent" :bottom-content="bottomContent" :sort="sort" :filter-value="filterValue"
|
9
|
+
:filter-icon="filterIcon" :tree="tree" :resizable="resizable" :column-controller="columnController"
|
10
|
+
:column-controller-visible="columnControllerVisible" :expandable="expandable" :disabled-sort="disabledSort"
|
11
|
+
:virtual-scroll="virtualScroll" :indent="indent" :row-attributes="rowAttributes" :scroll="scroll"
|
12
|
+
:show-sort-column-bg="showSortColumnBg" :allow-sort-by-click-header="allowSortByClickHeader" :dragSort="dragSort"
|
13
|
+
:select-on-row-click="selectOnRowClick" :merge-cells="mergeCells" :value="value" :row-className="rowClassName"
|
14
|
+
:fixed-rows="fixedRows" :highlight-current-row="highlightCurrentRow" :ellipsis-title="ellipsisTitle"
|
15
|
+
@page-change="handlePageChange" @sort-change="handleSortChange" @filter-change="handleFilterChange"
|
16
|
+
@select-change="handleSelectChange" @expanded-change="handleExpandedChange" @cell-click="handleCellClick"
|
17
|
+
@row-click="handleRowClick" @row-hover="handleRowHover" @row-dblclick="handleRowDblclick" @scroll="handleScroll"
|
18
|
+
@column-change="handleColumnChange" @expand-all="handleExpandAll" @tree-expand-change="handleTreeExpandChange"
|
19
|
+
@display-columns-change="handleDisplayColumnsChange"
|
20
|
+
@column-controller-visible-change="handleColumnControllerVisibleChange" @drag-sort="handleDragSort"
|
21
|
+
@validate="handleValidate">
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
<!-- 顶部内容插槽 -->
|
26
|
+
<template v-if="$slots.topContent" #topContent>
|
27
|
+
<slot name="topContent"></slot>
|
28
|
+
</template>
|
29
|
+
|
30
|
+
<!-- 底部内容插槽 -->
|
31
|
+
<template v-if="$slots.bottomContent" #bottomContent>
|
32
|
+
<slot name="bottomContent"></slot>
|
33
|
+
</template>
|
34
|
+
|
35
|
+
<!-- 空状态插槽 -->
|
36
|
+
<template v-if="$slots.empty" #empty>
|
37
|
+
<slot name="empty"></slot>
|
38
|
+
</template>
|
39
|
+
|
40
|
+
<!-- 加载更多插槽 -->
|
41
|
+
<template v-if="$slots.loadMore" #loadMore>
|
42
|
+
<slot name="loadMore"></slot>
|
43
|
+
</template>
|
44
|
+
|
45
|
+
<!-- 表头插槽 -->
|
46
|
+
<template v-if="$slots.header" #header>
|
47
|
+
<slot name="header"></slot>
|
48
|
+
</template>
|
49
|
+
|
50
|
+
<!-- 表尾插槽 -->
|
51
|
+
<template v-if="$slots.footer" #footer>
|
52
|
+
<slot name="footer"></slot>
|
53
|
+
</template>
|
54
|
+
|
55
|
+
<!-- 自定义单元格插槽 -->
|
56
|
+
<template v-for="column in dynamicColumns" :key="column.colKey" v-if="column.cell" #[column.cell]="cellProps">
|
57
|
+
<slot :name="`cell-${column.colKey}`" v-bind="cellProps"></slot>
|
58
|
+
</template>
|
59
|
+
<template v-for="column in dynamicColumns" :key="column.colKey" v-if="column.title" #[column.title]="titleProps">
|
60
|
+
<slot :name="`title-${column.colKey}`" v-bind="titleProps"></slot>
|
61
|
+
</template>
|
62
|
+
|
63
|
+
<!-- 展开行插槽 -->
|
64
|
+
<template v-if="$slots.expandedRow" #expandedRow="slotProps">
|
65
|
+
<slot name="expandedRow" v-bind="slotProps"></slot>
|
66
|
+
</template>
|
67
|
+
|
68
|
+
<!-- 过滤图标插槽 -->
|
69
|
+
<template v-if="$slots.filterIcon" #filterIcon="slotProps">
|
70
|
+
<slot name="filterIcon" v-bind="slotProps"></slot>
|
71
|
+
</template>
|
72
|
+
|
73
|
+
<!-- 自定义列配置按钮插槽 -->
|
74
|
+
<template v-if="$slots.columnController" #columnController="slotProps">
|
75
|
+
<slot name="columnController" v-bind="slotProps"></slot>
|
76
|
+
</template>
|
77
|
+
|
78
|
+
<!-- 自定义分页器插槽 -->
|
79
|
+
<template v-if="$slots.pagination" #pagination="slotProps">
|
80
|
+
<slot name="pagination" v-bind="slotProps"></slot>
|
81
|
+
</template>
|
82
|
+
|
83
|
+
<!-- 默认插槽 -->
|
84
|
+
<slot></slot>
|
85
|
+
</t-table>
|
86
|
+
</div>
|
87
|
+
|
128
88
|
</template>
|
129
89
|
|
130
90
|
<script>
|
@@ -134,8 +94,8 @@ export default {
|
|
134
94
|
</script>
|
135
95
|
|
136
96
|
<script setup>
|
137
|
-
import {
|
138
|
-
import { Table
|
97
|
+
import { ref, computed, onMounted, watch, provide } from 'vue';
|
98
|
+
import { Table } from 'tdesign-vue-next';
|
139
99
|
|
140
100
|
const props = defineProps({
|
141
101
|
// 表格数据
|
@@ -284,8 +244,8 @@ const props = defineProps({
|
|
284
244
|
},
|
285
245
|
// 列配置器
|
286
246
|
columnController: {
|
287
|
-
type:
|
288
|
-
default:
|
247
|
+
type: Boolean,
|
248
|
+
default: false
|
289
249
|
},
|
290
250
|
// 列配置器是否显示
|
291
251
|
columnControllerVisible: {
|
@@ -335,8 +295,8 @@ const props = defineProps({
|
|
335
295
|
// 拖拽排序配置
|
336
296
|
dragSort: {
|
337
297
|
type: String,
|
338
|
-
default:
|
339
|
-
validator: (val) => ['
|
298
|
+
default: '',
|
299
|
+
validator: (val) => ['', 'row', 'col', 'row-handler', 'row-handler-col'].includes(val)
|
340
300
|
},
|
341
301
|
// 点击行是否选中
|
342
302
|
selectOnRowClick: {
|
@@ -371,7 +331,7 @@ const props = defineProps({
|
|
371
331
|
// 表头文字超出是否显示省略号
|
372
332
|
ellipsisTitle: {
|
373
333
|
type: Boolean,
|
374
|
-
default:
|
334
|
+
default: false
|
375
335
|
}
|
376
336
|
});
|
377
337
|
|
@@ -395,6 +355,26 @@ const emit = defineEmits([
|
|
395
355
|
'validate'
|
396
356
|
]);
|
397
357
|
|
358
|
+
// 动态列配置(由EbizTableColumn子组件注册)
|
359
|
+
const dynamicColumns = ref([]);
|
360
|
+
|
361
|
+
// 合并props中的columns和动态注册的columns
|
362
|
+
const mergedColumns = computed(() => {
|
363
|
+
return [...props.columns, ...dynamicColumns.value];
|
364
|
+
});
|
365
|
+
|
366
|
+
// 提供注册列的方法给子组件
|
367
|
+
const registerColumn = (column) => {
|
368
|
+
if (!dynamicColumns.value.some(item => item.colKey === column.colKey)) {
|
369
|
+
dynamicColumns.value.push(column);
|
370
|
+
}
|
371
|
+
};
|
372
|
+
|
373
|
+
// 提供表格上下文给子组件
|
374
|
+
provide('tableCtx', {
|
375
|
+
registerColumn
|
376
|
+
});
|
377
|
+
|
398
378
|
// 分页变化
|
399
379
|
const handlePageChange = (pageInfo) => {
|
400
380
|
emit('page-change', pageInfo);
|
@@ -0,0 +1,117 @@
|
|
1
|
+
<script setup>
|
2
|
+
import { computed, inject, onMounted, getCurrentInstance } from 'vue';
|
3
|
+
|
4
|
+
const props = defineProps({
|
5
|
+
// 列唯一标识
|
6
|
+
colKey: {
|
7
|
+
type: String,
|
8
|
+
required: true
|
9
|
+
},
|
10
|
+
// 列标题
|
11
|
+
title: {
|
12
|
+
type: String,
|
13
|
+
default: ''
|
14
|
+
},
|
15
|
+
// 列宽度
|
16
|
+
width: {
|
17
|
+
type: [String, Number],
|
18
|
+
default: ''
|
19
|
+
},
|
20
|
+
// 最小列宽
|
21
|
+
minWidth: {
|
22
|
+
type: [String, Number],
|
23
|
+
default: ''
|
24
|
+
},
|
25
|
+
// 水平对齐方式
|
26
|
+
align: {
|
27
|
+
type: String,
|
28
|
+
default: 'left',
|
29
|
+
validator: (val) => ['left', 'center', 'right'].includes(val)
|
30
|
+
},
|
31
|
+
// 固定列位置
|
32
|
+
fixed: {
|
33
|
+
type: String,
|
34
|
+
default: '',
|
35
|
+
validator: (val) => ['', 'left', 'right'].includes(val)
|
36
|
+
},
|
37
|
+
// 列类型
|
38
|
+
type: {
|
39
|
+
type: String,
|
40
|
+
default: '',
|
41
|
+
validator: (val) => ['', 'multiple', 'single', 'index', 'expand'].includes(val)
|
42
|
+
},
|
43
|
+
// 超出省略
|
44
|
+
ellipsis: {
|
45
|
+
type: Boolean,
|
46
|
+
default: false
|
47
|
+
},
|
48
|
+
// 标题超出省略
|
49
|
+
ellipsisTitle: {
|
50
|
+
type: Boolean,
|
51
|
+
default: false
|
52
|
+
},
|
53
|
+
// 是否支持排序
|
54
|
+
sorter: {
|
55
|
+
type: Boolean,
|
56
|
+
default: false
|
57
|
+
},
|
58
|
+
// 过滤配置
|
59
|
+
filter: {
|
60
|
+
type: Object,
|
61
|
+
default: null
|
62
|
+
},
|
63
|
+
// 自定义类名
|
64
|
+
className: {
|
65
|
+
type: String,
|
66
|
+
default: ''
|
67
|
+
},
|
68
|
+
// 是否禁用
|
69
|
+
disabled: {
|
70
|
+
type: Boolean,
|
71
|
+
default: false
|
72
|
+
}
|
73
|
+
});
|
74
|
+
|
75
|
+
// 获取父级表格组件实例
|
76
|
+
const tableCtx = inject('tableCtx', null);
|
77
|
+
const instance = getCurrentInstance();
|
78
|
+
|
79
|
+
// 格式化列配置对象
|
80
|
+
const columnConfig = computed(() => {
|
81
|
+
return {
|
82
|
+
colKey: props.colKey,
|
83
|
+
title: props.title,
|
84
|
+
width: props.width,
|
85
|
+
minWidth: props.minWidth,
|
86
|
+
align: props.align,
|
87
|
+
fixed: props.fixed || '',
|
88
|
+
type: props.type || '',
|
89
|
+
ellipsis: props.ellipsis,
|
90
|
+
ellipsisTitle: props.ellipsisTitle,
|
91
|
+
sorter: props.sorter,
|
92
|
+
filter: props.filter,
|
93
|
+
className: props.className,
|
94
|
+
disabled: props.disabled,
|
95
|
+
cell: instance.slots.default ? props.colKey : undefined,
|
96
|
+
title: instance.slots.title ? `title-${props.colKey}` : undefined
|
97
|
+
};
|
98
|
+
});
|
99
|
+
|
100
|
+
// 在组件挂载时将列配置注册到表格组件
|
101
|
+
onMounted(() => {
|
102
|
+
if (tableCtx && typeof tableCtx.registerColumn === 'function') {
|
103
|
+
tableCtx.registerColumn(columnConfig.value);
|
104
|
+
} else {
|
105
|
+
console.warn('EbizTableColumn必须在EbizTable内部使用');
|
106
|
+
}
|
107
|
+
});
|
108
|
+
</script>
|
109
|
+
|
110
|
+
<template>
|
111
|
+
<template v-if="$slots.default">
|
112
|
+
<slot></slot>
|
113
|
+
</template>
|
114
|
+
<template v-if="$slots.title">
|
115
|
+
<slot name="title"></slot>
|
116
|
+
</template>
|
117
|
+
</template>
|