@lx-frontend/wrap-element-ui 1.0.13 → 1.0.14-beta.2
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/EditableTable/bizHooks/useColumnHeaderOperation.ts +71 -39
- package/src/components/EditableTable/features/bizTableHeaderPopover.vue +79 -45
- package/src/components/EditableTable/index.less +21 -4
- package/src/components/EditableTable/index.vue +10 -9
- package/src/components/EditableTable/types/index.ts +22 -6
package/package.json
CHANGED
|
@@ -16,11 +16,11 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
16
16
|
|
|
17
17
|
// 生效中的排序配置
|
|
18
18
|
const sortType = ref<'ascending' | 'descending' | null>(null);
|
|
19
|
-
const
|
|
19
|
+
const sortProp = ref('')
|
|
20
20
|
|
|
21
21
|
// 临时的排序配置
|
|
22
22
|
const tempSortType = ref<'ascending' | 'descending' | ''>('');
|
|
23
|
-
const
|
|
23
|
+
const tempSortProp = ref('')
|
|
24
24
|
|
|
25
25
|
// 生效中的过滤配置 和 临时过滤配置
|
|
26
26
|
const filteredValue = ref<Record<string, string | number | number[] | string[]>>({});
|
|
@@ -78,17 +78,28 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
78
78
|
&& (searchValue.value[column.doubleDatePicker.props[0]] || searchValue.value[column.doubleDatePicker.props[1]])
|
|
79
79
|
)
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
const isUseFilter = !!(column.filters && (Array.isArray(column.filters)
|
|
82
|
+
? (filteredValue.value[column.prop] as any[]).length
|
|
83
|
+
: column.filters.type === 'radio'
|
|
84
|
+
? filteredValue.value[column.filters.prop || column.prop]
|
|
85
|
+
: (filteredValue.value[column.filters.prop || column.prop] as any[]).length))
|
|
86
|
+
|
|
87
|
+
const isUseSort = Array.isArray(column._sortable)
|
|
88
|
+
? column._sortable.some(v => v.prop === sortProp.value)
|
|
89
|
+
: sortProp.value === column.prop
|
|
90
|
+
|
|
91
|
+
const isUseSearch = Array.isArray(column.search)
|
|
92
|
+
? column.search?.some(v => {
|
|
93
|
+
const props = typeof v.prop === 'string' ? [v.prop] : v.prop
|
|
94
|
+
return props.some(p => searchValue.value[p])
|
|
95
|
+
})
|
|
96
|
+
: !!searchValue.value[column.prop]
|
|
97
|
+
|
|
98
|
+
return isUseFilter
|
|
99
|
+
|| isUseSearch
|
|
100
|
+
|| hasPickerParams
|
|
101
|
+
|| isUseSort
|
|
102
|
+
|| summaryList.value.includes(column.prop);
|
|
92
103
|
}
|
|
93
104
|
|
|
94
105
|
const handleHeaderPopoverShow = (column: IColumnConfig) => {
|
|
@@ -97,7 +108,7 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
97
108
|
tempFilteredValue.value = { ...filteredValue.value };
|
|
98
109
|
tempSearchValue.value = { ...searchValue.value };
|
|
99
110
|
tempSortType.value = sortType.value || '';
|
|
100
|
-
|
|
111
|
+
tempSortProp.value = sortProp.value || '';
|
|
101
112
|
// 临时合计项设置成实际的合计项
|
|
102
113
|
tempSummaryList.value = [...summaryList.value];
|
|
103
114
|
}
|
|
@@ -110,9 +121,9 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
110
121
|
});
|
|
111
122
|
}
|
|
112
123
|
|
|
113
|
-
const handleSort = (type: 'ascending' | 'descending',
|
|
124
|
+
const handleSort = (type: 'ascending' | 'descending', prop: string) => {
|
|
114
125
|
tempSortType.value = type;
|
|
115
|
-
|
|
126
|
+
tempSortProp.value = prop;
|
|
116
127
|
}
|
|
117
128
|
|
|
118
129
|
const columnMap = computed(() => {
|
|
@@ -130,12 +141,16 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
130
141
|
showingColumns.value.forEach(prop => {
|
|
131
142
|
const column = columnMap.value[prop]
|
|
132
143
|
if (column.filters) {
|
|
133
|
-
|
|
144
|
+
const _prop = (Array.isArray(column.filters) ? prop : column.filters.prop) || prop
|
|
145
|
+
params[_prop] = filteredValue.value[_prop]
|
|
134
146
|
}
|
|
135
147
|
if (column.search) {
|
|
136
148
|
if (Array.isArray(column.search)) {
|
|
137
149
|
column.search.forEach(v => {
|
|
138
|
-
|
|
150
|
+
const props = typeof v.prop === 'string' ? [v.prop] : v.prop
|
|
151
|
+
props.forEach(p => {
|
|
152
|
+
params[p] = searchValue.value[p]
|
|
153
|
+
})
|
|
139
154
|
})
|
|
140
155
|
} else {
|
|
141
156
|
params[prop] = searchValue.value[prop]
|
|
@@ -168,11 +183,13 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
168
183
|
if (Array.isArray(column.search)) {
|
|
169
184
|
let validate = true;
|
|
170
185
|
column.search.forEach(v => {
|
|
171
|
-
if (!
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
186
|
+
if (!('type' in v) || v.type === 'input') {
|
|
187
|
+
if (!tempSearchValue.value[v.prop]) tempSearchValue.value[v.prop] = ''
|
|
188
|
+
if (!validate) return
|
|
189
|
+
if (v.validator) {
|
|
190
|
+
const result = v.validator(tempSearchValue.value[v.prop]?.trim());
|
|
191
|
+
if (validate && !result) validate = false;
|
|
192
|
+
}
|
|
176
193
|
}
|
|
177
194
|
})
|
|
178
195
|
// 校验未通过
|
|
@@ -183,18 +200,18 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
183
200
|
}
|
|
184
201
|
|
|
185
202
|
summaryList.value = [...tempSummaryList.value];
|
|
186
|
-
|
|
203
|
+
sortProp.value = tempSortProp.value || '';
|
|
187
204
|
sortType.value = tempSortType.value || null;
|
|
188
205
|
|
|
189
|
-
if (
|
|
206
|
+
if (sortProp.value) { // 确认时提交排序
|
|
190
207
|
if (props.localSort) {
|
|
191
208
|
// 恢复列配置的sortable属性,只有列配置的sortable为true,才能用下面的sort方法
|
|
192
209
|
inSorting.value = true;
|
|
193
210
|
await nextTick();
|
|
194
|
-
tableDomRef.value?.sort(
|
|
211
|
+
tableDomRef.value?.sort(sortProp.value, sortType.value);
|
|
195
212
|
inSorting.value = false
|
|
196
213
|
} else {
|
|
197
|
-
emit('sort-change', { order: sortType.value, prop:
|
|
214
|
+
emit('sort-change', { order: sortType.value, prop: sortProp.value });
|
|
198
215
|
}
|
|
199
216
|
}
|
|
200
217
|
|
|
@@ -214,7 +231,7 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
214
231
|
}
|
|
215
232
|
|
|
216
233
|
const clearSort = () => {
|
|
217
|
-
|
|
234
|
+
sortProp.value = '';
|
|
218
235
|
sortType.value = null;
|
|
219
236
|
if (props.localSort) { // 前端过滤
|
|
220
237
|
tableDomRef.value?.clearSort();
|
|
@@ -224,9 +241,12 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
224
241
|
}
|
|
225
242
|
|
|
226
243
|
const setSort = (params: { order: 'ascending' | 'descending', prop: string }) => {
|
|
227
|
-
const column = props.columnConfig.find(c => c.
|
|
244
|
+
const column = props.columnConfig.find(c => Array.isArray(c.sortable)
|
|
245
|
+
? c.sortable.some(v => v.prop === params.prop)
|
|
246
|
+
: c.prop === params.prop);
|
|
247
|
+
|
|
228
248
|
if (column) {
|
|
229
|
-
|
|
249
|
+
sortProp.value = params.prop
|
|
230
250
|
sortType.value = params.order;
|
|
231
251
|
if (props.localSort) {
|
|
232
252
|
tableDomRef.value?.sort(params.prop, params.order);
|
|
@@ -237,7 +257,7 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
237
257
|
function handleResetFilterValue (column: IColumnConfig) {
|
|
238
258
|
if (column.filters) {
|
|
239
259
|
if (Array.isArray(column.filters)) {
|
|
240
|
-
filteredValue.value[column.
|
|
260
|
+
filteredValue.value[column.prop] = []
|
|
241
261
|
} else if (column.filters.default) {
|
|
242
262
|
filteredValue.value[column.filters.prop || column.prop] = column.filters.default
|
|
243
263
|
} else {
|
|
@@ -247,7 +267,12 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
247
267
|
}
|
|
248
268
|
|
|
249
269
|
const handleHeaderOperationReset = async (column: IColumnConfig, scope) => {
|
|
250
|
-
if (
|
|
270
|
+
if (
|
|
271
|
+
sortProp.value &&
|
|
272
|
+
(Array.isArray(column._sortable)
|
|
273
|
+
? column._sortable.some(v => v.prop === sortProp.value)
|
|
274
|
+
: sortProp.value === column.prop)
|
|
275
|
+
) {
|
|
251
276
|
clearSort();
|
|
252
277
|
}
|
|
253
278
|
|
|
@@ -260,7 +285,10 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
260
285
|
searchValue.value[column.prop] = '';
|
|
261
286
|
} else {
|
|
262
287
|
column.search.forEach(v => {
|
|
263
|
-
|
|
288
|
+
const props = typeof v.prop === 'string' ? [v.prop] : v.prop
|
|
289
|
+
props.forEach(p => {
|
|
290
|
+
searchValue.value[p] = '';
|
|
291
|
+
})
|
|
264
292
|
})
|
|
265
293
|
}
|
|
266
294
|
}
|
|
@@ -314,15 +342,19 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
314
342
|
if (column.search) {
|
|
315
343
|
if (Array.isArray(column.search)) {
|
|
316
344
|
column.search.forEach(v => {
|
|
317
|
-
|
|
345
|
+
const props = typeof v.prop === 'string' ? [v.prop] : v.prop
|
|
346
|
+
props.forEach(p => {
|
|
347
|
+
_searchValue[p] = params[p];
|
|
348
|
+
})
|
|
318
349
|
});
|
|
319
350
|
} else {
|
|
320
351
|
_searchValue[column.prop] = params[column.prop] ?? '';
|
|
321
352
|
}
|
|
322
353
|
}
|
|
323
354
|
if (column.filters) {
|
|
324
|
-
const
|
|
325
|
-
|
|
355
|
+
const _prop = (Array.isArray(column.filters) ? column.prop : column.filters.prop) || column.prop
|
|
356
|
+
const value = params[_prop] ?? (Array.isArray(column.filters) ? [] : column.filters.default);
|
|
357
|
+
_filteredValue[_prop] = value;
|
|
326
358
|
}
|
|
327
359
|
if (column.doubleDatePicker) {
|
|
328
360
|
_searchValue[column.doubleDatePicker.props[0]] = params[column.doubleDatePicker.props[0]] ?? '';
|
|
@@ -332,7 +364,7 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
332
364
|
|
|
333
365
|
if (props.colorFilterConfig) {
|
|
334
366
|
const { prop, filters } = props.colorFilterConfig
|
|
335
|
-
_filteredValue[prop] = params[prop] ?? (Array.isArray(filters) ? [] : filters
|
|
367
|
+
_filteredValue[prop] = params[prop] ?? (Array.isArray(filters) ? [] : filters?.default);
|
|
336
368
|
}
|
|
337
369
|
|
|
338
370
|
searchValue.value = { ...searchValue.value, ..._searchValue }
|
|
@@ -352,12 +384,12 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
|
|
|
352
384
|
tableSummaryMethod,
|
|
353
385
|
filteredValue,
|
|
354
386
|
showColumnHeadSortIcon,
|
|
355
|
-
|
|
387
|
+
tempSortProp,
|
|
356
388
|
tempSearchValue,
|
|
357
389
|
tempFilteredValue,
|
|
358
390
|
tempSummaryList,
|
|
359
391
|
tempSortType,
|
|
360
|
-
|
|
392
|
+
sortProp,
|
|
361
393
|
isColumnFiltering,
|
|
362
394
|
searchValue,
|
|
363
395
|
inSorting,
|
|
@@ -26,61 +26,79 @@
|
|
|
26
26
|
<div class="editable-table-sort-filter__column-title">
|
|
27
27
|
{{ column.label }}
|
|
28
28
|
</div>
|
|
29
|
+
|
|
29
30
|
<div
|
|
30
31
|
v-if="column.isColumnSortable"
|
|
31
32
|
class="editable-table-sort-filter__sort"
|
|
32
33
|
>
|
|
33
|
-
<div
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
>
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
>
|
|
55
|
-
<div class="editable-table-sort-filter__search-title">
|
|
56
|
-
搜索
|
|
34
|
+
<div
|
|
35
|
+
v-for="item in sortConfigs"
|
|
36
|
+
:key="item.prop"
|
|
37
|
+
>
|
|
38
|
+
<div class="editable-table-sort-filter__sort-title">
|
|
39
|
+
{{ item.label }}
|
|
40
|
+
</div>
|
|
41
|
+
<div class="editable-table-sort-filter__sort-btns">
|
|
42
|
+
<el-button
|
|
43
|
+
:class="['editable-table-sort-filter__sort-btn', checkActiveProp('ascending', item.prop) && 'editable-table-sort-filter__sort-btn--active']"
|
|
44
|
+
@click="() => emit('update:sort', 'ascending', item.prop)"
|
|
45
|
+
>
|
|
46
|
+
升序
|
|
47
|
+
</el-button>
|
|
48
|
+
<el-button
|
|
49
|
+
:class="['editable-table-sort-filter__sort-btn', checkActiveProp('descending', item.prop) && 'editable-table-sort-filter__sort-btn--active']"
|
|
50
|
+
@click="() => emit('update:sort', 'descending', item.prop)"
|
|
51
|
+
>
|
|
52
|
+
降序
|
|
53
|
+
</el-button>
|
|
54
|
+
</div>
|
|
57
55
|
</div>
|
|
58
|
-
<el-input
|
|
59
|
-
class="editable-table-sort-filter__search-input"
|
|
60
|
-
placeholder="请输入内容"
|
|
61
|
-
:value="tempSearchValue[column.prop]"
|
|
62
|
-
@input="val => emit('update:tempSearchValue', column.prop, val)"
|
|
63
|
-
/>
|
|
64
56
|
</div>
|
|
65
57
|
|
|
66
58
|
<div
|
|
67
|
-
v-if="column.search
|
|
59
|
+
v-if="!!column.search"
|
|
68
60
|
class="editable-table-sort-filter__search"
|
|
69
61
|
style="display: flex;flex-direction: column;gap: 12px;"
|
|
70
62
|
>
|
|
71
63
|
<div
|
|
72
|
-
v-for="item in
|
|
73
|
-
:key="item.
|
|
64
|
+
v-for="item in searchConfigs"
|
|
65
|
+
:key="item.label"
|
|
74
66
|
>
|
|
75
67
|
<div class="editable-table-sort-filter__search-title">
|
|
76
68
|
{{ item.label }}
|
|
77
69
|
</div>
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
<template v-if="!('type' in item) || item.type === 'input'">
|
|
71
|
+
<el-input
|
|
72
|
+
class="editable-table-sort-filter__search-input"
|
|
73
|
+
placeholder="请输入内容"
|
|
74
|
+
:value="tempSearchValue[item.prop]"
|
|
75
|
+
@input="val => emit('update:tempSearchValue', item.prop, val)"
|
|
76
|
+
/>
|
|
77
|
+
</template>
|
|
78
|
+
<template v-if="item.type === 'doubleDatePicker'">
|
|
79
|
+
<div class="editable-table-sort-filter__search__date-range">
|
|
80
|
+
<el-date-picker
|
|
81
|
+
@input="val => emit('update:tempSearchValue', item.prop[0], val || '')"
|
|
82
|
+
:value="tempSearchValue[item.prop[0]]"
|
|
83
|
+
value-format="yyyy-MM-dd"
|
|
84
|
+
format="yyyy-MM-dd"
|
|
85
|
+
type="date"
|
|
86
|
+
size="small"
|
|
87
|
+
placeholder="开始日期"
|
|
88
|
+
:picker-options="item.pickerOptions ?? {}"
|
|
89
|
+
/>
|
|
90
|
+
<el-date-picker
|
|
91
|
+
@input="val => emit('update:tempSearchValue', item.prop[1], val || '')"
|
|
92
|
+
:value="tempSearchValue[item.prop[1]]"
|
|
93
|
+
value-format="yyyy-MM-dd"
|
|
94
|
+
format="yyyy-MM-dd"
|
|
95
|
+
size="small"
|
|
96
|
+
type="date"
|
|
97
|
+
placeholder="结束日期"
|
|
98
|
+
:picker-options="item.pickerOptions ?? {}"
|
|
99
|
+
/>
|
|
100
|
+
</div>
|
|
101
|
+
</template>
|
|
84
102
|
</div>
|
|
85
103
|
</div>
|
|
86
104
|
|
|
@@ -96,7 +114,7 @@
|
|
|
96
114
|
style="display: flex;flex-direction: column;gap: 12px;"
|
|
97
115
|
>
|
|
98
116
|
<el-date-picker
|
|
99
|
-
@input="val => emit('update:tempSearchValue', column.doubleDatePicker
|
|
117
|
+
@input="val => emit('update:tempSearchValue', column.doubleDatePicker!.props[0], val || '')"
|
|
100
118
|
:value="tempSearchValue[column.doubleDatePicker.props[0]]"
|
|
101
119
|
value-format="yyyy-MM-dd"
|
|
102
120
|
format="yyyy-MM-dd"
|
|
@@ -105,7 +123,7 @@
|
|
|
105
123
|
placeholder="开始日期"
|
|
106
124
|
/>
|
|
107
125
|
<el-date-picker
|
|
108
|
-
@input="val => emit('update:tempSearchValue', column.doubleDatePicker
|
|
126
|
+
@input="val => emit('update:tempSearchValue', column.doubleDatePicker!.props[1], val || '')"
|
|
109
127
|
:value="tempSearchValue[column.doubleDatePicker.props[1]]"
|
|
110
128
|
value-format="yyyy-MM-dd"
|
|
111
129
|
format="yyyy-MM-dd"
|
|
@@ -166,6 +184,7 @@
|
|
|
166
184
|
</el-radio>
|
|
167
185
|
</el-radio-group>
|
|
168
186
|
</div>
|
|
187
|
+
|
|
169
188
|
<div
|
|
170
189
|
v-if="column.summary"
|
|
171
190
|
class="editable-table-sort-filter__filter"
|
|
@@ -191,6 +210,7 @@
|
|
|
191
210
|
</el-checkbox>
|
|
192
211
|
</el-checkbox-group>
|
|
193
212
|
</div>
|
|
213
|
+
|
|
194
214
|
<div class="editable-table-sort-filter__footer">
|
|
195
215
|
<el-button
|
|
196
216
|
class="editable-table-sort-filter__reset-btn"
|
|
@@ -211,15 +231,15 @@
|
|
|
211
231
|
</template>
|
|
212
232
|
|
|
213
233
|
<script setup lang="ts">
|
|
214
|
-
import { ref } from 'vue'
|
|
234
|
+
import { computed, ref } from 'vue'
|
|
215
235
|
import { IColumnConfig } from '../types'
|
|
216
236
|
|
|
217
|
-
defineProps<{
|
|
237
|
+
const props = defineProps<{
|
|
218
238
|
headActive: boolean
|
|
219
239
|
column: IColumnConfig
|
|
220
240
|
tempSummaryList: string[]
|
|
221
|
-
tempSortingColumn: IColumnConfig | null
|
|
222
241
|
tempSortType: 'ascending' | 'descending' | ''
|
|
242
|
+
tempSortProp: string
|
|
223
243
|
tempSearchValue: Record<string, string>
|
|
224
244
|
tempFilteredValue: Record<string, string | number | number[] | string[]>
|
|
225
245
|
}>()
|
|
@@ -228,7 +248,7 @@ const emit = defineEmits<{
|
|
|
228
248
|
(e: 'update:tempSearchValue', key: string, value: string): void
|
|
229
249
|
(e: 'update:tempFilteredValue', key: string, value: string): void
|
|
230
250
|
(e: 'update:tempSummaryList', value: string[]): void
|
|
231
|
-
(e: 'update:sort', type: 'ascending' | 'descending'): void
|
|
251
|
+
(e: 'update:sort', type: 'ascending' | 'descending', prop: string): void
|
|
232
252
|
(e: 'popover-show'): void
|
|
233
253
|
(e: 'reset'): void
|
|
234
254
|
(e: 'confirm'): void
|
|
@@ -236,6 +256,20 @@ const emit = defineEmits<{
|
|
|
236
256
|
|
|
237
257
|
const popoverRef = ref(null as any)
|
|
238
258
|
|
|
259
|
+
const searchConfigs = computed(() => {
|
|
260
|
+
if (Array.isArray(props.column.search)) return props.column.search
|
|
261
|
+
return [{ prop: props.column.prop, label: '搜索' }]
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
const sortConfigs = computed(() => {
|
|
265
|
+
if (Array.isArray(props.column._sortable)) return props.column._sortable
|
|
266
|
+
return [{ ...props.column, label: '排序' }]
|
|
267
|
+
})
|
|
268
|
+
|
|
269
|
+
const checkActiveProp = (type: 'ascending' | 'descending', prop: string) => {
|
|
270
|
+
return props.tempSortType === type && props.tempSortProp === prop
|
|
271
|
+
}
|
|
272
|
+
|
|
239
273
|
defineExpose({
|
|
240
274
|
close: () => {
|
|
241
275
|
popoverRef.value?.doClose()
|
|
@@ -388,7 +388,6 @@
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
&__filter,
|
|
391
|
-
&__sort,
|
|
392
391
|
&__search {
|
|
393
392
|
padding: 14px;
|
|
394
393
|
|
|
@@ -433,6 +432,13 @@
|
|
|
433
432
|
}
|
|
434
433
|
}
|
|
435
434
|
|
|
435
|
+
&__sort {
|
|
436
|
+
padding: 14px;
|
|
437
|
+
display: flex;
|
|
438
|
+
flex-direction: column;
|
|
439
|
+
gap: 8px;
|
|
440
|
+
}
|
|
441
|
+
|
|
436
442
|
&__filter-title,
|
|
437
443
|
&__sort-title,
|
|
438
444
|
&__search-title {
|
|
@@ -442,9 +448,20 @@
|
|
|
442
448
|
margin-bottom: 10px;
|
|
443
449
|
}
|
|
444
450
|
|
|
445
|
-
&__search
|
|
446
|
-
|
|
447
|
-
|
|
451
|
+
&__search {
|
|
452
|
+
&-input {
|
|
453
|
+
& .el-input__inner {
|
|
454
|
+
height: 32px;
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
&__date-range {
|
|
458
|
+
display: flex;
|
|
459
|
+
flex-direction: column;
|
|
460
|
+
gap: 12px;
|
|
461
|
+
|
|
462
|
+
.el-date-editor.el-input, .el-date-editor.el-input__inner {
|
|
463
|
+
width: 100%;
|
|
464
|
+
}
|
|
448
465
|
}
|
|
449
466
|
}
|
|
450
467
|
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
:column="colorFilterConfig"
|
|
112
112
|
:showing-columns="showingColumns"
|
|
113
113
|
:temp-summary-list="tempSummaryList"
|
|
114
|
-
:temp-
|
|
114
|
+
:temp-sort-prop="tempSortProp"
|
|
115
115
|
:temp-sort-type="tempSortType"
|
|
116
116
|
:temp-filtered-value="tempFilteredValue"
|
|
117
117
|
:temp-search-value="tempSearchValue"
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
@update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
|
|
120
120
|
@update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
|
|
121
121
|
@popover-show="() => handleHeaderPopoverShow(colorFilterConfig)"
|
|
122
|
-
@update:sort="
|
|
122
|
+
@update:sort="handleSort"
|
|
123
123
|
@reset="() => handleHeaderOperationReset(colorFilterConfig, scope)"
|
|
124
124
|
@confirm="() => handleHeaderOperationConfirm(colorFilterConfig, scope)"
|
|
125
125
|
>
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
:column="column"
|
|
167
167
|
:showing-columns="showingColumns"
|
|
168
168
|
:temp-summary-list="tempSummaryList"
|
|
169
|
-
:temp-
|
|
169
|
+
:temp-sort-prop="tempSortProp"
|
|
170
170
|
:temp-sort-type="tempSortType"
|
|
171
171
|
:temp-filtered-value="tempFilteredValue"
|
|
172
172
|
:temp-search-value="tempSearchValue"
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
@update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
|
|
175
175
|
@update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
|
|
176
176
|
@popover-show="() => handleHeaderPopoverShow(column)"
|
|
177
|
-
@update:sort="
|
|
177
|
+
@update:sort="handleSort"
|
|
178
178
|
@reset="() => handleHeaderOperationReset(column, scope)"
|
|
179
179
|
@confirm="() => handleHeaderOperationConfirm(column, scope)"
|
|
180
180
|
>
|
|
@@ -453,8 +453,9 @@ const actualColumns = computed(() => {
|
|
|
453
453
|
const rawItem = props.columnConfig.find(c => c.prop === prop) ?? {} as IColumnConfig;
|
|
454
454
|
const item: IColumnConfig = {
|
|
455
455
|
...rawItem,
|
|
456
|
-
isColumnSortable: rawItem.sortable,
|
|
457
|
-
sortable: inSorting.value ? rawItem.sortable : false
|
|
456
|
+
isColumnSortable: !!rawItem.sortable,
|
|
457
|
+
sortable: inSorting.value ? !!rawItem.sortable : false,
|
|
458
|
+
_sortable: rawItem.sortable,
|
|
458
459
|
};
|
|
459
460
|
if (cnt > 0) {
|
|
460
461
|
item.fixed = 'left';
|
|
@@ -543,12 +544,12 @@ const {
|
|
|
543
544
|
tableSummaryMethod,
|
|
544
545
|
filteredValue,
|
|
545
546
|
showColumnHeadSortIcon,
|
|
546
|
-
|
|
547
|
+
sortProp,
|
|
547
548
|
tempSearchValue,
|
|
548
549
|
tempFilteredValue,
|
|
549
550
|
tempSummaryList,
|
|
550
551
|
tempSortType,
|
|
551
|
-
|
|
552
|
+
tempSortProp,
|
|
552
553
|
isColumnFiltering,
|
|
553
554
|
searchValue,
|
|
554
555
|
inSorting,
|
|
@@ -562,7 +563,7 @@ const {
|
|
|
562
563
|
/************ 表格行拖拽和显示设置列拖拽 ************ */
|
|
563
564
|
const beforeDragStart = () => {
|
|
564
565
|
// 如果有列存在排序,不允许拖拽
|
|
565
|
-
if (
|
|
566
|
+
if (sortProp.value) {
|
|
566
567
|
Message.warning('已有列正在排序,不允许拖拽。');
|
|
567
568
|
return false;
|
|
568
569
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { TableColumn } from 'element-ui'
|
|
1
|
+
import type { TableColumn, DatePicker } from 'element-ui'
|
|
2
2
|
|
|
3
3
|
export enum IEditType {
|
|
4
4
|
INPUT = 'input',
|
|
@@ -11,7 +11,8 @@ type _IColumnConfigRequired = {
|
|
|
11
11
|
label: string;
|
|
12
12
|
editType?: IEditType; // 编辑格式
|
|
13
13
|
editSlotName?: string; // 编辑时,自定义编辑组件的slotName
|
|
14
|
-
sortable?: boolean; // 该列是否允许排序,ture则表头弹窗会显示升降序按钮
|
|
14
|
+
sortable?: boolean | ISortOption[]; // 该列是否允许排序,ture则表头弹窗会显示升降序按钮
|
|
15
|
+
_sortable?: _IColumnConfigRequired['sortable']; // 内部使用,el-table 的 sortable 不支持数组,用来同步 sortable
|
|
15
16
|
/** 内部使用, */
|
|
16
17
|
isColumnSortable?: boolean;
|
|
17
18
|
slotName?: string; // 如果要自定义,传入 slotName
|
|
@@ -48,11 +49,26 @@ export type IColumnConfigRequired = _IColumnConfigRequired & Partial<Omit<TableC
|
|
|
48
49
|
|
|
49
50
|
type FiltersOption = { value: string | number; text: string; [key: string]: any }
|
|
50
51
|
|
|
51
|
-
type
|
|
52
|
-
prop: string
|
|
53
|
-
label: string
|
|
52
|
+
type ISortOption = {
|
|
53
|
+
prop: string
|
|
54
|
+
label: string
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
type InputSearchOption = {
|
|
58
|
+
prop: string
|
|
59
|
+
label: string
|
|
54
60
|
validator?: (value: string) => boolean
|
|
55
|
-
|
|
61
|
+
type?: 'input'
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type DoubleDatePickerSearchOption = {
|
|
65
|
+
prop: [string, string]
|
|
66
|
+
label: string
|
|
67
|
+
type: 'doubleDatePicker'
|
|
68
|
+
pickerOptions?: DatePicker['pickerOptions']
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type ISearchOptions = (InputSearchOption | DoubleDatePickerSearchOption)[]
|
|
56
72
|
|
|
57
73
|
type IInputColumn = IColumnConfigRequired & {
|
|
58
74
|
inputType: string | number;
|