From d0dc609cf95a3cba3fd2b5f1736052d4ae0c5e13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B4=A4=E5=BF=83?= <3277200+sentsim@users.noreply.github.com> Date: Thu, 21 Nov 2024 10:40:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(table):=20=E4=BF=AE=E5=A4=8D=E6=8E=92?= =?UTF-8?q?=E5=BA=8F=E4=B8=94=E9=87=8D=E8=BD=BD=E5=90=8E=20`table.cache`?= =?UTF-8?q?=20=E6=95=B0=E6=8D=AE=E4=B8=AD=E7=9A=84=20`LAY=5FINDEX`=20?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E7=9A=84=E9=97=AE=E9=A2=98=20(#2340)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/table.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/table.js b/src/modules/table.js index 0cf66c57..af172189 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -20,7 +20,8 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ var table = { config: { // 全局配置项 checkName: 'LAY_CHECKED', // 是否选中状态的特定字段名 - indexName: 'LAY_INDEX', // 初始下标索引名,用于恢复当前页表格排序 + indexName: 'LAY_INDEX', // 下标索引 + initIndexName: 'LAY_INDEX_INIT', // 初始下标索引名,仅用于内部恢复当前页表格排序 numbersName: 'LAY_NUM', // 序号 disabledName: 'LAY_DISABLED' // 禁用状态的特定字段名 }, @@ -1312,8 +1313,9 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ // 加入序号保留字段 item1[table.config.numbersName] = numbers; - // 记录下标索引,用于恢复排序 - if(!sort) item1[table.config.indexName] = i1; + // 记录下标, + item1[table.config.indexName] = i1; + if(!sort) item1[table.config.initIndexName] = i1; // 记录初始状态下标,仅用于内部恢复当前页表格排序 // 遍历表头 that.eachCols(function(i3, item3){ @@ -1460,6 +1462,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ reloadType: opts.type }); } + that.getTrHtml(data, sort, curr, { trs: trs, trs_fixed: trs_fixed, @@ -1894,7 +1897,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ } else if(opts.type === 'desc'){ //降序 thisData = layui.sort(data, field, true, true); } else { // 清除排序 - thisData = layui.sort(data, table.config.indexName, null, true); + thisData = layui.sort(data, table.config.initIndexName, null, true); delete that.sortKey; delete options.initSort; } @@ -3300,6 +3303,7 @@ layui.define(['lay', 'laytpl', 'laypage', 'form', 'util'], function(exports){ data = $.extend({}, data); delete data[table.config.checkName]; delete data[table.config.indexName]; + delete data[table.config.initIndexName]; delete data[table.config.numbersName]; delete data[table.config.disabledName]; return data;