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

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@lx-frontend/wrap-element-ui",
3
- "version": "1.0.14-beta.7",
3
+ "version": "1.0.14-beta.8",
4
4
  "description": "wrap-element-ui",
5
5
  "author": "",
6
6
  "main": "src/components/index.ts",
@@ -1,5 +1,5 @@
1
1
  import { computed, nextTick, ref, Ref, watch } from 'vue'
2
- import { IColumnConfig, IEmits, IProps } from '../types';
2
+ import { IColumnConfig, IEmits, IProps, ISearchOptions, DoubleDatePickerSearchOption, SlotSearchOption } from '../types';
3
3
 
4
4
  interface IUseColumnHeaderOperationParams {
5
5
  props: IProps
@@ -171,9 +171,6 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
171
171
  if (params[key] === undefined) delete params[key]
172
172
  })
173
173
 
174
- console.log(searchValue.value);
175
-
176
-
177
174
  emit('search', {
178
175
  ...params,
179
176
  page: 1
@@ -186,12 +183,17 @@ export function useColumnHeaderOperation({ props, tableDomRef, emit, showingColu
186
183
  if (Array.isArray(column.search)) {
187
184
  let validate = true;
188
185
  column.search.forEach(v => {
186
+ if (!validate) return
189
187
  if (!('type' in v) || v.type === 'input') {
190
188
  if (!tempSearchValue.value[v.prop]) tempSearchValue.value[v.prop] = ''
191
- if (!validate) return
192
189
  if (v.validator) {
193
190
  const result = v.validator(tempSearchValue.value[v.prop]?.trim());
194
- if (validate && !result) validate = false;
191
+ if (!result) validate = false;
192
+ }
193
+ } else if (v.type === 'doubleDatePicker' || v.type === 'slot') {
194
+ if (v.validator) {
195
+ const result = v.validator?.(tempSearchValue.value);
196
+ if (!result) validate = false;
195
197
  }
196
198
  }
197
199
  })
@@ -340,7 +340,6 @@
340
340
  <script lang="ts" setup>
341
341
  import BizColorSelect from './features/bizColorSelect.vue';
342
342
  import BizViewSettingDialog from './features/bizViewSettingDialog.vue'
343
- // import BizTableHeaderPopover from './features/bizTableHeaderPopover.vue'
344
343
  import BizTableHeaderPopover from './features/bizTableHeaderPopover/index.vue'
345
344
  import BizEditCell from './features/bizEditCell.vue'
346
345
  import BizTableOperatePopover from './features/bizTableOperatePopover.vue'
@@ -54,28 +54,30 @@ type ISortOption = {
54
54
  label: string
55
55
  }
56
56
 
57
- type InputSearchOption = {
57
+ export type InputSearchOption = {
58
58
  prop: string
59
59
  label: string
60
60
  validator?: (value: string) => boolean
61
61
  type?: 'input'
62
62
  }
63
63
 
64
- type DoubleDatePickerSearchOption = {
64
+ export type DoubleDatePickerSearchOption = {
65
65
  prop: [string, string]
66
66
  label: string
67
67
  type: 'doubleDatePicker'
68
68
  pickerOptions?: DatePicker['pickerOptions']
69
+ validator?: (tempSearchValue: Record<string, any>) => boolean
69
70
  }
70
71
 
71
- type SlotSearchOption = {
72
+ export type SlotSearchOption = {
72
73
  prop: string | string[]
73
74
  label: string
74
75
  type: 'slot'
75
76
  slotName: string
77
+ validator?: (tempSearchValue: Record<string, any>) => boolean
76
78
  }
77
79
 
78
- type ISearchOptions = (InputSearchOption | DoubleDatePickerSearchOption | SlotSearchOption)[]
80
+ export type ISearchOptions = (InputSearchOption | DoubleDatePickerSearchOption | SlotSearchOption)[]
79
81
 
80
82
  type IInputColumn = IColumnConfigRequired & {
81
83
  inputType: string | number;
@@ -1,285 +0,0 @@
1
- <template>
2
- <el-popover
3
- ref="popoverRef"
4
- placement="bottom"
5
- trigger="click"
6
- popper-class="editable-table-sort-filter"
7
- data-popper-name="editable-table-sort-filter"
8
- :data-prop="column.prop"
9
- @show="() => emit('popover-show')"
10
- >
11
- <template slot="reference">
12
- <slot
13
- v-if="column.customColorLabel"
14
- name="custom"
15
- />
16
- <!-- 筛选中,或排序中,高亮 -->
17
- <span
18
- v-else
19
- :class="['editable-table__sort-reference', headActive && 'editable-table__sort-reference--active']"
20
- >
21
- {{ column.label }}
22
- <div :class="['editable-table__sort-icon', headActive && 'editable-table__sort-icon--active']" />
23
- </span>
24
- </template>
25
- <div class="editable-table-sort-filter">
26
- <div class="editable-table-sort-filter__column-title">
27
- {{ column.label }}
28
- </div>
29
-
30
- <div
31
- v-if="column.isColumnSortable"
32
- class="editable-table-sort-filter__sort"
33
- >
34
- <div
35
- v-for="item in sortConfigs"
36
- :key="item.prop"
37
- >
38
- <div class="editable-table-sort-filter__sort-title">
39
- {{ item.label }}
40
- </div>
41
- <div class="editable-table-sort-filter__sort-btns">
42
- <el-button
43
- :class="['editable-table-sort-filter__sort-btn', checkActiveProp('ascending', item.prop) && 'editable-table-sort-filter__sort-btn--active']"
44
- @click="() => emit('update:sort', 'ascending', item.prop)"
45
- >
46
- 升序
47
- </el-button>
48
- <el-button
49
- :class="['editable-table-sort-filter__sort-btn', checkActiveProp('descending', item.prop) && 'editable-table-sort-filter__sort-btn--active']"
50
- @click="() => emit('update:sort', 'descending', item.prop)"
51
- >
52
- 降序
53
- </el-button>
54
- </div>
55
- </div>
56
- </div>
57
-
58
- <div
59
- v-if="!!column.search"
60
- class="editable-table-sort-filter__search"
61
- style="display: flex;flex-direction: column;gap: 12px;"
62
- >
63
- <div
64
- v-for="item in searchConfigs"
65
- :key="item.label"
66
- >
67
- <div class="editable-table-sort-filter__search-title">
68
- {{ item.label }}
69
- </div>
70
- <template v-if="!('type' in item) || item.type === 'input'">
71
- <el-input
72
- class="editable-table-sort-filter__search-input"
73
- placeholder="请输入内容"
74
- :value="tempSearchValue[item.prop]"
75
- @input="val => emit('update:tempSearchValue', item.prop, val)"
76
- />
77
- </template>
78
- <template v-if="item.type === 'doubleDatePicker'">
79
- <div class="editable-table-sort-filter__search__date-range">
80
- <el-date-picker
81
- @input="val => emit('update:tempSearchValue', item.prop[0], val || '')"
82
- :value="tempSearchValue[item.prop[0]]"
83
- value-format="yyyy-MM-dd"
84
- format="yyyy-MM-dd"
85
- type="date"
86
- size="small"
87
- placeholder="开始日期"
88
- :picker-options="item.pickerOptions ?? {}"
89
- />
90
- <el-date-picker
91
- @input="val => emit('update:tempSearchValue', item.prop[1], val || '')"
92
- :value="tempSearchValue[item.prop[1]]"
93
- value-format="yyyy-MM-dd"
94
- format="yyyy-MM-dd"
95
- size="small"
96
- type="date"
97
- placeholder="结束日期"
98
- :picker-options="item.pickerOptions ?? {}"
99
- />
100
- </div>
101
- </template>
102
- <template v-if="item.type === 'slot'">
103
- <slot
104
- :name="item.slotName"
105
- :data="tempSearchValue"
106
- :set="(key, value) => emit('update:tempSearchValue', key, value)"
107
- />
108
- </template>
109
- </div>
110
- </div>
111
-
112
- <div
113
- v-if="column.doubleDatePicker"
114
- class="editable-table-sort-filter__sort"
115
- >
116
- <div class="editable-table-sort-filter__search-title">
117
- {{ column.doubleDatePicker.label }}
118
- </div>
119
- <div
120
- class="editable-table-sort-filter__date-picker-content"
121
- style="display: flex;flex-direction: column;gap: 12px;"
122
- >
123
- <el-date-picker
124
- @input="val => emit('update:tempSearchValue', column.doubleDatePicker.props[0], val || '')"
125
- :value="tempSearchValue[column.doubleDatePicker.props[0]]"
126
- value-format="yyyy-MM-dd"
127
- format="yyyy-MM-dd"
128
- type="date"
129
- size="small"
130
- placeholder="开始日期"
131
- />
132
- <el-date-picker
133
- @input="val => emit('update:tempSearchValue', column.doubleDatePicker.props[1], val || '')"
134
- :value="tempSearchValue[column.doubleDatePicker.props[1]]"
135
- value-format="yyyy-MM-dd"
136
- format="yyyy-MM-dd"
137
- size="small"
138
- type="date"
139
- placeholder="结束日期"
140
- />
141
- </div>
142
- </div>
143
-
144
- <div
145
- v-if="column.filters && ((Array.isArray(column.filters) ? column.filters : column.filters.options).length > 0)"
146
- class="editable-table-sort-filter__filter"
147
- >
148
- <div class="editable-table-sort-filter__filter-title">
149
- 筛选
150
- </div>
151
- <el-checkbox-group
152
- v-if="column.filters && (Array.isArray(column.filters) || column.filters.type === 'checkbox')"
153
- class="editable-table-sort-filter__filter-checkbox-group"
154
- :value="tempFilteredValue[column.filters.prop || column.prop]"
155
- @input="val => emit('update:tempFilteredValue', column.filters?.prop || column.prop, val)"
156
- >
157
- <el-checkbox
158
- v-for="item in (Array.isArray(column.filters) ? column.filters : column.filters.options)"
159
- :key="item.value"
160
- :label="item.value"
161
- :title="item.text"
162
- class="editable-table-sort-filter__filter-checkbox"
163
- >
164
- <slot
165
- name="filter-item"
166
- v-bind="item"
167
- >
168
- {{ item.text }}
169
- </slot>
170
- </el-checkbox>
171
- </el-checkbox-group>
172
-
173
- <el-radio-group
174
- v-if="column.filters && !Array.isArray(column.filters) && column.filters.type === 'radio'"
175
- style="display: flex;flex-direction: column;gap: 6px;"
176
- :value="tempFilteredValue[column.filters.prop || column.prop]"
177
- @input="val => emit('update:tempFilteredValue', column.filters?.prop || column.prop, val)"
178
- >
179
- <el-radio
180
- v-for="item in column.filters.options"
181
- :key="item.value"
182
- :label="item.value"
183
- :title="item.text"
184
- >
185
- <slot
186
- name="filter-item"
187
- v-bind="item"
188
- >
189
- {{ item.text }}
190
- </slot>
191
- </el-radio>
192
- </el-radio-group>
193
- </div>
194
-
195
- <div
196
- v-if="column.summary"
197
- class="editable-table-sort-filter__filter"
198
- >
199
- <div class="editable-table-sort-filter__filter-title">
200
- 统计
201
- </div>
202
- <el-checkbox-group
203
- class="editable-table-sort-filter__filter-checkbox-group"
204
- :value="tempSummaryList"
205
- @input="val => emit('update:tempSummaryList', val)"
206
- >
207
- <el-checkbox
208
- :label="column.prop"
209
- class="editable-table-sort-filter__filter-checkbox"
210
- >
211
- <slot
212
- name="summay-item"
213
- v-bind="column"
214
- >
215
- {{ column.label }}
216
- </slot>
217
- </el-checkbox>
218
- </el-checkbox-group>
219
- </div>
220
-
221
- <div class="editable-table-sort-filter__footer">
222
- <el-button
223
- class="editable-table-sort-filter__reset-btn"
224
- @click="() => emit('reset')"
225
- >
226
- 重置
227
- </el-button>
228
- <el-button
229
- class="editable-table-sort-filter__confirm-btn"
230
- type="primary"
231
- @click="() => emit('confirm')"
232
- >
233
- 确定
234
- </el-button>
235
- </div>
236
- </div>
237
- </el-popover>
238
- </template>
239
-
240
- <script setup lang="ts">
241
- import { computed, ref } from 'vue'
242
- import { IColumnConfig } from '../types'
243
-
244
- const props = defineProps<{
245
- headActive: boolean
246
- column: IColumnConfig
247
- tempSummaryList: string[]
248
- tempSortType: 'ascending' | 'descending' | ''
249
- tempSortProp: string
250
- tempSearchValue: Record<string, string>
251
- tempFilteredValue: Record<string, string | number | number[] | string[]>
252
- }>()
253
-
254
- const emit = defineEmits<{
255
- (e: 'update:tempSearchValue', key: string, value: string): void
256
- (e: 'update:tempFilteredValue', key: string, value: string): void
257
- (e: 'update:tempSummaryList', value: string[]): void
258
- (e: 'update:sort', type: 'ascending' | 'descending', prop: string): void
259
- (e: 'popover-show'): void
260
- (e: 'reset'): void
261
- (e: 'confirm'): void
262
- }>()
263
-
264
- const popoverRef = ref(null as any)
265
-
266
- const searchConfigs = computed(() => {
267
- if (Array.isArray(props.column.search)) return props.column.search
268
- return [{ prop: props.column.prop, label: '搜索' }]
269
- })
270
-
271
- const sortConfigs = computed(() => {
272
- if (Array.isArray(props.column._sortable)) return props.column._sortable
273
- return [{ ...props.column, label: '排序' }]
274
- })
275
-
276
- const checkActiveProp = (type: 'ascending' | 'descending', prop: string) => {
277
- return props.tempSortType === type && props.tempSortProp === prop
278
- }
279
-
280
- defineExpose({
281
- close: () => {
282
- popoverRef.value?.doClose()
283
- }
284
- })
285
- </script>