180 lines
9.6 KiB
JavaScript
180 lines
9.6 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form','layer'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'orders/dispatch/index' + location.search,
|
|
add_url: 'orders/dispatch/add',
|
|
edit_url: 'orders/dispatch/edit',
|
|
// del_url: 'orders/dispatch/del',
|
|
multi_url: 'orders/dispatch/multi',
|
|
import_url: 'orders/dispatch/import',
|
|
table: 'order_dispatch',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
fixedColumns: true,
|
|
fixedRightNumber: 1,
|
|
columns: [
|
|
[
|
|
//{checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
//{field: 'order_id', title: __('Order_id')},
|
|
|
|
{field: 'order.order_no', title: __('Order.order_no'), operate: 'LIKE'},
|
|
|
|
// {field: 'worker_id', title: __('Worker_id')},
|
|
{field: 'worker_name', title: __('Worker_name'), operate: 'LIKE'},
|
|
{field: 'worker_tel', title: __('Worker_tel'), operate: 'LIKE'},
|
|
|
|
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1')}, formatter: Table.api.formatter.normal},
|
|
|
|
|
|
{field: 'order.source_shop', title: __('Order.source_shop'), operate: 'LIKE'},
|
|
{field: 'order.source', title: __('Order.source')},
|
|
{field: 'order.customer', title: __('Order.customer'), operate: 'LIKE'},
|
|
{field: 'order.tel', title: __('Order.tel'), operate: 'LIKE'},
|
|
{field: 'order.address', title: __('Order.address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'order.item_title', title: __('Order.item_title'), operate: 'LIKE'},
|
|
{field: 'order.detail', title: __('Order.detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'order.images', title: __('Order.images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
|
|
|
|
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"10":__('Status 10'),"20":__('Status 20'),"25":__('Status 25'),"30":__('Status 30'),"60":__('Status 60'),"-10":__('Status -10'),"-20":__('Status -20'),"-30":__('Status -30')}, formatter: Table.api.formatter.status},
|
|
{field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
|
|
{field: 'plan_time', title: __('Plan_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
// {field: 'is_notice', title: __('Is_notice'), searchList: {"0":__('Is_notice 0'),"1":__('Is_notice 1')}, formatter: Table.api.formatter.normal},
|
|
{field: 'finish_time', title: __('Finish_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
// {field: 'admin_id', title: __('Admin_id')},
|
|
{field: 'admin_user', title: __('Admin_user'), operate: 'LIKE'},
|
|
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
{field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
|
|
|
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
|
|
|
buttons: [
|
|
{
|
|
name: 'edit',
|
|
text:"修改",
|
|
title:"修改",
|
|
icon: 'fa fa-pencil',
|
|
//title: __('Edit'),
|
|
extend: 'data-toggle="tooltip" data-container="body"',
|
|
classname: 'btn btn-xs btn-success btn-editone',
|
|
visible:function(row){
|
|
if(row.btn_edit){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
},
|
|
{
|
|
name: 'del',
|
|
text:"取消",
|
|
title:"取消",
|
|
icon: 'fa fa-trash',
|
|
//title: __('Del'),
|
|
extend: 'data-toggle="tooltip" data-container="body"',
|
|
classname: 'btn btn-xs btn-danger btn-delone',
|
|
click: function (data, row) {
|
|
layer.prompt({
|
|
formType: 2,
|
|
value: '',
|
|
title: '请输入备注',
|
|
maxlength: 140,
|
|
},function(value, index, elem) {
|
|
var url = 'orders/dispatch/del' + row.id;
|
|
var options = {url: url, data: {remark: value}};
|
|
Fast.api.ajax(options, function (data, ret) {
|
|
// table.trigger("uncheckbox");
|
|
table.bootstrapTable('refresh');
|
|
})
|
|
},function (data, ret) {
|
|
var error = $(this).data("error") || $.noop;
|
|
if (typeof error === 'function') {
|
|
if (false === error.call(this, data, ret)) {
|
|
return false;
|
|
}
|
|
}
|
|
});
|
|
layer.close(index);
|
|
},
|
|
visible:function(row){
|
|
if(row.btn_cancel){
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
},
|
|
{
|
|
name:"income",
|
|
text:"新增收款",
|
|
title:"新增收款",
|
|
classname:"btn-view btn-dialog",
|
|
icon:'fa fa-money',
|
|
url: function(row){
|
|
return 'orders/income/add?order_id='+row.order_id;
|
|
},
|
|
dropdown:"更多",
|
|
visible:function(row){
|
|
if(row.btn_income){
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
refresh:true,
|
|
},
|
|
{
|
|
name:"abnormal",
|
|
text:"创建异常",
|
|
title:"创建异常",
|
|
classname:"btn-add btn-dialog",
|
|
icon:'fa fa-add',
|
|
url:function(row) {
|
|
return "orders/abnormal/add?order_id="+row.order_id
|
|
},
|
|
dropdown:"更多",
|
|
visible:function(row){
|
|
if(row.btn_income){
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
//refresh:true,
|
|
}
|
|
],
|
|
|
|
}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
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;
|
|
});
|