108 lines
4.2 KiB
JavaScript
108 lines
4.2 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form','editable'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'setting/abnormal/index' + location.search,
|
|
add_url: 'setting/abnormal/add',
|
|
edit_url: 'setting/abnormal/edit',
|
|
del_url: 'setting/abnormal/del',
|
|
multi_url: 'setting/abnormal/multi',
|
|
import_url: 'setting/abnormal/import',
|
|
table: 'abnormal',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
commonSearch:false,
|
|
search:false,
|
|
columns: [
|
|
[
|
|
// {checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
{field: 'type', title: '种类',formatter: function ($val) {
|
|
if($val === 1){
|
|
return '订单报错';
|
|
}
|
|
if($val === 2){
|
|
return '取消订单';
|
|
}
|
|
|
|
if($val === 3){
|
|
return '取消派单'
|
|
}
|
|
return $val === 1 ? '异常类型' : '取消类型';
|
|
}},
|
|
{field: 'title', title: __('Title'), operate: 'LIKE',editable:true},
|
|
{field: 'sort', title: __('Sort'),sortable:true},
|
|
{field: 'operate', title: __('Operate'), table: table,
|
|
buttons:[
|
|
{
|
|
name: 'edit',
|
|
text: "修改",
|
|
icon: 'fa fa-pencil',
|
|
title: __('Edit'),
|
|
extend: 'data-toggle="tooltip" data-container="body"',
|
|
classname: 'btn btn-xs btn-info btn-editone',
|
|
},
|
|
{
|
|
name: 'del',
|
|
text: "删除",
|
|
icon: 'fa fa-trash',
|
|
title: __('Delete'),
|
|
extend: 'data-toggle="tooltip"',
|
|
classname: 'btn btn-xs btn-danger btn-delone',
|
|
},
|
|
],
|
|
events: Table.api.events.operate, formatter: Table.api.formatter.operate}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
var cloneQueryParams = null;
|
|
//绑定tab事件
|
|
$('a[data-toggle="tab"]').on('show.bs.tab',function(event){
|
|
let type =$(this).attr("data-value");
|
|
let options = table.bootstrapTable('getOptions');
|
|
$('.nav-tabs li').attr('class','');
|
|
$(this).parent().attr("class",'active');
|
|
options.pageNumber =1;
|
|
if (cloneQueryParams == null) {
|
|
cloneQueryParams = options.queryParams;
|
|
}
|
|
|
|
options.queryParams =function(params){
|
|
params.type = type;
|
|
return cloneQueryParams(params);
|
|
};
|
|
table.bootstrapTable('refresh',{});
|
|
return false;
|
|
});
|
|
|
|
},
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|