diff --git a/public/assets/js/require-table.js b/public/assets/js/require-table.js index 94b3bfa4c804991a7f70fad0ab2b9b7df92ffa7f..f799161137042a08b4c42ff3caf7e8ac07d38d77 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');