SOURCE

console 命令行工具 X clear

                    
>
console
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>年月日季度日历多选demo</title>
    <link rel="stylesheet" type="text/css" href="//lib.baomitu.com/air-datepicker/2.2.3/css/datepicker.css"/>
    <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.12.1/jquery.js"></script>
    <script type="text/javascript" src="//lib.baomitu.com/air-datepicker/2.2.3/js/datepicker.min.js"></script>
    <script type="text/javascript" src="//lib.baomitu.com/air-datepicker/2.2.3/js/i18n/datepicker.zh.min.js"></script>
    <style>
        body{padding: 20px;}
        .demo-input{padding-left: 10px; height: 38px; min-width: 262px; line-height: 38px; border: 1px solid #e6e6e6;  background-color: #fff;  border-radius: 2px;text-overflow: ellipsis;}

        /* 季度样式修改 */
        .datepicker-cell-block{display: block; width: 100%; height: 40px; line-height:40px;text-align: center; margin: 2px 0;}
        .datepicker-cell-none{display: none;}
        .datepicker--cell.-in-range-{background-color: rgba(92,196,239,.3);}
        .datepicker--cell.-in-range-.-focus- { background-color: rgba(92,196,239,.5);}
  </style>
</head>
<body>

    日历区间 <input type="text" id="dayInterval" class="demo-input" placeholder="请选择日期" readonly="readonly">
    月份区间 <input type="text" id="monthInterval" class="demo-input" placeholder="请选择月份" readonly="readonly">
    年份区间 <input type="text" id="yearInterval" class="demo-input" placeholder="请选择年份" readonly="readonly">
    季度区间 <input type="text" id="quarterInterval" class="demo-input" placeholder="请选择季度" readonly="readonly">

<script>
    /* 日期区间选择 */
    $('#dayInterval').datepicker({
        clearButton:true,
        language:'zh',
        range:true,                     
        multipleDatesSeparator:'~',             
        onHide:function(inst, animationCompleted){
           
        }
    })

    /* 月份区间选择 */
    $('#monthInterval').datepicker({
        clearButton:true,
        language:'zh',
        view:'months',
        minView:'months',
        dateFormat:'yyyy-mm',
        range:true,                    
        multipleDatesSeparator:'~',             
        onHide:function(inst, animationCompleted){
           
        }
    })

    /* 年度区间选择 */
    $('#yearInterval').datepicker({
        clearButton:true,
        language:'zh',
        view:'years',
        minView:'years',
        dateFormat:'yyyy',
        range:true,                    
        multipleDatesSeparator:'~',             
        onHide:function(inst, animationCompleted){
           
        }
    })

    /* 季度计算 */
    var quarterFn = function(month){
    return month < 4 ? 1 :
        month < 7 ? 2 :
            month < 10 ? 3 : 4;
    }

    /* 季度区间选择 */
    $('#quarterInterval').datepicker({
        clearButton:true,
        language:'zh',
        view:'months',
        minView:'months',
        dateFormat:'yyyy-第m季度',
        range:true,                    
        multipleDatesSeparator:'~',             
        onHide:function(inst, animationCompleted){
           
        },
        onRenderCell:function(date,cellType){
            if(cellType == 'month'){
                if((date.getMonth()+1)%3 == 0) {
                    return {
                        html: '第'+quarterFn(date.getMonth() + 1)+'季度',
                        classes: 'datepicker-cell-block',
                    }
                }else{
                    return {
                        html: '第n季度',
                        classes: 'datepicker-cell-none',
                    }
                }
            }
        },
        onSelect:function(formattedDate, date, inst){

            var _val = ''
            $.each(inst.selectedDates,function(k,v){
                k === inst.selectedDates.length - 1 ?
                _val += v.getFullYear() + '-' + '第' + quarterFn(v.getMonth() + 1) + '季度' :
                _val += v.getFullYear() + '-' + '第' + quarterFn(v.getMonth() + 1) + '季度~';
            })
            inst.$el.val(_val)
        }
    })
</script>
</body>
</html>