order_detail.js
10.0 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'order_detail/index' + location.search,
del_url: 'order_detail/del',
detail_url: 'order_detail/detail',
send_url: 'order_detail/send',
refund_url: 'order_detail/refund',
apply_invoice_url: 'order_detail/apply_invoice',
table: 'order_detail',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'user_id', title: __('User_id')},
{field: 'user.nickname', title: __('User.nickname')},
{field: 'store.name', title: __('Store.name')},
{field: 'num', title: __('Num')},
{field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Pay_type 1'),"2":__('Pay_type 2'),"3":__('Pay_type 3')}, formatter: Table.api.formatter.normal},
{field: 'express', title: __('Express'), searchList: {"1":__('Express 1'),"2":__('Express 2'),"3":__('Express 3')}, formatter: Table.api.formatter.normal},
{field: 'total', title: __('Total'), operate:'BETWEEN'},
{field: 'goods_total', title: __('Goods_total'), operate:'BETWEEN'},
{field: 'postage_total', title: __('Postage_total'), operate:'BETWEEN'},
{field: 'name', title: __('Name')},
{field: 'mobile', title: __('Mobile')},
{field: 'province_name', title: __('Province_name')},
{field: 'city_name', title: __('City_name')},
{field: 'county_name', title: __('County_name')},
{field: 'address', title: __('Address')},
{field: 'logistic_code', title: __('运单号')},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7'),"8":__('Status 8'),"9":__('Status 9'),"10":__('Status 10'),"11":__('Status 11')}, formatter: Table.api.formatter.status},
{field: 'invoice_status', title: __('Invoice_status'), searchList: {"1":__('Invoice_status 1'),"2":__('Invoice_status 2'),"3":__('Invoice_status 3')},
formatter: function(value,row,index){
if(value=='0'){
return "-";
}else{
return Table.api.formatter.status(__('Invoice_status '+value), row, index);
}
}
},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text: __('详情'),
title: __('详情'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.detail_url,
extend:"data-area='[\"50%\",\"80%\"]'",
},
{
name: 'send',
text: __('发货'),
title: __('发货'),
classname: 'btn btn-xs btn-info btn-dialog',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.send_url,
confirm: '是否确认通过已发货?',
hidden:function(row){
if(row.status != 2){
return true;
}
},
success: function (data) {
table.bootstrapTable('refresh');
}
},
{
name: 'refund',
text: __('已退款'),
title: __('已退款'),
classname: 'btn btn-xs btn-success btn-ajax',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.refund_url + '/status/9',
confirm: '是否确认通过已退款?',
hidden:function(row){
if(row.status != 8){
return true;
}
},
success: function (data) {
table.bootstrapTable('refresh');
}
},
{
name: 'refund',
text: __('未退款'),
title: __('未退款'),
classname: 'btn btn-xs btn-success btn-ajax',
icon: '',
url: $.fn.bootstrapTable.defaults.extend.refund_url + '/status/11',
confirm: '是否确认通过未退款?',
hidden:function(row){
if(row.status != 8){
return true;
}
},
success: function (data) {
table.bootstrapTable('refresh');
}
},
{
name: 'del',
text: __(''),
title: __('删除'),
classname: 'btn btn-xs btn-danger btn-delone',
icon: 'fa fa-trash',
url: $.fn.bootstrapTable.defaults.extend.refund_url,
hidden:function(row){
if(row.status != 7 && row.status != 10){
return true;
}
},
success: function (data) {
table.bootstrapTable('refresh');
}
},
{
name: 'apply_invoice',
text: __('申请发票'),
title: __('申请发票'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: '',
hidden:function(row){
if(row.status != 1 && row.invoice_status == 0){
return false;
}
return true;
},
url: $.fn.bootstrapTable.defaults.extend.apply_invoice_url,
extend:"data-area='[\"50%\",\"80%\"]'",
},
], formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
detail: function () {
Controller.api.bindevent();
},
apply_invoice: function () {
Controller.api.bindevent();
Form.api.bindevent($("form[role=form]"));
function init(){
var type = $('#c-type').val();
if(type == 1){
//企业单位
$('.duty_number_html').show();
}else if(type == 2){
//个人/非企业单位
$('.duty_number_html').hide();
}
}
init();
$('#c-type').change(function(){
init();
})
},
send:function(){
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});