wujingjing
2024-12-31 7357a3709ebeb22f28c17a21f103d0c715213b34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<template>
    <el-date-picker
        v-model="dateValue"
        type="daterange"
        :range-separator="RANGE_SEPARATOR"
        :start-placeholder="START_PLACEHOLDER"
        :end-placeholder="END_PLACEHOLDER"
        :shortcuts="SHORTCUTS"
        :value-format="valueFormat"
        :disabled-date="disabledDate"
    >
        <template v-for="(value, name) in $slots" #[name]="slotData">
            <slot :name="name" v-bind="slotData || {}"></slot>
        </template>
    </el-date-picker>
</template>
 
<script setup lang="ts">
import { ElDatePicker } from 'element-plus';
import { definePropType } from 'element-plus/es/utils/vue/props/runtime';
import { CURRENT_DAY, DEFAULT_FORMATS_DATE, END_PLACEHOLDER, RANGE_SEPARATOR, SHORTCUTS, START_PLACEHOLDER } from './constants';
 
const props = defineProps({
    valueFormat: {
        type: String,
        default: DEFAULT_FORMATS_DATE,
    },
});
 
const dateValue = defineModel({
    type: definePropType<[string, string]>(Array),
});
 
const disabledDate = (date: Date) => {
    return date > CURRENT_DAY;
};
</script>
<style scoped lang="scss"></style>