From 2feccb2a8a838ba9b58de415741f1c90c281953f Mon Sep 17 00:00:00 2001 From: CSXing <910955951@qq.com> Date: Tue, 14 Jun 2022 01:41:04 +0000 Subject: [PATCH] =?UTF-8?q?update=20ruoyi-admin/src/main/resources/static/?= =?UTF-8?q?ruoyi/js/common.js.=20=E4=BF=AE=E5=A4=8D-=E5=A4=9A=E7=BB=84?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E8=8C=83=E5=9B=B4-=E5=85=AC=E5=85=B1?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E4=B8=8D=E7=94=9F=E6=95=88bug=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E5=A2=9E=E5=8A=A0=E9=99=90=E5=88=B6=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=8D=8A=E5=B9=B4=E5=86=85=E7=9A=84=E6=97=A5=E6=9C=9F=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/resources/static/ruoyi/js/common.js | 102 +++++++++++------- 1 file changed, 62 insertions(+), 40 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js index e3b7a97aa..7aa2cd7b0 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js @@ -3,8 +3,7 @@ * Copyright (c) 2019 ruoyi */ -var startLayDate; -var endLayDate; +var startLayDate=[], endLayDate=[], iLayDate=0; //[chenshuixing]修复多组日期范围无效 2022-06-14 $(function() { // layer扩展皮肤 @@ -47,47 +46,70 @@ $(function() { } }); - // laydate 时间控件绑定 + // laydate 时间控件绑定 [chenshuixing]修复多组日期范围无效 2022-06-14 if ($(".select-time").length > 0) { - layui.use('laydate', function() { - var laydate = layui.laydate; - startLayDate = laydate.render({ - elem: '#startTime', - max: $('#endTime').val(), - theme: 'molv', - type: $('#startTime').attr("data-type") || 'date', - trigger: 'click', - done: function(value, date) { - // 结束时间大于开始时间 - if (value !== '') { - endLayDate.config.min.year = date.year; - endLayDate.config.min.month = date.month - 1; - endLayDate.config.min.date = date.date; - } else { - endLayDate.config.min.year = ''; - endLayDate.config.min.month = ''; - endLayDate.config.min.date = ''; + // 遍历 + $('.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() { + var laydate = layui.laydate; + + var bdObj = laydate.render({ + 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 = ''; + } } - } - }); - endLayDate = laydate.render({ - elem: '#endTime', - min: $('#startTime').val(), - theme: 'molv', - type: $('#endTime').attr("data-type") || 'date', - trigger: 'click', - done: function(value, date) { - // 开始时间小于结束时间 - if (value !== '') { - startLayDate.config.max.year = date.year; - startLayDate.config.max.month = date.month - 1; - startLayDate.config.max.date = date.date; - } else { - startLayDate.config.max.year = '2099'; - startLayDate.config.max.month = '12'; - startLayDate.config.max.date = '31'; + }); + var edObj = laydate.render({ + index: iLayDate, + elem: '#'+endObj[0].id, + min: startObj.val(), + max: maxdate, + theme: 'molv', + type: endObj.attr("data-type") || 'date', + trigger: 'click', + done: function(value, date) { + // 开始时间小于结束时间 + if (value !== '') { + startLayDate[this.index].config.max.year = date.year; + startLayDate[this.index].config.max.month = date.month - 1; + startLayDate[this.index].config.max.date = date.date; + } else { + startLayDate[this.index].config.max.year = '2099'; + startLayDate[this.index].config.max.month = '12'; + startLayDate[this.index].config.max.date = '31'; + } } - } + }) + startLayDate.push(bdObj); + endLayDate.push(edObj); + + iLayDate++; }); }); }