From 3846329c82fda3a06b83ef63613096c192c263a5 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Sun, 21 Jun 2020 23:04:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90=E4=B8=BB?= =?UTF-8?q?=E5=AD=90=E8=A1=A8=E5=BA=8F=E5=8F=B7=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/ruoyi/js/common.js | 12 +----------- .../src/main/resources/static/ruoyi/js/ry-ui.js | 5 +++-- .../main/resources/templates/demo/table/subdata.html | 7 +++++-- .../src/main/resources/vm/html/add.html.vm | 7 +++++-- .../src/main/resources/vm/html/edit.html.vm | 8 +++++--- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js index 845d77e71..68a43ba8a 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/common.js @@ -365,6 +365,7 @@ var sub = { $("#" + table.options.id).bootstrapTable("updateRow", params); }, delColumn: function(column) { + sub.editColumn(); var subColumn = $.common.isEmpty(column) ? "index" : column; var ids = $.table.selectColumns(subColumn); if (ids.length == 0) { @@ -372,17 +373,6 @@ var sub = { return; } $("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids }); - if($.common.equals("index", subColumn)) - { - sub.resetIndex(); - } - }, - resetIndex: function(msg) { - var count = $("#" + table.options.id).bootstrapTable('getData').length; - for (var index = 0; index <= count; index++) { - // 重置序号 - $("#" + table.options.id).bootstrapTable('updateRow', { index: index, row: { index: parseInt(index + 1) } }) - } } }; diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 2b07117ce..7b1951b58 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -45,6 +45,7 @@ var table = { pagination: true, paginationLoop: false, pageSize: 10, + pageNumber: 1, pageList: [10, 25, 50], toolbar: "toolbar", striped: false, @@ -275,8 +276,8 @@ var table = { serialNumber: function (index, tableId) { var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId; var tableParams = $("#" + currentId).bootstrapTable('getOptions'); - var pageSize = tableParams.pageSize; - var pageNumber = tableParams.pageNumber; + var pageSize = $.common.isNotEmpty(tableParams.pageSize) ? tableParams.pageSize: table.options.pageSize; + var pageNumber = $.common.isNotEmpty(tableParams.pageNumber) ? tableParams.pageNumber: table.options.pageNumber; return pageSize * (pageNumber - 1) + index + 1; }, // 列超出指定长度浮动提示 target(copy单击复制文本 open弹窗打开文本) diff --git a/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html b/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html index 519adf6fe..ea86580d1 100644 --- a/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html +++ b/ruoyi-admin/src/main/resources/templates/demo/table/subdata.html @@ -96,7 +96,11 @@ { field: 'index', align: 'center', - title: "序号" + title: "序号", + formatter: function (value, row, index) { + var columnIndex = $.common.sprintf("", $.table.serialNumber(index)); + return columnIndex + $.table.serialNumber(index); + } }, { field: 'name', @@ -164,7 +168,6 @@ type: "", } }); - sub.resetIndex(); } diff --git a/ruoyi-generator/src/main/resources/vm/html/add.html.vm b/ruoyi-generator/src/main/resources/vm/html/add.html.vm index 77dd71427..0d32c3655 100644 --- a/ruoyi-generator/src/main/resources/vm/html/add.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/add.html.vm @@ -210,7 +210,11 @@ { field: 'index', align: 'center', - title: "序号" + title: "序号", + formatter: function (value, row, index) { + var columnIndex = $.common.sprintf("", $.table.serialNumber(index)); + return columnIndex + $.table.serialNumber(index); + } }, #foreach($column in $subTable.columns) #set($dictType=$column.dictType) @@ -269,7 +273,6 @@ #end } }); - sub.resetIndex(); } #end diff --git a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm index af31dd0f2..5d2ea8cb7 100644 --- a/ruoyi-generator/src/main/resources/vm/html/edit.html.vm +++ b/ruoyi-generator/src/main/resources/vm/html/edit.html.vm @@ -211,7 +211,11 @@ { field: 'index', align: 'center', - title: "序号" + title: "序号", + formatter: function (value, row, index) { + var columnIndex = $.common.sprintf("", $.table.serialNumber(index)); + return columnIndex + $.table.serialNumber(index); + } }, #foreach($column in $subTable.columns) #set($dictType=$column.dictType) @@ -250,7 +254,6 @@ }] }; $.table.init(options); - sub.resetIndex(); }); function addColumn() { @@ -271,7 +274,6 @@ #end } }); - sub.resetIndex(); } #end