修复一些问题和加强一些功能

pull/1128/head
sunxiaobin89 2 years ago
parent 63250383ce
commit 1c10d93ed6

@ -290,10 +290,8 @@
} }
//设置唯一KEY //设置唯一KEY
// if(!options.elem.attr('lay-key')){
options.elem.attr('lay-key', that.index); options.elem.attr('lay-key', that.index);
options.eventElem.attr('lay-key', that.index); options.eventElem.attr('lay-key', that.index);
// }
//记录重要日期 //记录重要日期
options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? { options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? {
@ -514,23 +512,6 @@
options.showBottom && elem.appendChild(divFooter); options.showBottom && elem.appendChild(divFooter);
//生成自定义主题 //生成自定义主题
// if(/^#/.test(options.theme)){
// var style = lay.elem('style')
// ,styleText = [
// '#{{id}} .layui-laydate-header{background-color:{{theme}};}'
// ,'#{{id}} .layui-this{background-color:{{theme}} !important;}'
// ].join('').replace(/{{id}}/g, that.elemID).replace(/{{theme}}/g, options.theme);
//
// if('styleSheet' in style){
// style.setAttribute('type', 'text/css');
// style.styleSheet.cssText = styleText;
// } else {
// style.innerHTML = styleText;
// }
//
// lay(elem).addClass('laydate-theme-molv');
// elem.appendChild(style);
// }
var style; var style;
var styleText = []; var styleText = [];
lay.each(options.theme, function (index, theme) { lay.each(options.theme, function (index, theme) {
@ -1730,39 +1711,26 @@
var that = this var that = this
var options = that.config var options = that.config
//绑定呼出控件事件
// var showEvent = function(elem, bind){
// elem.on(options.trigger, function(){
// //已经打开的面板避免重新渲染
// if(laydate.thisId === options.id) return;
// bind && (that.bindElem = this);
// that.render();
// });
// };
if(!options.elem[0] || options.elem[0].eventHandler) return; if(!options.elem[0] || options.elem[0].eventHandler) return;
// showEvent(options.elem, 'bind'); var showEvent = function(){
// showEvent(options.eventElem);
var showFn = function(){
// 已经打开的面板避免重新渲染 // 已经打开的面板避免重新渲染
if(laydate.thisId === options.id) return; if(laydate.thisId === options.id) return;
that.bindElem = this; that.bindElem = this;
that.render(); that.render();
} }
options.elem.on(options.trigger, showFn); //绑定呼出控件事件
options.elem.on(options.trigger, showEvent);
options.elem[0].eventHandler = true; options.elem[0].eventHandler = true;
options.eventElem.on(options.trigger, showFn); options.eventElem.on(options.trigger, showEvent);
options.eventElem[0].eventHandler = true;
that.destroy = function () { that.destroy = function () {
that.remove(); that.remove();
layui.each(['elem', 'eventElem'], function (index, name) { options.elem.off(options.trigger, showEvent);
options[name].off(options.trigger, showFn); options.elem.removeAttr('lay-key');
options[name][0].eventHandler = false; options.elem[0].eventHandler = false;
options[name].removeAttr('lay-key'); options.eventElem.off(options.trigger, showEvent);
}) options.eventElem.removeAttr('lay-key');
delete thisModule.that[options.id]; delete thisModule.that[options.id];
} }

@ -786,9 +786,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){
// 给设定百分比的列分配列宽 // 给设定百分比的列分配列宽
else if(/\d+%$/.test(item3.width)){ else if(/\d+%$/.test(item3.width)){
that.getCssRule(options.index +'-'+ item3.key, function(item){ that.getCssRule(item3.key, function(item){
var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth); // 计算结果有可能大于最大或者小于最小 todo var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth);
item.style.width = (width < minWidth ? minWidth : width) + 'px'; width < minWidth && (width = minWidth);
width > maxWidth && (width = maxWidth);
item.style.width = width + 'px';
}); });
} }

Loading…
Cancel
Save