1.公共的Scheduler界面增加开始时间和结束时间之差不能小于1分钟的校验
2.公共的Scheduler界面单次选项中的开始时间加上不能小于当前时间加上2分钟的校验
This commit is contained in:
@@ -16,8 +16,36 @@
|
||||
$(function(){
|
||||
//获取国际化文件
|
||||
var title=$.validator.messages.compareDate;
|
||||
var diff=$.validator.messages.expireTip;
|
||||
var tip=$.validator.messages.compareTip;
|
||||
var date="2019-03-25 ";
|
||||
//day 时间验证
|
||||
//one 开始时间不能小于当前时间加上2分钟 验证
|
||||
jQuery.validator.addMethod("oneStartDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var singleValid = $("#singleValid").val();
|
||||
if(singleValid !=null && singleValid !=""){
|
||||
var date =new Date();
|
||||
var min=date.getMinutes();
|
||||
date.setMinutes(min+2);
|
||||
if(date <= (new Date(singleValid.replace(/-/g,"\/")))){
|
||||
flagTypeSame=true;
|
||||
}else{
|
||||
flagTypeSame=false;
|
||||
}
|
||||
}
|
||||
return flagTypeSame;
|
||||
},tip);
|
||||
//one 结束时间不能小于开始时间验证
|
||||
jQuery.validator.addMethod("oneDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var singleValid = $("#singleValid").val();
|
||||
var singleInvalid = $("#singleInvalid").val();
|
||||
if(singleValid !=null && singleValid !="" && singleInvalid !=null && singleInvalid !=""){
|
||||
flagTypeSame=CompareDate(singleValid,singleInvalid);
|
||||
}
|
||||
return flagTypeSame;
|
||||
},title);
|
||||
//day 结束时间不能小于开始时间验证
|
||||
jQuery.validator.addMethod("dayDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var dayValid = $("#dayValid").val();
|
||||
@@ -27,7 +55,7 @@
|
||||
}
|
||||
return flagTypeSame;
|
||||
},title);
|
||||
//week 时间验证
|
||||
//week 结束时间不能小于开始时间验证
|
||||
jQuery.validator.addMethod("weekDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var weekValid = $("#weekValid").val();
|
||||
@@ -37,7 +65,7 @@
|
||||
}
|
||||
return flagTypeSame;
|
||||
},title);
|
||||
//month 时间验证
|
||||
//month 结束时间不能小于开始时间验证
|
||||
jQuery.validator.addMethod("monthDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var monthValid = $("#monthValid").val();
|
||||
@@ -47,11 +75,61 @@
|
||||
}
|
||||
return flagTypeSame;
|
||||
},title);
|
||||
|
||||
//一次 验证时间差
|
||||
jQuery.validator.addMethod("oneDiffDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var singleValid = $("#singleValid").val();
|
||||
var singleInvalid = $("#singleInvalid").val();
|
||||
if(singleValid !=null && singleValid !="" && singleInvalid !=null && singleInvalid !=""){
|
||||
flagTypeSame=timeToDiffer(singleValid,singleInvalid);
|
||||
}
|
||||
return flagTypeSame;
|
||||
},diff);
|
||||
//day 验证时间差
|
||||
jQuery.validator.addMethod("dayDiffDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var dayValid = $("#dayValid").val();
|
||||
var dayInvalid = $("#dayInvalid").val();
|
||||
if(dayValid !=null && dayValid !="" && dayInvalid !=null && dayInvalid !=""){
|
||||
flagTypeSame=timeToDiffer(date+dayValid,date+dayInvalid);
|
||||
}
|
||||
return flagTypeSame;
|
||||
},diff);
|
||||
//week 验证时间差
|
||||
jQuery.validator.addMethod("weekDiffDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var weekValid = $("#weekValid").val();
|
||||
var weekInvalid = $("#weekInvalid").val();
|
||||
if(weekValid !=null && weekValid !="" && weekInvalid !=null && weekInvalid !=""){
|
||||
flagTypeSame=timeToDiffer(date+weekValid,date+weekInvalid);
|
||||
}
|
||||
return flagTypeSame;
|
||||
},diff);
|
||||
//month 验证时间差
|
||||
jQuery.validator.addMethod("monthDiffDate",function(value,element){
|
||||
var flagTypeSame=true;
|
||||
var monthValid = $("#monthValid").val();
|
||||
var monthInvalid = $("#monthInvalid").val();
|
||||
if(monthValid !=null && monthValid !="" && monthInvalid !=null && monthInvalid !=""){
|
||||
flagTypeSame=timeToDiffer(date+monthValid,date+monthInvalid);
|
||||
}
|
||||
return flagTypeSame;
|
||||
},diff);
|
||||
//比较两个时间的大小
|
||||
function CompareDate(d1,d2){
|
||||
return ((new Date(d1.replace(/-/g,"\/"))) <= (new Date(d2.replace(/-/g,"\/"))));
|
||||
}
|
||||
//计算两个时间的差 是否大于1分钟
|
||||
function timeToDiffer(d1,d2){
|
||||
var dateBegin = new Date(d1.replace(/-/g,"\/"));//将-转化为/,使用new Date
|
||||
var dateEnd = new Date(d2.replace(/-/g,"\/"))
|
||||
var dateDiff = dateEnd.getTime() - dateBegin.getTime();//时间差的毫秒数
|
||||
if(dateDiff<(60*1000)){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
//day week 切换
|
||||
function initDayWeek(){
|
||||
var dayWeekCheck = $("input.dayWeek:checked");
|
||||
@@ -183,14 +261,14 @@
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-2"><spring:message code="startTime"/></label>
|
||||
<div class="col-md-4">
|
||||
<input name="schedule.cronValid" id="singleValid" type="text" class="form-control Wdate required" readonly="readonly" value="${_cfg.schedule.cronValid }" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,minDate:'%y-%M-%d %H:{%m+2}:%s', maxDate:'#F{$dp.$D(\'singleInvalid\')}'});"/>
|
||||
<input name="schedule.cronValid" id="singleValid" type="text" class="form-control Wdate required oneStartDate" readonly="readonly" value="${_cfg.schedule.cronValid }" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
|
||||
</div>
|
||||
<div for="schedule.cronValid"></div>
|
||||
</div>
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-2"><spring:message code="endTime"/></label>
|
||||
<div class="col-md-4">
|
||||
<input name="schedule.cronInvalid" id="singleInvalid" type="text" class="form-control Wdate required" readonly="readonly" value="${_cfg.schedule.cronInvalid }" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true,minDate:'#F{$dp.$D(\'singleValid\')}'});"/>
|
||||
<input name="schedule.cronInvalid" id="singleInvalid" type="text" class="form-control Wdate required oneDate oneDiffDate" readonly="readonly" value="${_cfg.schedule.cronInvalid }" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:true});"/>
|
||||
</div>
|
||||
<div for="schedule.cronInvalid"></div>
|
||||
</div>
|
||||
@@ -216,7 +294,7 @@
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-2"><spring:message code="endTime"/></label>
|
||||
<div class="col-md-4">
|
||||
<input name="schedule.cronInvalid" type="text" id="dayInvalid" class="form-control Wdate required dayDate" readonly="readonly" value="${_cfg.schedule.cronInvalid }" onClick="WdatePicker({dateFmt:'H:mm:ss'})"/>
|
||||
<input name="schedule.cronInvalid" type="text" id="dayInvalid" class="form-control Wdate required dayDate dayDiffDate" readonly="readonly" value="${_cfg.schedule.cronInvalid }" onClick="WdatePicker({dateFmt:'H:mm:ss'})"/>
|
||||
</div>
|
||||
<div for="schedule.cronInvalid"></div>
|
||||
</div>
|
||||
@@ -256,7 +334,7 @@
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-2"><spring:message code="endTime"/></label>
|
||||
<div class="col-md-4">
|
||||
<input name="schedule.cronInvalid" type="text" id="weekInvalid" class="form-control Wdate required weekDate" readonly="readonly" value="${_cfg.schedule.cronInvalid }" onClick="WdatePicker({dateFmt:'H:mm:ss'})"/>
|
||||
<input name="schedule.cronInvalid" type="text" id="weekInvalid" class="form-control Wdate required weekDate weekDiffDate" readonly="readonly" value="${_cfg.schedule.cronInvalid }" onClick="WdatePicker({dateFmt:'H:mm:ss'})"/>
|
||||
</div>
|
||||
<div for="schedule.cronInvalid"></div>
|
||||
</div>
|
||||
@@ -361,7 +439,7 @@
|
||||
<div class="form-group ">
|
||||
<label class="control-label col-md-2"><spring:message code="endTime"/></label>
|
||||
<div class="col-md-4">
|
||||
<input name="schedule.cronInvalid" type="text" id="monthInvalid" class="form-control Wdate required monthDate" readonly="readonly" value='${_cfg.schedule.cronInvalid }' onClick="WdatePicker({dateFmt:'H:mm:ss'})"/>
|
||||
<input name="schedule.cronInvalid" type="text" id="monthInvalid" class="form-control Wdate required monthDate monthDiffDate" readonly="readonly" value='${_cfg.schedule.cronInvalid }' onClick="WdatePicker({dateFmt:'H:mm:ss'})"/>
|
||||
</div>
|
||||
<div for="schedule.cronInvalid"></div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user