Pre Merge pull request !393 from CSXing/N/A

This commit is contained in:
CSXing 2022-07-19 07:39:22 +00:00 committed by Gitee
commit 0a93f5e600
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 62 additions and 40 deletions

View File

@ -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) {
layui.use('laydate', function() { // 遍历
var laydate = layui.laydate; $('.select-time').each(function(){
startLayDate = laydate.render({
elem: '#startTime', var mindate = new Date();
max: $('#endTime').val(), mindate.setMonth(mindate.getMonth()-6);
theme: 'molv', mindate = $.common.dateFormat(mindate,"yyyy-MM-dd");
type: $('#startTime').attr("data-type") || 'date', var maxdate = new Date();
trigger: 'click', maxdate.setMonth(maxdate.getMonth()+6);
done: function(value, date) { maxdate = $.common.dateFormat(maxdate,"yyyy-MM-dd");
// 结束时间大于开始时间
if (value !== '') { var startObj = $(this).find('input[id^=startTime]');
endLayDate.config.min.year = date.year; var endObj = $(this).find('input[id^=endTime]');
endLayDate.config.min.month = date.month - 1;
endLayDate.config.min.date = date.date; layui.use('laydate', function() {
} else { var laydate = layui.laydate;
endLayDate.config.min.year = '';
endLayDate.config.min.month = ''; var bdObj = laydate.render({
endLayDate.config.min.date = ''; index: iLayDate,
elem: '#'+startObj[0].id,
min: mindate,
max: endObj.val(),
theme: 'molv',
type: startObj.attr("data-type") || 'date',
trigger: 'click',
done: function(value, date) {
// 结束时间大于开始时间
if (value !== '') {
endLayDate[this.index].config.min.year = date.year;
endLayDate[this.index].config.min.month = date.month - 1;
endLayDate[this.index].config.min.date = date.date;
} else {
endLayDate[this.index].config.min.year = '';
endLayDate[this.index].config.min.month = '';
endLayDate[this.index].config.min.date = '';
}
} }
} });
}); var edObj = laydate.render({
endLayDate = laydate.render({ index: iLayDate,
elem: '#endTime', elem: '#'+endObj[0].id,
min: $('#startTime').val(), min: startObj.val(),
theme: 'molv', max: maxdate,
type: $('#endTime').attr("data-type") || 'date', theme: 'molv',
trigger: 'click', type: endObj.attr("data-type") || 'date',
done: function(value, date) { trigger: 'click',
// 开始时间小于结束时间 done: function(value, date) {
if (value !== '') { // 开始时间小于结束时间
startLayDate.config.max.year = date.year; if (value !== '') {
startLayDate.config.max.month = date.month - 1; startLayDate[this.index].config.max.year = date.year;
startLayDate.config.max.date = date.date; startLayDate[this.index].config.max.month = date.month - 1;
} else { startLayDate[this.index].config.max.date = date.date;
startLayDate.config.max.year = '2099'; } else {
startLayDate.config.max.month = '12'; startLayDate[this.index].config.max.year = '2099';
startLayDate.config.max.date = '31'; startLayDate[this.index].config.max.month = '12';
startLayDate[this.index].config.max.date = '31';
}
} }
} })
startLayDate.push(bdObj);
endLayDate.push(edObj);
iLayDate++;
}); });
}); });
} }