@lx-frontend/wrap-element-ui 1.0.21-beta.1 → 1.0.21-beta.3
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 +1 -1
- package/src/components/EditableTable/features/bizTableHeaderPopover/BizDoubleDatePickerFilter.vue +28 -33
- package/src/components/EditableTable/types/index.ts +12 -3
- package/src/components/SearchForm/index.vue +10 -1
- package/src/components/SearchForm/types/index.ts +14 -1
- package/src/components/helper.ts +37 -0
package/package.json
CHANGED
package/src/components/EditableTable/features/bizTableHeaderPopover/BizDoubleDatePickerFilter.vue
CHANGED
|
@@ -9,14 +9,14 @@
|
|
|
9
9
|
v-bind="datePickerCommonProps"
|
|
10
10
|
placeholder="开始日期"
|
|
11
11
|
:value="tempFilteredValue[config.prop[0]]"
|
|
12
|
-
:picker-options="
|
|
12
|
+
:picker-options="pickerStartOptions"
|
|
13
13
|
@input="handleStartDateChange"
|
|
14
14
|
/>
|
|
15
15
|
<el-date-picker
|
|
16
16
|
v-bind="datePickerCommonProps"
|
|
17
17
|
placeholder="结束日期"
|
|
18
18
|
:value="tempFilteredValue[config.prop[1]]"
|
|
19
|
-
:picker-options="
|
|
19
|
+
:picker-options="pickerEndOptions"
|
|
20
20
|
@input="handleEndDateChange"
|
|
21
21
|
/>
|
|
22
22
|
</div>
|
|
@@ -24,19 +24,19 @@
|
|
|
24
24
|
</template>
|
|
25
25
|
|
|
26
26
|
<script setup lang="ts">
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import
|
|
30
|
-
import type { DatePickerOptions } from 'element-ui/types/date-picker';
|
|
27
|
+
import { IFilterDoubleDatePicker, IFilterDoubleDatePickerLimit } from '../../types';
|
|
28
|
+
import { genStartDateDisabledOptions, genEndDateDisabledOptions } from '../../../helper';
|
|
29
|
+
import { computed, toRefs } from 'vue';
|
|
31
30
|
|
|
32
31
|
interface IFilterDoubleDatePickerProps {
|
|
33
32
|
/** 日期选择器配置 */
|
|
34
|
-
config: IFilterDoubleDatePicker;
|
|
33
|
+
config: IFilterDoubleDatePicker | IFilterDoubleDatePickerLimit;
|
|
35
34
|
/** 临时筛选值 */
|
|
36
35
|
tempFilteredValue: Record<string, string>;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
const props = defineProps<IFilterDoubleDatePickerProps>();
|
|
39
|
+
const { config, tempFilteredValue } = toRefs(props)
|
|
40
40
|
|
|
41
41
|
const emit = defineEmits<{
|
|
42
42
|
(e: 'update:tempFilteredValue', key: string, value: string): void;
|
|
@@ -51,41 +51,36 @@ const datePickerCommonProps = {
|
|
|
51
51
|
editable: false,
|
|
52
52
|
} as const;
|
|
53
53
|
|
|
54
|
-
/** 开始日期禁用配置 */
|
|
55
|
-
const startDateDisabledOptions = computed<DatePickerOptions>(() => {
|
|
56
|
-
const endDate = props.tempFilteredValue[props.config.prop[1]];
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
55
|
+
const pickerStartOptions = computed(() => {
|
|
56
|
+
if ('startOptions' in config.value && config.value.startOptions) {
|
|
57
|
+
return config.value.startOptions;
|
|
58
|
+
}
|
|
59
|
+
if ('limit' in config.value) {
|
|
60
|
+
return genStartDateDisabledOptions(tempFilteredValue.value[config.value.prop[1]], config.value.limit);
|
|
61
|
+
}
|
|
62
|
+
// 默认,无限制
|
|
63
|
+
return genStartDateDisabledOptions(tempFilteredValue.value[config.value.prop[1]]);
|
|
66
64
|
});
|
|
67
65
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
});
|
|
66
|
+
const pickerEndOptions = computed(() => {
|
|
67
|
+
if ('endOptions' in config.value && config.value.endOptions) {
|
|
68
|
+
return config.value.endOptions;
|
|
69
|
+
}
|
|
70
|
+
if ('limit' in config.value) {
|
|
71
|
+
return genEndDateDisabledOptions(tempFilteredValue.value[config.value.prop[0]], config.value.limit);
|
|
72
|
+
}
|
|
73
|
+
// 默认,无限制
|
|
74
|
+
return genEndDateDisabledOptions(tempFilteredValue.value[config.value.prop[0]]);
|
|
75
|
+
})
|
|
81
76
|
|
|
82
77
|
/** 处理开始日期变更 */
|
|
83
78
|
const handleStartDateChange = (val: string | null) => {
|
|
84
|
-
emit('update:tempFilteredValue',
|
|
79
|
+
emit('update:tempFilteredValue', config.value.prop[0], val || '');
|
|
85
80
|
};
|
|
86
81
|
|
|
87
82
|
/** 处理结束日期变更 */
|
|
88
83
|
const handleEndDateChange = (val: string | null) => {
|
|
89
|
-
emit('update:tempFilteredValue',
|
|
84
|
+
emit('update:tempFilteredValue', config.value.prop[1], val || '');
|
|
90
85
|
};
|
|
91
86
|
</script>
|
|
@@ -36,11 +36,20 @@ export interface IFilterSelect {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/** 筛选组件 - 日期范围(拆分两个日期选择器) */
|
|
39
|
-
export interface
|
|
39
|
+
export interface IFilterDoubleDatePickerBase {
|
|
40
40
|
type: 'doubleDatePicker',
|
|
41
41
|
prop: [string, string],
|
|
42
42
|
label?: string,
|
|
43
|
-
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface IFilterDoubleDatePicker extends IFilterDoubleDatePickerBase {
|
|
46
|
+
startOptions?: DatePicker['pickerOptions'],
|
|
47
|
+
endOptions?: DatePicker['pickerOptions'],
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IFilterDoubleDatePickerLimit extends IFilterDoubleDatePickerBase {
|
|
51
|
+
/** 限制天数范围 */
|
|
52
|
+
limit?: number
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
/** 筛选组件 - 月日选择器 */
|
|
@@ -66,7 +75,7 @@ export interface IFilterSolt {
|
|
|
66
75
|
active: () => boolean
|
|
67
76
|
}
|
|
68
77
|
|
|
69
|
-
export type FilterItem = IFilterInput | IFilterSelect | IFilterDoubleDatePicker | IFilterMonthDayPicker | IFilterColorRadio | IFilterSolt
|
|
78
|
+
export type FilterItem = IFilterInput | IFilterSelect | IFilterDoubleDatePicker | IFilterDoubleDatePickerLimit | IFilterMonthDayPicker | IFilterColorRadio | IFilterSolt
|
|
70
79
|
|
|
71
80
|
/** 筛选组件类型 */
|
|
72
81
|
export type FilterListType = Array<FilterItem>
|
|
@@ -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, maxlength = 255,
|
|
11
|
+
doubleIsInline = true, maxlength = 255, datePickerOptions, doubleDatePickerStartOptions, doubleDatePickerEndOptions, doubleDatePickerLimit
|
|
12
12
|
}) in config"
|
|
13
13
|
:key="label"
|
|
14
14
|
:label="showLabel ? label : ''"
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
:placeholder="dateType == 'date' ? placeholder || '选择日期' : '选择日期范围'"
|
|
73
73
|
start-placeholder="开始日期"
|
|
74
74
|
end-placeholder="结束日期"
|
|
75
|
+
:picker-options="datePickerOptions"
|
|
75
76
|
/>
|
|
76
77
|
<div
|
|
77
78
|
v-if="type === 'doubleDatePicker'"
|
|
@@ -84,7 +85,9 @@
|
|
|
84
85
|
value-format="yyyy-MM-dd"
|
|
85
86
|
format="yyyy-MM-dd"
|
|
86
87
|
type="date"
|
|
88
|
+
:editable="false"
|
|
87
89
|
:placeholder="(placeholder || [])[0] || '开始日期'"
|
|
90
|
+
:picker-options="doubleDatePickerStartOptions || genStartDateDisabledOptions(formData[prop[1]], doubleDatePickerLimit)"
|
|
88
91
|
/>
|
|
89
92
|
<el-date-picker
|
|
90
93
|
@input="val => handleInput(val, prop[1], '', key)"
|
|
@@ -93,7 +96,9 @@
|
|
|
93
96
|
value-format="yyyy-MM-dd"
|
|
94
97
|
format="yyyy-MM-dd"
|
|
95
98
|
type="date"
|
|
99
|
+
:editable="false"
|
|
96
100
|
:placeholder="(placeholder || [])[1] || '结束日期'"
|
|
101
|
+
:picker-options="doubleDatePickerEndOptions || genEndDateDisabledOptions(formData[prop[0]], doubleDatePickerLimit)"
|
|
97
102
|
/>
|
|
98
103
|
<el-checkbox
|
|
99
104
|
:value="checkedIds[key]"
|
|
@@ -124,6 +129,8 @@
|
|
|
124
129
|
</template>
|
|
125
130
|
|
|
126
131
|
<script>
|
|
132
|
+
import { genStartDateDisabledOptions, genEndDateDisabledOptions } from '../helper';
|
|
133
|
+
|
|
127
134
|
export default {
|
|
128
135
|
name: 'SearchForm',
|
|
129
136
|
props: {
|
|
@@ -187,6 +194,8 @@ export default {
|
|
|
187
194
|
this.initialData = Object.freeze({ ...this.formData })
|
|
188
195
|
},
|
|
189
196
|
methods: {
|
|
197
|
+
genStartDateDisabledOptions,
|
|
198
|
+
genEndDateDisabledOptions,
|
|
190
199
|
handleInput (val, prop, inputLimitCallback, key) {
|
|
191
200
|
if (inputLimitCallback && !inputLimitCallback(val)) return false
|
|
192
201
|
if (val) {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { DatePicker } from "element-ui/types/element-ui"
|
|
2
|
+
|
|
1
3
|
type BaseOption = {
|
|
2
4
|
label: string
|
|
3
5
|
prop: string
|
|
@@ -37,6 +39,7 @@ type SelectOption = BaseOption & {
|
|
|
37
39
|
type DatePickerOption = BaseOption & {
|
|
38
40
|
type: 'datePicker'
|
|
39
41
|
dateType?: string
|
|
42
|
+
datePickerOptions?: DatePicker['pickerOptions']
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
type BaseDoubleOption = Omit<BaseOption, 'prop'> & {
|
|
@@ -49,15 +52,25 @@ type DoubleInputOption = BaseDoubleOption & {
|
|
|
49
52
|
inputLimitCallback?: (value: string) => boolean
|
|
50
53
|
}
|
|
51
54
|
|
|
52
|
-
type
|
|
55
|
+
type DoubleDatePickerOptionBase = BaseDoubleOption & {
|
|
53
56
|
type: 'doubleDatePicker'
|
|
54
57
|
isEmpty?: boolean
|
|
55
58
|
}
|
|
56
59
|
|
|
60
|
+
type DoubleDatePickerOption = DoubleDatePickerOptionBase & {
|
|
61
|
+
doubleDatePickerStartOptions?: DatePicker['pickerOptions']
|
|
62
|
+
doubleDatePickerEndOptions?: DatePicker['pickerOptions']
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
type DoubleDatePickerOptionLimit = DoubleDatePickerOptionBase & {
|
|
66
|
+
doubleDatePickerLimit?: number
|
|
67
|
+
}
|
|
68
|
+
|
|
57
69
|
export type SearchFormConfigOption =
|
|
58
70
|
| InputOption
|
|
59
71
|
| SelectOption
|
|
60
72
|
| DatePickerOption
|
|
61
73
|
| DoubleInputOption
|
|
62
74
|
| DoubleDatePickerOption
|
|
75
|
+
| DoubleDatePickerOptionLimit
|
|
63
76
|
| SlotOption
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import dayjs from "dayjs";
|
|
2
|
+
|
|
3
|
+
/** 开始日期禁用配置 */
|
|
4
|
+
export function genStartDateDisabledOptions(endDate: string, limit: number = 0) {
|
|
5
|
+
return {
|
|
6
|
+
disabledDate: (time: Date) => {
|
|
7
|
+
if (!endDate) return false;
|
|
8
|
+
|
|
9
|
+
const currentDate = dayjs(time);
|
|
10
|
+
const baseOption = currentDate.isAfter(dayjs(endDate), 'day');
|
|
11
|
+
|
|
12
|
+
if (!limit) {
|
|
13
|
+
return baseOption
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return baseOption || currentDate.isBefore(dayjs(endDate).subtract(limit - 1, 'day'), 'day');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 结束日期禁用配置 */
|
|
22
|
+
export function genEndDateDisabledOptions(startDate: string, limit: number = 0) {
|
|
23
|
+
return {
|
|
24
|
+
disabledDate: (time: Date) => {
|
|
25
|
+
if (!startDate) return false;
|
|
26
|
+
|
|
27
|
+
const currentDate = dayjs(time);
|
|
28
|
+
const baseOption = currentDate.isBefore(dayjs(startDate), 'day');
|
|
29
|
+
|
|
30
|
+
if (!limit) {
|
|
31
|
+
return baseOption
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return baseOption || currentDate.isAfter(dayjs(startDate).add(limit - 1, 'day'), 'day');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|