define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'user/report/index' + location.search,
// add_url: 'user/report/add',
// edit_url: 'user/report/edit',
del_url: 'user/report/del',
// multi_url: 'user/report/multi',
// import_url: 'user/report/import',
table: 'user_report',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'user.u_id', title: __('举报用户ID')},
{field: 'user.nickname', title: __('举报用户昵称'), operate: 'LIKE'},
{
field: 'reportable_type', title: __('举报对象类型'), operate: false, formatter: function (value, row, index) {
if (value.indexOf("User") != -1) {
return "用户";
} else if (value.indexOf("Party") != -1) {
return '房间';
}
}
},
{
field: 'reportable_id', title: __('举报对象'), operate: false, formatter: function (value, row, index) {
if (row.reportable_type.indexOf("User") != -1) {
return row.model.nickname + '
(用户ID:' + row.model.u_id + ')';
} else if (row.reportable_type.indexOf("Party") != -1) {
return row.model.party_name + '
(派对ID:' + row.model.party_id + ')';
}
}
},
{
field: 'content', title: __('Content'), operate: 'LIKE',
formatter: function (value, row, index, field) {
return "" + value + "";
},
cellStyle: function (value, row, index, field) {
return {
css: {
"white-space": "nowrap",
"text-overflow": "ellipsis",
"overflow": "hidden",
"max-width": "250px"
}
};
}
},
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
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;
});