@lx-frontend/wrap-element-ui 1.0.1-beta.5 → 1.0.1-beta.7
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/README.md +45 -45
- package/package.json +14 -14
- package/src/components/AddMembers/index.vue +157 -157
- package/src/components/AuditSteps/index.vue +140 -140
- package/src/components/DemoComponent/index.vue +20 -20
- package/src/components/EditableTable/README.md +147 -147
- package/src/components/EditableTable/bizHooks/index.ts +17 -0
- package/src/components/EditableTable/{useCellHover.ts → bizHooks/useCellHover.ts} +71 -71
- package/src/components/EditableTable/{useColumnHeaderOperation.ts → bizHooks/useColumnHeaderOperation.ts} +326 -325
- package/src/components/EditableTable/{useDefaultOperation.ts → bizHooks/useDefaultOperation.ts} +95 -95
- package/src/components/EditableTable/{useDragSort.ts → bizHooks/useDragSort.ts} +290 -290
- package/src/components/EditableTable/{usePagination.ts → bizHooks/usePagination.ts} +30 -30
- package/src/components/EditableTable/{useRowBgColor.ts → bizHooks/useRowBgColor.ts} +43 -50
- package/src/components/EditableTable/{useViewSetting.ts → bizHooks/useViewSetting.ts} +118 -119
- package/src/components/EditableTable/features/bizColorSelect.vue +65 -0
- package/src/components/EditableTable/features/bizEditCell.vue +44 -0
- package/src/components/EditableTable/features/bizTableHeaderPopover.vue +202 -0
- package/src/components/EditableTable/features/bizViewSettingDialog.vue +137 -0
- package/src/components/EditableTable/index.less +733 -724
- package/src/components/EditableTable/index.vue +630 -914
- package/src/components/Ellipsis/MultilineEllipsis.vue +141 -141
- package/src/components/Ellipsis/index.vue +119 -119
- package/src/components/LxTable/index.vue +296 -296
- package/src/components/PopoverForm/index.vue +66 -66
- package/src/components/SearchForm/index.vue +243 -243
- package/src/components/SearchSelect/index.vue +153 -153
- package/src/components/index.ts +24 -24
- package/src/components/singleMessage/index.ts +44 -44
- /package/src/components/EditableTable/{types.ts → types/index.ts} +0 -0
|
@@ -1,51 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return {
|
|
45
|
-
isDefaultColor,
|
|
46
|
-
getColorById,
|
|
47
|
-
setRowStyle,
|
|
48
|
-
handleColorChange,
|
|
49
|
-
colorPopoverRef
|
|
50
|
-
}
|
|
1
|
+
import { IColorList, IEmits } from '../types';
|
|
2
|
+
|
|
3
|
+
interface IUseRowBgColorParams {
|
|
4
|
+
colorList: IColorList;
|
|
5
|
+
emit: IEmits;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export default function useRowBgColor({ colorList, emit }: IUseRowBgColorParams) {
|
|
9
|
+
const isDefaultColor = (id: number) => {
|
|
10
|
+
if (!id) {
|
|
11
|
+
// 没有颜色id,则认为是默认色
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return colorList.find(c => +c.id === +id)?.default;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const getColorById = (id: number, type: 'bg' | 'sample' = 'bg') => {
|
|
18
|
+
return colorList.find(c => +c.id === +id)?.[`${type}Color`] || '';
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const setRowStyle = (scope) => {
|
|
22
|
+
const row = scope.row;
|
|
23
|
+
return {
|
|
24
|
+
backgroundColor: row.colorId ? getColorById(row.colorId) : ''
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const handleColorChange = async (colorId: number, scope) => {
|
|
29
|
+
const { row, $index: rowIndex, store } = scope;
|
|
30
|
+
const dataList = store.states.data;
|
|
31
|
+
const curRow = { ...dataList[rowIndex], colorId: +colorId };
|
|
32
|
+
const newList = [...dataList];
|
|
33
|
+
newList.splice(rowIndex, 1, curRow);
|
|
34
|
+
store.states.data = newList;
|
|
35
|
+
emit('row-bg-change', { colorId, row, rowIndex });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
isDefaultColor,
|
|
40
|
+
getColorById,
|
|
41
|
+
setRowStyle,
|
|
42
|
+
handleColorChange,
|
|
43
|
+
};
|
|
51
44
|
}
|
|
@@ -1,119 +1,118 @@
|
|
|
1
|
-
import { ref,
|
|
2
|
-
import { IColumnConfig, IProps } from "
|
|
3
|
-
|
|
4
|
-
interface IViewSettingParams {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
props: IProps
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
return {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
1
|
+
import { ref, watch, Ref, computed, nextTick } from "vue"
|
|
2
|
+
import { IColumnConfig, IProps } from "../types"
|
|
3
|
+
|
|
4
|
+
interface IViewSettingParams {
|
|
5
|
+
showingColumns: Ref<string[]>
|
|
6
|
+
actualColumns: Ref<IColumnConfig[]>
|
|
7
|
+
viewSettingDragSortOptions: Ref<IColumnConfig[]>
|
|
8
|
+
props: IProps
|
|
9
|
+
emit: {
|
|
10
|
+
(e: 'update:leftFixedColumnCount', val: number): void
|
|
11
|
+
(e: 'update:showingColumns', val: string[]): void
|
|
12
|
+
(e: 'update:viewSettingDragSortOptions', val: IColumnConfig[]): void
|
|
13
|
+
(e: 'tableDoLayout'): void
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export default function useViewSetting({
|
|
18
|
+
showingColumns,
|
|
19
|
+
actualColumns,
|
|
20
|
+
props,
|
|
21
|
+
viewSettingDragSortOptions,
|
|
22
|
+
emit
|
|
23
|
+
}: IViewSettingParams) {
|
|
24
|
+
const columnsToBeShown = ref<string[]>([]); // 显示设置弹窗中勾选的列
|
|
25
|
+
const viewSettingVisible = ref(false);
|
|
26
|
+
const leftFixedColumnCount = ref(0);
|
|
27
|
+
const tempLeftFixedColumnCount = ref(0);
|
|
28
|
+
|
|
29
|
+
const updateShowingColumns = (val: string[]) => emit('update:showingColumns', val);
|
|
30
|
+
|
|
31
|
+
const storageKey = computed(() => `@lx-frontend/wrap-element-ui/table_setting_cloumns/${props.settingStorgeKey || (location.pathname === '/' ? location.hash : location.pathname)}`);
|
|
32
|
+
|
|
33
|
+
const saveSettingToStorge = async() => {
|
|
34
|
+
await nextTick()
|
|
35
|
+
localStorage.setItem(storageKey.value, JSON.stringify({
|
|
36
|
+
showingColumns: showingColumns.value,
|
|
37
|
+
leftFixedColumnCount: leftFixedColumnCount.value
|
|
38
|
+
}))
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleViewSettingShow = () => {
|
|
42
|
+
emit('update:viewSettingDragSortOptions', [...actualColumns.value]);
|
|
43
|
+
tempLeftFixedColumnCount.value = leftFixedColumnCount.value;
|
|
44
|
+
viewSettingVisible.value = true;
|
|
45
|
+
columnsToBeShown.value = [...showingColumns.value];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const handleViewSettingClose = () => {
|
|
49
|
+
viewSettingVisible.value = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const handleViewSettingConfirm = async () => {
|
|
53
|
+
viewSettingVisible.value = false;
|
|
54
|
+
updateShowingColumns(viewSettingDragSortOptions.value.map(c => c.prop));
|
|
55
|
+
leftFixedColumnCount.value = tempLeftFixedColumnCount.value;
|
|
56
|
+
await saveSettingToStorge()
|
|
57
|
+
emit('tableDoLayout')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const handleInputTempLeftFixedColumnCount = (value: string) => {
|
|
61
|
+
const _value = Number(value)
|
|
62
|
+
if (isNaN(_value)) return
|
|
63
|
+
tempLeftFixedColumnCount.value = Math.max(0, Math.min(columnsToBeShown.value.length, Math.floor(_value)))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
watch(
|
|
67
|
+
() => props.columnConfig,
|
|
68
|
+
async(val) => {
|
|
69
|
+
const _keys = new Set(val.map(c => (c.prop)));
|
|
70
|
+
const _cache = localStorage.getItem(storageKey.value);
|
|
71
|
+
const setColumns = () => updateShowingColumns(val.filter(v => !v.defaultHide).map(c => c.prop));
|
|
72
|
+
if (!_cache) {
|
|
73
|
+
setColumns();
|
|
74
|
+
leftFixedColumnCount.value = props.leftFixedCount as number;
|
|
75
|
+
} else {
|
|
76
|
+
try {
|
|
77
|
+
// 缓存数据字段可能随着更新导致对不上,清理无效数据,防止出问题
|
|
78
|
+
const cache = JSON.parse(_cache);
|
|
79
|
+
if (!cache.showingColumns || !Array.isArray(cache.showingColumns)) {
|
|
80
|
+
setColumns();
|
|
81
|
+
} else {
|
|
82
|
+
updateShowingColumns(cache.showingColumns.filter(key => _keys.has(key)))
|
|
83
|
+
}
|
|
84
|
+
const _leftFixedColumnCount = Number(cache?.leftFixedColumnCount)
|
|
85
|
+
leftFixedColumnCount.value = isNaN(_leftFixedColumnCount) ? (props.leftFixedCount as number) : _leftFixedColumnCount;
|
|
86
|
+
// 写入清理后的数据
|
|
87
|
+
saveSettingToStorge();
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.error(error);
|
|
90
|
+
localStorage.removeItem(storageKey.value);
|
|
91
|
+
setColumns();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
{ immediate: true }
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
watch(columnsToBeShown, (val) => {
|
|
99
|
+
const _map = new Map<string, IColumnConfig>()
|
|
100
|
+
props.columnConfig.forEach(c => _map.set(c.prop, c))
|
|
101
|
+
// 展示时保留顺序
|
|
102
|
+
emit('update:viewSettingDragSortOptions', val.map(prop => _map.get(prop)!))
|
|
103
|
+
if (tempLeftFixedColumnCount.value > val.length) tempLeftFixedColumnCount.value = val.length
|
|
104
|
+
}, { immediate: true })
|
|
105
|
+
|
|
106
|
+
watch(leftFixedColumnCount, (val) => emit('update:leftFixedColumnCount', val), { immediate: true });
|
|
107
|
+
|
|
108
|
+
return {
|
|
109
|
+
columnsToBeShown,
|
|
110
|
+
viewSettingVisible,
|
|
111
|
+
leftFixedColumnCount,
|
|
112
|
+
tempLeftFixedColumnCount,
|
|
113
|
+
handleInputTempLeftFixedColumnCount,
|
|
114
|
+
handleViewSettingShow,
|
|
115
|
+
handleViewSettingClose,
|
|
116
|
+
handleViewSettingConfirm,
|
|
117
|
+
}
|
|
118
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<!-- 行颜色选择组件 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div>
|
|
4
|
+
<el-popover
|
|
5
|
+
v-model="visible"
|
|
6
|
+
placement="right"
|
|
7
|
+
trigger="click"
|
|
8
|
+
popper-class="color-popover"
|
|
9
|
+
>
|
|
10
|
+
<div class="color-list">
|
|
11
|
+
<div
|
|
12
|
+
v-for="color in colorList"
|
|
13
|
+
:key="color.id"
|
|
14
|
+
class="color-list__item"
|
|
15
|
+
:style="{ backgroundColor: color.sampleColor }"
|
|
16
|
+
@click="() => {
|
|
17
|
+
visible = false
|
|
18
|
+
handleColorChange(color.id, scope)
|
|
19
|
+
}"
|
|
20
|
+
>
|
|
21
|
+
<span :style="{color: color.textColor}">{{ color.name }}</span>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div slot="reference">
|
|
26
|
+
<div
|
|
27
|
+
v-if="isDefaultColor(scope.row.colorId)"
|
|
28
|
+
class="editable-table__color-icon"
|
|
29
|
+
/>
|
|
30
|
+
<div
|
|
31
|
+
v-else
|
|
32
|
+
class="editable-table__selected-color"
|
|
33
|
+
:style="{ backgroundColor: getColorById(scope.row.colorId, 'sample') }"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
</el-popover>
|
|
37
|
+
</div>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import { ref } from 'vue';
|
|
42
|
+
import { IColorList, IEmits, ITableDataItem } from '../types';
|
|
43
|
+
import { useRowBgColor } from '../bizHooks';
|
|
44
|
+
|
|
45
|
+
const props = defineProps<{
|
|
46
|
+
colorList: IColorList,
|
|
47
|
+
scope: any
|
|
48
|
+
}>();
|
|
49
|
+
|
|
50
|
+
const emit = defineEmits<{
|
|
51
|
+
(e: 'row-bg-change', param: { colorId: number; row: ITableDataItem; rowIndex: number }): void
|
|
52
|
+
}>();
|
|
53
|
+
|
|
54
|
+
const {
|
|
55
|
+
getColorById,
|
|
56
|
+
isDefaultColor,
|
|
57
|
+
handleColorChange,
|
|
58
|
+
} = useRowBgColor({
|
|
59
|
+
colorList: props.colorList,
|
|
60
|
+
emit: emit as IEmits,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const visible = ref(false);
|
|
64
|
+
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<el-input
|
|
4
|
+
v-if="column.editType === 'input'"
|
|
5
|
+
clearable
|
|
6
|
+
:value="value"
|
|
7
|
+
@input="val => emit('input', val)"
|
|
8
|
+
/>
|
|
9
|
+
|
|
10
|
+
<el-select
|
|
11
|
+
v-if="column.editType === 'select'"
|
|
12
|
+
:value="value"
|
|
13
|
+
@input="val => emit('input', val)"
|
|
14
|
+
>
|
|
15
|
+
<el-option
|
|
16
|
+
v-for="item in column.selectOptions"
|
|
17
|
+
:key="item.label"
|
|
18
|
+
:label="item.label"
|
|
19
|
+
:value="item.value"
|
|
20
|
+
/>
|
|
21
|
+
</el-select>
|
|
22
|
+
|
|
23
|
+
<el-date-picker
|
|
24
|
+
v-if="column.editType === 'date'"
|
|
25
|
+
type="date"
|
|
26
|
+
placeholder="选择日期"
|
|
27
|
+
:value="value"
|
|
28
|
+
@input="val => emit('input', val)"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script setup lang="ts">
|
|
34
|
+
import { IColumnConfig } from '../types'
|
|
35
|
+
|
|
36
|
+
defineProps<{
|
|
37
|
+
column: IColumnConfig;
|
|
38
|
+
value: any;
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
const emit = defineEmits<{
|
|
42
|
+
(e: 'input', value: any): void;
|
|
43
|
+
}>()
|
|
44
|
+
</script>
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-popover
|
|
3
|
+
ref="popoverRef"
|
|
4
|
+
placement="bottom"
|
|
5
|
+
trigger="click"
|
|
6
|
+
popper-class="editable-table__sort-filter"
|
|
7
|
+
:data-prop="column.prop"
|
|
8
|
+
@show="() => emit('popover-show')"
|
|
9
|
+
>
|
|
10
|
+
<template slot="reference">
|
|
11
|
+
<!-- 筛选中,或排序中,高亮 -->
|
|
12
|
+
<span :class="['editable-table__sort-reference', headActive && 'editable-table__sort-reference--active']">
|
|
13
|
+
{{ column.label }}
|
|
14
|
+
<div :class="['editable-table__sort-icon', headActive && 'editable-table__sort-icon--active']" />
|
|
15
|
+
</span>
|
|
16
|
+
</template>
|
|
17
|
+
<div class="sort-filter">
|
|
18
|
+
<div class="sort-filter__column-title">
|
|
19
|
+
{{ column.label }}
|
|
20
|
+
</div>
|
|
21
|
+
<div
|
|
22
|
+
v-if="column.isColumnSortable"
|
|
23
|
+
class="sort-filter__sort"
|
|
24
|
+
>
|
|
25
|
+
<div class="sort-filter__sort-title">
|
|
26
|
+
排序
|
|
27
|
+
</div>
|
|
28
|
+
<div class="sort-filter__sort-btns">
|
|
29
|
+
<el-button
|
|
30
|
+
:class="['sort-filter__sort-btn', tempSortingColumn?.prop === column.prop && tempSortType === 'ascending' && 'sort-filter__sort-btn--active']"
|
|
31
|
+
@click="() => emit('update:sort', 'ascending')"
|
|
32
|
+
>
|
|
33
|
+
升序
|
|
34
|
+
</el-button>
|
|
35
|
+
<el-button
|
|
36
|
+
:class="['sort-filter__sort-btn', tempSortingColumn?.prop === column.prop && tempSortType === 'descending' && 'sort-filter__sort-btn--active']"
|
|
37
|
+
@click="() => emit('update:sort', 'descending')"
|
|
38
|
+
>
|
|
39
|
+
降序
|
|
40
|
+
</el-button>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
<div
|
|
44
|
+
v-if="column.search && !Array.isArray(column.search)"
|
|
45
|
+
class="sort-filter__search"
|
|
46
|
+
>
|
|
47
|
+
<div class="sort-filter__search-title">
|
|
48
|
+
搜索
|
|
49
|
+
</div>
|
|
50
|
+
<el-input
|
|
51
|
+
class="sort-filter__search-input"
|
|
52
|
+
placeholder="请输入内容"
|
|
53
|
+
:value="tempSearchValue[column.prop]"
|
|
54
|
+
@input="val => emit('update:tempSearchValue', column.prop, val)"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
v-if="column.search && Array.isArray(column.search)"
|
|
60
|
+
class="sort-filter__search"
|
|
61
|
+
style="display: flex;flex-direction: column;gap: 12px;"
|
|
62
|
+
>
|
|
63
|
+
<div
|
|
64
|
+
v-for="item in column.search"
|
|
65
|
+
:key="item.prop"
|
|
66
|
+
>
|
|
67
|
+
<div class="sort-filter__search-title">
|
|
68
|
+
{{ item.label }}
|
|
69
|
+
</div>
|
|
70
|
+
<el-input
|
|
71
|
+
class="sort-filter__search-input"
|
|
72
|
+
placeholder="请输入内容"
|
|
73
|
+
:value="tempSearchValue[item.prop]"
|
|
74
|
+
@input="val => emit('update:tempSearchValue', item.prop, val)"
|
|
75
|
+
/>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div
|
|
80
|
+
v-if="column.filters && ((Array.isArray(column.filters) ? column.filters : column.filters.options).length > 0)"
|
|
81
|
+
class="sort-filter__filter"
|
|
82
|
+
>
|
|
83
|
+
<div class="sort-filter__filter-title">
|
|
84
|
+
筛选
|
|
85
|
+
</div>
|
|
86
|
+
<el-checkbox-group
|
|
87
|
+
v-if="column.filters && (Array.isArray(column.filters) || column.filters.type === 'checkbox')"
|
|
88
|
+
class="sort-filter__filter-checkbox-group"
|
|
89
|
+
:value="tempFilteredValue[column.prop]"
|
|
90
|
+
@input="val => emit('update:tempFilteredValue', column.prop, val)"
|
|
91
|
+
>
|
|
92
|
+
<el-checkbox
|
|
93
|
+
v-for="item in (Array.isArray(column.filters) ? column.filters : column.filters.options)"
|
|
94
|
+
:key="item.value"
|
|
95
|
+
:label="item.value"
|
|
96
|
+
class="sort-filter__filter-checkbox"
|
|
97
|
+
>
|
|
98
|
+
<slot
|
|
99
|
+
name="filter-item"
|
|
100
|
+
v-bind="item"
|
|
101
|
+
>
|
|
102
|
+
{{ item.text }}
|
|
103
|
+
</slot>
|
|
104
|
+
</el-checkbox>
|
|
105
|
+
</el-checkbox-group>
|
|
106
|
+
|
|
107
|
+
<el-radio-group
|
|
108
|
+
v-if="column.filters && !Array.isArray(column.filters) && column.filters.type === 'radio'"
|
|
109
|
+
style="display: flex;flex-direction: column;gap: 6px;"
|
|
110
|
+
:value="tempFilteredValue[column.prop]"
|
|
111
|
+
@input="val => emit('update:tempFilteredValue', column.prop, val)"
|
|
112
|
+
>
|
|
113
|
+
<el-radio
|
|
114
|
+
v-for="item in column.filters.options"
|
|
115
|
+
:key="item.value"
|
|
116
|
+
:label="item.value"
|
|
117
|
+
>
|
|
118
|
+
<slot
|
|
119
|
+
name="filter-item"
|
|
120
|
+
v-bind="item"
|
|
121
|
+
>
|
|
122
|
+
{{ item.text }}
|
|
123
|
+
</slot>
|
|
124
|
+
</el-radio>
|
|
125
|
+
</el-radio-group>
|
|
126
|
+
</div>
|
|
127
|
+
<div
|
|
128
|
+
v-if="column.summary"
|
|
129
|
+
class="sort-filter__filter"
|
|
130
|
+
>
|
|
131
|
+
<div class="sort-filter__filter-title">
|
|
132
|
+
统计
|
|
133
|
+
</div>
|
|
134
|
+
<el-checkbox-group
|
|
135
|
+
class="sort-filter__filter-checkbox-group"
|
|
136
|
+
:value="tempSummaryList"
|
|
137
|
+
@input="val => emit('update:tempSummaryList', val)"
|
|
138
|
+
>
|
|
139
|
+
<el-checkbox
|
|
140
|
+
:label="column.prop"
|
|
141
|
+
class="sort-filter__filter-checkbox"
|
|
142
|
+
>
|
|
143
|
+
<slot
|
|
144
|
+
name="summay-item"
|
|
145
|
+
v-bind="column"
|
|
146
|
+
>
|
|
147
|
+
{{ column.label }}
|
|
148
|
+
</slot>
|
|
149
|
+
</el-checkbox>
|
|
150
|
+
</el-checkbox-group>
|
|
151
|
+
</div>
|
|
152
|
+
<div class="sort-filter__footer">
|
|
153
|
+
<el-button
|
|
154
|
+
class="sort-filter__reset-btn"
|
|
155
|
+
@click="() => emit('reset')"
|
|
156
|
+
>
|
|
157
|
+
重置
|
|
158
|
+
</el-button>
|
|
159
|
+
<el-button
|
|
160
|
+
class="sort-filter__confirm-btn"
|
|
161
|
+
type="primary"
|
|
162
|
+
@click="() => emit('confirm')"
|
|
163
|
+
>
|
|
164
|
+
确定
|
|
165
|
+
</el-button>
|
|
166
|
+
</div>
|
|
167
|
+
</div>
|
|
168
|
+
</el-popover>
|
|
169
|
+
</template>
|
|
170
|
+
|
|
171
|
+
<script setup lang="ts">
|
|
172
|
+
import { ref } from 'vue'
|
|
173
|
+
import { IColumnConfig } from '../types'
|
|
174
|
+
|
|
175
|
+
defineProps<{
|
|
176
|
+
headActive: boolean
|
|
177
|
+
column: IColumnConfig
|
|
178
|
+
tempSummaryList: string[]
|
|
179
|
+
tempSortingColumn: IColumnConfig | null
|
|
180
|
+
tempSortType: 'ascending' | 'descending' | ''
|
|
181
|
+
tempSearchValue: Record<string, string>
|
|
182
|
+
tempFilteredValue: Record<string, string | number | number[] | string[]>
|
|
183
|
+
}>()
|
|
184
|
+
|
|
185
|
+
const emit = defineEmits<{
|
|
186
|
+
(e: 'update:tempSearchValue', key: string, value: string): void
|
|
187
|
+
(e: 'update:tempFilteredValue', key: string, value: string): void
|
|
188
|
+
(e: 'update:tempSummaryList', value: string[]): void
|
|
189
|
+
(e: 'update:sort', type: 'ascending' | 'descending'): void
|
|
190
|
+
(e: 'popover-show'): void
|
|
191
|
+
(e: 'reset'): void
|
|
192
|
+
(e: 'confirm'): void
|
|
193
|
+
}>()
|
|
194
|
+
|
|
195
|
+
const popoverRef = ref(null as any)
|
|
196
|
+
|
|
197
|
+
defineExpose({
|
|
198
|
+
close: () => {
|
|
199
|
+
popoverRef.value?.doClose()
|
|
200
|
+
}
|
|
201
|
+
})
|
|
202
|
+
</script>
|