@lx-frontend/wrap-element-ui 1.0.10 → 1.0.11-beta.0
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
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { computed,
|
|
1
|
+
import { computed, nextTick, ref, Ref, watch } from 'vue'
|
|
2
2
|
import { IColumnConfig, IEmits, IProps } from '../types';
|
|
3
3
|
|
|
4
4
|
interface IUseColumnHeaderOperationParams {
|
|
5
5
|
props: IProps
|
|
6
6
|
tableDomRef: any
|
|
7
|
-
sortFilterPopoverRef: any
|
|
8
7
|
emit: IEmits;
|
|
9
8
|
showingColumns: Ref<string[]>
|
|
10
9
|
}
|
|
11
10
|
|
|
12
|
-
export function useColumnHeaderOperation({ props, tableDomRef,
|
|
11
|
+
export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColumns }: IUseColumnHeaderOperationParams) {
|
|
13
12
|
|
|
14
13
|
// column如果有sortable属性,点击列头部,会直接触发排序,为了在弹窗点确定时再触发排序,需要阻止点击立即排序
|
|
15
14
|
// 所以,初始渲染时,将sortable设置为false,在触发排序逻辑时再设置成真实的值,再利用el-table自身的排序逻辑触发排序
|
|
@@ -85,11 +84,11 @@ export function useColumnHeaderOperation({ props, tableDomRef, sortFilterPopover
|
|
|
85
84
|
: column.filters.type === 'radio'
|
|
86
85
|
? filteredValue.value[column.prop]
|
|
87
86
|
: (filteredValue.value[column.prop] as any[]).length))
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
) || (
|
|
88
|
+
!!(column.search
|
|
89
|
+
? Array.isArray(column.search) && column.search?.some(v => searchValue.value[v.prop])
|
|
90
|
+
: searchValue.value[column.prop])
|
|
91
|
+
) || hasPickerParams || sortingColumn.value?.prop === column.prop || summaryList.value.includes(column.prop);
|
|
93
92
|
}
|
|
94
93
|
|
|
95
94
|
const handleHeaderPopoverShow = (column: IColumnConfig) => {
|
|
@@ -104,9 +103,9 @@ export function useColumnHeaderOperation({ props, tableDomRef, sortFilterPopover
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
const closeSortAndFilterPopover = (exceptProp?: string) => {
|
|
107
|
-
|
|
108
|
-
if (!exceptProp || exceptProp !== item
|
|
109
|
-
item
|
|
106
|
+
document.querySelectorAll('span[data-popper-name]').forEach((item: any) => {
|
|
107
|
+
if (!exceptProp || exceptProp !== item.dataset.prop) {
|
|
108
|
+
item?.__vue__?.doClose();
|
|
110
109
|
}
|
|
111
110
|
});
|
|
112
111
|
}
|
|
@@ -121,6 +120,7 @@ export function useColumnHeaderOperation({ props, tableDomRef, sortFilterPopover
|
|
|
121
120
|
props.columnConfig.forEach(column => {
|
|
122
121
|
obj[column.prop] = column
|
|
123
122
|
})
|
|
123
|
+
|
|
124
124
|
return obj
|
|
125
125
|
})
|
|
126
126
|
|
|
@@ -147,8 +147,13 @@ export function useColumnHeaderOperation({ props, tableDomRef, sortFilterPopover
|
|
|
147
147
|
}
|
|
148
148
|
})
|
|
149
149
|
|
|
150
|
+
if (props.colorFilterConfig) {
|
|
151
|
+
const { prop } = props.colorFilterConfig
|
|
152
|
+
params[prop] = filteredValue.value[prop]
|
|
153
|
+
}
|
|
154
|
+
|
|
150
155
|
Object.keys(params).forEach(key => {
|
|
151
|
-
if (params[key] === undefined) delete params[key]
|
|
156
|
+
if (params[key] === undefined || params[key] === null || params[key] === '') delete params[key]
|
|
152
157
|
})
|
|
153
158
|
|
|
154
159
|
emit('search', {
|
|
@@ -264,7 +269,6 @@ export function useColumnHeaderOperation({ props, tableDomRef, sortFilterPopover
|
|
|
264
269
|
searchValue.value[column.doubleDatePicker.props[1]] = '';
|
|
265
270
|
}
|
|
266
271
|
|
|
267
|
-
|
|
268
272
|
emitSearch();
|
|
269
273
|
|
|
270
274
|
filterColumns(scope.store);
|
|
@@ -326,6 +330,11 @@ export function useColumnHeaderOperation({ props, tableDomRef, sortFilterPopover
|
|
|
326
330
|
}
|
|
327
331
|
})
|
|
328
332
|
|
|
333
|
+
if (props.colorFilterConfig) {
|
|
334
|
+
const { prop, filters } = props.colorFilterConfig
|
|
335
|
+
_filteredValue[prop] = params[prop] ?? (Array.isArray(filters) ? [] : filters.default);
|
|
336
|
+
}
|
|
337
|
+
|
|
329
338
|
searchValue.value = { ...searchValue.value, ..._searchValue }
|
|
330
339
|
filteredValue.value = { ...filteredValue.value, ..._filteredValue }
|
|
331
340
|
}
|
|
@@ -4,13 +4,18 @@
|
|
|
4
4
|
placement="bottom"
|
|
5
5
|
trigger="click"
|
|
6
6
|
popper-class="editable-table-sort-filter"
|
|
7
|
+
data-popper-name="editable-table-sort-filter"
|
|
7
8
|
:data-prop="column.prop"
|
|
8
9
|
@show="() => emit('popover-show')"
|
|
9
10
|
>
|
|
10
11
|
<template slot="reference">
|
|
11
12
|
<!-- 筛选中,或排序中,高亮 -->
|
|
12
13
|
<span :class="['editable-table__sort-reference', headActive && 'editable-table__sort-reference--active']">
|
|
13
|
-
|
|
14
|
+
<slot
|
|
15
|
+
v-if="column.customColorLabel"
|
|
16
|
+
name="custom"
|
|
17
|
+
/>
|
|
18
|
+
<span v-else>{{ column.label }}</span>
|
|
14
19
|
<div :class="['editable-table__sort-icon', headActive && 'editable-table__sort-icon--active']" />
|
|
15
20
|
</span>
|
|
16
21
|
</template>
|
|
@@ -75,7 +80,7 @@
|
|
|
75
80
|
/>
|
|
76
81
|
</div>
|
|
77
82
|
</div>
|
|
78
|
-
|
|
83
|
+
|
|
79
84
|
<div
|
|
80
85
|
v-if="column.doubleDatePicker"
|
|
81
86
|
class="editable-table-sort-filter__sort"
|
|
@@ -99,12 +99,47 @@
|
|
|
99
99
|
<!-- 颜色选择列 -->
|
|
100
100
|
<el-table-column
|
|
101
101
|
v-if="colorList && colorList.length > 0"
|
|
102
|
-
width="22px"
|
|
102
|
+
:width="colorFilterConfig ? '40px' : '22px'"
|
|
103
103
|
class-name="editable-table__color-column no-inner-cell-border"
|
|
104
104
|
:fixed="leftFixedColumnCount > 0 ? 'left' : false"
|
|
105
|
+
:filtered-value="filteredValue[colorFilterConfig?.prop]"
|
|
105
106
|
>
|
|
106
|
-
<template #header>
|
|
107
|
-
<div
|
|
107
|
+
<template #header="scope">
|
|
108
|
+
<div v-if="colorFilterConfig">
|
|
109
|
+
<biz-table-header-popover
|
|
110
|
+
:head-active="isColumnHeadActive(colorFilterConfig)"
|
|
111
|
+
:column="colorFilterConfig"
|
|
112
|
+
:showing-columns="showingColumns"
|
|
113
|
+
:temp-summary-list="tempSummaryList"
|
|
114
|
+
:temp-sorting-column="tempSortingColumn"
|
|
115
|
+
:temp-sort-type="tempSortType"
|
|
116
|
+
:temp-filtered-value="tempFilteredValue"
|
|
117
|
+
:temp-search-value="tempSearchValue"
|
|
118
|
+
@update:tempSummaryList="val => { tempSummaryList = val }"
|
|
119
|
+
@update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
|
|
120
|
+
@update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
|
|
121
|
+
@popover-show="() => handleHeaderPopoverShow(colorFilterConfig)"
|
|
122
|
+
@update:sort="(type) => handleSort(type, colorFilterConfig)"
|
|
123
|
+
@reset="() => handleHeaderOperationReset(colorFilterConfig, scope)"
|
|
124
|
+
@confirm="() => handleHeaderOperationConfirm(colorFilterConfig, scope)"
|
|
125
|
+
>
|
|
126
|
+
<template #custom>
|
|
127
|
+
<div class="editable-table__color-icon" />
|
|
128
|
+
</template>
|
|
129
|
+
<template #filter-item="item">
|
|
130
|
+
<slot
|
|
131
|
+
:name="colorFilterConfig.prop + '-filter-item'"
|
|
132
|
+
v-bind="item"
|
|
133
|
+
>
|
|
134
|
+
{{ item.text }}
|
|
135
|
+
</slot>
|
|
136
|
+
</template>
|
|
137
|
+
</biz-table-header-popover>
|
|
138
|
+
</div>
|
|
139
|
+
<div
|
|
140
|
+
v-else
|
|
141
|
+
class="editable-table__color-icon"
|
|
142
|
+
/>
|
|
108
143
|
</template>
|
|
109
144
|
<template #default="scope">
|
|
110
145
|
<biz-color-select
|
|
@@ -128,7 +163,6 @@
|
|
|
128
163
|
#header="scope"
|
|
129
164
|
>
|
|
130
165
|
<biz-table-header-popover
|
|
131
|
-
ref="sortFilterPopoverRef"
|
|
132
166
|
:head-active="isColumnHeadActive(column)"
|
|
133
167
|
:column="column"
|
|
134
168
|
:showing-columns="showingColumns"
|
|
@@ -337,6 +371,8 @@ interface IProps {
|
|
|
337
371
|
defaultOperations?: IDefaultOperationType[];
|
|
338
372
|
/** 行背景色列表 */
|
|
339
373
|
colorList?: IColorList;
|
|
374
|
+
/** 自定义颜色列的表头筛选 */
|
|
375
|
+
colorFilterConfig?: IColumnConfig;
|
|
340
376
|
/** 左侧固定列数 */
|
|
341
377
|
leftFixedCount?: number;
|
|
342
378
|
/** 性能优化参数,调整拖拽的范围 */
|
|
@@ -391,6 +427,7 @@ const props = withDefaults(defineProps<IProps>(), {
|
|
|
391
427
|
total: 0,
|
|
392
428
|
defaultOperations: () => [],
|
|
393
429
|
colorList: () => [],
|
|
430
|
+
colorFilterConfig: () => null,
|
|
394
431
|
leftFixedCount: 1,
|
|
395
432
|
dragSemiRange: 15,
|
|
396
433
|
loading: false,
|
|
@@ -444,7 +481,6 @@ const actualColumns = computed(() => {
|
|
|
444
481
|
return res;
|
|
445
482
|
});
|
|
446
483
|
|
|
447
|
-
const sortFilterPopoverRef = ref<any>(null);
|
|
448
484
|
const tableDomRef = ref<any>(null);
|
|
449
485
|
const currScope = ref<any>(null);
|
|
450
486
|
|
|
@@ -520,7 +556,6 @@ const {
|
|
|
520
556
|
inSorting,
|
|
521
557
|
} = useColumnHeaderOperation({
|
|
522
558
|
tableDomRef,
|
|
523
|
-
sortFilterPopoverRef,
|
|
524
559
|
props,
|
|
525
560
|
emit,
|
|
526
561
|
showingColumns,
|
|
@@ -33,10 +33,13 @@ type _IColumnConfigRequired = {
|
|
|
33
33
|
formatter?: (row: any, column: IColumnConfig, value: any, index: number) => string | number;
|
|
34
34
|
width?: number | string;
|
|
35
35
|
minWidth?: number | string;
|
|
36
|
+
/** 是否开启日期范围选择器 */
|
|
36
37
|
doubleDatePicker?: {
|
|
37
38
|
props: [string, string],
|
|
38
39
|
label: string,
|
|
39
|
-
};
|
|
40
|
+
};
|
|
41
|
+
/** 自定义颜色表头label */
|
|
42
|
+
customColorLabel?: boolean
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
export type IColumnConfigRequired = _IColumnConfigRequired & Partial<Omit<TableColumn, keyof _IColumnConfigRequired>>
|
|
@@ -108,6 +111,7 @@ export interface IProps {
|
|
|
108
111
|
total: number;
|
|
109
112
|
defaultOperations?: IDefaultOperationType[];
|
|
110
113
|
colorList?: IColorList;
|
|
114
|
+
colorFilterConfig?: IColumnConfig
|
|
111
115
|
leftFixedCount?: number;
|
|
112
116
|
dragSemiRange?: number;
|
|
113
117
|
loading?: boolean;
|