update ruoyi-admin/src/main/resources/static/ruoyi/js/common.js.
修复-多组日期范围-公共加载不生效bug,并增加限制选择半年内的日期范围。
This commit is contained in:
parent
d1b3f4f397
commit
2feccb2a8a
|
|
@ -3,8 +3,7 @@
|
||||||
* Copyright (c) 2019 ruoyi
|
* Copyright (c) 2019 ruoyi
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var startLayDate;
|
var startLayDate=[], endLayDate=[], iLayDate=0; //[chenshuixing]修复多组日期范围无效 2022-06-14
|
||||||
var endLayDate;
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// layer扩展皮肤
|
// layer扩展皮肤
|
||||||
|
|
@ -47,47 +46,70 @@ $(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// laydate 时间控件绑定
|
// laydate 时间控件绑定 [chenshuixing]修复多组日期范围无效 2022-06-14
|
||||||
if ($(".select-time").length > 0) {
|
if ($(".select-time").length > 0) {
|
||||||
|
// 遍历
|
||||||
|
$('.select-time').each(function(){
|
||||||
|
|
||||||
|
var mindate = new Date();
|
||||||
|
mindate.setMonth(mindate.getMonth()-6);
|
||||||
|
mindate = $.common.dateFormat(mindate,"yyyy-MM-dd");
|
||||||
|
var maxdate = new Date();
|
||||||
|
maxdate.setMonth(maxdate.getMonth()+6);
|
||||||
|
maxdate = $.common.dateFormat(maxdate,"yyyy-MM-dd");
|
||||||
|
|
||||||
|
var startObj = $(this).find('input[id^=startTime]');
|
||||||
|
var endObj = $(this).find('input[id^=endTime]');
|
||||||
|
|
||||||
layui.use('laydate', function() {
|
layui.use('laydate', function() {
|
||||||
var laydate = layui.laydate;
|
var laydate = layui.laydate;
|
||||||
startLayDate = laydate.render({
|
|
||||||
elem: '#startTime',
|
var bdObj = laydate.render({
|
||||||
max: $('#endTime').val(),
|
index: iLayDate,
|
||||||
|
elem: '#'+startObj[0].id,
|
||||||
|
min: mindate,
|
||||||
|
max: endObj.val(),
|
||||||
theme: 'molv',
|
theme: 'molv',
|
||||||
type: $('#startTime').attr("data-type") || 'date',
|
type: startObj.attr("data-type") || 'date',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
done: function(value, date) {
|
done: function(value, date) {
|
||||||
// 结束时间大于开始时间
|
// 结束时间大于开始时间
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
endLayDate.config.min.year = date.year;
|
endLayDate[this.index].config.min.year = date.year;
|
||||||
endLayDate.config.min.month = date.month - 1;
|
endLayDate[this.index].config.min.month = date.month - 1;
|
||||||
endLayDate.config.min.date = date.date;
|
endLayDate[this.index].config.min.date = date.date;
|
||||||
} else {
|
} else {
|
||||||
endLayDate.config.min.year = '';
|
endLayDate[this.index].config.min.year = '';
|
||||||
endLayDate.config.min.month = '';
|
endLayDate[this.index].config.min.month = '';
|
||||||
endLayDate.config.min.date = '';
|
endLayDate[this.index].config.min.date = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
endLayDate = laydate.render({
|
var edObj = laydate.render({
|
||||||
elem: '#endTime',
|
index: iLayDate,
|
||||||
min: $('#startTime').val(),
|
elem: '#'+endObj[0].id,
|
||||||
|
min: startObj.val(),
|
||||||
|
max: maxdate,
|
||||||
theme: 'molv',
|
theme: 'molv',
|
||||||
type: $('#endTime').attr("data-type") || 'date',
|
type: endObj.attr("data-type") || 'date',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
done: function(value, date) {
|
done: function(value, date) {
|
||||||
// 开始时间小于结束时间
|
// 开始时间小于结束时间
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
startLayDate.config.max.year = date.year;
|
startLayDate[this.index].config.max.year = date.year;
|
||||||
startLayDate.config.max.month = date.month - 1;
|
startLayDate[this.index].config.max.month = date.month - 1;
|
||||||
startLayDate.config.max.date = date.date;
|
startLayDate[this.index].config.max.date = date.date;
|
||||||
} else {
|
} else {
|
||||||
startLayDate.config.max.year = '2099';
|
startLayDate[this.index].config.max.year = '2099';
|
||||||
startLayDate.config.max.month = '12';
|
startLayDate[this.index].config.max.month = '12';
|
||||||
startLayDate.config.max.date = '31';
|
startLayDate[this.index].config.max.date = '31';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
startLayDate.push(bdObj);
|
||||||
|
endLayDate.push(edObj);
|
||||||
|
|
||||||
|
iLayDate++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue