/** layui-v2.5.6 MIT License By https://www.layui.com */
;!function(){"use strict";
var e=window.layui&&layui.define, // 定义 layui 和 layui.define 模块
t={
// 获取当前脚本路径
getPath:function(){
var e=document.currentScript?document.currentScript.src:function(){
for(var e,t=document.scripts,n=t.length-1,a=n;a>0;a--)
if("interactive"===t[a].readyState){
e=t[a].src;
break
}
return e||t[n].src
}();
return e.substring(0,e.lastIndexOf("/")+1) // 返回当前脚本所在的路径
}(),
// 获取指定元素的样式
getStyle:function(e,t){
var n=e.currentStyle?e.currentStyle:window.getComputedStyle(e,null);
return n[n.getPropertyValue?"getPropertyValue":"getAttribute"](t)
},
// 动态加载 CSS 样式表
link:function(e,a,i){
if(n.path){
var r=document.getElementsByTagName("head")[0],
o=document.createElement("link");
"string"==typeof a&&(i=a); // 如果 a 是字符串,则将 i 设置为 a
var s=(i||e).replace(/\.|\//g,""),
l="layuicss-"+s,d=0;
o.rel="stylesheet",
o.href=n.path+e,
o.id=l,
document.getElementById(l)||r.appendChild(o),
// 加载后调用回调函数
"function"==typeof a&&!function c(){
return++d>80?window.console&&console.error("laydate.css: Invalid"):void(1989===parseInt(t.getStyle(document.getElementById(l),"width"))?a():setTimeout(c,100))
}()
}
}
},
// 版本和配置初始化
n={
v:"5.0.9",
config:{},
index:window.laydate&&window.laydate.v?1e5:0,
path:t.getPath,
// 设置配置项
set:function(e){
var t=this;
return t.config=w.extend({},t.config,e),t
},
// 加载资源后,执行初始化
ready:function(a){
var i="laydate",
r="",
o=(e?"modules/laydate/":"theme/")+"default/laydate.css?v="+n.v+r;
return e?layui.addcss(o,a,i):t.link(o,a,i),this
}
},
// 组件对象初始化
a=function(){
var e=this;
return{
hint:function(t){
e.hint.call(e,t)
},
config:e.config
}
},
i="laydate",
r=".layui-laydate",
o="layui-this",
s="laydate-disabled",
l="开始日期超出了结束日期
建议重新选择",
d=[100,2e5],
c="layui-laydate-static",
m="layui-laydate-list",
u="laydate-selected",
h="layui-laydate-hint",
y="laydate-day-prev",
f="laydate-day-next",
p="layui-laydate-footer",
g=".laydate-btns-confirm",
v="laydate-time-text",
D=".laydate-btns-time",
// 初始化函数
T=function(e){
var t=this;
t.index=++n.index,
t.config=w.extend({},t.config,n.config,e),
n.ready(function(){
t.init()
})
},
// 工具函数,返回元素对象
w=function(e){
return new C(e)
},
// C 构造函数,操作 DOM 元素
C=function(e){
for(var t=0,n="object"==typeof e?[e]:(this.selector=e,document.querySelectorAll(e||null));t0)return n[0].getAttribute(e)
}():n.each(function(n,a){
a.setAttribute(e,t)
})
},
// 移除属性
C.prototype.removeAttr=function(e){
return this.each(function(t,n){
n.removeAttribute(e)
})
},
// 设置 HTML 内容
C.prototype.html=function(e){
return this.each(function(t,n){
n.innerHTML=e
})
},
// 设置或获取输入框的值
T.prototype.render=function(e){ // 渲染日期选择器
var t=this,n=(t.config,w("#"+t.elemID)),a=n.hasClass("laydate-footer"),i=n.find("td"),r=n.find("ul"); // 获取配置和HTML元素
if(!t.config.range||a){ // 如果是日期范围选择或者没有日期范围
if(!a){ // 如果没有footer元素
t.elemFooter&&(t.elemFooter.style.display="none"); // 隐藏footer
}else{ // 如果有footer元素
r.css("display","block"); // 显示时间列表
}
}
t.dateTime={year:e.year,month:e.month,date:e.date,hours:e.hours,minutes:e.minutes,seconds:e.seconds}; // 更新日期时间
t.renderList(e); // 渲染日期列表
},
T.prototype.renderList=function(e){ // 渲染日期列表
var t=this,n=(t.config,w("#"+t.elemID)),a=n.find("td");
w.each(a,function(t,a){ // 遍历每个单元格
var i=w(a),r=i.attr("lay-ymd").split("-"),s=n.newDate({year:r[0],month:r[1]-1,date:r[2]}).getTime(); // 获取每个日期的时间戳
if(s===t.dateTime.getTime())i.addClass("laydate-day-selected"); // 如果日期匹配,添加选中样式
else i.removeClass("laydate-day-selected"); // 否则移除选中样式
});
},
T.prototype.position=function(){ // 计算并设置日期选择器的位置
var e=this,t=e.config,n=e.bindElem||t.elem[0],a=n.getBoundingClientRect(),i=e.elem.offsetWidth,r=e.elem.offsetHeight;
var o=function(e){ // 获取滚动位置
return e=e?"scrollLeft":"scrollTop",document.body[e]|document.documentElement[e];
};
var s=function(e){ // 获取窗口大小
return document.documentElement[e?"clientWidth":"clientHeight"];
};
var l=5,d=a.left,c=a.bottom; // 设置偏移量
d+i+l>s("width")&&(d=s("width")-i-l); // 如果超出窗口宽度,调整位置
c+r+l>s()&&(c=a.top>r?a.top-r:s()-r,c-=2*l); // 如果超出窗口高度,调整位置
t.position&&(e.elem.style.position=t.position); // 如果有指定位置类型,设置位置类型
e.elem.style.left=d+("fixed"===t.position?0:o(1))+"px"; // 设置左边距
e.elem.style.top=c+("fixed"===t.position?0:o())+"px"; // 设置顶部边距
},
T.prototype.checkDate=function(e){ // 检查日期是否合法
var t=this,n=(t.config,w("#"+t.elemID));
// 判断日期范围
var i=t.dateTime=e.dateTime||new Date();
var r=t.bindElem||n[0];
var o=function(e){ // 日期合法性检查
if(e.year>d[1]){ // 如果年份超过最大年份
e.year=d[1];
a=!0;
}
};
// 校验并返回检查结果
},