litestoreorder.js
6.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
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'litestoreorder/index',
add_url: 'litestoreorder/add',
// edit_url: 'litestoreorder/edit',
del_url: 'litestoreorder/del',
multi_url: 'litestoreorder/multi',
table: 'litestore_order',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
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:'RANGE', 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: 'pay_status', title: __('Pay_status'), searchList: {"10":__('Pay_status 10'),"20":__('Pay_status 20')},
formatter: Controller.api.status_formatter},
{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:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
{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: '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","litestoreorder/detail").submit();
});
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;
});