@ebiz/designer-components 0.0.18-kzy.1 → 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 +14954 -14547
- 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/EbizStatusBadge.vue +182 -0
- 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 +9 -1
- package/src/router/index.js +26 -5
- package/src/views/Home.vue +4 -1
- package/src/views/StatusBadgeExample.vue +146 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
package/package.json
CHANGED
@@ -7,8 +7,10 @@
|
|
7
7
|
import axios from 'axios'
|
8
8
|
import { TinyNotify } from '@opentiny/vue'
|
9
9
|
|
10
|
-
//
|
11
|
-
const API_BASE_URL = "http://localhost:8090/api";
|
10
|
+
// 本地开发使用
|
11
|
+
// const API_BASE_URL = "http://localhost:8090/api";
|
12
|
+
// 组件发布使用
|
13
|
+
const API_BASE_URL = 'http://' + window.location.host + '/api'
|
12
14
|
|
13
15
|
/**
|
14
16
|
* 创建axios实例
|
@@ -0,0 +1,104 @@
|
|
1
|
+
<template>
|
2
|
+
<tiny-tooltip :content="!isNormal && !apiConfig.apiId ? tooltipText : ''" placement="top">
|
3
|
+
|
4
|
+
<tiny-button :disabled="disabled" :type="type" :size="size" @click="click">
|
5
|
+
<slot>{{ text }}</slot>
|
6
|
+
</tiny-button>
|
7
|
+
|
8
|
+
</tiny-tooltip>
|
9
|
+
</template>
|
10
|
+
|
11
|
+
|
12
|
+
<script lang='js'>
|
13
|
+
export default {
|
14
|
+
name: "EbizButton"
|
15
|
+
}
|
16
|
+
</script>
|
17
|
+
|
18
|
+
<script lang='js' setup>
|
19
|
+
|
20
|
+
import { ref, reactive, computed, toRef, toRefs } from 'vue';
|
21
|
+
import { TinyButton, TinyTooltip, TinyNotify } from '@opentiny/vue';
|
22
|
+
import dataService from '../apiService/simpleDataService';
|
23
|
+
|
24
|
+
|
25
|
+
const props = defineProps({
|
26
|
+
text: {
|
27
|
+
type: String,
|
28
|
+
default: ''
|
29
|
+
},
|
30
|
+
isNormal: {//是否为普通按钮
|
31
|
+
type: Boolean,
|
32
|
+
default: false
|
33
|
+
},
|
34
|
+
disabled: {
|
35
|
+
type: Boolean,
|
36
|
+
default: false
|
37
|
+
},
|
38
|
+
type: {//'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text'
|
39
|
+
type: String,
|
40
|
+
default: 'default'
|
41
|
+
},
|
42
|
+
size: {//'large' | 'medium' | 'small' | 'mini'
|
43
|
+
type: String,
|
44
|
+
default: 'medium'
|
45
|
+
},
|
46
|
+
apiConfig: {//接口配置
|
47
|
+
type: Object,
|
48
|
+
default: {
|
49
|
+
key: null,
|
50
|
+
apiId: null,
|
51
|
+
apiType: ''
|
52
|
+
}
|
53
|
+
},
|
54
|
+
data: {
|
55
|
+
type: Object,
|
56
|
+
default: {}
|
57
|
+
},
|
58
|
+
onClick: {
|
59
|
+
type: Function,
|
60
|
+
default: () => { }
|
61
|
+
},
|
62
|
+
onPrepare: {//调用接口前置事件
|
63
|
+
type: Function,
|
64
|
+
default: () => { }
|
65
|
+
},
|
66
|
+
onFinish: {//调用接口后置事件
|
67
|
+
type: Function,
|
68
|
+
default: () => { }
|
69
|
+
}
|
70
|
+
})
|
71
|
+
|
72
|
+
const apiMap = [
|
73
|
+
'MULTIPLE_DATA_SEARCH',
|
74
|
+
'DETAILS_DATA',
|
75
|
+
'INTERFACE_PLUGIN',
|
76
|
+
'DATA_INSERT',
|
77
|
+
'BATCH_DATA_INSERT',
|
78
|
+
'DATA_MODIFY',
|
79
|
+
'BATCH_DATA_MODIFY',
|
80
|
+
'DEL_DATA',
|
81
|
+
'BATCH_DEL_DATA',
|
82
|
+
'MULTIPLE_DATA_LINK_SEARCH'
|
83
|
+
];
|
84
|
+
|
85
|
+
const emit = defineEmits(['click'])
|
86
|
+
|
87
|
+
const { text, isNormal, disabled, type, size, apiConfig, data, isUseMethod } = toRefs(props)
|
88
|
+
|
89
|
+
const tooltipText = ref('请先设置接口配置')
|
90
|
+
|
91
|
+
const click = () => {
|
92
|
+
props.onClick()
|
93
|
+
if (!isNormal.value && apiConfig.value.apiId) {
|
94
|
+
props.onPrepare()
|
95
|
+
dataService.fetch(data.value, { key: apiConfig.value.key, apiId: apiConfig.value.apiId, apiType: apiMap[apiConfig.value.apiType] }).then((res) => {
|
96
|
+
emit('click', res)
|
97
|
+
props.onFinish()
|
98
|
+
})
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
</script>
|
103
|
+
|
104
|
+
<style lang='less' scoped></style>
|
@@ -62,7 +62,7 @@ const props = defineProps({
|
|
62
62
|
*/
|
63
63
|
clearable: {
|
64
64
|
type: Boolean,
|
65
|
-
default:
|
65
|
+
default: false
|
66
66
|
},
|
67
67
|
/**
|
68
68
|
* 是否禁用
|
@@ -155,11 +155,16 @@ const handleRemoteSearch = async (keyword) => {
|
|
155
155
|
keyword
|
156
156
|
}
|
157
157
|
};
|
158
|
-
const res = await dataService.fetch(params,
|
158
|
+
const res = await dataService.fetch(params, {
|
159
|
+
key: props.apiConfig.key,
|
160
|
+
apiId: props.apiConfig.apiId,
|
161
|
+
apiType: 'MULTIPLE_DATA_SEARCH'
|
162
|
+
});
|
159
163
|
|
160
164
|
options.value = res.data.map(item => ({
|
161
|
-
|
162
|
-
|
165
|
+
...item,
|
166
|
+
label: labelField.value ? item[labelField.value] : (item.label || item.name),
|
167
|
+
value: valueField.value ? item[valueField.value] : (item.value || item.id)
|
163
168
|
}));
|
164
169
|
} catch (error) {
|
165
170
|
console.error('远程搜索失败:', error);
|
@@ -188,7 +193,11 @@ const handleBlur = (value, context) => {
|
|
188
193
|
const handleChange = (value, context) => {
|
189
194
|
emit('update:modelValue', value);
|
190
195
|
emit('change', value, context);
|
191
|
-
|
196
|
+
if (value instanceof Array) {
|
197
|
+
emit('selectOption', options.value.filter(item => value.includes(item.value)));
|
198
|
+
} else {
|
199
|
+
emit('selectOption', options.value.find(item => item.value === value));
|
200
|
+
}
|
192
201
|
};
|
193
202
|
|
194
203
|
// 组件挂载时,如果有默认值则加载对应的选项
|
@@ -205,10 +214,10 @@ onMounted(async () => {
|
|
205
214
|
apiType: 'MULTIPLE_DATA_SEARCH'
|
206
215
|
});
|
207
216
|
|
208
|
-
console.log('res', res)
|
209
217
|
options.value = res.data.map(item => ({
|
210
|
-
|
211
|
-
|
218
|
+
...item,
|
219
|
+
label: labelField.value ? item[labelField.value] : (item.label || item.name),
|
220
|
+
value: valueField.value ? item[valueField.value] : (item.value || item.id)
|
212
221
|
}));
|
213
222
|
} catch (error) {
|
214
223
|
console.error('加载默认选项失败:', error);
|
@@ -0,0 +1,182 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-status-badge" :style="containerStyle">
|
3
|
+
<div class="status-indicator" :style="indicatorStyle"></div>
|
4
|
+
<div class="status-text" v-if="showText">{{ text }}</div>
|
5
|
+
</div>
|
6
|
+
</template>
|
7
|
+
|
8
|
+
<script>
|
9
|
+
export default {
|
10
|
+
name: "EbizStatusBadge"
|
11
|
+
}
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script setup>
|
15
|
+
import { computed } from 'vue';
|
16
|
+
|
17
|
+
const props = defineProps({
|
18
|
+
/**
|
19
|
+
* 状态类型
|
20
|
+
*/
|
21
|
+
status: {
|
22
|
+
type: String,
|
23
|
+
default: 'default',
|
24
|
+
validator: (val) => ['default', 'success', 'warning', 'error', 'processing'].includes(val)
|
25
|
+
},
|
26
|
+
/**
|
27
|
+
* 自定义颜色
|
28
|
+
*/
|
29
|
+
color: {
|
30
|
+
type: String,
|
31
|
+
default: ''
|
32
|
+
},
|
33
|
+
/**
|
34
|
+
* 自定义预设颜色映射
|
35
|
+
*/
|
36
|
+
colorMap: {
|
37
|
+
type: Object,
|
38
|
+
default: () => ({})
|
39
|
+
},
|
40
|
+
/**
|
41
|
+
* 指示点大小
|
42
|
+
*/
|
43
|
+
size: {
|
44
|
+
type: [String, Number],
|
45
|
+
default: 'small',
|
46
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val) || typeof val === 'number'
|
47
|
+
},
|
48
|
+
/**
|
49
|
+
* 是否显示文字
|
50
|
+
*/
|
51
|
+
showText: {
|
52
|
+
type: Boolean,
|
53
|
+
default: true
|
54
|
+
},
|
55
|
+
/**
|
56
|
+
* 状态文字
|
57
|
+
*/
|
58
|
+
text: {
|
59
|
+
type: String,
|
60
|
+
default: ''
|
61
|
+
},
|
62
|
+
/**
|
63
|
+
* 状态点位置
|
64
|
+
*/
|
65
|
+
position: {
|
66
|
+
type: String,
|
67
|
+
default: 'left',
|
68
|
+
validator: (val) => ['left', 'right', 'top', 'bottom'].includes(val)
|
69
|
+
},
|
70
|
+
/**
|
71
|
+
* 闪烁效果
|
72
|
+
*/
|
73
|
+
pulse: {
|
74
|
+
type: Boolean,
|
75
|
+
default: false
|
76
|
+
}
|
77
|
+
});
|
78
|
+
|
79
|
+
// 获取预设状态颜色
|
80
|
+
const getStatusColor = (status) => {
|
81
|
+
const defaultColorMap = {
|
82
|
+
default: '#999999',
|
83
|
+
success: '#35c613',
|
84
|
+
warning: '#ed7b2f',
|
85
|
+
error: '#e34d59',
|
86
|
+
processing: '#0052d9'
|
87
|
+
};
|
88
|
+
|
89
|
+
// 优先使用props.color,其次使用用户提供的colorMap,最后使用默认颜色
|
90
|
+
return props.color || props.colorMap[status] || defaultColorMap[status];
|
91
|
+
};
|
92
|
+
|
93
|
+
// 获取点大小
|
94
|
+
const getSize = () => {
|
95
|
+
if (typeof props.size === 'number') {
|
96
|
+
return `${props.size}px`;
|
97
|
+
}
|
98
|
+
|
99
|
+
const sizeMap = {
|
100
|
+
small: '6px',
|
101
|
+
medium: '10px',
|
102
|
+
large: '14px'
|
103
|
+
};
|
104
|
+
|
105
|
+
return sizeMap[props.size];
|
106
|
+
};
|
107
|
+
|
108
|
+
// 计算指示器样式
|
109
|
+
const indicatorStyle = computed(() => {
|
110
|
+
const style = {
|
111
|
+
backgroundColor: getStatusColor(props.status),
|
112
|
+
width: getSize(),
|
113
|
+
height: getSize(),
|
114
|
+
animationName: props.pulse ? 'ebiz-status-pulse' : 'none'
|
115
|
+
};
|
116
|
+
|
117
|
+
return style;
|
118
|
+
});
|
119
|
+
|
120
|
+
// 计算容器样式
|
121
|
+
const containerStyle = computed(() => {
|
122
|
+
const style = {
|
123
|
+
flexDirection: 'row', // 默认水平排列
|
124
|
+
};
|
125
|
+
|
126
|
+
// 根据位置调整排列方向
|
127
|
+
if (props.position === 'top' || props.position === 'bottom') {
|
128
|
+
style.flexDirection = props.position === 'top' ? 'column-reverse' : 'column';
|
129
|
+
} else {
|
130
|
+
style.flexDirection = props.position === 'left' ? 'row' : 'row-reverse';
|
131
|
+
}
|
132
|
+
|
133
|
+
return style;
|
134
|
+
});
|
135
|
+
</script>
|
136
|
+
|
137
|
+
<style scoped>
|
138
|
+
.ebiz-status-badge {
|
139
|
+
display: inline-flex;
|
140
|
+
align-items: center;
|
141
|
+
font-size: 14px;
|
142
|
+
line-height: 1;
|
143
|
+
}
|
144
|
+
|
145
|
+
.status-indicator {
|
146
|
+
border-radius: 50%;
|
147
|
+
flex-shrink: 0;
|
148
|
+
}
|
149
|
+
|
150
|
+
.status-text {
|
151
|
+
margin-left: 8px;
|
152
|
+
}
|
153
|
+
|
154
|
+
.ebiz-status-badge[style*="column"] .status-text {
|
155
|
+
margin-left: 0;
|
156
|
+
margin-top: 4px;
|
157
|
+
}
|
158
|
+
|
159
|
+
.ebiz-status-badge[style*="row-reverse"] .status-text {
|
160
|
+
margin-left: 0;
|
161
|
+
margin-right: 8px;
|
162
|
+
}
|
163
|
+
|
164
|
+
@keyframes ebiz-status-pulse {
|
165
|
+
0% {
|
166
|
+
opacity: 1;
|
167
|
+
transform: scale(1);
|
168
|
+
}
|
169
|
+
50% {
|
170
|
+
opacity: 0.6;
|
171
|
+
transform: scale(1.2);
|
172
|
+
}
|
173
|
+
100% {
|
174
|
+
opacity: 1;
|
175
|
+
transform: scale(1);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
.status-indicator[style*="ebiz-status-pulse"] {
|
180
|
+
animation: ebiz-status-pulse 1.5s infinite ease-in-out;
|
181
|
+
}
|
182
|
+
</style>
|
@@ -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);
|