<input type="text" class="layui-input" readonly="readonly" autocomplete="off" id="test1" placeholder="请选择开始日期"><em style="float:left;margin:0 10px;margin-top:5px;">-</em>
<input type="text" class="layui-input" readonly="readonly" autocomplete="off" id="test2" placeholder="请选择结束日期">
//日期范围
function Appendzero(obj)
{
if(obj<10)return "0" +""+ obj;
else return obj;
}
var minData,minDay,startDay ='',endDay ='';
laydate.render({//日期
elem:'#test1' ,//指定元素
btns: ['clear','confirm'],
trigger:'click',
done:function(value, date, endDate){
startDay = value;
if(endDay !=undefined){
var start =new Date(startDay.replace("-","/").replace("-","/"));
var end =new Date(endDay.replace("-","/").replace("-","/"));
if (end
$("#test1").val("");
layer.msg('結束日期不能小于开始日期!');
return false;
}
}
vm.q.startTime =startDay;
}
});
//第一种 单独引用laydata
function adyAge(minData,even,init_date){
layui.use(['jquery','layer'],function(){
var $ =layui.$;//jq
var layer =layui.layer;//加载layer
lay(even).each(function(){
laydate.render({
elem:'#test2'
,min: minData
,show:init_date//默认显示
// ,trigger: 'click'
,btns: ['clear','confirm']
,done:function(value, date, endDate){
vm.q.endTime = value;
},
});
});
});
}
//第二种方法 没单独引用laydata
function adyAge(minData,even,init_date){
layui.use(['jquery','laydate','layer'], function(){
var $ = layui.$; //jq
var layer = layui.layer; //加载layer
var laydate = layui.laydate;
var _number = 0,_number1 = 1;
var date = new Date(minData);
if(_typeInsurance == 60){
date.setDate(date.getDate() + 60);
}else{
date.setDate(date.getDate() + 182);
}
var minDay = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + addZero(date.getDate()-1);
lay(even).each(function(){
laydate.render({
elem: '#test2'
,min: minData
,max: minDay
,show:init_date//默认显示
// ,trigger: 'click'
,btns: ['clear', 'confirm']
,done: function(value, date, endDate){
},
});
});
});
return false;
};
$('.grid-btn > div').on('click','#test2',function(){
var _this =this;
if(vm.q.startTime ==''){
layer.msg('请先选择开始日期!');
return false;
}
adyAge(startDay,this,true);
});
网友评论