define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'mobile_upload/index' + location.search,
add_url: 'mobile_upload/add',
edit_url: 'mobile_upload/edit',
del_url: 'mobile_upload/del',
multi_url: 'mobile_upload/multi',
import_url: 'mobile_upload/import',
table: 'mobile_upload',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
searchFormVisible:true,
columns: [
[
{checkbox: true},
{field: 'id', title: __('编号')},
{field: 'filename', title: __('Filename')},
{field: 'rows_total', title: __('Rows_total')},
{
field: 'id',
operate: false,
title: "执行情况",
formatter(_,info){
let a=[]
a.push(`总记录数:${info.rows_total}`)
a.push(`成功:${info.rows_succ}`)
a.push(`失败:${info.rows_fail}`)
a.push(`用时:${info.run_time}秒`)
if(info.rows_fail>0){
a.push(`【下载错误清单】`)
}
return a.join(' ')
}
},
{field: 'status', title: __('状态'),formatter: Table.api.formatter.label,searchList:{0:'待导入',1:'导入中',2:'导入完成'}},
{field: 'create_time', title: __('Create_time'),formatter: Table.api.formatter.datetime,addClass:'datetimerange',operate: 'range'},
{
field: 'buttons',
title: __('错误信息'),
events: Table.api.events.operate,
table: table,
formatter: Table.api.formatter.buttons,
operate: false,
buttons:[
{
name: 'detail',
text: __('查看'),
title: __('查看'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-list',
url: 'mobile_upload/error_log?aaa=1',
callback: function (data) {
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
return table.data('operate-error_log') && row.rows_fail>0;
}
},
{
name: 'detail',
text: __('删除'),
title: __('删除'),
confirm:"确认删除吗?",
classname: 'btn btn-xs btn-danger btn-ajax',
icon: 'fa fa-list',
url: 'mobile_upload/del',
callback: function (data) {
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
return table.data('operate-del');
},
success(){
$('.btn-refresh').trigger('click')
}
}
]
}
]
]
});
// 为表格绑定事件
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;
});