@lx-frontend/wrap-element-ui 1.0.15 → 1.0.16-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.
@@ -104,7 +104,7 @@
104
104
  :fixed="leftFixedColumnCount > 0 ? 'left' : false"
105
105
  :filtered-value="Array.isArray(filteredValue[colorFilterConfig?.prop]) ? filteredValue[colorFilterConfig?.prop] : []"
106
106
  >
107
- <template #header="scope">
107
+ <template #header>
108
108
  <biz-table-header-popover
109
109
  v-if="colorFilterConfig"
110
110
  :head-active="isColumnHeadActive(colorFilterConfig)"
@@ -114,26 +114,16 @@
114
114
  :temp-sort-prop="tempSortProp"
115
115
  :temp-sort-type="tempSortType"
116
116
  :temp-filtered-value="tempFilteredValue"
117
- :temp-search-value="tempSearchValue"
118
117
  @update:tempSummaryList="val => { tempSummaryList = val }"
119
118
  @update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
120
- @update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
121
119
  @popover-show="() => handleHeaderPopoverShow(colorFilterConfig)"
122
120
  @update:sort="handleSort"
123
- @reset="() => handleHeaderOperationReset(colorFilterConfig, scope)"
124
- @confirm="() => handleHeaderOperationConfirm(colorFilterConfig, scope)"
121
+ @reset="() => handleHeaderOperationReset(colorFilterConfig)"
122
+ @confirm="() => handleHeaderOperationConfirm(colorFilterConfig)"
125
123
  >
126
124
  <template #custom>
127
125
  <div class="editable-table__color-icon" />
128
126
  </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
127
  </biz-table-header-popover>
138
128
  <div
139
129
  v-else
@@ -158,8 +148,8 @@
158
148
  v-bind="getColumnBindProps(column)"
159
149
  >
160
150
  <template
151
+ #header
161
152
  v-if="showColumnHeadSortIcon(column)"
162
- #header="scope"
163
153
  >
164
154
  <biz-table-header-popover
165
155
  :head-active="isColumnHeadActive(column)"
@@ -169,23 +159,13 @@
169
159
  :temp-sort-prop="tempSortProp"
170
160
  :temp-sort-type="tempSortType"
171
161
  :temp-filtered-value="tempFilteredValue"
172
- :temp-search-value="tempSearchValue"
173
162
  @update:tempSummaryList="val => { tempSummaryList = val }"
174
163
  @update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
175
- @update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
176
164
  @popover-show="() => handleHeaderPopoverShow(column)"
177
165
  @update:sort="handleSort"
178
- @reset="() => handleHeaderOperationReset(column, scope)"
179
- @confirm="() => handleHeaderOperationConfirm(column, scope)"
166
+ @reset="() => handleHeaderOperationReset(column)"
167
+ @confirm="() => handleHeaderOperationConfirm(column)"
180
168
  >
181
- <template #filter-item="item">
182
- <slot
183
- :name="column.prop + '-filter-item'"
184
- v-bind="item"
185
- >
186
- {{ item.text }}
187
- </slot>
188
- </template>
189
169
  <template #summay-item>
190
170
  <slot
191
171
  :name="column.prop + '-summay-item'"
@@ -194,15 +174,6 @@
194
174
  {{ column.label }}
195
175
  </slot>
196
176
  </template>
197
- <template
198
- v-for="searchOption in (Array.isArray(column.search) ? column.search : []).filter(v => v.type === 'slot')"
199
- #[searchOption.slotName]="rest"
200
- >
201
- <slot
202
- :name="searchOption.slotName"
203
- v-bind="rest"
204
- />
205
- </template>
206
177
  </biz-table-header-popover>
207
178
  </template>
208
179
  <!-- 默认操作按钮,defaultOperations属性不为空数组时展示。编辑状态下隐藏 -->
@@ -346,6 +317,7 @@ import BizTableOperatePopover from './features/bizTableOperatePopover.vue'
346
317
 
347
318
  import { computed, nextTick, ref, watch } from 'vue';
348
319
  import { Message } from 'element-ui';
320
+ import omit from 'lodash/omit';
349
321
 
350
322
  import {
351
323
  usePagination,
@@ -434,7 +406,7 @@ const props = withDefaults(defineProps<IProps>(), {
434
406
  total: 0,
435
407
  defaultOperations: () => [],
436
408
  colorList: () => [],
437
- colorFilterConfig: () => null,
409
+ colorFilterConfig: undefined,
438
410
  leftFixedCount: 1,
439
411
  dragSemiRange: 15,
440
412
  loading: false,
@@ -516,7 +488,7 @@ const {
516
488
  const {
517
489
  setRowStyle,
518
490
  } = useRowBgColor({
519
- colorList: props.colorList,
491
+ colorList: props.colorList || [],
520
492
  emit
521
493
  });
522
494
 
@@ -554,13 +526,11 @@ const {
554
526
  filteredValue,
555
527
  showColumnHeadSortIcon,
556
528
  sortProp,
557
- tempSearchValue,
558
529
  tempFilteredValue,
559
530
  tempSummaryList,
560
531
  tempSortType,
561
532
  tempSortProp,
562
533
  isColumnFiltering,
563
- searchValue,
564
534
  inSorting,
565
535
  } = useColumnHeaderOperation({
566
536
  tableDomRef,
@@ -605,9 +575,14 @@ const doTableLayout = async () => {
605
575
 
606
576
  // 过滤出自定义属性,将其它属性全部透传给 el-table-column
607
577
  const getColumnBindProps = (column: IColumnConfig) => {
608
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
609
- const { editType, slotName, inputType, options, filters, ...rest } = column;
610
- return rest;
578
+ // 过滤掉自定义属性,只保留 el-table-column 支持的属性
579
+ return omit(column, [
580
+ 'editType',
581
+ 'slotName',
582
+ 'inputType',
583
+ 'options',
584
+ 'filters'
585
+ ]);
611
586
  };
612
587
 
613
588
  const setRowClassName = (scope) => {
@@ -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>