litestoreorder.js
8.2 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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'litestore/litestoreorder/index',
add_url: 'litestore/litestoreorder/add',
// edit_url: 'litestoreorder/edit',
del_url: 'litestore/litestoreorder/del',
multi_url: 'litestore/litestoreorder/multi',
table: 'litestore_order',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
search:false,
showExport:false,
searchFormVisible:true,
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{field: 'order_no', title: __('Order_no')},
{field: 'total_price', title: __('Total_price'), operate:'BETWEEN'},
{field: 'express_price', title: __('Express_price'), operate:'BETWEEN'},
{field: 'pay_price', title: __('Pay_price'), operate:'BETWEEN'},
{field: 'pay_time', title: __('Pay_time'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'freight_time', title: __('Freight_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'receipt_time', title: __('Receipt_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'comment_time', title: __('Comment_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'order_status', title: __('Order_status'), searchList: {"10":__('Order_status 10'),"20":__('Order_status 20'),"30":__('Order_status 30')},
formatter: Controller.api.status_formatter},
{field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{field: 'address.name', title: __('Address.name'),operate: 'LIKE'},
{
field: 'rider.nickname',
title: __('选择配送骑手'),
table: table,
operate: false,
events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text: __('选择配送骑手'),
title: __('选择配送骑手'),
classname: 'btn btn-xs btn-primary btn-dialog',
icon: 'fa fa-fighter-jet',
url: 'litestore/litestoreorder/rider?ids={ids}',
callback: function (data) {
Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
},
visible: function (row) {
//返回true时按钮显示,返回false隐藏
if(row.pay_status == '20' && row.freight_status == '10' && row.order_status == '10'){
return true;
}
}
}
],
formatter: Table.api.formatter.buttons
},
{field: 'rider_user_id', title: __('骑手'), searchList: Config.riderList, operate: 'IN', formatter: Table.api.formatter.flag},
{field: 'operate', title: __('Operate'), table: table, buttons: [
{name: 'send', text: __('view'), icon: 'fa fa-eye', classname: 'btn btn-xs btn-warning btn-dialog chakan', url: 'litestore/litestoreorder/detail'},
], events: Table.api.events.operate, formatter: Table.api.formatter.operate}
]
]
});
// 绑定TAB事件
$('.panel-heading a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var that = $(this);
var options = table.bootstrapTable('getOptions');
options.pageNumber = 1;
options.queryParams = function (params) {
var filter = {};
filter['pay_status'] = that.data("pay_status");
filter['freight_status'] = that.data("freight_status");
filter['order_status'] = that.data("order_status");
filter['receipt_status'] = that.data("receipt_status");
params.filter = JSON.stringify(filter);
return params;
};
table.bootstrapTable('refresh', {});
return false;
});
// 为表格绑定事件
Table.api.bindevent(table);
table.on('load-success.bs.table',function(data){
$('.chakan').data("area", ["1000px","800px"]);
});
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
detail: function(){
$("#send").on('click', function() {
var sn = $("#c-virtual_sn").val();
var name = $("#c-virtual_name").val();
if(sn == '' || name == '')
{
layer.msg("请填写正确的快递信息");
return false;
}
$("#send-form").attr("action","litestore/litestoreorder/detail").submit();
});
Controller.api.bindevent();
},
rider: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
status_formatter: function (value, row, index) {
var colorArr = ["success", "gray", "blue", "primary", "danger", "warning", "info", "red", "yellow", "aqua", "navy", "teal", "olive", "lime", "fuchsia", "purple", "maroon"];
var custom = {};
if (typeof this.custom !== 'undefined') {
custom = $.extend(custom, this.custom);
}
value = value === null ? '' : value.toString();
var keys = typeof this.searchList === 'object' ? Object.keys(this.searchList) : [];
var index = keys.indexOf(value);
var color = value && typeof custom[value] !== 'undefined' ? custom[value] : null;
var display = index > -1 ? this.searchList[value] : null;
var icon = "fa fa-circle";
if (!color) {
color = index > -1 && typeof colorArr[index] !== 'undefined' ? colorArr[index] : 'primary';
}
if (!display) {
display = __(value.charAt(0).toUpperCase() + value.slice(1));
}
var html = '<span class="text-' + color + '">' + (icon ? '<i class="' + icon + '"></i> ' : '') + display + '</span>';
if (this.operate != false) {
html = '<a href="javascript:;" class="searchit" data-toggle="tooltip" title="' + __('Click to search %s', display) + '" data-field="' + this.field + '" data-value="' + value + '">' + html + '</a>';
}
return html;
},
}
};
return Controller;
});