<template>
    <div id="cptDate">
        <el-date-picker v-model="date" :type="type"
                        :value-format="valueFormat||type.includes('time')?'yyyy-MM-dd HH:mm:ss':'yyyy-MM-dd'" placeholder="请选择"
                        :pickerOptions="{disabledDate:disabledDate}"></el-date-picker>
    </div>

</template>

<script>

export default {
    name: "enoDate",
    data () {
        return {
            date:'',
        }
    },
    components: {  },
    props:{
        type:String,
        valueFormat:String,
        disabledDateType:String,
        upperLimitDate:String,
        lowerLimitDate:String,
    },
    mounted () {

    },

    methods: {


        /*日期范围*/
        disabledDate: function (time) {
            /*time 默认时间是00：00：00  new Date()默认的时间是 08：00：00*/
            let today = new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate();

            if(this.upperLimitDate){
                return  time.getTime() > new Date(this.upperLimitDate).getTime()||time.getTime()===new Date(this.upperLimitDate).getTime();
            }

            if(this.lowerLimitDate){
                return  time.getTime() < new Date(this.lowerLimitDate).getTime();
            }

            switch(this.disabledDateType){
                case 'lt':
                    return time.getTime() > new Date(today).getTime();
                case 'gt':
                    return time.getTime() < new Date(today).getTime();

            }


        },
    }
}
</script>

<style scoped>
</style>