Merge pull request #1171 from layui/main

同步 main 的相关修改到 2.x
pull/1181/head
贤心 2022-11-29 00:06:14 +08:00 committed by GitHub
commit 3f85f8cb66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 250 additions and 89 deletions

View File

@ -136,9 +136,11 @@ exports.laydate = () => { // gulp laydate
// js // js
return gulp.src(['./src/layui.js', './src/modules/{lay,laydate}.js']) return gulp.src(['./src/layui.js', './src/modules/{lay,laydate}.js'])
.pipe(replace('win.layui =', 'var layui =')) // 将 layui 替换为局部变量 .pipe(replace('win.layui =', 'var layui =')) // 将 layui 替换为局部变量
.pipe(replace('})(window); //gulp build: layui-footer', '')) // 替换 layui.js 的落脚 .pipe(replace('}(window); //gulp build: layui-footer', '')) // 替换 layui.js 的落脚
.pipe(replace('(function(window){ //gulp build: lay-header', '')) // 替换 lay.js 的头部 .pipe(replace(';!function(window){ //gulp build: lay-header', '')) // 替换 lay.js 的头部
.pipe(replace('}(window, window.document); //gulp build: lay-footer', '')) // 替换 lay.js 的落脚
.pipe(concat('laydate.js', {newLine: ''})) .pipe(concat('laydate.js', {newLine: ''}))
.pipe(replace(';!function(window, document){ //gulp build: laydate-header', '')) // 替换 laydate.js 的头部
.pipe(header.apply(null, comment)) //追加头部 .pipe(header.apply(null, comment)) //追加头部
.pipe(gulp.dest(dest + 'src')); .pipe(gulp.dest(dest + 'src'));
}; };

View File

