<template>
    <div class="v-f9-date-input" v-show="date_show">
        <div class="v-f9-date-input-top">
            <div @click="forward">&lt;&lt;</div>
            <div @click="toggleMode(title)" class="v-f9-date-input-top-now">{{title}}</div>
            <div @click="backward">&gt;&gt;</div>
        </div>
        <div :class="panel_body_class">
            <div v-for="(item, index) in time" :class="panelClass" :key="index">
                <span :index="index+1"
                      @click="clickSpan(item,$event)"
                      :class="[activeSpan(index,item),disabledSpan(index,item)]"
                >{{formatDate(item)}}</span>
            </div>
        </div>
    </div>
</template>
<script>

import minxins from './mixins.js';

export default{
    mixins:[minxins],
    data(){
        return {
            mode: 0,//月模式0，年模式1，日模式 2,时模式 3,分模式 4,秒模式 5
            time: [],//日期面板展示的数据
            month: ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],//月份数据
            title: "",//日期面板的标题
            month_now: "",//当前选中的日期月
            year_now: "",//当前选中的日期年
            day_now:"",//当前选中的日期天
            hour_now:"",//当前选中的日期小时
            minute_now:"",//当前选中的日期分钟
            second_now:"",//当前选中日期秒
            years_start:"",//日期面板展示日期范围的开始年份
            years_end: "",//日期面板展示日期范围的结束年份
            panelClass: "em-dateSelect-div-month"//日期面板的样式
        }
    },
    computed:{
        //面板的样式
        panel_body_class(){

            let className;

            if(this.mode<=3){

                className='v-f9-date-input-year-body';

            }
            else{

                className='v-f9-date-input-hour-body';

            }

            return className;

        }
    },

    props: {
        date_show: [Boolean],//是否展示日期面板
        //日期格式的模式( 0:年月日(YYYY-MM-DD), 1:年月(YYYY-MM), 2:年(YYYY),3:年月日 时(YYYY-MM-DD HH),4:年月日 时:分(YYYY-MM-DD HH:mm),5:年月日 时:分:秒(YYYY-MM-DD HH:mm:ss),6:时(HH),7:时:分(HH:mm),8:时:分:秒(HH:mm:ss) )
        em_date_mode: {
            type: Number,
            default: 2
        },
    },
    methods: {

        //日期面板选中项的样式
        activeSpan(index,item){

            let value;//日期框的类型值(日期年,日期月,日期天,日期时,日期分,日期秒)
            let currentValue;//当前选择的日期的类型值(日期年,日期月,日期天)
            let activeClass='';//日期项选中时的样式类名称
            let maxDateInfo;//最大日期
            let minDateInfo;//最小日期
            let maxDateInstance=this.maxDate? this.getDateObject(new Date(this.getWholeDate(this.maxDate))):null;//最大可选日期实例
            let minDateInstance=this.minDate?this.getDateObject(new Date(this.getWholeDate(this.minDate))):null;//最小可选日期实例
            let isValidDate=true;
            //选择的日期
            let selectedDate={
                year:this.year_now,//年
                month:this.month_now,//月
                day:this.day_now,//日
                hour:this.hour_now,//时
                minute:this.hour_now,//分
                second:this.second_now//秒
            };
            let currentDateInfo;//当前选择的日期


            switch(this.mode){
                
                //日期月
                case 0:

                    currentValue=index+1;
                    value=Number(this.month_now);
                    selectedDate.month=this.getFormatDate(currentValue);

                break;

                //日期年
                case 1:

                    currentValue=Number(item);
                    value=Number(this.year_now);
                    selectedDate.year=this.getFormatDate(currentValue);

                break;

                //日期天
                case 2:

                    currentValue=Number(item);
                    value=Number(this.day_now);
                    selectedDate.day=this.getFormatDate(currentValue);

                break;

                //日期时
                case 3:

                    currentValue=index;
                    value=Number(this.hour_now);
                    selectedDate.hour=this.getFormatDate(currentValue);

                break;
                //日期分
                case 4:

                    currentValue=index;
                    value=Number(this.minute_now);
                    selectedDate.minute=this.getFormatDate(currentValue);

                break;
                //日期秒
                case 5:

                    currentValue=index;
                    value=Number(this.second_now);
                    selectedDate.second=this.getFormatDate(currentValue);

                break;

            }

            currentDateInfo=this.getDateInstance(selectedDate);

            if( value== currentValue ){

                if(maxDateInstance){
                    maxDateInfo=this.getDateInstance(maxDateInstance);
                }
                if(minDateInstance){
                    minDateInfo=this.getDateInstance(minDateInstance);
                }

                if(maxDateInfo && currentDateInfo>maxDateInfo){

                    isValidDate=false;

                }

                if(minDateInfo && currentDateInfo<minDateInfo){

                    isValidDate=false;

                }

                if(isValidDate){

                    activeClass='activeDate';

                }

            }

            return activeClass;

        },

        //日期禁用的样式
        disabledSpan(index,item){

            let currentValue;//当前选择的日期的类型值(日期年,日期月,日期天)
            let maxDateInfo;//最大日期
            let minDateInfo;//最小日期
            let disabledClass='';//日期项禁用的样式类名称
            let maxDateInstance=this.maxDate? this.getDateObject(new Date(this.getWholeDate(this.maxDate))):null;//最大可选日期实例
            let minDateInstance=this.minDate?this.getDateObject(new Date(this.getWholeDate(this.minDate))):null;//最小可选日期实例
            let isInValidDate=false;
            //选择的日期
            let selectedDate={
                year:this.year_now,//年
                month:this.month_now,//月
                day:this.day_now,//日
                hour:this.hour_now,//时
                minute:this.minute_now,//分
                second:this.second_now//秒
            };
            let currentDateInfo;//当前选择的日期

            switch(this.mode){
                
                //日期月
                case 0:

                    currentValue=index+1;
                    selectedDate.month=this.getFormatDate(currentValue);

                break;

                //日期年
                case 1:

                    currentValue=Number(item);
                    selectedDate.year=this.getFormatDate(currentValue);

                break;

                //日期天
                case 2:

                    currentValue=Number(item);
                    selectedDate.day=this.getFormatDate(currentValue);

                break;

                //日期时
                case 3:

                    currentValue=index;
                    selectedDate.hour=this.getFormatDate(currentValue);

                break;
                //日期分
                case 4:

                    currentValue=index;
                    selectedDate.minute=this.getFormatDate(currentValue);

                break;
                //日期秒
                case 5:

                    currentValue=index;
                    selectedDate.second=this.getFormatDate(currentValue);

                break;

            }
            
            currentDateInfo=this.getDateInstance(selectedDate);

            if(maxDateInstance){
                maxDateInfo=this.getDateInstance(maxDateInstance);
            }
            if(minDateInstance){
                minDateInfo=this.getDateInstance(minDateInstance);
            }
            

            if(maxDateInfo && currentDateInfo>maxDateInfo){

                isInValidDate=true;

            }

            if(minDateInfo && currentDateInfo<minDateInfo){

                isInValidDate=true;

            }


            if(isInValidDate){

                disabledClass='v-f9-date-input-span-disable';

            }

            return disabledClass;

        },
        //切换模式
        toggleMode(){


            switch(this.mode){

                //当前是月模式
                case 0:

                    this.mode = 1;//年模式
                    var num = this.year_now.toString().substring(0,3);//月转年
                    var yearList = [];//年数据的集合

                    //生成年份日期面板数据
                    for (var i = 0; i < 10; i++) {
                        yearList.push(num + i);
                    }
                    this.time = yearList;

                break;

                //当前是日模式
                case 2:

                    this.mode = 0;//日模式转换为月模式
                    this.panelClass = "v-f9-date-input-div-month";
                    this.time = this.month;

                break;

                //当前是时模式
                case 3:

                    if(this.em_date_mode>5){
                        
                        return false;

                    }

                    this.mode = 2;//时模式转换为日模式
                    this.panelClass = "v-f9-date-input-div-day";
                    this.calculateDays();

                break;

                //当前是分模式
                case 4:

                    this.mode = 3;//分模式转换为时模式
                    this.panelClass = "v-f9-date-input-div-hour";
                    this.calculateHour();

                break;

                //当前是秒模式
                case 5:

                    this.mode = 4;//秒模式转换为分模式
                    this.calculateMiniteOrSecond();

                break;

            }

            this.getSelectedDateTitle();

        },
        //向前生成日期
        forward(){

            let currentSeletedDate;//当前选择的日期
            let minDateInstance= this.minDate? this.getDateObject(new Date(this.getWholeDate(this.minDate))):null;//最大可选日期实例
            let minDateInfo;
            if(minDateInstance){
                minDateInfo=this.getDateInstance(minDateInstance);
            }

            switch(this.mode){

                //当前是年模式
                case 1:

                    currentSeletedDate=this.getDateInstance({year:this.years_start});//日期面板的结束日期

                    if(minDateInfo && currentSeletedDate<=minDateInfo){

                        return false;

                    }

                    let yearList = [];//面板日期数据
                    this.years_start -= 10;//日期面板开始日期向前推10年
                    this.years_end -= 10;//日期面板结束日期向前推10年

                    //生成年份日期数据
                    for (var i = 0; i < 10; i++) {
                        yearList.push(this.years_start + i);
                    }

                    this.time = yearList;

                break;

                //当前是月模式
                case 0:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now});//日期面板的结束日期

                    if(minDateInfo && (currentSeletedDate>=minDateInfo || currentSeletedDate<minDateInfo) && minDateInstance.year==this.year_now){

                        return false;

                    }

                    this.year_now -= 1;

                break;

                //当前是日模式
                case 2:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now});//日期面板的结束日期

                    if(minDateInfo && (currentSeletedDate>=minDateInfo || currentSeletedDate<minDateInfo) && minDateInstance.year==this.year_now && minDateInstance.month==this.month_now){

                        return false;

                    }

                    if (this.month_now > 1) {

                        this.month_now -= 1;

                    } 
                    else
                    {

                        this.year_now -= 1
                        this.month_now = 12;

                    }

                    this.calculateDays();

                break;

                //当前是时模式
                case 3:

                    if(this.em_date_mode>5){
                        
                        return false;

                    }

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now,hour:this.hour_now});//日期面板的结束日期

                    if(minDateInfo && (currentSeletedDate>=minDateInfo || currentSeletedDate<minDateInfo) && minDateInstance.year==this.year_now && minDateInstance.month==this.month_now && minDateInstance.day==this.day_now){

                        return false;

                    }

                    if (this.day_now > 1) {

                        this.day_now -= 1;

                    } 
                    else
                    {

                        if(this.month_now>1){

                            this.month_now -= 1;

                        }
                        else{

                            this.year_now-=1;
                            this.month_now=12;

                        }
                        

                        let month = this.month_now;//当前选择的月
                        let year = this.year_now;//当前选择的年
                        let days;//当前月的天数
                        days = new Date(year, month, 0).getDate();//获取当前月的最大天数
                        this.day_now = days;

                    }

                    this.calculateHour();

                break;
                //当前是分模式
                case 4:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now,hour:this.hour_now,minute:this.minute_now});//日期面板的结束日期

                    if(minDateInfo && (currentSeletedDate>=minDateInfo || currentSeletedDate<minDateInfo) && minDateInstance.year==this.year_now && minDateInstance.month==this.month_now && minDateInstance.day==this.day_now && minDateInstance.hour==this.hour_now){

                        return false;

                    }

                    if (this.hour_now > 0) {

                        this.hour_now -= 1;
                        this.calculateMiniteOrSecond();

                    } 
                    else
                    {

                        this.hour_now=23;

                        if(this.em_date_mode<=5){
                        
                            if(this.day_now>1){

                                this.day_now-=1;

                            }
                            else{

                                if(this.month_now>1){

                                    this.month_now -= 1;

                                }
                                else{

                                    this.year_now-=1;
                                    this.month_now=12;

                                }

                                let month = this.month_now;//当前选择的月
                                let year = this.year_now;//当前选择的年
                                let days;//当前月的天数
                                days = new Date(year, month, 0).getDate();//获取当前月的最大天数
                                this.day_now = days;

                            }

                        }

                    }

                    this.calculateMiniteOrSecond();

                break;
                //当前是秒模式
                case 5:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now,hour:this.hour_now,minute:this.minute_now,second:this.second_now});//日期面板的结束日期

                    if(minDateInfo && (currentSeletedDate>=minDateInfo || currentSeletedDate<minDateInfo) && minDateInstance.year==this.year_now && minDateInstance.month==this.month_now && minDateInstance.day==this.day_now && minDateInstance.hour==this.hour_now && minDateInstance.minute==this.minute_now){

                        return false;

                    }

                    if (this.minute_now > 0) {

                        this.minute_now -= 1;
                        this.calculateMiniteOrSecond();

                    } 
                    else
                    {

                        this.minute_now=59;

                        if(this.em_date_mode<=5){

                            if(this.hour_now>0){

                                this.hour_now-=1;

                            }
                            else{

                                this.hour_now=23;

                                if(this.day_now>1){

                                    this.day_now-=1;

                                }
                                else{

                                    if(this.month_now>1){

                                        this.month_now -= 1;

                                    }
                                    else{

                                        this.year_now-=1;
                                        this.month_now=12;

                                    }

                                    let month = this.month_now;//当前选择的月
                                    let year = this.year_now;//当前选择的年
                                    let days;//当前月的天数
                                    days = new Date(year, month, 0).getDate();//获取当前月的最大天数
                                    this.day_now = days;

                                }

                            }

                        }
                        else{

                            if(this.hour_now>0){

                                this.hour_now-=1;

                            }
                            else{

                                this.hour_now=23;

                            }
                            
                        }


                    }

                    this.calculateMiniteOrSecond();

                break;

            }

            this.getSelectedDateTitle();

        },
        //向后生成日期
        backward(){

            let month = this.month_now;//当前选择的月
            let year = this.year_now;//当前选择的年
            let days;//当前月的天数
            days = new Date(year, month, 0).getDate();//获取当前月的最大天数
            let currentSeletedDate;//当前选择的日期
            let maxDateInstance= this.maxDate? this.getDateObject(new Date(this.getWholeDate(this.maxDate))):null;//最大可选日期实例
            let maxDateInfo;
            if(maxDateInstance){
                maxDateInfo=this.getDateInstance(maxDateInstance);
            }

            switch(this.mode){

                //当前是年模式
                case 1:

                    currentSeletedDate=this.getDateInstance({year:this.years_end});//日期面板的结束日期

                    if(maxDateInfo && currentSeletedDate>=maxDateInfo){

                        return false;

                    }

                    let yearList = [];//面板日期数据
                    this.years_start = Number(this.years_start) + 10;//日期面板开始日期向后推10年
                    this.years_end = Number(this.years_end) + 10;//日期面板结束日期向后推10年

                    //生成年份日期数据
                    for (var i = 0; i < 10; i++) {
                        yearList.push(this.years_start + i);
                    }

                    this.time = yearList;

                break;

                //当前是月模式
                case 0:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now});//日期面板的结束日期

                    if(maxDateInfo && (currentSeletedDate<=maxDateInfo || currentSeletedDate>maxDateInfo) && maxDateInstance.year==this.year_now){

                        return false;

                    }

                    this.year_now +=1;

                break;

                //当前是日模式
                case 2:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now});//日期面板的结束日期

                    if(maxDateInfo && (currentSeletedDate<=maxDateInfo || currentSeletedDate>maxDateInfo) && maxDateInstance.year==this.year_now && maxDateInstance.month==this.month_now){

                        return false;

                    }

                    if (this.month_now < 12) {

                        this.month_now += 1;

                    } 
                    else 
                    {

                        this.year_now+= 1;
                        this.month_now = 1;

                    }

                    this.calculateDays();

                break;

                //当前是时模式
                case 3:

                    if(this.em_date_mode>5){
                        
                        return false;

                    }

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now,hour:this.hour_now});//日期面板的结束日期

                    if(maxDateInfo && (currentSeletedDate<=maxDateInfo || currentSeletedDate>maxDateInfo) && maxDateInstance.year==this.year_now && maxDateInstance.month==this.month_now && maxDateInstance.day==this.day_now){

                        return false;

                    }

                    if (this.day_now <days) {

                        this.day_now += 1;

                    } 
                    else
                    {

                        if(this.month_now<12){

                            this.month_now += 1;

                        }
                        else{

                            this.year_now+=1;
                            this.month_now=1;

                        }
                        
                        
                        this.day_now = 1;

                    }

                    this.calculateHour();

                break;
                //当前是分模式
                case 4:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now,hour:this.hour_now,minute:this.minute_now});//日期面板的结束日期

                    if(maxDateInfo && (currentSeletedDate<=maxDateInfo || currentSeletedDate>maxDateInfo) && maxDateInstance.year==this.year_now && maxDateInstance.month==this.month_now && maxDateInstance.day==this.day_now && maxDateInstance.hour==this.hour_now){

                        return false;

                    }

                    if (this.hour_now < 23) {

                        this.hour_now += 1;

                    } 
                    else
                    {

                        this.hour_now=0;

                        if(this.em_date_mode<=5){
                        
                            if(this.day_now<days){

                                this.day_now+=1;

                            }
                            else{

                                if(this.month_now<12){

                                    this.month_now += 1;

                                }
                                else{

                                    this.year_now+=1;
                                    this.month_now=1;

                                }

                                this.day_now = 1;

                            }

                        }

                    }

                    this.calculateMiniteOrSecond();

                break;
                //当前是秒模式
                case 5:

                    currentSeletedDate=this.getDateInstance({year:this.year_now,month:this.month_now,day:this.day_now,hour:this.hour_now,minute:this.minute_now,second:this.second_now});//日期面板的结束日期

                    if(maxDateInfo && (currentSeletedDate<=maxDateInfo || currentSeletedDate>maxDateInfo) && maxDateInstance.year==this.year_now && maxDateInstance.month==this.month_now && maxDateInstance.day==this.day_now && maxDateInstance.hour==this.hour_now && maxDateInstance.minute==this.minute_now){

                        return false;

                    }

                    if (this.minute_now <59) {

                        this.minute_now += 1;

                    } 
                    else
                    {

                        this.minute_now=0;

                        if(this.em_date_mode<=5){
                        
                            if(this.hour_now<23){

                                this.hour_now+=1;

                            }
                            else{

                                this.hour_now=0;

                                if(this.day_now<days){

                                    this.day_now+=1;

                                }
                                else{

                                    if(this.month_now<12){

                                        this.month_now += 1;

                                    }
                                    else{

                                        this.year_now+=1;
                                        this.month_now=1;

                                    }

                                    this.day_now = 1;

                                }

                            }

                        }
                        else{

                            if(this.hour_now<23){

                                this.hour_now+=1;

                            }
                            else{

                                this.hour_now=0;

                            }

                        }


                    }

                    this.calculateMiniteOrSecond();

                break;

            }

            this.getSelectedDateTitle();

        },
        //选中日期面板项
        clickSpan(item, event){

            let isCanUse=event.target.className.indexOf('v-f9-date-input-span-disable')<0;//当前点击的日期项是否禁用

            //事件
            let events={
                //年份选择
                yearSelect:(item, event)=>{

                    this.year_now =Number(item);
                    this.$emit('dateChange', this.year_now.toString());
                    this.$props.date_show = false;

                },
                //年月选择
                yearMonthSelect:(item, event)=>{

                    if (this.mode == 0) {

                        this.month_now =Number(event.srcElement.getAttribute("index"));
                        this.$emit('dateChange', `${this.year_now.toString()}-${this.getFormatDate(this.month_now)}`);
                        this.$props.date_show = false;

                    } 
                    else 
                    {

                        this.mode = 0;
                        this.time = this.month;
                        this.year_now = Number(item);

                    }

                },
                //年月日选择
                yearMonthDaySelect:(item, event)=>{

                    if (this.mode == 2) {

                        this.$emit('dateChange',`${this.year_now.toString()}-${this.getFormatDate(this.month_now)}-${this.getFormatDate(item)}`);
                        this.$props.date_show = false;
                        this.mode = 1;

                    } 
                    else if (this.mode == 0) 
                    {

                        this.mode = 2;
                        this.panelClass = "v-f9-date-input-div-day";
                        this.month_now =Number(event.srcElement.getAttribute("index"));
                        this.calculateDays();

                    } 
                    else {

                        this.mode = 0;
                        this.time = this.month;
                        this.year_now = Number(item);

                    }

                },
                //年月日 时选择
                yearMonthDayHourSelect:(item, event)=>{

                    if(this.mode == 3){

                        this.$emit('dateChange',`${this.year_now.toString()}-${this.getFormatDate(this.month_now)}-${this.getFormatDate(this.day_now)} ${this.getFormatDate(item)}`);
                        this.$props.date_show = false;
                        this.mode = 1;

                    }
                    else if (this.mode == 2) {

                        this.mode = 3;
                        this.day_now=Number(item);
                        this.calculateHour();//计算小时的数据

                    } 
                    else if (this.mode == 0) 
                    {

                        this.mode = 2;
                        this.panelClass = "v-f9-date-input-div-day";
                        this.month_now = Number(event.srcElement.getAttribute("index"));
                        this.calculateDays();

                    } 
                    else {

                        this.mode = 0;
                        this.time = this.month;
                        this.year_now = Number(item);

                    }

                },
                //年月日 时:分选择
                yearMonthDayHourMinuteSelect:(item, event)=>{


                    if(this.mode == 4){

                        this.$emit('dateChange',`${this.year_now.toString()}-${this.getFormatDate(this.month_now)}-${this.getFormatDate(this.day_now)} ${this.getFormatDate(this.hour_now)}:${this.getFormatDate(item)}`);
                        this.$props.date_show = false;
                        this.mode = 1;

                    }
                    else if(this.mode == 3){

                        this.mode = 4;
                        this.hour_now=Number(item);
                        this.panelClass = "v-f9-date-input-div-hour";
                        this.calculateMiniteOrSecond();//计算分钟的数据

                    }
                    else if (this.mode == 2) {

                        this.mode = 3;
                        this.day_now=Number(item);
                        this.calculateHour();//计算小时的数据

                    } 
                    else if (this.mode == 0) 
                    {

                        this.mode = 2;
                        this.panelClass = "v-f9-date-input-div-day";
                        this.month_now = Number(event.srcElement.getAttribute("index"));
                        this.calculateDays();

                    } 
                    else {

                        this.mode = 0;
                        this.time = this.month;
                        this.year_now = Number(item);

                    }

                },
                //年月日 时:分:秒选择
                yearMonthDayHourMinuteSecondSelect:(item, event)=>{

                    if(this.mode == 5){

                        this.$emit('dateChange',`${this.year_now.toString()}-${this.getFormatDate(this.month_now)}-${this.getFormatDate(this.day_now)} ${this.getFormatDate(this.hour_now)}:${this.getFormatDate(this.minute_now)}:${this.getFormatDate(item)}`);
                        this.$props.date_show = false;
                        this.mode = 1;

                    }
                    else if(this.mode == 4){

                        this.mode = 5;
                        this.minute_now=Number(item);
                        this.calculateMiniteOrSecond();//计算秒钟的数据

                    }
                    else if(this.mode == 3){

                        this.mode = 4;
                        this.hour_now=Number(item);
                        this.panelClass = "v-f9-date-input-div-hour";
                        this.calculateMiniteOrSecond();//计算分钟的数据

                    }
                    else if (this.mode == 2) {

                        this.mode = 3;
                        this.day_now=Number(item);
                        this.calculateHour();//计算小时的数据

                    } 
                    else if (this.mode == 0) 
                    {

                        this.mode = 2;
                        this.panelClass = "v-f9-date-input-div-day";
                        this.month_now =Number(event.srcElement.getAttribute("index"));
                        this.calculateDays();

                    } 
                    else {

                        this.mode = 0;
                        this.time = this.month;
                        this.year_now = Number(item);

                    }

                },
                //时选择
                hourSelect:(item, event)=>{

                    this.$emit('dateChange',`${this.getFormatDate(item)}`);
                    this.$props.date_show = false;

                },
                //时分选择
                hourMinuteSelect:(item, event)=>{
                    
                    if(this.mode==4){

                        this.$emit('dateChange',`${this.getFormatDate(this.hour_now)}:${this.getFormatDate(item)}`);
                        this.$props.date_show = false;
                        this.mode = 3;

                    }
                    else if(this.mode==3){

                        this.mode = 4;
                        this.hour_now=Number(item);
                        this.calculateMiniteOrSecond();//计算小时,分钟,秒钟的数据

                    }

                },
                //时分秒选择
                hourMinuteSecondSelect:(item, event)=>{
                    
                    if(this.mode==5){

                        this.$emit('dateChange',`${this.getFormatDate(this.hour_now)}:${this.getFormatDate(this.minute_now)}:${this.getFormatDate(item)}`);
                        this.$props.date_show = false;
                        this.mode = 3;

                    }
                    else if(this.mode==4){

                        this.mode = 5;
                        this.minute_now=Number(item);
                        this.calculateMiniteOrSecond();//计算小时,分钟,秒钟的数据

                    }
                    else if(this.mode==3){

                        this.mode = 4;
                        this.hour_now=Number(item);
                        this.calculateMiniteOrSecond();//计算小时,分钟,秒钟的数据

                    }

                }
            };

            if(isCanUse){

                let dic={
                    0:events.yearMonthDaySelect,//年月日
                    1:events.yearMonthSelect,//年月
                    2:events.yearSelect,//年
                    3:events.yearMonthDayHourSelect,//年月日 时
                    4:events.yearMonthDayHourMinuteSelect,//年月日 时:分
                    5:events.yearMonthDayHourMinuteSecondSelect,//年月日 时:分:秒
                    6:events.hourSelect,//时
                    7:events.hourMinuteSelect,//时:分
                    8:events.hourMinuteSecondSelect//时:分:秒
                };

                dic[this.em_date_mode](item, event);
                this.getSelectedDateTitle();

            }
        },
        //计算每月天数
        calculateDays(){

            let month = this.month_now;//当前选择的月
            let year = this.year_now;//当前选择的年
            let days;//当前月的天数
            days = new Date(year, month, 0).getDate();//获取当前月的最大天数
            this.time = days;//日期面板展示的数据集合

        },
        //计算分,秒的数据
        calculateMiniteOrSecond(){

            let data=[];

            for(let i=0;i<60;i++){

                data.push(i);

            }

            this.time = data;//日期面板展示的数据集合

        },
        //计算时的数据
        calculateHour(){

            let data=[];

            for(let i=0;i<24;i++){

                data.push(i);

            }

            this.time = data;//日期面板展示的数据集合

        }
    }
}

</script>
