define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'order/index' + location.search,
add_url: 'order/add',
edit_url: 'order/edit',
del_url: 'order/del',
multi_url: 'order/multi',
import_url: 'order/import',
table: 'order',
}
});
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: 'warehouse.title', title: __('所属仓库'),operate: 'LIKE'},
{field: 'bank', title: __('商品名称'),operate:'LIKE', align: 'left', formatter: function (value, row) {
var _html = ' ';
_html += '';
_html += '
' + row.detail.goods_name;
_html += '
订单号:' + row.order_sn;
return _html;
}, operate:false},
{field: 'price', title: __('委托价/商品价/手续费/佣金抵扣手续费'),operate:'LIKE', align: 'left', formatter: function (value, row) {
var _html = ' ';
_html += '
' + row.detail.commission_price;
_html += '
' + row.detail.goods_price;
_html += '
' + row.detail.fee;
_html += '
' + row.detail.dikou_price;
return _html;
}, operate:false},
{field: 'user', title: __('卖家/买家'),operate:'LIKE', align: 'left', formatter: function (value, row) {
var _html = ' ';
_html += '
' + row.user1.nickname;
_html += '
' + row.user1.mobile;
_html += '
---------';
_html += '
' + row.user.nickname;
_html += '
' + row.user.mobile;
return _html;
}, operate:false},
{field: 'user', title: __('状态/下单时间/支付时间'),operate:'LIKE', align: 'left', formatter: function (value, row) {
var _html = ' ';
_html += '
' + row.status_text;
_html += '
---------';
_html += '
' + row.createtime_text;
_html += '
---------';
_html += '
' + row.pay_time_text;
return _html;
}, operate:false},
{field: 'order_sn', title: __('Order_sn'), visible:false,operate:"LIKE"},
{field: 'user.mobile', title: __('购买人手机号'),visible:false,operate:"LIKE"},
{field: 'user1.mobile', title: __('售卖人手机号'),visible:false,operate:"LIKE"},
{field: 'order_amount', title: __('应付金额'), operate:'BETWEEN'},
{field: 'pay_amount', title: __('实付金额'), operate:'BETWEEN'},
{field: 'coupon_price', title: __('委托优惠金额'), operate:'BETWEEN'},
{field: 'createtime', title: __('下单时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible:false},
//{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: Config.statusList,visible:false},
{field: 'cancel_time', title: __('取消时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'pay_method', title: __('Pay_method'), formatter: Table.api.formatter.status, searchList: {1: __('支付宝'), 0: __('银行卡'), 2: __('微信')}},
{field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible:false},
// {field: 'pay_voucher', title: __('Pay_voucher'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'coupon_id', title: __('Coupon_id')},
// {field: 'consignee', title: __('Consignee'), operate: 'LIKE'},
// {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
// {field: 'province', title: __('Province'), operate: 'LIKE'},
// {field: 'city', title: __('City'), operate: 'LIKE'},
// {field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
{field: 'operate', title: __('Operate'), table: table,events: Table.api.events.operate,
buttons:[
{
name:'split',
text:'发货',
title:'发货',
classname: 'btn btn-xs btn-info btn-view btn-dialog',
icon: 'fa fa-check',
url: 'order/send/type/1',
visible:function(row){
if (row.status == 4) {
return true;
}
return false;
},
//refresh:true
},
{
name:'split',
text:'查看物流',
title:'查看物流',
classname: 'btn btn-xs btn-info btn-view btn-dialog',
icon: 'fa fa-check',
url: 'order/send/type/2',
visible:function(row){
if (row.status == 5 || row.status == 6) {
return true;
}
return false;
},
//refresh:true
},
],
formatter: function(value, row, index) {
var that = $.extend({}, this);
var table = $(that.table).clone(true);
// operate-edit编辑 perate-del删除
//判断什么时候显示什么时候不显示
if (row.status == 1) {
//$(table).data("operate-edit", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
//$(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
}
that.table = table;
return Table.api.formatter.operate.call(that, value, row, index);
},
// cellStyle: {css: {"max-width": "100px","white-space":"pre-line","word-wrap":"break-word","word-break":"break-all"}}
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
send: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});