mirror of https://gitee.com/karson/fastadmin.git
parent
9df6949c55
commit
8756cf38a1
|
|
@ -35,7 +35,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
showExport: false,
|
||||
commonSearch: true,
|
||||
searchFormVisible: false,
|
||||
pageSize: 10
|
||||
pageSize: 12
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
|
|
|
|||
|
|
@ -9729,7 +9729,9 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
// 添加按钮事件
|
||||
$(toolbar).on('click', Table.config.addbtn, function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
Fast.api.open(options.extend.add_url + (ids.length > 0 ? (options.extend.add_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ids.join(",") : ''), __('Add'), $(this).data() || {});
|
||||
var url = options.extend.add_url;
|
||||
url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
|
||||
Fast.api.open(url, __('Add'), $(this).data() || {});
|
||||
});
|
||||
// 导入按钮事件
|
||||
if ($(Table.config.importbtn, toolbar).size() > 0) {
|
||||
|
|
@ -9746,11 +9748,13 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
}
|
||||
// 批量编辑按钮事件
|
||||
$(toolbar).on('click', Table.config.editbtn, function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
var that = this;
|
||||
//循环弹出多个编辑框
|
||||
$.each(ids, function (i, j) {
|
||||
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + j, __('Edit'), $(that).data() || {});
|
||||
$.each(table.bootstrapTable('getSelections'), function (index, row) {
|
||||
var url = options.extend.edit_url;
|
||||
row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
|
||||
var url = Table.api.replaceurl(url, row, table);
|
||||
Fast.api.open(url, __('Edit'), $(that).data() || {});
|
||||
});
|
||||
});
|
||||
// 批量操作按钮事件
|
||||
|
|
@ -9814,7 +9818,18 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
});
|
||||
$(table).on("click", "[data-id].btn-edit", function (e) {
|
||||
e.preventDefault();
|
||||
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + $(this).data("id"), __('Edit'), $(this).data() || {});
|
||||
var ids = $(this).data("id");
|
||||
var row = {};
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
$.each(table.bootstrapTable('getData'), function (i, j) {
|
||||
if (j[options.pk] == ids) {
|
||||
row = j;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
row.ids = ids;
|
||||
var url = Table.api.replaceurl(options.extend.edit_url, row, table);
|
||||
Fast.api.open(url, __('Edit'), $(this).data() || {});
|
||||
});
|
||||
$(table).on("click", "[data-id].btn-del", function (e) {
|
||||
e.preventDefault();
|
||||
|
|
@ -9837,8 +9852,9 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
multi: function (action, ids, table, element) {
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var data = element ? $(element).data() : {};
|
||||
var ids = ($.isArray(ids) ? ids.join(",") : ids);
|
||||
var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
|
||||
url = url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ($.isArray(ids) ? ids.join(",") : ids);
|
||||
url = this.replaceurl(url, {ids: ids}, table);
|
||||
var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
|
||||
var options = {url: url, data: {action: action, ids: ids, params: params}};
|
||||
Fast.api.ajax(options, function (data) {
|
||||
|
|
@ -9851,8 +9867,12 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
'click .btn-editone': function (e, value, row, index) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var options = $(this).closest('table').bootstrapTable('getOptions');
|
||||
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk], __('Edit'), $(this).data() || {});
|
||||
var table = $(this).closest('table');
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var ids = row[options.pk];
|
||||
row = $.extend({}, row ? row : {}, {ids: ids});
|
||||
var url = options.extend.edit_url;
|
||||
Fast.api.open(Table.api.replaceurl(url, row, table), __('Edit'), $(this).data() || {});
|
||||
},
|
||||
'click .btn-delone': function (e, value, row, index) {
|
||||
e.stopPropagation();
|
||||
|
|
@ -9925,12 +9945,12 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
return '<a href="javascript:;" class="searchit" data-field="' + this.field + '" data-value="' + value + '">' + value + '</a>';
|
||||
},
|
||||
addtabs: function (value, row, index) {
|
||||
var url = Table.api.replaceurl(this.url, value, row, this.table);
|
||||
var url = Table.api.replaceurl(this.url, row, this.table);
|
||||
var title = this.atitle ? this.atitle : __("Search %s", value);
|
||||
return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
|
||||
},
|
||||
dialog: function (value, row, index) {
|
||||
var url = Table.api.replaceurl(this.url, value, row, this.table);
|
||||
var url = Table.api.replaceurl(this.url, row, this.table);
|
||||
var title = this.atitle ? this.atitle : __("View %s", value);
|
||||
return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
|
||||
},
|
||||
|
|
@ -10000,11 +10020,7 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
var attr = table.data(type + "-" + j.name);
|
||||
if (typeof attr === 'undefined' || attr) {
|
||||
url = j.url ? j.url : '';
|
||||
if (!url.match(/\{(.*?)\}/i)) {
|
||||
url = url ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
|
||||
}
|
||||
url = Table.api.replaceurl(url, value, row, table);
|
||||
url = url ? Fast.api.fixurl(url) : 'javascript:;';
|
||||
url = 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 = j.text ? j.text : '';
|
||||
|
|
@ -10018,8 +10034,12 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
return html.join(' ');
|
||||
},
|
||||
//替换URL中的数据
|
||||
replaceurl: function (url, value, row, table) {
|
||||
url = url.replace(/\{value\}/ig, value);
|
||||
replaceurl: function (url, 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);
|
||||
//自动添加ids参数
|
||||
url = !url.match(/\{ids\}/i) ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
|
||||
url = url.replace(/\{(.*?)\}/gi, function (matched) {
|
||||
matched = matched.substring(1, matched.length - 1);
|
||||
if (matched.indexOf(".") !== -1) {
|
||||
|
|
@ -10034,12 +10054,6 @@ define('table',['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstr
|
|||
}
|
||||
return row[matched];
|
||||
});
|
||||
if (table) {
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
url = url.replace(/\{ids\}/ig, row[options.pk]);
|
||||
} else {
|
||||
url = url.replace(/\{ids\}/ig, 0);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
// 获取选中的条目ID集合
|
||||
|
|
|
|||
|
|
@ -156,7 +156,9 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
// 添加按钮事件
|
||||
$(toolbar).on('click', Table.config.addbtn, function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
Fast.api.open(options.extend.add_url + (ids.length > 0 ? (options.extend.add_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ids.join(",") : ''), __('Add'), $(this).data() || {});
|
||||
var url = options.extend.add_url;
|
||||
url = Table.api.replaceurl(url, {ids: ids.length > 0 ? ids.join(",") : 0}, table);
|
||||
Fast.api.open(url, __('Add'), $(this).data() || {});
|
||||
});
|
||||
// 导入按钮事件
|
||||
if ($(Table.config.importbtn, toolbar).size() > 0) {
|
||||
|
|
@ -173,11 +175,13 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
}
|
||||
// 批量编辑按钮事件
|
||||
$(toolbar).on('click', Table.config.editbtn, function () {
|
||||
var ids = Table.api.selectedids(table);
|
||||
var that = this;
|
||||
//循环弹出多个编辑框
|
||||
$.each(ids, function (i, j) {
|
||||
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + j, __('Edit'), $(that).data() || {});
|
||||
$.each(table.bootstrapTable('getSelections'), function (index, row) {
|
||||
var url = options.extend.edit_url;
|
||||
row = $.extend({}, row ? row : {}, {ids: row[options.pk]});
|
||||
var url = Table.api.replaceurl(url, row, table);
|
||||
Fast.api.open(url, __('Edit'), $(that).data() || {});
|
||||
});
|
||||
});
|
||||
// 批量操作按钮事件
|
||||
|
|
@ -241,7 +245,18 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
});
|
||||
$(table).on("click", "[data-id].btn-edit", function (e) {
|
||||
e.preventDefault();
|
||||
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + $(this).data("id"), __('Edit'), $(this).data() || {});
|
||||
var ids = $(this).data("id");
|
||||
var row = {};
|
||||
var options = table.bootstrapTable("getOptions");
|
||||
$.each(table.bootstrapTable('getData'), function (i, j) {
|
||||
if (j[options.pk] == ids) {
|
||||
row = j;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
row.ids = ids;
|
||||
var url = Table.api.replaceurl(options.extend.edit_url, row, table);
|
||||
Fast.api.open(url, __('Edit'), $(this).data() || {});
|
||||
});
|
||||
$(table).on("click", "[data-id].btn-del", function (e) {
|
||||
e.preventDefault();
|
||||
|
|
@ -264,8 +279,9 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
multi: function (action, ids, table, element) {
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var data = element ? $(element).data() : {};
|
||||
var ids = ($.isArray(ids) ? ids.join(",") : ids);
|
||||
var url = typeof data.url !== "undefined" ? data.url : (action == "del" ? options.extend.del_url : options.extend.multi_url);
|
||||
url = url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + ($.isArray(ids) ? ids.join(",") : ids);
|
||||
url = this.replaceurl(url, {ids: ids}, table);
|
||||
var params = typeof data.params !== "undefined" ? (typeof data.params == 'object' ? $.param(data.params) : data.params) : '';
|
||||
var options = {url: url, data: {action: action, ids: ids, params: params}};
|
||||
Fast.api.ajax(options, function (data) {
|
||||
|
|
@ -278,8 +294,12 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
'click .btn-editone': function (e, value, row, index) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
var options = $(this).closest('table').bootstrapTable('getOptions');
|
||||
Fast.api.open(options.extend.edit_url + (options.extend.edit_url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk], __('Edit'), $(this).data() || {});
|
||||
var table = $(this).closest('table');
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
var ids = row[options.pk];
|
||||
row = $.extend({}, row ? row : {}, {ids: ids});
|
||||
var url = options.extend.edit_url;
|
||||
Fast.api.open(Table.api.replaceurl(url, row, table), __('Edit'), $(this).data() || {});
|
||||
},
|
||||
'click .btn-delone': function (e, value, row, index) {
|
||||
e.stopPropagation();
|
||||
|
|
@ -352,12 +372,12 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
return '<a href="javascript:;" class="searchit" data-field="' + this.field + '" data-value="' + value + '">' + value + '</a>';
|
||||
},
|
||||
addtabs: function (value, row, index) {
|
||||
var url = Table.api.replaceurl(this.url, value, row, this.table);
|
||||
var url = Table.api.replaceurl(this.url, row, this.table);
|
||||
var title = this.atitle ? this.atitle : __("Search %s", value);
|
||||
return '<a href="' + Fast.api.fixurl(url) + '" class="addtabsit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
|
||||
},
|
||||
dialog: function (value, row, index) {
|
||||
var url = Table.api.replaceurl(this.url, value, row, this.table);
|
||||
var url = Table.api.replaceurl(this.url, row, this.table);
|
||||
var title = this.atitle ? this.atitle : __("View %s", value);
|
||||
return '<a href="' + Fast.api.fixurl(url) + '" class="dialogit" data-value="' + value + '" title="' + title + '">' + value + '</a>';
|
||||
},
|
||||
|
|
@ -427,11 +447,7 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
var attr = table.data(type + "-" + j.name);
|
||||
if (typeof attr === 'undefined' || attr) {
|
||||
url = j.url ? j.url : '';
|
||||
if (!url.match(/\{(.*?)\}/i)) {
|
||||
url = url ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + row[options.pk] : '';
|
||||
}
|
||||
url = Table.api.replaceurl(url, value, row, table);
|
||||
url = url ? Fast.api.fixurl(url) : 'javascript:;';
|
||||
url = 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 = j.text ? j.text : '';
|
||||
|
|
@ -445,8 +461,12 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
return html.join(' ');
|
||||
},
|
||||
//替换URL中的数据
|
||||
replaceurl: function (url, value, row, table) {
|
||||
url = url.replace(/\{value\}/ig, value);
|
||||
replaceurl: function (url, 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);
|
||||
//自动添加ids参数
|
||||
url = !url.match(/\{ids\}/i) ? url + (url.match(/(\?|&)+/) ? "&ids=" : "/ids/") + '{ids}' : url;
|
||||
url = url.replace(/\{(.*?)\}/gi, function (matched) {
|
||||
matched = matched.substring(1, matched.length - 1);
|
||||
if (matched.indexOf(".") !== -1) {
|
||||
|
|
@ -461,12 +481,6 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
|
|||
}
|
||||
return row[matched];
|
||||
});
|
||||
if (table) {
|
||||
var options = table.bootstrapTable('getOptions');
|
||||
url = url.replace(/\{ids\}/ig, row[options.pk]);
|
||||
} else {
|
||||
url = url.replace(/\{ids\}/ig, 0);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
// 获取选中的条目ID集合
|
||||
|
|
|
|||
Loading…
Reference in New Issue