@lx-frontend/wrap-element-ui 1.0.15-beta.8 → 1.0.15

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.
@@ -0,0 +1,74 @@
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>
@@ -5,7 +5,7 @@
5
5
  :key="item.prop"
6
6
  >
7
7
  <div class="editable-table-sort-filter__sort-title">
8
- {{ item.label || '排序' }}
8
+ {{ item.label }}
9
9
  </div>
10
10
  <div class="editable-table-sort-filter__sort-btns">
11
11
  <el-button
@@ -47,4 +47,4 @@ const sortConfigs = computed(() => {
47
47
  if (Array.isArray(props.column._sortable)) return props.column._sortable
48
48
  return [{ ...props.column, label: '排序' }]
49
49
  })
50
- </script>
50
+ </script>
@@ -387,28 +387,9 @@
387
387
  border-bottom: 1px solid #d6dbe3;
388
388
  }
389
389
 
390
- &__item {
391
- margin-top: 14px;
392
- }
393
-
394
- &__date-picker-content {
395
- display: flex;
396
- flex-direction: column;
397
- gap: 12px;
398
-
399
- .el-date-editor.el-input,
400
- .el-date-editor.el-input__inner {
401
- width: 100%;
402
- }
403
- }
404
-
405
390
  &__filter,
406
391
  &__search {
407
- padding: 0 14px;
408
-
409
- .el-select {
410
- width: 100%;
411
- }
392
+ padding: 14px;
412
393
 
413
394
  .el-radio {
414
395
  width: 100%;
@@ -441,6 +422,7 @@
441
422
  }
442
423
 
443
424
  &__filter {
425
+ padding-top: 0;
444
426
 
445
427
  .el-radio-group,
446
428
  .el-checkbox-group {
@@ -451,9 +433,10 @@
451
433
  }
452
434
 
453
435
  &__sort {
454
- padding: 0 14px;
436
+ padding: 14px;
455
437
  display: flex;
456
438
  flex-direction: column;
439
+ gap: 8px;
457
440
  }
458
441
 
459
442
  &__filter-title,
@@ -471,19 +454,22 @@
471
454
  height: 32px;
472
455
  }
473
456
  }
474
-
475
457
  &__date-range {
476
458
  display: flex;
477
459
  flex-direction: column;
478
460
  gap: 12px;
479
461
 
480
- .el-date-editor.el-input,
481
- .el-date-editor.el-input__inner {
462
+ .el-date-editor.el-input, .el-date-editor.el-input__inner {
482
463
  width: 100%;
483
464
  }
484
465
  }
485
466
  }
486
467
 
468
+ &__filter-title {
469
+ border-top: 1px solid #f3f3f3;
470
+ padding-top: 14px;
471
+ }
472
+
487
473
  &__sort-btns {
488
474
  display: flex;
489
475
  justify-content: space-between;
@@ -557,7 +543,6 @@
557
543
  justify-content: flex-end;
558
544
  align-items: center;
559
545
  padding: 0 15px;
560
- margin-top: 14px;
561
546
  }
562
547
 
563
548
  &__reset-btn,
@@ -817,4 +802,4 @@
817
802
  &::before {
818
803
  bottom: -4px;
819
804
  }
820
- }
805
+ }
@@ -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>
107
+ <template #header="scope">
108
108
  <biz-table-header-popover
109
109
  v-if="colorFilterConfig"
110
110
  :head-active="isColumnHeadActive(colorFilterConfig)"
@@ -114,12 +114,14 @@
114
114
  :temp-sort-prop="tempSortProp"
115
115
  :temp-sort-type="tempSortType"
116
116
  :temp-filtered-value="tempFilteredValue"
117
+ :temp-search-value="tempSearchValue"
117
118
  @update:tempSummaryList="val => { tempSummaryList = val }"
118
119
  @update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
120
+ @update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
119
121
  @popover-show="() => handleHeaderPopoverShow(colorFilterConfig)"
120
122
  @update:sort="handleSort"
121
- @reset="() => handleHeaderOperationReset(colorFilterConfig)"
122
- @confirm="() => handleHeaderOperationConfirm(colorFilterConfig)"
123
+ @reset="() => handleHeaderOperationReset(colorFilterConfig, scope)"
124
+ @confirm="() => handleHeaderOperationConfirm(colorFilterConfig, scope)"
123
125
  >
124
126
  <template #custom>
125
127
  <div class="editable-table__color-icon" />
@@ -156,8 +158,8 @@
156
158
  v-bind="getColumnBindProps(column)"
157
159
  >
158
160
  <template
159
- #header
160
161
  v-if="showColumnHeadSortIcon(column)"
162
+ #header="scope"
161
163
  >
162
164
  <biz-table-header-popover
163
165
  :head-active="isColumnHeadActive(column)"
@@ -167,12 +169,14 @@
167
169
  :temp-sort-prop="tempSortProp"
168
170
  :temp-sort-type="tempSortType"
169
171
  :temp-filtered-value="tempFilteredValue"
172
+ :temp-search-value="tempSearchValue"
170
173
  @update:tempSummaryList="val => { tempSummaryList = val }"
171
174
  @update:tempFilteredValue="(key, value) => { $set(tempFilteredValue, key, value) }"
175
+ @update:tempSearchValue="(key, value) => { $set(tempSearchValue, key, value) }"
172
176
  @popover-show="() => handleHeaderPopoverShow(column)"
173
177
  @update:sort="handleSort"
174
- @reset="() => handleHeaderOperationReset(column)"
175
- @confirm="() => handleHeaderOperationConfirm(column)"
178
+ @reset="() => handleHeaderOperationReset(column, scope)"
179
+ @confirm="() => handleHeaderOperationConfirm(column, scope)"
176
180
  >
177
181
  <template #filter-item="item">
178
182
  <slot
@@ -190,6 +194,15 @@
190
194
  {{ column.label }}
191
195
  </slot>
192
196
  </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>
193
206
  </biz-table-header-popover>
194
207
  </template>
195
208
  <!-- 默认操作按钮,defaultOperations属性不为空数组时展示。编辑状态下隐藏 -->
@@ -421,7 +434,7 @@ const props = withDefaults(defineProps<IProps>(), {
421
434
  total: 0,
422
435
  defaultOperations: () => [],
423
436
  colorList: () => [],
424
- colorFilterConfig: undefined,
437
+ colorFilterConfig: () => null,
425
438
  leftFixedCount: 1,
426
439
  dragSemiRange: 15,
427
440
  loading: false,
@@ -503,7 +516,7 @@ const {
503
516
  const {
504
517
  setRowStyle,
505
518
  } = useRowBgColor({
506
- colorList: props.colorList || [],
519
+ colorList: props.colorList,
507
520
  emit
508
521
  });
509
522
 
@@ -541,11 +554,13 @@ const {
541
554
  filteredValue,
542
555
  showColumnHeadSortIcon,
543
556
  sortProp,
557
+ tempSearchValue,
544
558
  tempFilteredValue,
545
559
  tempSummaryList,
546
560
  tempSortType,
547
561
  tempSortProp,
548
562
  isColumnFiltering,
563
+ searchValue,
549
564
  inSorting,
550
565
  } = useColumnHeaderOperation({
551
566
  tableDomRef,
@@ -6,65 +6,6 @@ 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
-
68
9
  type _IColumnConfigRequired = {
69
10
  prop: string;
70
11
  label: string;
@@ -79,19 +20,65 @@ type _IColumnConfigRequired = {
79
20
  isAlwaysShow?: boolean; // 不可隐藏,显示设置中,该列不允许隐藏
80
21
  /** 默认隐藏,显示设置中,该列默认隐藏 */
81
22
  defaultHide?: boolean;
23
+ /** 列是否允许搜索,true则表头弹窗会多一个搜索框,一列中有多个搜索字段时传数组进行配置 */
24
+ search?: boolean | ISearchOptions
82
25
  summary?: boolean; // 是否可以显示该列的统计
83
26
  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[]
84
35
  /** 格式化函数,用于自定义渲染 */
85
36
  formatter?: (row: any, column: IColumnConfig, value: any, index: number) => string | number;
86
37
  width?: number | string;
87
38
  minWidth?: number | string;
39
+ /** 是否开启日期范围选择器 */
40
+ doubleDatePicker?: {
41
+ props: [string, string],
42
+ label: string,
43
+ };
88
44
  /** 自定义颜色表头label */
89
- customColorLabel?: boolean;
90
- filters?: FilterListType;
45
+ customColorLabel?: boolean
91
46
  }
92
47
 
93
48
  export type IColumnConfigRequired = _IColumnConfigRequired & Partial<Omit<TableColumn, keyof _IColumnConfigRequired>>
94
49
 
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
+
95
82
  type IInputColumn = IColumnConfigRequired & {
96
83
  inputType: string | number;
97
84
  }
@@ -8,7 +8,7 @@
8
8
  v-for="({
9
9
  isEmpty = true, key, type, prop, label, placeholder, candidate, filterable=false, withoutAll=false, collapseTags=false,
10
10
  clearable=false, multiple=false, multipleLimit=0, changeCb, inputLimitCallback, slotName, dateType='date',
11
- doubleIsInline = true,
11
+ doubleIsInline = true, maxlength = 255,
12
12
  }) in config"
13
13
  :key="label"
14
14
  :label="showLabel ? label : ''"
@@ -18,6 +18,7 @@
18
18
  v-if="type === 'input'"
19
19
  :placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
20
20
  :value="formData[prop]"
21
+ :maxlength="maxlength"
21
22
  @input="val => handleInput(val, prop, inputLimitCallback)"
22
23
  />
23
24
  <div
@@ -16,6 +16,7 @@ type SlotOption = Omit<BaseOption, 'prop'> & {
16
16
  type InputOption = BaseOption & {
17
17
  type: 'input'
18
18
  inputLimitCallback?: (value: string) => boolean
19
+ maxlength?: number
19
20
  }
20
21
 
21
22
  type SelectOption = BaseOption & {
@@ -1,45 +0,0 @@
1
- <!-- 复选框 -->
2
- <template>
3
- <div class="editable-table-sort-filter__filter">
4
- <div class="editable-table-sort-filter__filter-title">
5
- {{ config.label || '筛选' }}
6
- </div>
7
- <el-checkbox-group
8
- class="editable-table-sort-filter__filter-checkbox-group"
9
- :value="tempFilteredValue[config.prop]"
10
- @input="val => emit('update:tempFilteredValue', config.prop, val)"
11
- >
12
- <el-checkbox
13
- v-for="item in config.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
- </div>
28
- </template>
29
-
30
- <script setup lang="ts">
31
- import { IFilterSelect } from '../../types';
32
-
33
- defineProps<{
34
- config: IFilterSelect
35
- tempFilteredValue: Record<string, string>
36
- }>()
37
-
38
- const emit = defineEmits<{
39
- (e: 'update:tempFilteredValue', key: string, value: string): void
40
- }>()
41
- </script>
42
-
43
- <style scoped lang="less">
44
-
45
- </style>
@@ -1,56 +0,0 @@
1
- <!-- 单选框 -->
2
- <template>
3
- <div class="editable-table-sort-filter__filter">
4
- <div class="editable-table-sort-filter__filter-title">
5
- {{ config.label || '筛选' }}
6
- </div>
7
- <el-radio-group
8
- style="display: flex;flex-direction: column;gap: 6px;"
9
- :value="tempFilteredValue[config.prop]"
10
- @input="val => emit('update:tempFilteredValue', config.prop, val)"
11
- >
12
- <el-radio
13
- v-for="item in config.options"
14
- :key="item.value"
15
- :label="item.value"
16
- :title="item.text"
17
- >
18
- <span class="color-option">
19
- <span
20
- class="icon"
21
- :style="{ background: item.color }"
22
- />
23
- <span>{{ item.text }}</span>
24
- </span>
25
- </el-radio>
26
- </el-radio-group>
27
- </div>
28
- </template>
29
-
30
- <script setup lang="ts">
31
- import { IFilterColorRadio } from '../../types';
32
-
33
- defineProps<{
34
- config: IFilterColorRadio
35
- tempFilteredValue: Record<string, string>
36
- }>()
37
-
38
- const emit = defineEmits<{
39
- (e: 'update:tempFilteredValue', key: string, value: string): void
40
- }>()
41
- </script>
42
-
43
- <style scoped lang="less">
44
- .color-option {
45
- display: flex;
46
- align-items: center;
47
-
48
- .icon {
49
- border-radius: 50%;
50
- width: 1em;
51
- height: 1em;
52
- margin-right: 0.3em;
53
- border: 1px solid #ccc;
54
- }
55
- }
56
- </style>
@@ -1,47 +0,0 @@
1
- <!-- 日期范围选择(分开的两个日期选择器) -->
2
- <template>
3
- <div class="editable-table-sort-filter__sort">
4
- <div class="editable-table-sort-filter__search-title">
5
- {{ config.label || '筛选' }}
6
- </div>
7
- <div class="editable-table-sort-filter__date-picker-content">
8
- <el-date-picker
9
- value-format="yyyy-MM-dd"
10
- format="yyyy-MM-dd"
11
- type="date"
12
- size="small"
13
- placeholder="开始日期"
14
- :value="tempFilteredValue[config.prop[0]]"
15
- :editable="false"
16
- @input="val => emit('update:tempFilteredValue', config.prop[0], val || '')"
17
- />
18
- <el-date-picker
19
- value-format="yyyy-MM-dd"
20
- format="yyyy-MM-dd"
21
- size="small"
22
- type="date"
23
- placeholder="结束日期"
24
- :value="tempFilteredValue[config.prop[1]]"
25
- :editable="false"
26
- @input="val => emit('update:tempFilteredValue', config.prop[1], val || '')"
27
- />
28
- </div>
29
- </div>
30
- </template>
31
-
32
- <script setup lang="ts">
33
- import { IFilterDoubleDatePicker } from '../../types';
34
-
35
- defineProps<{
36
- config: IFilterDoubleDatePicker
37
- tempFilteredValue: Record<string, string>
38
- }>()
39
-
40
- const emit = defineEmits<{
41
- (e: 'update:tempFilteredValue', key: string, value: string): void
42
- }>()
43
- </script>
44
-
45
- <style scoped lang="less">
46
-
47
- </style>
@@ -1,26 +0,0 @@
1
- <template>
2
- <div class="editable-table-sort-filter__search">
3
- <div class="editable-table-sort-filter__search-title">
4
- {{ config.label || '搜索' }}
5
- </div>
6
- <el-input
7
- class="editable-table-sort-filter__search-input"
8
- :placeholder="config.placeholder || '请输入内容'"
9
- :value="tempFilteredValue[config.prop]"
10
- @input="val => emit('update:tempFilteredValue', config.prop, val)"
11
- />
12
- </div>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import { IFilterInput } from '../../types';
17
-
18
- defineProps<{
19
- config: IFilterInput
20
- tempFilteredValue: Record<string, string>
21
- }>()
22
-
23
- const emit = defineEmits<{
24
- (e: 'update:tempFilteredValue', key: string, value: string): void
25
- }>()
26
- </script>