laydate修复一些问题新增快捷选项功能;table新增maxHeight配置

pull/1135/head
sunxiaobin89 2022-09-18 18:06:39 +08:00
parent e1222cf891
commit 118cd98c9f
3 changed files with 43 additions and 23 deletions

View File

@ -76,9 +76,9 @@ html #layuicss-laydate{display: none; position: absolute; width: 1989px;}
.laydate-footer-btns span{margin: 0 0 0 -1px;}
/* 快捷栏 */
.layui-laydate-shortcut{width: 80px;display: inline-block;vertical-align: top;overflow: hidden;max-height: 276px;}
.layui-laydate-shortcut+.layui-laydate-main{border-left: 1px solid #e2e2e2;}
.layui-laydate-shortcut>li{padding: 6px;cursor: pointer;}
.layui-laydate-shortcut{width: 80px;display: inline-block;vertical-align: top;overflow: auto;max-height: 276px;}
.layui-laydate-shortcut+.layui-laydate-main{display: inline-block;border-left: 1px solid #e2e2e2;}
.layui-laydate-shortcut>li{padding: 6px;cursor: pointer;line-height: 18px;}
/* 年月列表 */
.layui-laydate-list{position: absolute; left: 0; top: 0; width: 100%; height: 100%; padding: 10px; box-sizing: border-box; background-color: #fff;}

View File

@ -528,19 +528,34 @@
return html.join('');
}());
//生成快捷键栏
elem.appendChild(divShortcut);
lay(divShortcut).html(function () {
var shortcutBtns = [];
lay.each(options.shortcuts, function (i, item) {
shortcutBtns.push('<li>'+item.text+'</li>')
// 生成快捷键栏
if (options.shortcuts) {
elem.appendChild(divShortcut);
lay(divShortcut).html(function () {
var shortcutBtns = [];
lay.each(options.shortcuts, function (i, item) {
shortcutBtns.push('<li data-index="' + i + '">'+item.text+'</li>')
})
return shortcutBtns.join('');
}()).find('li').on('click', function (event) {
var btnSetting = options.shortcuts[this.dataset['index']] || {};
var value = btnSetting.value || [];
if (!layui.isArray(value)) {
value = [value];
}
lay.each(value, function (i, item) {
lay.extend([options.dateTime, that.endDate][i], that.systemDate(layui.type(item) === 'date' ? item : new Date(item)))
that.checkDate('limit').calendar(null,i);
});
that.closeList();
var timeBtn = lay(that.footer).find('.'+ ELEM_TIME_BTN).removeClass(DISABLED);
timeBtn.attr('lay-type') === 'date' && timeBtn.click();
that.done(null, 'change');
lay(this).addClass(THIS);
})
return shortcutBtns.join('');
}()).find('li').on('click', function (event) {
lay(this.parentElement).find('li.layui-this').removeClass(THIS);
lay(this).addClass(THIS);
})
}
//插入到主区域
lay.each(elemMain, function(i, main){
elem.appendChild(main);
@ -1087,6 +1102,9 @@
//同步按钮可点状态
that.setBtnStatus();
// 重置快捷栏选中状态
lay(that.shortcut).find('li.' + THIS).removeClass(THIS);
return that;
};

View File

@ -355,6 +355,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
type: 'reloadData'
});
}
// 初始化索引
options.index = that.index;
that.key = options.id || options.index;
//初始化一些其他参数
that.setInit();
//高度铺满full-差距值
if(options.height && /^full-\d+$/.test(options.height)){
@ -367,13 +374,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
options.height = $(that.parentDiv).height() - that.parentHeightGap;
}
// 初始化索引
options.index = that.index;
that.key = options.id || options.index;
//初始化一些其他参数
that.setInit();
//开始插入替代元素
var othis = options.elem
,hasRender = othis.next('.' + ELEM_VIEW)
@ -488,6 +488,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
}();
if(type === 'width') return options.clientWidth;
// 初始化高度配置,如果设置了最高高度,以最高高度形式为准
options.height = options.maxHeight || options.height;
// 初始化 css 参数
if(options.css && options.css.indexOf(ELEM_VIEW) === -1){
@ -1567,7 +1569,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
bodyHeight -= (that.layPage.outerHeight() || 43);
}
if (options.adaptiveHeight) {
if (options.maxHeight) {
layui.each({elem: height, layMain: bodyHeight}, function (elemName, elemHeight) {
that[elemName].css({
height: 'auto',