From 7198a0a3ac6bb7e54416aa1eee0c7ed86da6dd1e Mon Sep 17 00:00:00 2001 From: qlo1062 <1062584641@qq.com> Date: Wed, 21 Aug 2019 10:18:06 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=AF=B9text=E3=80=81title=E3=80=81confirm?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=A8=A1=E6=9D=BF=E6=95=B0=E6=8D=AE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-table.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 94b3bfa4c..69fd8dbdc 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -639,11 +639,13 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;'); classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one'; icon = j.icon ? j.icon : ''; - text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : ''; - title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text; + text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? Table.api.replacetplval(text, row, table) : ''; + title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? Table.api.replacetplval(title, row, table) : text; refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : ''; confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false); + confirm = Table.api.replacetplval(confirm, row, table); confirm = confirm ? 'data-confirm="' + confirm + '"' : ''; + extend = j.extend ? j.extend : ''; disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false); if (disable) { @@ -692,6 +694,27 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table }); return url; }, + //替换模板数据 + replacetplval: function (text, row, table) { + var options = table ? table.bootstrapTable('getOptions') : null; + var ids = options ? row[options.pk] : 0; + row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0); + text = text.replace(/\{(.*?)\}/gi, function (matched) { + matched = matched.substring(1, matched.length - 1); + if (matched.indexOf(".") !== -1) { + var temp = row; + var arr = matched.split(/\./); + for (var i = 0; i < arr.length; i++) { + if (typeof temp[arr[i]] !== 'undefined') { + temp = temp[arr[i]]; + } + } + return typeof temp === 'object' ? '' : temp; + } + return row[matched]; + }); + return text; + }, // 获取选中的条目ID集合 selectedids: function (table) { var options = table.bootstrapTable('getOptions'); -- Gitee From d4db5fe996e7365c971f5e09ca3f6d73a468b382 Mon Sep 17 00:00:00 2001 From: qlo1062 <1062584641@qq.com> Date: Wed, 21 Aug 2019 11:06:01 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AF=B9text=E3=80=81title=E3=80=81confirm?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E6=A8=A1=E6=9D=BF=E6=95=B0=E6=8D=AE=E6=9B=BF?= =?UTF-8?q?=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/require-table.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 94b3bfa4c..f79916113 100644 --- a/public/assets/js/require-table.js +++ b/public/assets/js/require-table.js @@ -639,11 +639,13 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table url = typeof url === 'function' ? url.call(table, row, j) : (url ? Fast.api.fixurl(Table.api.replaceurl(url, row, table)) : 'javascript:;'); classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one'; icon = j.icon ? j.icon : ''; - text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.text : ''; - title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? j.title : text; + text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? Table.api.replacetplval(text, row, table) : ''; + title = typeof j.title === 'function' ? j.title.call(table, row, j) : j.title ? Table.api.replacetplval(title, row, table) : text; refresh = j.refresh ? 'data-refresh="' + j.refresh + '"' : ''; confirm = typeof j.confirm === 'function' ? j.confirm.call(table, row, j) : (typeof j.confirm !== 'undefined' ? j.confirm : false); + confirm = Table.api.replacetplval(confirm, row, table); confirm = confirm ? 'data-confirm="' + confirm + '"' : ''; + extend = j.extend ? j.extend : ''; disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false); if (disable) { @@ -692,6 +694,28 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table }); return url; }, + //替换模板数据 + replacetplval: function (text, row, table) { + var options = table ? table.bootstrapTable('getOptions') : null; + var ids = options ? row[options.pk] : 0; + row.ids = ids ? ids : (typeof row.ids !== 'undefined' ? row.ids : 0); + text = text ? text : ""; + text = text.replace(/\{(.*?)\}/gi, function (matched) { + matched = matched.substring(1, matched.length - 1); + if (matched.indexOf(".") !== -1) { + var temp = row; + var arr = matched.split(/\./); + for (var i = 0; i < arr.length; i++) { + if (typeof temp[arr[i]] !== 'undefined') { + temp = temp[arr[i]]; + } + } + return typeof temp === 'object' ? '' : temp; + } + return row[matched]; + }); + return text; + }, // 获取选中的条目ID集合 selectedids: function (table) { var options = table.bootstrapTable('getOptions'); -- Gitee