order.js
7.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
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,
del_url: 'order/del',
table: 'order',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'updatetime',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'order_no', title: __('订单号')},
{
field: 'goods_info',
title: __('商品信息'),
formatter:function(value,row){
var html = '';
$.each(row.goods,function(i,v){
var boder_bottom = row.goods.length != (i + 1) ? 'border-bottom:1px solid #ddd;' : '';
html += '<div style="padding:5px; '+boder_bottom+'">'+
'<img src="'+v.goods_image+'" class="img-sm">'+
'<div>'+
'<div>'+
'<div>商品:'+v.goods_name+'</div>'+
'</div>'+
'<div>'+
'<!--<span>规格:丝质柔滑,750ml</span>-->'+
'<span>单价:'+v.goods_price+'元 </span>'+
'<span class="col-xs-offset-1">数量:'+v.goods_num+'</span>'+
'</div>'+
'</div>'+
'</div>';
})
return html;
}
},
{field: 'pay_status', title: __('支付状态'), searchList: {"0":__('未支付'),"1":__('已支付')}, formatter: Table.api.formatter.normal},
{field: 'delivery_status', title: __('发货状态'), searchList: {"0":__('未发货'),"1":__('已发货')}, formatter: Table.api.formatter.normal},
{field: 'user.nickname', title: __('下单用户')},
{field: 'order_price', title: __('实际支付(元)')},
{field: 'createtime', title: __('下单时间'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
//操作栏,默认有编辑、删除或排序按钮,可自定义配置buttons来扩展按钮
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'detail',
title: __('查看详情'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-book',
url: 'order/info?order_id={id}'
},
{
name: 'detail',
title: __('发货'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-send',
url: 'order/delivery?order_id={id}',
visible: function(row){
if(row.type.value == 'delivery'){
return true;
}
}
},
{
name: 'detail',
title: __('退款'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-send',
url: 'order/refundY?order_id={id}',
visible: function(row){
if(row.type.value == 'refund_1'){
return true;
}
}
},
// {
// name: 'detail',
// title: __('拒绝退款'),
// classname: 'btn btn-xs btn-warning btn-dialog',
// icon: 'fa fa-send',
// url: 'order/refund_3?order_id={id}',
// visible: function(row){
// if(row.type.value == 'refund_1'){
// return true;
// }
// }
// },
{
name: 'detail',
title: __('退货'),
classname: 'btn btn-xs btn-warning btn-dialog',
icon: 'fa fa-send',
url: 'order/refundY?order_id={id}',
visible: function(row){
if(row.type.value == 'return_goods_1'){
return true;
}
}
},
// {
// name: 'detail',
// title: __('拒绝退货'),
// classname: 'btn btn-xs btn-warning btn-dialog',
// icon: 'fa fa-send',
// url: 'order/return_goods_3?order_id={id}',
// visible: function(row){
// if(row.type.value == 'return_goods_1'){
// return true;
// }
// }
// },
],
formatter: function (value, row, index) {
var that = $.extend({}, this);
var table = $(that.table).clone(true);
if(row.type.value != 'payment'){
$(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
}
that.table = table;
return Table.api.formatter.operate.call(that, value, row, index);
}
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
info: function () {
Controller.api.bindevent();
},
delivery: function () {
Controller.api.bindevent();
},
refundy: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});