mirror of https://gitee.com/karson/fastadmin.git
69 lines
2.6 KiB
Plaintext
69 lines
2.6 KiB
Plaintext
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: '{%controllerUrl%}/index',
|
|
add_url: '{%controllerUrl%}/add',
|
|
edit_url: '{%controllerUrl%}/edit',
|
|
del_url: '{%controllerUrl%}/del',
|
|
//import_url: '{%controllerUrl%}/import',
|
|
multi_url: '{%controllerUrl%}/multi',
|
|
table: '{%table%}',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
var date = new Date();
|
|
|
|
//在表格内容渲染完成后回调的事件
|
|
table.on('post-body.bs.table', function (e, settings, json, xhr) {
|
|
$(".btn-add").data("area", ["1000px", "95%"]).data("title", '添加{%tableCNName%}');
|
|
$(".btn-editone").data("area", ["1000px", "95%"]).data("title", '编辑{%tableCNName%}');
|
|
$(".btn-edit").data("area", ["1000px", "95%"]).data("title", '编辑{%tableCNName%}');
|
|
});
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: '{%pk%}',
|
|
sortName: '{%order%}',
|
|
exportTypes: ['csv', 'excel'],
|
|
exportOptions: {
|
|
fileName: '{%controllerUrl%}_' + [date.getFullYear(), date.getMonth() + 1, date.getDate()].join('-'),
|
|
ignoreColumn: [0, 'operate'], //默认不导出第一列(checkbox)与操作(operate)列
|
|
},
|
|
columns: [
|
|
[
|
|
{%javascriptList%}
|
|
]
|
|
],
|
|
//禁用默认搜索
|
|
search: false,
|
|
//启用普通表单搜索
|
|
commonSearch: true,
|
|
//可以控制是否默认显示搜索单表,false则隐藏,默认为false
|
|
searchFormVisible: false,
|
|
showColumns: false,
|
|
showToggle: false,
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
}); |