From 777e0a19996e0434e6b76896db21b2b67b1a3a64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Sun, 18 Jun 2023 23:53:43 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E5=8F=96=E6=B6=88=20#1280=20=E5=85=B3?= =?UTF-8?q?=E4=BA=8E=20select=20=E7=9A=84=E5=86=85=E5=AE=B9=EF=BC=8C?= =?UTF-8?q?=E7=94=B1=E4=BA=8E=E5=AD=98=E5=9C=A8=E8=8B=A5=E5=B9=B2=E4=B8=8D?= =?UTF-8?q?=E5=8F=AF=E6=8E=A7=E7=9A=84=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/versions.md | 13 +++++++------ src/modules/form.js | 8 -------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/docs/versions.md b/docs/versions.md index 857a3f10..dc210690 100644 --- a/docs/versions.md +++ b/docs/versions.md @@ -17,23 +17,24 @@ toc: true 2023-06-16 -#### form - - 优化 `select` 开启搜索时输入状态,将值转义到 `placeholder`,便于输入 # 1280 -#### table +- #### form + - ~~优化 `select` 开启搜索时输入状态,将值转移到 `placeholder`,便于输入~~ # 1280 +
*注:由于存在若干影响,该项功能已在 `2.8.8` 中取消* +- #### table - 新增 表头复选框的半选效果,当数据项部分选中且未全选时显示 - 优化 `table.setRowChecked()` 方法,新增当前行选中背景色,便于与 hover 等活动背景色区分 - 剔除 `table.setRowChecked()` 方法中的 `selectedStyle` 属性,因为没有实质意义 - 优化 表头部分字段为 `hide` 在数据异常的情况下可能出现的表头错位的问题 # 1281 - 优化 `done` 回调函数,新增参数 `origin` 用于区分重载和重新渲染数据 # 1281 - 加强 `ignoreExport` 表头属性,允许指定不排除哪些字段 # 1281 -#### treeTable +- #### treeTable - 新增 `view.expandAllDefault` 属性,用于设置是否默认展开全部节点 # 1281 - 修复 开启排序且在 `done` 回调中执行了 `expandAll` 展开全部导致死循环问题 # 1281 - 修复 执行 `treeTable.reload(id)` 若 `id` 未匹配到对应实例时出现的报错问题 # 1281/I7CXLN -#### grid +- #### grid - 修复 space30 和 space32 边距相同的问题 # I7D7YP -### 下载: [layui-v2.8.7.zip](https://gitee.com/layui/layui/attach_files/1441026/download) +- ### 下载: [layui-v2.8.7.zip](https://gitee.com/layui/layui/attach_files/1441026/download) --- diff --git a/src/modules/form.js b/src/modules/form.js index 80ddf21f..38e44887 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -317,14 +317,6 @@ layui.define(['lay', 'layer', 'util'], function(exports){ if(top + dlHeight > $win.height() && top >= dlHeight){ reElem.addClass(CLASS + 'up'); } - - // 删除 input 已有文本并放入 placeholder,方便输入 - var inputValue = $.trim(input.val()); - // 有值时才删除并替换 placeholder - if(inputValue){ - input.attr('placeholder', inputValue); - input.val(''); // 清空输入框的值 - } followScroll(); }; From 7eef6ea99c06691259c31b766e01252e4c8e7c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Mon, 19 Jun 2023 00:19:25 +0800 Subject: [PATCH 02/15] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E5=B1=80?= =?UTF-8?q?=E9=83=A8=E4=BB=A3=E7=A0=81=E6=8E=92=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 95856060..7859168c 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1809,13 +1809,13 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var _BODY = $('body'); var dict = {}; - // 工具栏操作事件 + // 头部工具栏操作事件 that.layTool.on('click', '*[lay-event]', function(e){ - var othis = $(this) - ,events = othis.attr('lay-event') - ,openPanel = function(sets){ - var list = $(sets.list) - ,panel = $(''); + var othis = $(this); + var events = othis.attr('lay-event'); + var openPanel = function(sets){ + var list = $(sets.list); + var panel = $(''); panel.html(list); From 9d678a6be62e516b116e94c46a7f0c924a8b4438 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:02:50 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20table=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E8=BF=94=E5=9B=9E=E7=9A=84=20`dataCache`=20=E5=85=AC?= =?UTF-8?q?=E5=85=B1=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/table.js b/src/modules/table.js index 7859168c..47c2aa9c 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2113,6 +2113,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ tr: tr, // 行元素 config: options, data: table.clearCacheKey(data), // 当前行数据 + dataCache: data, // 当前行缓存中的数据 index: index, del: function(){ // 删除行数据 table.cache[that.key][index] = []; From 3c8d20d23d256e8309e7d42d52540cb9654f18f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:03:36 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20table=20`colTool`=20?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E7=82=B9=E5=87=BB=E8=A1=A8=E5=A4=B4?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E5=85=83=E7=B4=A0=E8=A7=A6=E5=8F=91?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=20table=20=E7=9A=84=E5=8F=AF?= =?UTF-8?q?=E7=8E=A9=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 2 ++ src/modules/table.js | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/css/layui.css b/src/css/layui.css index 64c206b7..f44e9f6a 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -1011,7 +1011,9 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-view .layui-table[lay-skin="row"]{border-width: 0; border-bottom-width: 1px;} .layui-table-view .layui-table th, .layui-table-view .layui-table td{padding: 0; border-top: none; border-left: none;} +.layui-table-view .layui-table th [lay-event], .layui-table-view .layui-table th.layui-unselect .layui-table-cell span{cursor: pointer;} +.layui-table-view .layui-table th span, .layui-table-view .layui-table td{cursor: default;} .layui-table-view .layui-table td[data-edit]{cursor: text;} .layui-table-view .layui-table td[data-edit]:hover:after{position: absolute; left: 0; top: 0; width: 100%; height: 100%; box-sizing: border-box; border: 1px solid #16B777; pointer-events: none; content: "";} diff --git a/src/modules/table.js b/src/modules/table.js index 47c2aa9c..9ecb5314 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -1948,6 +1948,21 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ },{})); }); + // 表头自定义元素事件 + that.layHeader.on('click', '*[lay-event]', function(e){ + var othis = $(this); + var events = othis.attr('lay-event'); + var th = othis.closest('th'); + var key = th.data('key'); + var col = that.col(key); + + layui.event.call(this, MOD_NAME, 'colTool('+ filter +')', $.extend({ + event: events, + config: options, + col: col + },{})); + }); + // 分页栏操作事件 that.layPagebar.on('click', '*[lay-event]', function(e){ var othis = $(this); From 6b967442ab74886e43a63f7e585506ed954e8067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Mon, 19 Jun 2023 17:04:33 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20upload=20=E7=9A=84?= =?UTF-8?q?=20`unified`=20=E5=B1=9E=E6=80=A7=EF=BC=8C=E7=94=A8=E4=BA=8E?= =?UTF-8?q?=E5=A4=9A=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0=E6=97=B6=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E4=B8=80=E8=B5=B7=E4=B8=8A=E4=BC=A0=EF=BC=8C=E5=8D=B3?= =?UTF-8?q?=E5=8F=AA=E5=8F=91=E9=80=81=E4=B8=80=E4=B8=AA=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/upload.js | 164 +++++++++++++++++++++++------------------- 1 file changed, 92 insertions(+), 72 deletions(-) diff --git a/src/modules/upload.js b/src/modules/upload.js index 24b00bfd..5ac07a7d 100644 --- a/src/modules/upload.js +++ b/src/modules/upload.js @@ -182,78 +182,97 @@ layui.define(['lay','layer'], function(exports){ return files || that.files || that.chooseFiles || elemFile.files; }; - //高级浏览器处理方式,支持跨域 + // 高级浏览器处理方式,支持跨域 var ajaxSend = function(){ var successful = 0; - var failed = 0 + var failed = 0; var items = getFiles(); - var allDone = function(){ // 多文件全部上传完毕的回调 + + // 多文件全部上传完毕的回调 + var allDone = function(){ if(options.multiple && successful + failed === that.fileLength){ typeof options.allDone === 'function' && options.allDone({ - total: that.fileLength - ,successful: successful - ,failed: failed + total: that.fileLength, + successful: successful, + failed: failed }); } }; - layui.each(items, function(index, file){ + + // 发送请求 + var request = function(sets){ var formData = new FormData(); - - //追加额外的参数 + + // 追加额外的参数 layui.each(options.data, function(key, value){ value = typeof value === 'function' ? value() : value; formData.append(key, value); }); - - //最后添加 file 到表单域 - formData.append(options.field, file); - - //提交文件 + + // 添加 file 到表单域 + sets.unified ? layui.each(items, function(index, file){ + formData.append(options.field, file); + }) : formData.append(options.field, sets.file); + + // ajax 参数 var opts = { - url: options.url - ,type: 'post' //统一采用 post 上传 - ,data: formData - ,contentType: false - ,processData: false - ,dataType: 'json' - ,headers: options.headers || {} - //成功回调 - ,success: function(res){ - successful++; - done(index, res); + url: options.url, + type: 'post', // 统一采用 post 上传 + data: formData, + contentType: false, + processData: false, + dataType: 'json', + headers: options.headers || {}, + success: function(res){ // 成功回调 + options.unified ? (successful += that.fileLength) : successful++; + done(sets.index, res); allDone(); - } - //异常回调 - ,error: function(e){ - failed++; + }, + error: function(e){ // 异常回调 + options.unified ? (failed += that.fileLength) : failed++; that.msg([ 'Upload failed, please try again.', 'status: '+ (e.status || '') +' - '+ (e.statusText || 'error') ].join('
')); - error(index); + error(sets.index); allDone(); } }; - //进度条 + // 进度条 if(typeof options.progress === 'function'){ opts.xhr = function(){ var xhr = $.ajaxSettings.xhr(); - //上传进度 + // 上传进度 xhr.upload.addEventListener("progress", function (obj) { if(obj.lengthComputable){ - var percent = Math.floor((obj.loaded/obj.total)* 100); //百分比 - options.progress(percent, (options.item ? options.item[0] : options.elem[0]) , obj, index); + var percent = Math.floor((obj.loaded/obj.total)* 100); // 百分比 + options.progress(percent, (options.item ? options.item[0] : options.elem[0]) , obj, sets.index); } }); return xhr; } } $.ajax(opts); - }); - } + }; + + // 多文件是否一起上传 + if(options.unified){ + request({ + unified: true, + index: 0 + }); + } else { + layui.each(items, function(index, file){ + request({ + index: index, + file: file + }); + }); + } + }; - //低版本 IE 处理方式,不支持跨域 - ,iframeSend = function(){ + // 低版本 IE 处理方式,不支持跨域 + var iframeSend = function(){ var iframe = $('#'+ ELEM_IFRAME); that.elemFile.parent().submit(); @@ -275,10 +294,10 @@ layui.define(['lay','layer'], function(exports){ done(0, res); } }, 30); - } + }; - //统一回调 - ,done = function(index, res){ + // 统一回调 + var done = function(index, res){ that.elemFile.next('.'+ ELEM_CHOOSE).remove(); elemFile.value = ''; @@ -296,74 +315,75 @@ layui.define(['lay','layer'], function(exports){ typeof options.done === 'function' && options.done(res, index || 0, function(files){ that.upload(files); }); - } + }; - //统一网络异常回调 - ,error = function(index){ + // 统一网络异常回调 + var error = function(index){ if(options.auto){ elemFile.value = ''; } typeof options.error === 'function' && options.error(index || 0, function(files){ that.upload(files); }); - } + }; - ,exts = options.exts - ,check ,value = function(){ + var check; + var exts = options.exts; + var value = function(){ var arr = []; layui.each(files || that.chooseFiles, function(i, item){ arr.push(item.name); }); return arr; - }() + }(); - //回调返回的参数 - ,args = { - //预览 + // 回调函数返回的参数 + var args = { + // 预览 preview: function(callback){ that.preview(callback); - } - //上传 - ,upload: function(index, file){ + }, + // 上传 + upload: function(index, file){ var thisFile = {}; thisFile[index] = file; that.upload(thisFile); - } - //追加文件到队列 - ,pushFile: function(){ + }, + // 追加文件到队列 + pushFile: function(){ that.files = that.files || {}; layui.each(that.chooseFiles, function(index, item){ that.files[index] = item; }); return that.files; - } - //重置文件 - ,resetFile: function(index, file, filename){ + }, + // 重置文件 + resetFile: function(index, file, filename){ var newFile = new File([file], filename); that.files = that.files || {}; that.files[index] = newFile; } - } + }; - //提交上传 - ,send = function(){ - //上传前的回调 - 如果回调函数明确返回false,则停止上传(#pulls55) + // 提交上传 + var send = function(){ + // 上传前的回调 - 如果回调函数明确返回 false,则停止上传 if(options.before && (options.before(args) === false)) return; - //IE兼容处理 + // IE兼容处理 if(device.ie){ return device.ie > 9 ? ajaxSend() : iframeSend(); } ajaxSend(); - } + }; - //文件类型名称 - ,typeName = ({ - file: '文件' - ,images: '图片' - ,video: '视频' - ,audio: '音频' + // 文件类型名称 + var typeName = ({ + file: '文件', + images: '图片', + video: '视频', + audio: '音频' })[options.accept] || '文件'; //校验文件格式 From 1f4a44fd42d0c477d4445ff6e4bee8325c21376c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Mon, 19 Jun 2023 18:27:39 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20`input`=20=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=84=A6=E7=82=B9=E6=97=B6=E7=9A=84=E5=85=89=E7=8E=AF?= =?UTF-8?q?=E6=95=88=E6=9E=9C=EF=BC=8C=E4=BB=A5=E6=8F=90=E5=8D=87=E5=BD=93?= =?UTF-8?q?=E5=89=8D=E8=BE=93=E5=85=A5=E6=A1=86=E7=9A=84=E8=BE=A8=E5=88=AB?= =?UTF-8?q?=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/css/layui.css | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/css/layui.css b/src/css/layui.css index f44e9f6a..eb8021e3 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -720,7 +720,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-select::-webkit-input-placeholder{line-height: 1.3;} .layui-input, .layui-textarea{display: block; width: 100%; padding-left: 10px;} .layui-input:hover, .layui-textarea:hover{border-color: #d2d2d2 !important;} -.layui-input:focus, .layui-textarea:focus{border-color: #d2d2d2 !important;} +.layui-input:focus, .layui-textarea:focus{border-color: #16b777 !important; box-shadow: 0 0 0 3px rgba(22,183,119,0.08);} .layui-textarea{position: relative; min-height: 100px; height: auto; line-height: 20px; padding: 6px 10px; resize: vertical;} .layui-select{padding: 0 10px;} .layui-form select, @@ -744,7 +744,7 @@ a cite{font-style: normal; *cursor:pointer;} /* 警告条 */ .layui-form-danger:focus, -.layui-form-danger+.layui-form-select .layui-input{border-color: #ff5722 !important;} +.layui-form-danger+.layui-form-select .layui-input{border-color: #ff5722 !important; box-shadow: 0 0 0 3px rgba(255,87,34,0.08);} /* 输入框点缀 */ @@ -780,7 +780,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-input-wrap .layui-input-prefix, .layui-input-wrap .layui-input-suffix, .layui-input-wrap .layui-input-split{pointer-events: none;} -.layui-input-wrap .layui-input:focus + .layui-input-split{border-color: #d2d2d2;} +.layui-input-wrap .layui-input:focus + .layui-input-split{border-color: #16b777;} .layui-input-wrap .layui-input-prefix.layui-input-split{border-width: 0; border-right-width: 1px;} /* 输入框动态点缀 */ From fddfed030006fb33f5ff83942229f5bf721289eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Tue, 20 Jun 2023 00:03:02 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20upload=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/upload.html | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/upload.html b/examples/upload.html index c0e7358d..3d8fd50c 100644 --- a/examples/upload.html +++ b/examples/upload.html @@ -92,9 +92,9 @@ hr{margin: 30px 0;}