From 1b57e28a978ce4594a04d1ffc77b0665172f12e7 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <470459819@qq.com> Date: Mon, 12 Jun 2023 22:50:28 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20table=20=E5=A4=8D?= =?UTF-8?q?=E6=9D=82=E8=A1=A8=E5=A4=B4=E9=83=A8=E5=88=86=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=20hide=20=E5=9C=A8=E6=95=B0=E6=8D=AE=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E7=9A=84=E6=83=85=E5=86=B5=E4=B8=8B=E5=87=BA=E7=8E=B0=E8=A1=A8?= =?UTF-8?q?=E5=A4=B4=E9=94=99=E4=BD=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 1ccb6b0b..ed44fb1d 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -919,6 +919,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ Class.prototype.pullData = function(curr, opts){ var that = this; var options = that.config; + // 同步表头父列的相关值 + options.HAS_SET_COLS_PATCH || that.setColsPatch(); + options.HAS_SET_COLS_PATCH = true; var request = options.request; var response = options.response; var sort = function(){ @@ -1229,10 +1232,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 渲染视图 var render = function(){ // 后续性能提升的重点 - // 同步表头父列的相关值 - options.HAS_SET_COLS_PATCH || that.setColsPatch(); - options.HAS_SET_COLS_PATCH = true; - if(!sort && that.sortKey){ return that.sort({ field: that.sortKey.field, From 94a951d392a7a0a596c57e117d3ac1afa82894de Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 13 Jun 2023 13:50:18 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20`reload(?= =?UTF-8?q?id)`=20=E5=A6=82=E6=9E=9C=E6=89=BE=E4=B8=8D=E5=88=B0=20id=20?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E5=AE=9E=E4=BE=8B=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 9bf348c1..e6115e35 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -54,11 +54,6 @@ layui.define(['table'], function (exports) { return that || null; } - // 获取当前实例配置项 - var getThisTableConfig = function (id) { - return getThisTable(id).config; - } - // 字符 var MOD_NAME = 'treeTable'; var HIDE = 'layui-hide'; @@ -1856,12 +1851,9 @@ layui.define(['table'], function (exports) { // 重载 treeTable.reload = function (id, options, deep, type) { deep = deep !== false; // 默认采用深拷贝 - var config = getThisTableConfig(id); // 获取当前实例配置项 - if (!config) return; - var that = getThisTable(id); + if (!that) return; that.reload(options, deep, type); - return thisTreeTable.call(that); }; From 9f9c2a72eba196c136aafaf1724f78a7693ff7e9 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 13 Jun 2023 15:14:44 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E5=8A=A0=E5=BC=BA=20table=20`ignoreExpor?= =?UTF-8?q?t`=20=E7=9A=84=E9=85=8D=E7=BD=AE=E6=94=AF=E6=8C=81=EF=BC=8C?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E6=8C=87=E5=AE=9A=E4=B8=8D=E6=8E=92=E9=99=A4?= =?UTF-8?q?=E5=93=AA=E4=BA=9B=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/table.js b/src/modules/table.js index ed44fb1d..e42c24c4 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -84,6 +84,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var options = this.config || {}; var item3 = obj.item3; // 表头数据 var content = obj.content; // 原始内容 + if (item3.type === 'numbers') content = obj.tplData[table.config.numbersName]; // 是否编码 HTML var escaped = 'escape' in item3 ? item3.escape : options.escape; @@ -2741,7 +2742,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ }); } else { table.eachCols(id, function(i3, item3){ - if(item3.field && item3.type == 'normal'){ + if(item3.ignoreExport === false || item3.field && item3.type == 'normal'){ // 不导出隐藏列 if(item3.hide || item3.ignoreExport){ if(i1 == 0) fieldsIsHide[item3.field] = true; // 记录隐藏列 From f57f36199cc7bd8516f07c44a284eed407d130ee Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Tue, 13 Jun 2023 18:10:55 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E8=A1=8C=E5=86=85=E7=82=B9=E5=87=BB=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=B4=BB=E5=8A=A8=E8=A1=8C=E7=9A=84=E5=92=8C=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=9A=84=E8=B0=83=E7=94=A8=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index e42c24c4..3924f0fd 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -2444,6 +2444,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var othis = $(this); var td = othis.closest('td'); var index = othis.parents('tr').eq(0).data('index'); + // 标记当前活动行 + that.setRowActive(index); + // 执行事件 layui.event.call( this, @@ -2456,8 +2459,6 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ } }) ); - // 标记当前活动行 - that.setRowActive(index); }; // 行工具条单击事件 From c480f4928a938af8758b825af827382acb7e7db2 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 14 Jun 2023 11:27:23 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E4=BC=98=E5=8C=96=20table=20`done`=20?= =?UTF-8?q?=E5=9B=9E=E8=B0=83=E6=96=B0=E5=A2=9E=E4=B8=80=E4=B8=AA=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20`isRenderData`=20=E5=8C=BA=E5=88=86=E9=87=8D?= =?UTF-8?q?=E8=BD=BD=E5=92=8C=E9=87=8D=E6=96=B0=E6=B8=B2=E6=9F=93=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 3924f0fd..a97a904f 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -934,10 +934,10 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ }); } }; - var done = function(res){ + var done = function(res, isRenderData){ that.setColsWidth(); typeof options.done === 'function' && options.done( - res, curr, res[response.countName] + res, curr, res[response.countName], isRenderData ); }; @@ -964,7 +964,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ curr: curr, count: res[response.countName], type: opts.type, - }), sort(), done(res); + }), sort(), done(res, true); } else if(options.url){ // Ajax请求 var params = {}; // 当 page 开启,默认自动传递 page、limit 参数 From 9576df6908167f6f68f90100faea4eedff0721bf Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 14 Jun 2023 11:34:19 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20?= =?UTF-8?q?=E5=BC=80=E5=90=AF=E4=BA=86=E6=8E=92=E5=BA=8F=E5=B9=B6=E4=B8=94?= =?UTF-8?q?=E5=9C=A8=20`done`=20=E5=9B=9E=E8=B0=83=E4=B8=AD=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E4=BA=86=20`expandAll`=20=E5=B1=95=E5=BC=80=E5=85=A8?= =?UTF-8?q?=E9=83=A8=E5=AF=BC=E8=87=B4=E6=AD=BB=E5=BE=AA=E7=8E=AF=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index e6115e35..0da38eac 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -171,6 +171,11 @@ layui.define(['table'], function (exports) { options.done = function () { var args = arguments; var doneThat = this; + that.initSort = doneThat.initSort; + var isRenderData = args[3]; // 是否是 renderData + if (!isRenderData) { + delete that.isExpandAll; + } var tableView = this.elem.next(); that.updateStatus(null, { @@ -891,7 +896,9 @@ layui.define(['table'], function (exports) { d[idKey] !== undefined && (that.status.expand[d[idKey]] = true); } }); - if (options.initSort && options.initSort.type && (!options.url || options.autoSort)) { + if (options.initSort && options.initSort.type && + (!that.initSort || options.initSort.type !== that.initSort.type && options.initSort.field !== that.initSort.field) && + (!options.url || options.autoSort)) { return treeTable.sort(id); } var trAll = table.getTrHtml(id, tableDataFlat); From 451a1df48b1da58cb7c125731f99b53eab99bccf Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 14 Jun 2023 11:38:11 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20treeTable=20`expandA?= =?UTF-8?q?llDefault`=20=E6=98=AF=E5=90=A6=E9=BB=98=E8=AE=A4=E5=B1=95?= =?UTF-8?q?=E5=BC=80=E5=85=A8=E9=83=A8=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index 0da38eac..c5cc0f6c 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -230,6 +230,7 @@ layui.define(['table'], function (exports) { id: "id", // 唯一标识的属性名称 pid: "parentId", // 父节点唯一标识的属性名称 icon: "icon", // 图标的属性名称 + expandAllDefault: false, // 默认展开所有节点 }, view: { indent: 14, // 层级缩进量 @@ -738,6 +739,7 @@ layui.define(['table'], function (exports) { } } } else { + treeTableThat.isExpandAll = false; // 关闭 if (sonSign && !isToggle) { // 非状态切换的情况下 layui.each(childNodes, function (i1, item1) { @@ -812,8 +814,9 @@ layui.define(['table'], function (exports) { } var that = getThisTable(id); - if(!that) return; + if (!that) return; + that.isExpandAll = expandFlag; var options = that.getOptions(); var treeOptions = options.tree; var tableView = options.elem.next(); @@ -1014,6 +1017,10 @@ layui.define(['table'], function (exports) { }); }); + if (!level && treeOptions.view.expandAllDefault && that.isExpandAll === undefined) { + return treeTable.expandAll(tableId, true); // 默认展开全部 + } + // 当前层的数据看看是否需要展开 if (sonSign !== false && dataExpand) { layui.each(dataExpand, function (index, item) { From 5051ef8d9044f4504edcfa196876de93436f9cae Mon Sep 17 00:00:00 2001 From: zhangyutong <53220154+zhangyutongdeyonghuming@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:00:17 +0000 Subject: [PATCH 08/10] =?UTF-8?q?=E5=88=A0=E9=99=A4input=E5=B7=B2=E6=9C=89?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E5=B9=B6=E6=94=BE=E5=85=A5=20placeholder?= =?UTF-8?q?=EF=BC=8C=E6=96=B9=E4=BE=BF=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/form.js b/src/modules/form.js index 8003a01a..792536d9 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -314,6 +314,10 @@ layui.define(['lay', 'layer', 'util'], function(exports){ reElem.addClass(CLASS + 'up'); } + // 删除input已有文本并放入 placeholder,方便输入 + input.attr('placeholder', input.val()); + input.val(''); // 清空输入框的值 + followScroll(); } From 5a6b5a1bd08f74c7fd36d9c730f7470a2e458987 Mon Sep 17 00:00:00 2001 From: sunxiaobin89 <285584806@qq.com> Date: Wed, 14 Jun 2023 21:00:58 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20treeTable=20?= =?UTF-8?q?=E5=B1=95=E5=BC=80=E5=85=A8=E9=83=A8=E4=B9=8B=E5=90=8E=E5=AD=90?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=B2=A1=E6=9C=89=E6=8C=89=E7=85=A7=E5=BD=93?= =?UTF-8?q?=E5=89=8D=20`initSort`=20=E6=8E=92=E5=BA=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/treeTable.js | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/src/modules/treeTable.js b/src/modules/treeTable.js index c5cc0f6c..a2f0e838 100644 --- a/src/modules/treeTable.js +++ b/src/modules/treeTable.js @@ -161,9 +161,6 @@ layui.define(['table'], function (exports) { if (treeOptions.data.isSimpleData) { options.data = that.flatToTree(options.data); } - if (options.initSort && options.initSort.type) { - layui.sort(options.data, options.initSort.field, options.initSort.type === 'desc', true) - } that.initData(options.data); } @@ -171,7 +168,6 @@ layui.define(['table'], function (exports) { options.done = function () { var args = arguments; var doneThat = this; - that.initSort = doneThat.initSort; var isRenderData = args[3]; // 是否是 renderData if (!isRenderData) { delete that.isExpandAll; @@ -899,9 +895,7 @@ layui.define(['table'], function (exports) { d[idKey] !== undefined && (that.status.expand[d[idKey]] = true); } }); - if (options.initSort && options.initSort.type && - (!that.initSort || options.initSort.type !== that.initSort.type && options.initSort.field !== that.initSort.field) && - (!options.url || options.autoSort)) { + if (options.initSort && options.initSort.type && (!options.url || options.autoSort)) { return treeTable.sort(id); } var trAll = table.getTrHtml(id, tableDataFlat); @@ -1073,7 +1067,7 @@ layui.define(['table'], function (exports) { }); // 根据需要处理options中的一些参数 - updateOptions(that.config.id, options, type || true); + updateOptions(that.getOptions().id, options, type || true); // 对参数进行深度或浅扩展 that.config = $.extend(deep, {}, that.config, options); @@ -1137,26 +1131,9 @@ layui.define(['table'], function (exports) { if(!that) return; var options = that.getOptions(); - var initSort = options.initSort; - - if (!options.url) { - if (initSort.type) { - layui.sort(options.data, initSort.field, initSort.type === 'desc', true); - } else { - layui.sort(options.data, table.config.indexName, null, true); - } - that.initData(options.data); - treeTable.reloadData(id); - } else { - // url异步取数的表格一般需要自己添加监听之后进行reloadData并且把排序参数加入到where中 - if (options.autoSort) { - var tableData = that.initData(); - var res = {}; - res[options.response.dataName] = tableData; - typeof options.done === 'function' && options.done( - res, that.page, that.count - ); - } + if (!options.url || options.autoSort) { + that.initData(); + treeTable.renderData(id); } } From 255bcb8cc9dcc0d98c08af3d7c16a5fd79aea75e Mon Sep 17 00:00:00 2001 From: zhangyutong Date: Thu, 15 Jun 2023 13:17:02 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A4=E6=96=AD=20?= =?UTF-8?q?=E6=9C=89=E5=80=BC=E6=97=B6=E6=89=8D=E8=A6=86=E7=9B=96placehold?= =?UTF-8?q?er?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/form.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/form.js b/src/modules/form.js index 792536d9..3a0e196f 100644 --- a/src/modules/form.js +++ b/src/modules/form.js @@ -315,9 +315,11 @@ layui.define(['lay', 'layer', 'util'], function(exports){ } // 删除input已有文本并放入 placeholder,方便输入 - input.attr('placeholder', input.val()); - input.val(''); // 清空输入框的值 - + if (input.val()) { + // 有值时才删除并替换placeholder + input.attr('placeholder', input.val()); + input.val(''); // 清空输入框的值 + } followScroll(); }