From 1c10d93ed6a2bbd72da0cbd9d97743a4189ff5bf Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Wed, 31 Aug 2022 12:48:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E5=92=8C=E5=8A=A0=E5=BC=BA=E4=B8=80=E4=BA=9B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/laydate.js | 54 +++++++++--------------------------------- src/modules/table.js | 8 ++++--- 2 files changed, 16 insertions(+), 46 deletions(-) diff --git a/src/modules/laydate.js b/src/modules/laydate.js index ab2836fe..976b0e10 100644 --- a/src/modules/laydate.js +++ b/src/modules/laydate.js @@ -290,11 +290,9 @@ } //设置唯一KEY - // if(!options.elem.attr('lay-key')){ options.elem.attr('lay-key', that.index); options.eventElem.attr('lay-key', that.index); - // } - + //记录重要日期 options.mark = lay.extend({}, (options.calendar && options.lang === 'cn') ? { '0-1-1': '元旦' @@ -514,23 +512,6 @@ 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 styleText = []; lay.each(options.theme, function (index, theme) { @@ -1730,39 +1711,26 @@ var that = this 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; - // showEvent(options.elem, 'bind'); - // showEvent(options.eventElem); - - var showFn = function(){ - //已经打开的面板避免重新渲染 + var showEvent = function(){ + // 已经打开的面板避免重新渲染 if(laydate.thisId === options.id) return; that.bindElem = this; that.render(); } - options.elem.on(options.trigger, showFn); + //绑定呼出控件事件 + options.elem.on(options.trigger, showEvent); options.elem[0].eventHandler = true; - options.eventElem.on(options.trigger, showFn); - options.eventElem[0].eventHandler = true; + options.eventElem.on(options.trigger, showEvent); that.destroy = function () { that.remove(); - layui.each(['elem', 'eventElem'], function (index, name) { - options[name].off(options.trigger, showFn); - options[name][0].eventHandler = false; - options[name].removeAttr('lay-key'); - }) + options.elem.off(options.trigger, showEvent); + options.elem.removeAttr('lay-key'); + options.elem[0].eventHandler = false; + options.eventElem.off(options.trigger, showEvent); + options.eventElem.removeAttr('lay-key'); delete thisModule.that[options.id]; } diff --git a/src/modules/table.js b/src/modules/table.js index 5bc36b7e..ec62da14 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -786,9 +786,11 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 给设定百分比的列分配列宽 else if(/\d+%$/.test(item3.width)){ - that.getCssRule(options.index +'-'+ item3.key, function(item){ - var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth); // 计算结果有可能大于最大或者小于最小 todo - item.style.width = (width < minWidth ? minWidth : width) + 'px'; + that.getCssRule(item3.key, function(item){ + var width = Math.floor((parseFloat(item3.width) / 100) * cntrWidth); + width < minWidth && (width = minWidth); + width > maxWidth && (width = maxWidth); + item.style.width = width + 'px'; }); }