mirror of https://gitee.com/karson/fastadmin.git
对text、title、confirm进行模板数据替换
parent
ebf38b470c
commit
7198a0a3ac
|
|
@ -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:;');
|
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';
|
classname = j.classname ? j.classname : 'btn-primary btn-' + name + 'one';
|
||||||
icon = j.icon ? j.icon : '';
|
icon = j.icon ? j.icon : '';
|
||||||
text = typeof j.text === 'function' ? j.text.call(table, row, j) : j.text ? j.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 ? j.title : text;
|
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 + '"' : '';
|
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 = 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 + '"' : '';
|
confirm = confirm ? 'data-confirm="' + confirm + '"' : '';
|
||||||
|
|
||||||
extend = j.extend ? j.extend : '';
|
extend = j.extend ? j.extend : '';
|
||||||
disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
|
disable = typeof j.disable === 'function' ? j.disable.call(table, row, j) : (typeof j.disable !== 'undefined' ? j.disable : false);
|
||||||
if (disable) {
|
if (disable) {
|
||||||
|
|
@ -692,6 +694,27 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
||||||
});
|
});
|
||||||
return url;
|
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集合
|
// 获取选中的条目ID集合
|
||||||
selectedids: function (table) {
|
selectedids: function (table) {
|
||||||
var options = table.bootstrapTable('getOptions');
|
var options = table.bootstrapTable('getOptions');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue