You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
2.4 KiB
60 lines
2.4 KiB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'example/controllerjump/index',
|
|
add_url: '',
|
|
edit_url: '',
|
|
del_url: 'example/controllerjump/del',
|
|
multi_url: '',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
columns: [
|
|
[
|
|
{field: 'state', checkbox: true, },
|
|
{field: 'id', title: 'ID'},
|
|
{field: 'admin_id', title: __('Admin_id')},
|
|
{field: 'title', title: __('Title')},
|
|
{field: 'ip', title: __('IP'),formatter: Controller.api.formatter.ip},
|
|
{field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
},
|
|
edit: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
},
|
|
api: {
|
|
formatter: {
|
|
ip: function (value, row, index) {
|
|
//这里手动构造URL
|
|
url = "example/bootstraptable?" + this.field + "=" + value;
|
|
|
|
//方式一,直接返回class带有addtabsit的链接,这可以方便自定义显示内容
|
|
//return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __('Search %s', value) + '</a>';
|
|
|
|
//方式二,直接调用Table.api.formatter.addtabs
|
|
this.url = url;
|
|
return Table.api.formatter.addtabs.call(this, value, row, index);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|
|
|