@ebiz/designer-components 0.0.18-kzy.2 → 0.0.18-kzy.4
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 +2 -2
- package/dist/index.mjs +46510 -41918
- package/package.json +1 -1
- package/src/apiService/simpleDataService.js +9 -4
- package/src/components/Button.vue +1 -1
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +249 -0
- package/src/components/EbizPageHeader.vue +96 -0
- package/src/components/EbizRemoteSelect.vue +22 -11
- 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/components/EbizTimePicker.vue +144 -0
- package/src/components/EbizTree.vue +153 -0
- package/src/components/EbizTreeSelector.vue +423 -0
- package/src/components/TddesignButton.vue +153 -0
- package/src/components/TdesignUpload.vue +2 -3
- package/src/components/TinyGridEditorSelect.vue +238 -0
- package/src/index.js +22 -1
- package/src/router/index.js +64 -5
- package/src/views/Button.vue +7 -3
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/Home.vue +33 -2
- package/src/views/PageHeaderDemo.vue +105 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TimePickerDemo.vue +147 -0
- package/src/views/TreeDemo.vue +255 -0
- package/src/views/TreeSelectorDemo.vue +246 -0
@@ -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>
|
@@ -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>
|