@ -98,9 +98,11 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
/* 双日历 */ /* 双日历 */
.layui-laydate-range{width: 546px;} .layui-laydate-range{width: 546px;}
.layui-laydate-range .layui-laydate-main{display: inline-block; vertical-align: middle;width:50%;} .layui-laydate-range .layui-laydate-main{display: inline-block; vertical-align: middle;max-width: 50%;}
.layui-laydate-range .laydate-main-list-1 .layui-laydate-header, .layui-laydate-range .laydate-main-list-1 .layui-laydate-header,
.layui-laydate-range .laydate-main-list-1 .layui-laydate-content{border-left: 1px solid #e2e2e2;} .layui-laydate-range .laydate-main-list-1 .layui-laydate-content{border-left: 1px solid #e2e2e2;}
.layui-laydate-range.layui-laydate-linkage .laydate-main-list-0 .laydate-next-m, .layui-laydate-range.layui-laydate-linkage .laydate-main-list-0 .laydate-next-y,
.layui-laydate-range.layui-laydate-linkage .laydate-main-list-1 .laydate-prev-m, .layui-laydate-range.layui-laydate-linkage .laydate-main-list-1 .laydate-prev-y{display: none;}
/* 默认简约主题 */ /* 默认简约主题 */
@ -111,8 +113,8 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.layui-laydate-content{border-top: none 0; border-bottom: none 0;} .layui-laydate-content{border-top: none 0; border-bottom: none 0;}
.layui-laydate-content th{color: #333;} .layui-laydate-content th{color: #333;}
.layui-laydate-content td{color: #666;} .layui-laydate-content td{color: #666;}
.layui-laydate-content td.laydate-selected{background-color: #B5FFF8;} .layui-laydate-content td.laydate-selected>div{background-color: #00F7DE;}
.laydate-selected:hover{background-color: #00F7DE !important;} .laydate-selected:hover>div{background-color: #00F7DE !important;}
.layui-laydate-content td>div:hover, .layui-laydate-content td>div:hover,
.layui-laydate-list li:hover, .layui-laydate-list li:hover,
.layui-laydate-shortcut>li:hover{background-color: #eee; color: #333;} .layui-laydate-shortcut>li:hover{background-color: #eee; color: #333;}
@ -121,8 +123,8 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.laydate-time-list>li:hover{background: none;} .laydate-time-list>li:hover{background: none;}
.layui-laydate-content .laydate-day-prev, .layui-laydate-content .laydate-day-prev,
.layui-laydate-content .laydate-day-next{color: #d2d2d2;} .layui-laydate-content .laydate-day-next{color: #d2d2d2;}
.laydate-selected.laydate-day-prev, .laydate-selected.laydate-day-prev>div,
.laydate-selected.laydate-day-next{background-color: #f8f8f8 !important;} .laydate-selected.laydate-day-next>div{background-color: #f8f8f8 !important;}
.layui-laydate-footer{border-top: 1px solid #e2e2e2;} .layui-laydate-footer{border-top: 1px solid #e2e2e2;}
.layui-laydate-hint{color: #FF5722;} .layui-laydate-hint{color: #FF5722;}
.laydate-day-mark::after{background-color: #5FB878;} .laydate-day-mark::after{background-color: #5FB878;}

View File

@ -148,7 +148,7 @@
(function poll() { (function poll() {
if(++timeout > config.timeout * 1000 / 4){ if(++timeout > config.timeout * 1000 / 4){
return error(item + ' is not a valid module', 'error'); return error(item + ' is not a valid module', 'error');
}; }
config.status[item] ? onCallback() : setTimeout(poll, 4); config.status[item] ? onCallback() : setTimeout(poll, 4);
}()); }());
} }
@ -221,7 +221,7 @@
(function poll() { (function poll() {
if(++timeout > config.timeout * 1000 / 4){ if(++timeout > config.timeout * 1000 / 4){
return error(item + ' is not a valid module', 'error'); return error(item + ' is not a valid module', 'error');
}; }
(typeof config.modules[item] === 'string' && config.status[item]) (typeof config.modules[item] === 'string' && config.status[item])
? onCallback() ? onCallback()
: setTimeout(poll, 4); : setTimeout(poll, 4);
@ -285,7 +285,7 @@
//如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范 //如果轮询超过指定秒数,则视为请求文件失败或 css 文件不符合规范
if(++timeout > config.timeout * 1000 / delay){ if(++timeout > config.timeout * 1000 / delay){
return error(href + ' timeout'); return error(href + ' timeout');
}; }
//css 加载就绪 //css 加载就绪
if(parseInt(that.getStyle(getLinkElem, 'width')) === 1989){ if(parseInt(that.getStyle(getLinkElem, 'width')) === 1989){
@ -671,7 +671,7 @@
} else { //数字 vs 数字 } else { //数字 vs 数字
return v1 - v2; return v1 - v2;
} }
}; }
/** /**
* 字典序排序 * 字典序排序

View File

@ -428,4 +428,4 @@
}); });
} }
}(window, window.document); }(window, window.document); //gulp build: lay-footer

View File

@ -1,6 +1,6 @@
/** layDate 日期与时间控件 | MIT Licensed */ /** layDate 日期与时间控件 | MIT Licensed */
;!function(window, document){ ;!function(window, document){ //gulp build: laydate-header
"use strict"; "use strict";
var isLayui = window.layui && layui.define, ready = { var isLayui = window.layui && layui.define, ready = {
@ -42,7 +42,7 @@
,ready: function(callback){ ,ready: function(callback){
var cssname = 'laydate'; var cssname = 'laydate';
var ver = '' var ver = ''
var path = (isLayui ? 'modules/' : 'css/') + 'laydate.css?v='+ laydate.v + ver; var path = (isLayui ? 'modules/' : '') + 'laydate.css?v='+ laydate.v + ver;
isLayui ? ( isLayui ? (
layui['layui.all'] layui['layui.all']
@ -245,7 +245,22 @@
that.rangeStr = options.range ? ( that.rangeStr = options.range ? (
typeof options.range === 'string' ? options.range : '-' typeof options.range === 'string' ? options.range : '-'
) : ''; ) : '';
//日期范围的日历面板是否联动
that.calendarLinkage = !!(options.range && options.calendarLinkage && (options.type === 'date' || options.type === 'datetime'))
//切换日历联动方式
that.autoCalendarModel = function () {
var state = that.calendarLinkage;
that.calendarLinkage = (options.range && (options.type === 'date' || options.type === 'datetime'))
&& that.startDate && that.endDate && that.startDate.year === that.endDate.year && that.startDate.month === that.endDate.month;
lay(that.elem)[that.calendarLinkage ? 'addClass' : 'removeClass']('layui-laydate-linkage');
return that.calendarLinkage != state; // 返回发生了变化
};
//是否自动切换
that.autoCalendarModel.auto = that.calendarLinkage && options.calendarLinkage === 'auto';
//若 range 参数为数组,则表示为开始日期和结束日期的 input 对象 //若 range 参数为数组,则表示为开始日期和结束日期的 input 对象
if(layui.type(options.range) === 'array'){ if(layui.type(options.range) === 'array'){
that.rangeElem = [ that.rangeElem = [
@ -394,6 +409,7 @@
,"class": [ ,"class": [
'layui-laydate' 'layui-laydate'
,options.range ? ' layui-laydate-range' : '' ,options.range ? ' layui-laydate-range' : ''
,that.calendarLinkage ? ' layui-laydate-linkage' : ''
,isStatic ? (' '+ ELEM_STATIC) : '' ,isStatic ? (' '+ ELEM_STATIC) : ''
,options.fullPanel ? ' laydate-theme-fullpanel' : '' // 全面版 ,options.fullPanel ? ' laydate-theme-fullpanel' : '' // 全面版
// ,options.theme && options.theme !== 'default' && !/^#/.test(options.theme) ? (' laydate-theme-' + options.theme) : '' // ,options.theme && options.theme !== 'default' && !/^#/.test(options.theme) ? (' laydate-theme-' + options.theme) : ''
@ -559,7 +575,7 @@
lay.extend(dateTime, that.systemDate(layui.type(item) === 'date' ? item : new Date(item))) lay.extend(dateTime, that.systemDate(layui.type(item) === 'date' ? item : new Date(item)))
} }
if (type === 'time') { if (type === 'time' || type === 'datetime') {
that[['startTime', 'endTime'][i]] = { that[['startTime', 'endTime'][i]] = {
hours: dateTime.hours, hours: dateTime.hours,
minutes: dateTime.minutes, minutes: dateTime.minutes,
@ -568,13 +584,15 @@
} }
if (type === 'year' || type === 'month' || type === 'time') { if (type === 'year' || type === 'month' || type === 'time') {
that.listYM[i] = [dateTime.year, dateTime.month + 1]; that.listYM[i] = [dateTime.year, dateTime.month + 1];
that.checkDate('limit').calendar(null,i);
that.list(type, i);
} else { } else {
that.checkDate('limit').calendar(null,i); if (i === 0) { // 第一个值作为startDate
that.closeList(); that.startDate = lay.extend({}, dateTime);
} else {
that.autoCalendarModel.auto && that.autoCalendarModel();
}
} }
}); });
that.checkDate('limit').calendar(null, null, 'init');
var timeBtn = lay(that.footer).find('.'+ ELEM_TIME_BTN).removeClass(DISABLED); var timeBtn = lay(that.footer).find('.'+ ELEM_TIME_BTN).removeClass(DISABLED);
timeBtn && timeBtn.attr('lay-type') === 'date' && timeBtn[0].click(); timeBtn && timeBtn.attr('lay-type') === 'date' && timeBtn[0].click();
@ -670,7 +688,11 @@
that.checkDate(function(){ that.checkDate(function(){
elem.remove(); elem.remove();
//delete options.dateTime; //delete options.dateTime;
//delete that.endDate; delete that.startDate;
delete that.endDate;
delete that.endState;
delete that.startTime;
delete that.endTime;
delete laydate.thisId; delete laydate.thisId;
typeof options.close === 'function' && options.close(that); typeof options.close === 'function' && options.close(that);
}); });
@ -815,7 +837,15 @@
checkValid(dateTime); checkValid(dateTime);
}; };
if(fn === 'limit') return checkValid(dateTime), that; if(fn === 'limit') {
if (options.range) {
checkValid(that.calendarLinkage ? that.startDate : dateTime); // 校验开始时间
that.endDate && checkValid(that.endDate); // 校验结束时间
} else {
checkValid(dateTime);
}
return that;
}
value = value || options.value; value = value || options.value;
if(typeof value === 'string'){ if(typeof value === 'string'){
@ -896,7 +926,7 @@
//校验日期有效数字 //校验日期有效数字
checkValid(dateTime); checkValid(dateTime);
if(options.range) checkValid(that.endDate); if(options.range) checkValid(that.endDate);
//如果初始值格式错误,则纠正初始值 //如果初始值格式错误,则纠正初始值
if(error && value){ if(error && value){
that.setValue( that.setValue(
@ -940,6 +970,10 @@
that.hint('value ' + lang.invalidDate + lang.formatError[1]); that.hint('value ' + lang.invalidDate + lang.formatError[1]);
} }
that.startDate = that.startDate || lay.extend({}, options.dateTime);
that.endState = !that.calendarLinkage || !!(that.startDate && that.endDate); // 初始化选中范围状态
that.autoCalendarModel.auto && that.autoCalendarModel();
fn && fn(); fn && fn();
return that; return that;
}; };
@ -991,10 +1025,9 @@
var timestrap = {} var timestrap = {}
var dateTime = opts.index > (opts.time ? 0 : 41) ? that.endDate : options.dateTime; var dateTime = opts.index > (opts.time ? 0 : 41) ? that.endDate : options.dateTime;
var isOut; var isOut;
var thisDateTime = lay.extend({}, dateTime, opts.date || {});
lay.each({ lay.each({
now: thisDateTime now: lay.extend({}, dateTime, opts.date || {})
,min: options.min ,min: options.min
,max: options.max ,max: options.max
}, function(key, item){ }, function(key, item){
@ -1063,7 +1096,9 @@
YMD = that.getAsYM(dateTime.year, dateTime.month, 'sub'); YMD = that.getAsYM(dateTime.year, dateTime.month, 'sub');
} else if(index_ >= startWeek && index_ < thisMaxDate + startWeek){ } else if(index_ >= startWeek && index_ < thisMaxDate + startWeek){
st = index_ - startWeek; st = index_ - startWeek;
st + 1 === dateTime.date && item.addClass(THIS); if (!that.calendarLinkage) {
st + 1 === dateTime.date && item.addClass(THIS);
}
} else { } else {
st = index_ - thisMaxDate - startWeek; st = index_ - thisMaxDate - startWeek;
item.addClass('laydate-day-next'); item.addClass('laydate-day-next');
@ -1098,9 +1133,18 @@
//初始默认选择器 //初始默认选择器
if(isAlone){ //年、月等独立选择器 if(isAlone){ //年、月等独立选择器
if(options.range){ if(options.range){
if(value){ // if (that.calendarLinkage) {
// value ? that.endDate = (that.endDate || {
// year: dateTime.year + (options.type === 'year' ? 1 : 0)
// ,month: dateTime.month + (options.type === 'month' ? 0 : -1)
// }) : (that.startDate = that.startDate || {
// year: dateTime.year
// ,month: dateTime.month
// });
// }
if(value || type !== 'init'){ // 判断是否需要显示年月时间列表
that.listYM = [ that.listYM = [
[options.dateTime.year, options.dateTime.month + 1] [(that.startDate || options.dateTime).year, (that.startDate || options.dateTime).month + 1]
,[that.endDate.year, that.endDate.month + 1] ,[that.endDate.year, that.endDate.month + 1]
]; ];
that.list(options.type, 0).list(options.type, 1); that.list(options.type, 0).list(options.type, 1);
@ -1118,9 +1162,17 @@
} }
//初始赋值双日历 //初始赋值双日历
if(options.range && type === 'init' && !value){ if(options.range && type === 'init'){
//执行渲染第二个日历 //执行渲染第二个日历
that.calendar(that.endDate, 1); if (that.calendarLinkage) {
var EYM = that.getAsYM(dateTime.year, dateTime.month, index ? 'sub' : null)
that.calendar(lay.extend({}, dateTime, {
year: EYM[0]
,month: EYM[1]
}), 1 - index); // 渲染另外一个
} else {
that.calendar(null, 1 - index);
}
} }
// 通过检测当前有效日期,来设定底部按钮状态 // 通过检测当前有效日期,来设定底部按钮状态
@ -1147,7 +1199,10 @@
// 重置快捷栏选中状态 // 重置快捷栏选中状态
lay(that.shortcut).find('li.' + THIS).removeClass(THIS); lay(that.shortcut).find('li.' + THIS).removeClass(THIS);
//标记选择范围
if(options.range && !isAlone && type !== 'init') that.stampRange();
return that; return that;
}; };
@ -1155,7 +1210,7 @@
Class.prototype.list = function(type, index){ Class.prototype.list = function(type, index){
var that = this var that = this
,options = that.config ,options = that.config
,dateTime = options.dateTime ,dateTime = that.calendarLinkage ? options.dateTime : [options.dateTime, that.endDate][index]
,lang = that.lang() ,lang = that.lang()
,isAlone = options.range && options.type !== 'date' && options.type !== 'datetime' //独立范围选择器 ,isAlone = options.range && options.type !== 'date' && options.type !== 'datetime' //独立范围选择器
@ -1327,14 +1382,13 @@
lay(ul).find('li').on('click', function(){ lay(ul).find('li').on('click', function(){
var ym = lay(this).attr('lay-ym') | 0; var ym = lay(this).attr('lay-ym') | 0;
if(lay(this).hasClass(DISABLED)) return; if(lay(this).hasClass(DISABLED)) return;
if(index === 0){ if (that.calendarLinkage) {
dateTime[type] = ym; lay.extend(dateTime, {
that.limit({ year: type === 'year' ? ym : listYM[0]
elem: lay(that.footer).find(ELEM_CONFIRM), ,month: type === 'year' ? listYM[1] - 1 : ym
index: 0
}); });
} else { //范围选择 } else {
that.endDate[type] = ym; dateTime[type] = ym;
} }
//当为年选择器或者年月选择器 //当为年选择器或者年月选择器
@ -1350,7 +1404,8 @@
that.list('month', index); that.list('month', index);
} }
} else { } else {
that.checkDate('limit').calendar(null, index); that.checkDate('limit').calendar(dateTime, index, 'init'); // 重新渲染一下两个面板
that.calendarLinkage || that.choose(lay(elemCont).find('td.layui-this'), index);
that.closeList(); that.closeList();
} }
@ -1448,10 +1503,10 @@
,lang = that.lang() ,lang = that.lang()
,isOut, elemBtn = lay(that.footer).find(ELEM_CONFIRM); ,isOut, elemBtn = lay(that.footer).find(ELEM_CONFIRM);
if(options.range && options.type !== 'time'){ if(options.range && options.type !== 'time'){
start = start || options.dateTime; start = start || (that.calendarLinkage ? that.startDate : options.dateTime);
end = end || that.endDate; end = end || that.endDate;
isOut = that.newDate(start).getTime() > that.newDate(end).getTime(); isOut = that.newDate(start).getTime() > that.newDate(end).getTime();
//如果不在有效日期内,直接禁用按钮,否则比较开始和结束日期 //如果不在有效日期内,直接禁用按钮,否则比较开始和结束日期
(that.limit({ (that.limit({
date: start date: start
@ -1476,7 +1531,7 @@
? lay.extend({}, that.endDate, that.endTime) ? lay.extend({}, that.endDate, that.endTime)
: ( : (
options.range options.range
? lay.extend({}, options.dateTime, that.startTime) ? lay.extend({}, that.calendarLinkage ? that.startDate : options.dateTime, that.startTime)
: options.dateTime) : options.dateTime)
) )
,format = laydate.parse(dateTime, that.format, 1); ,format = laydate.parse(dateTime, that.format, 1);
@ -1549,7 +1604,7 @@
if(!options.isPreview) return; if(!options.isPreview) return;
var elemPreview = lay(that.elem).find('.'+ ELEM_PREVIEW) var elemPreview = lay(that.elem).find('.'+ ELEM_PREVIEW)
,value = options.range ? (that.endDate ? that.parse() : '') : that.parse(); ,value = options.range ? ((that.calendarLinkage ? that.endState : that.endDate) ? that.parse() : '') : that.parse();
//显示预览 //显示预览
elemPreview.html(value).css({ elemPreview.html(value).css({
@ -1573,6 +1628,52 @@
} }
}; };
//标记范围内的日期
Class.prototype.stampRange = function(){
var that = this
,options = that.config
,startTime = that.calendarLinkage ? that.startDate : options.dateTime, endTime
,tds = lay(that.elem).find('td');
if(options.range && !that.endState) lay(that.footer).find(ELEM_CONFIRM).addClass(DISABLED);
// if(!that.endState) return;
startTime = startTime && that.newDate({
year: startTime.year
,month: startTime.month
,date: startTime.date
}).getTime();
endTime = that.endState && that.endDate && that.newDate({
year: that.endDate.year
,month: that.endDate.month
,date: that.endDate.date
}).getTime();
// if(startTime > endTime) return that.hint(TIPS_OUT);
lay.each(tds, function(i, item){
var ymd = lay(item).attr('lay-ymd').split('-')
,thisTime = that.newDate({
year: ymd[0]
,month: ymd[1] - 1
,date: ymd[2]
}).getTime();
lay(item).removeClass(ELEM_SELECTED + ' ' + THIS);
if(thisTime === startTime || thisTime === endTime){
(that.calendarLinkage || (!that.calendarLinkage && (i < 42 ? thisTime === startTime : thisTime === endTime))) &&
lay(item).addClass(
lay(item).hasClass(ELEM_PREV) || lay(item).hasClass(ELEM_NEXT)
? ELEM_SELECTED
: THIS
);
}
if(thisTime > startTime && thisTime < endTime){
lay(item).addClass(ELEM_SELECTED);
}
});
};
//执行 done/change 回调 //执行 done/change 回调
Class.prototype.done = function(param, type){ Class.prototype.done = function(param, type){
var that = this var that = this
@ -1598,9 +1699,24 @@
//选择日期 //选择日期
Class.prototype.choose = function(td, index){ Class.prototype.choose = function(td, index){
if(td.hasClass(DISABLED)) return;
var that = this var that = this
,options = that.config ,options = that.config;
,dateTime = that.thisDateTime(index)
if (that.calendarLinkage) {
if (that.endState || !that.startDate) {
// 重新选择或者第一次选择
index = 0;
that.endState = false;
that.endDate = {};
} else {
index = 1;
that.endState = true;
}
}
var dateTime = that.thisDateTime(index)
,tds = lay(that.elem).find('td') ,tds = lay(that.elem).find('td')
,YMD = td.attr('lay-ymd').split('-'); ,YMD = td.attr('lay-ymd').split('-');
@ -1610,9 +1726,7 @@
,month: (YMD[1] | 0) - 1 ,month: (YMD[1] | 0) - 1
,date: YMD[2] | 0 ,date: YMD[2] | 0
}; };
if(td.hasClass(DISABLED)) return;
lay.extend(dateTime, YMD); //同步 dateTime lay.extend(dateTime, YMD); //同步 dateTime
//范围选择 //范围选择
@ -1643,7 +1757,32 @@
} }
} }
}); });
that.calendar(null, index).done(null, 'change'); if (!index) {
that.startDate = lay.extend({}, dateTime); // 同步startDate
}
// 校验另外一个日期是否在有效的范围内
if (that.endState && !that.limit({date: that.thisDateTime(1 - index)})) {
// 根据选择之后判断是否需要切换模式
var isChange;
if (that.endState && that.autoCalendarModel.auto) {
isChange = that.autoCalendarModel();
}
var isSameDate = that.startDate.year === that.endDate.year && that.startDate.month === that.endDate.month && that.startDate.date === that.endDate.date;
if (that.calendarLinkage && that.endState && that.newDate(that.startDate) > that.newDate(that.endDate)) {
// 判断是否反选
var startDate = that.startDate;
that.startDate = lay.extend({}, that.endDate, isSameDate ? {} : that.startTime);
options.dateTime = lay.extend({}, that.startDate);
that.endDate = lay.extend({}, startDate, isSameDate ? {} : that.endTime);
isSameDate && ( // 如果是同一天并且出现了反选证明是时分秒出现开始时间大于结束时间的现象
startDate = that.startTime,
that.startTime = that.endTime,
that.endTime = startDate
)
}
isChange && (options.dateTime = lay.extend({}, that.startDate));
}
that.calendar(null, that.calendarLinkage ? null : index, isChange || that.calendarLinkage ? 'init' : null).done(null, 'change');
} else if(options.position === 'static'){ //直接嵌套的选中 } else if(options.position === 'static'){ //直接嵌套的选中
that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调 that.calendar().done().done(null, 'change'); //同时执行 done 和 change 回调
} else if(options.type === 'date'){ } else if(options.type === 'date'){
@ -1773,33 +1912,59 @@
return { return {
prevYear: function(){ prevYear: function(){
if(addSubYeay('sub')) return; if(addSubYeay('sub')) return;
dateTime.year--; if (that.calendarLinkage) {
that.checkDate('limit').calendar(null, index); options.dateTime.year--;
that.done(null, 'change'); that.checkDate('limit').calendar(null, null, 'init');
} else {
dateTime.year--;
that.checkDate('limit').calendar(null, index);
that.choose(lay(elemCont).find('td.layui-this'), index);
that.done(null, 'change');
}
} }
,prevMonth: function(){ ,prevMonth: function(){
if (that.calendarLinkage) {
dateTime = options.dateTime;
}
var YM = that.getAsYM(dateTime.year, dateTime.month, 'sub'); var YM = that.getAsYM(dateTime.year, dateTime.month, 'sub');
lay.extend(dateTime, { lay.extend(dateTime, {
year: YM[0] year: YM[0]
,month: YM[1] ,month: YM[1]
}); });
that.checkDate('limit').calendar(null, index);
that.done(null, 'change'); that.checkDate('limit').calendar(null, null, 'init');
if (!that.calendarLinkage) {
that.choose(lay(elemCont).find('td.layui-this'), index);
that.done(null, 'change');
}
} }
,nextMonth: function(){ ,nextMonth: function(){
if (that.calendarLinkage) {
dateTime = options.dateTime;
}
var YM = that.getAsYM(dateTime.year, dateTime.month); var YM = that.getAsYM(dateTime.year, dateTime.month);
lay.extend(dateTime, { lay.extend(dateTime, {
year: YM[0] year: YM[0]
,month: YM[1] ,month: YM[1]
}); });
that.checkDate('limit').calendar(null, index);
that.done(null, 'change'); that.checkDate('limit').calendar(null, null, 'init');
if (!that.calendarLinkage) {
that.choose(lay(elemCont).find('td.layui-this'), index);
that.done(null, 'change');
}
} }
,nextYear: function(){ ,nextYear: function(){
if(addSubYeay()) return; if(addSubYeay()) return;
dateTime.year++ if (that.calendarLinkage) {
that.checkDate('limit').calendar(null, index); options.dateTime.year++;
that.done(null, 'change'); that.checkDate('limit').calendar(null, 0, 'init');
} else {
dateTime.year++;
that.checkDate('limit').calendar(null, index);
that.choose(lay(elemCont).find('td.layui-this'), index);
that.done(null, 'change');
}
} }
}; };
}; };

View File

@ -87,16 +87,8 @@ layui.define('jquery',function(exports){
+ (i>Math.floor(options.value)?ICON_RATE:ICON_RATE_SOLID) + (i>Math.floor(options.value)?ICON_RATE:ICON_RATE_SOLID)
+ '" '+ style +'></i></li>'; + '" '+ style +'></i></li>';
if(options.half){ if(options.half&&parseInt(options.value) !== options.value&&i == Math.ceil(options.value)){
if(parseInt(options.value) !== options.value){ temp = temp + '<li><i class="layui-icon layui-icon-rate-half" '+ style +'></i></li>';
if(i == Math.ceil(options.value)){
temp = temp + '<li><i class="layui-icon layui-icon-rate-half" '+ style +'></i></li>';
}else{
temp = temp + item
}
}else{
temp = temp + item
}
}else{ }else{
temp = temp +item; temp = temp +item;
} }

View File

@ -438,18 +438,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
// 让表格平铺 // 让表格平铺
that.fullSize(); that.fullSize();
// 如果多级表头,则填补表头高度
if(options.cols.length > 1){
// 补全高度
var th = that.layFixed.find(ELEM_HEADER).find('th');
// 固定列表头同步跟本体 th 一致高度
var headerMain = that.layHeader.first();
layui.each(th, function (thIndex, thElem) {
thElem = $(thElem);
thElem.height(headerMain.find('th[data-key="' + thElem.attr('data-key') + '"]').height() + 'px');
})
}
that.pullData(that.page); //请求数据 that.pullData(that.page); //请求数据
that.events(); //事件 that.events(); //事件
}; };
@ -641,10 +629,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
hide ? parentColspan-- : parentColspan++; hide ? parentColspan-- : parentColspan++;
parentTh.attr('colspan', parentColspan); parentTh.attr('colspan', parentColspan);
parentTh[parentColspan < 1 ? 'addClass' : 'removeClass'](HIDE); parentTh[parentColspan >= 1 || !hide ? 'removeClass' : 'addClass'](HIDE); // 如果子列显示,父列必然需要显示
getThisCol.colspan = parentColspan; //同步 colspan 参数 getThisCol.colspan = parentColspan; //同步 colspan 参数
getThisCol.hide = parentColspan < 1; //同步 hide 参数 getThisCol.hide = parentColspan >= 1 || !hide; //同步 hide 参数
//递归,继续往上查询是否有父列 //递归,继续往上查询是否有父列
var nextParentKey = parentTh.data('parentkey'); var nextParentKey = parentTh.data('parentkey');
@ -1562,6 +1550,18 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
if (height < 135) height = 135; if (height < 135) height = 135;
that.elem.css("height", height); that.elem.css("height", height);
} }
// 如果多级表头,则填补表头高度
if(options.cols.length > 1){
// 补全高度
var th = that.layFixed.find(ELEM_HEADER).find('th');
// 固定列表头同步跟本体 th 一致高度
var headerMain = that.layHeader.first();
layui.each(th, function (thIndex, thElem) {
thElem = $(thElem);
thElem.height(headerMain.find('th[data-key="' + thElem.attr('data-key') + '"]').height() + 'px');
})
}
if(!height) return; if(!height) return;
@ -1702,7 +1702,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
var lis = []; var lis = [];
that.eachCols(function(i, item){ that.eachCols(function(i, item){
if(item.field && item.type == 'normal'){ if(item.field && item.type == 'normal'){
lis.push('<li><input type="checkbox" name="'+ item.field +'" data-key="'+ item.key +'" data-parentkey="'+ (item.parentKey||'') +'" lay-skin="primary" '+ (item.hide ? '' : 'checked') +' title="'+ util.escape($('<div>' + (item.title || item.field) + '</div>').text()) +'" lay-filter="LAY_TABLE_TOOL_COLS"></li>'); lis.push('<li><input type="checkbox" name="'+ item.field +'" data-key="'+ item.key +'" data-parentkey="'+ (item.parentKey||'') +'" lay-skin="primary" '+ (item.hide ? '' : 'checked') +' title="'+ util.escape($('<div>' + (item.fieldTitle || item.title || item.field) + '</div>').text()) +'" lay-filter="LAY_TABLE_TOOL_COLS"></li>');
} }
}); });
return lis.join(''); return lis.join('');
@ -2503,7 +2503,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
if(content === undefined || content === null) content = ''; if(content === undefined || content === null) content = '';
i1 == 0 && dataTitle.push(item3.title || ''); i1 == 0 && dataTitle.push(item3.fieldTitle || item3.title || item3.field || '');
vals.push('"'+ parseTempData.call(thatTable, { vals.push('"'+ parseTempData.call(thatTable, {
item3: item3 item3: item3
,content: content ,content: content

View File

@ -73,7 +73,7 @@ layui.define(['laytpl', 'form'], function(exports){
,'{{# if(d.data.showSearch){ }}' ,'{{# if(d.data.showSearch){ }}'
,'<div class="layui-transfer-search">' ,'<div class="layui-transfer-search">'
,'<i class="layui-icon layui-icon-search"></i>' ,'<i class="layui-icon layui-icon-search"></i>'
,'<input type="input" class="layui-input" placeholder="关键词搜索">' ,'<input type="text" class="layui-input" placeholder="关键词搜索">'
,'</div>' ,'</div>'
,'{{# } }}' ,'{{# } }}'
,'<ul class="layui-transfer-data"></ul>' ,'<ul class="layui-transfer-data"></ul>'