@lx-frontend/wrap-element-ui 1.0.15 → 1.0.16-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.
@@ -6,6 +6,65 @@ export enum IEditType {
6
6
  DATE_ONLY = 'date'
7
7
  }
8
8
 
9
+ export interface ISortOption {
10
+ prop: string
11
+ label: string
12
+ }
13
+
14
+ /** 筛选组件 - 输入框 */
15
+ export interface IFilterInput {
16
+ type: 'input'
17
+ prop: string,
18
+ label?: string,
19
+ validator?: (value: string) => boolean
20
+ placeholder?: string
21
+ }
22
+
23
+ export interface IFilterSelectOptions {
24
+ value: any;
25
+ text: string;
26
+ [key: string]: any;
27
+ }
28
+
29
+ /** 筛选组件 - 单选/多选 */
30
+ export interface IFilterSelect {
31
+ type: 'radio' | 'checkbox'
32
+ prop: string
33
+ options: IFilterSelectOptions[]
34
+ label?: string
35
+ defaultValue?: any | any[]
36
+ }
37
+
38
+ /** 筛选组件 - 日期范围(拆分两个日期选择器) */
39
+ export interface IFilterDoubleDatePicker {
40
+ type: 'doubleDatePicker',
41
+ prop: [string, string],
42
+ label?: string,
43
+ pickerOptions?: DatePicker['pickerOptions']
44
+ }
45
+
46
+ /** 筛选组件 - 月日选择器 */
47
+ export interface IFilterMonthDayPicker {
48
+ type: 'monthDayPicker',
49
+ prop: [string, string],
50
+ label?: string,
51
+ /** 可选择的范围 */
52
+ limit: number,
53
+ }
54
+
55
+ /** 筛选组件 - 颜色选择器 */
56
+ export interface IFilterColorRadio {
57
+ type: 'colorRadio',
58
+ prop: string,
59
+ label?: string,
60
+ options: Array<IFilterSelectOptions & { color: string }>
61
+ }
62
+
63
+ export type FilterItem = IFilterInput | IFilterSelect | IFilterDoubleDatePicker | IFilterMonthDayPicker | IFilterColorRadio
64
+
65
+ /** 筛选组件类型 */
66
+ export type FilterListType = Array<FilterItem>
67
+
9
68
  type _IColumnConfigRequired = {
10
69
  prop: string;
11
70
  label: string;
@@ -20,65 +79,19 @@ type _IColumnConfigRequired = {
20
79
  isAlwaysShow?: boolean; // 不可隐藏,显示设置中,该列不允许隐藏
21
80
  /** 默认隐藏,显示设置中,该列默认隐藏 */
22
81
  defaultHide?: boolean;
23
- /** 列是否允许搜索,true则表头弹窗会多一个搜索框,一列中有多个搜索字段时传数组进行配置 */
24
- search?: boolean | ISearchOptions
25
82
  summary?: boolean; // 是否可以显示该列的统计
26
83
  summaryMethod?: (values: any[]) => string | number; // 这一列的统计方法,values为该列的所有值
27
- /** 过滤,传数组时默认复选框 */
28
- filters?: {
29
- type?: 'checkbox' | 'radio',
30
- options: FiltersOption[]
31
- default?: string | number | string[] | number[],
32
- /** 自定义参数 优先于最外层的prop */
33
- prop?: string
34
- } | FiltersOption[]
35
84
  /** 格式化函数,用于自定义渲染 */
36
85
  formatter?: (row: any, column: IColumnConfig, value: any, index: number) => string | number;
37
86
  width?: number | string;
38
87
  minWidth?: number | string;
39
- /** 是否开启日期范围选择器 */
40
- doubleDatePicker?: {
41
- props: [string, string],
42
- label: string,
43
- };
44
88
  /** 自定义颜色表头label */
45
- customColorLabel?: boolean
89
+ customColorLabel?: boolean;
90
+ filters?: FilterListType;
46
91
  }
47
92
 
48
93
  export type IColumnConfigRequired = _IColumnConfigRequired & Partial<Omit<TableColumn, keyof _IColumnConfigRequired>>
49
94
 
50
- type FiltersOption = { value: string | number; text: string; [key: string]: any }
51
-
52
- type ISortOption = {
53
- prop: string
54
- label: string
55
- }
56
-
57
- type InputSearchOption = {
58
- prop: string
59
- label: string
60
- validator?: (value: string) => boolean
61
- type?: 'input'
62
- }
63
-
64
- type DoubleDatePickerSearchOption = {
65
- prop: [string, string]
66
- label: string
67
- type: 'doubleDatePicker'
68
- pickerOptions?: DatePicker['pickerOptions']
69
- validator?: (tempSearchValue: Record<string, any>) => boolean
70
- }
71
-
72
- type SlotSearchOption = {
73
- prop: string | string[]
74
- label: string
75
- type: 'slot'
76
- slotName: string
77
- validator?: (tempSearchValue: Record<string, any>) => boolean
78
- }
79
-
80
- type ISearchOptions = (InputSearchOption | DoubleDatePickerSearchOption | SlotSearchOption)[]
81
-
82
95
  type IInputColumn = IColumnConfigRequired & {
83
96
  inputType: string | number;
84
97
  }
@@ -1,62 +0,0 @@
1
- <template>
2
- <div class="editable-table-sort-filter__filter">
3
- <div class="editable-table-sort-filter__filter-title">
4
- 筛选
5
- </div>
6
- <el-checkbox-group
7
- v-if="column.filters && (Array.isArray(column.filters) || column.filters.type === 'checkbox')"
8
- class="editable-table-sort-filter__filter-checkbox-group"
9
- :value="tempFilteredValue[column.filters.prop || column.prop]"
10
- @input="val => emit('update:tempFilteredValue', column.filters?.prop || column.prop, val)"
11
- >
12
- <el-checkbox
13
- v-for="item in (Array.isArray(column.filters) ? column.filters : column.filters.options)"
14
- :key="item.value"
15
- :label="item.value"
16
- :title="item.text"
17
- class="editable-table-sort-filter__filter-checkbox"
18
- >
19
- <slot
20
- name="filter-item"
21
- v-bind="item"
22
- >
23
- {{ item.text }}
24
- </slot>
25
- </el-checkbox>
26
- </el-checkbox-group>
27
-
28
- <el-radio-group
29
- v-if="column.filters && !Array.isArray(column.filters) && column.filters.type === 'radio'"
30
- style="display: flex;flex-direction: column;gap: 6px;"
31
- :value="tempFilteredValue[column.filters.prop || column.prop]"
32
- @input="val => emit('update:tempFilteredValue', column.filters?.prop || column.prop, val)"
33
- >
34
- <el-radio
35
- v-for="item in column.filters.options"
36
- :key="item.value"
37
- :label="item.value"
38
- :title="item.text"
39
- >
40
- <slot
41
- name="filter-item"
42
- v-bind="item"
43
- >
44
- {{ item.text }}
45
- </slot>
46
- </el-radio>
47
- </el-radio-group>
48
- </div>
49
- </template>
50
-
51
- <script setup lang="ts">
52
- import { IColumnConfig } from '../../types';
53
-
54
- defineProps<{
55
- column: IColumnConfig
56
- tempFilteredValue: Record<string, string | number | number[] | string[]>
57
- }>()
58
-
59
- const emit = defineEmits<{
60
- (e: 'update:tempFilteredValue', key: string, value: string): void
61
- }>()
62
- </script>
@@ -1,74 +0,0 @@
1
- <template>
2
- <div
3
- class="editable-table-sort-filter__search"
4
- style="display: flex;flex-direction: column;gap: 12px;"
5
- >
6
- <div
7
- v-for="item in searchConfigs"
8
- :key="item.label"
9
- >
10
- <div class="editable-table-sort-filter__search-title">
11
- {{ item.label }}
12
- </div>
13
- <template v-if="!('type' in item) || item.type === 'input'">
14
- <el-input
15
- class="editable-table-sort-filter__search-input"
16
- placeholder="请输入内容"
17
- :value="tempSearchValue[item.prop]"
18
- @input="val => emit('update:tempSearchValue', item.prop, val)"
19
- />
20
- </template>
21
- <template v-if="item.type === 'doubleDatePicker'">
22
- <div class="editable-table-sort-filter__search__date-range">
23
- <el-date-picker
24
- @input="val => emit('update:tempSearchValue', item.prop[0], val || '')"
25
- :value="tempSearchValue[item.prop[0]]"
26
- value-format="yyyy-MM-dd"
27
- format="yyyy-MM-dd"
28
- type="date"
29
- size="small"
30
- placeholder="开始日期"
31
- :picker-options="item.pickerOptions ?? {}"
32
- />
33
- <el-date-picker
34
- @input="val => emit('update:tempSearchValue', item.prop[1], val || '')"
35
- :value="tempSearchValue[item.prop[1]]"
36
- value-format="yyyy-MM-dd"
37
- format="yyyy-MM-dd"
38
- size="small"
39
- type="date"
40
- placeholder="结束日期"
41
- :picker-options="item.pickerOptions ?? {}"
42
- />
43
- </div>
44
- </template>
45
- <template v-if="item.type === 'slot'">
46
- <slot
47
- :name="item.slotName"
48
- :data="tempSearchValue"
49
- :set="(key, value) => emit('update:tempSearchValue', key, value)"
50
- />
51
- </template>
52
- </div>
53
- </div>
54
- </template>
55
-
56
- <script setup lang="ts">
57
- import { computed } from 'vue';
58
- import { IColumnConfig } from '../../types';
59
-
60
-
61
- const props = defineProps<{
62
- column: IColumnConfig
63
- tempSearchValue: Record<string, string>
64
- }>()
65
-
66
- const emit = defineEmits<{
67
- (e: 'update:tempSearchValue', key: string, value: string): void
68
- }>()
69
-
70
- const searchConfigs = computed(() => {
71
- if (Array.isArray(props.column.search)) return props.column.search
72
- return [{ prop: props.column.prop, label: '搜索' }]
73
- })
74
- </script>