简单的layui laydate时间控件的最大值最小值

function renderDate(option) {
    var nowTime = new Date().getTime();
    var start = layui.laydate.render({
        elem: option.startEle,
        type: option.type,
        format: 'yyyyMMdd',
        max: nowTime,
        done: function (value, date) {
            end.config.min.year = date.year;
            end.config.min.month = date.month - 1;
            end.config.min.date = date.date + 1;
        }
    });
    var end = layui.laydate.render({
        elem: option.endEle,
        type: option.type,
        format: 'yyyyMMdd',
        max: nowTime,
        done: function (value, date) {
            start.config.max.year = date.year;
            start.config.max.month = date.month - 1;
            start.config.max.date = date.date - 1;
        }
    });

    return {
        reset: function () {
            start.config.max.year = new Date().getFullYear();
            start.config.max.month = new Date().getMonth();
            start.config.max.date = new Date().getDate();
            end.config.max.year = new Date().getFullYear();
            end.config.max.month = new Date().getMonth();
            end.config.max.date = new Date().getDate();

            start.config.min.year = '';
            start.config.min.month = '';
            start.config.min.date = '';
            end.config.min.year = '';
            end.config.min.month = '';
            end.config.min.date = '';
        }
    }
}

var callObj = renderDate({
        startEle: '#startDate',
        endEle: '#endDate',
        type: 'date',
    })

    $('#reset').click(function () {
        callObj.reset();
    })

 

posted on 2019-04-18 09:42  slfGJ  阅读(948)  评论(0编辑  收藏  举报

导航