Pu Zhibing
2024-11-15 dedfc9f1a3fb311874a360324447e717f3034c4a
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/**
 * 小件物流订单管理初始化
 */
var TOrderLogistics = {
    id: "TOrderLogisticsTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
TOrderLogistics.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '主键id', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '下单时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle',width:'8%',
            formatter: function (value, row) {
                var btn = "";
                if(row.insertTime != '' && row.insertTime != null) {
                    var time = row.insertTime.replace(" ",'<br>');
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.insertTime + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '订单类型', field: 'type', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.type != '' && row.type != null) {
                    if (row.type == 4){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="市内小件物流" onfocus="TUser.tooltip()">市内小件物流</p>']
                    } else if (row.type == 5){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="跨城物流" onfocus="TUser.tooltip()">跨城物流</p>']
                    }
                }
                return btn;
            }
        },
        {title: '订单编号', field: 'orderNum', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.orderNum != '' && row.orderNum != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.orderNum + '" onfocus="TUser.tooltip()">' + row.orderNum + '</p>']
                }
                return btn;
            }
        },
        {title: '订单来源', field: 'orderSource', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.orderSource != '' && row.orderSource != null) {
                    if (row.orderSource == 1){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="APP下单" onfocus="TUser.tooltip()">APP下单</p>']
                    } else if (row.orderSource == 2){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="扫码下单" onfocus="TUser.tooltip()">扫码下单</p>']
                    } else if (row.orderSource == 3){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="小程序下单" onfocus="TUser.tooltip()">小程序下单</p>']
                    } else if (row.orderSource == 4){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="司机下单" onfocus="TUser.tooltip()">司机下单</p>']
                    } else if (row.orderSource == 5){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="调度下单" onfocus="TUser.tooltip()">调度下单</p>']
                    }
                }
                return btn;
            }
        },
        {title: '乘车时间', field: 'travelTime', visible: true, align: 'center', valign: 'middle',width:'10%',
            formatter: function (value, row) {
                var btn = "";
                if(row.travelTime != '' && row.travelTime != null) {
                    var time = row.travelTime.replace(" ",'<br>');
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.travelTime + '" onfocus="TUser.tooltip()">' + time + '</p>']
                }
                return btn;
            }
        },
        {title: '用户id', field: 'userId', visible: false, align: 'center', valign: 'middle'},
        {title: '下单用<br/>户昵称', field: 'userName', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.userName != '' && row.userName != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.userName + '" onfocus="TUser.tooltip()">' + row.userName + '</p>']
                }
                return btn;
            }
        },
        {title: '下单用<br/>户手机', field: 'userPhone', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.userPhone != '' && row.userPhone != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.userPhone + '" onfocus="TUser.tooltip()">' + row.userPhone + '</p>']
                }
                return btn;
            }
        },
        {title: '收货人<br/>姓名', field: 'recipient', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.recipient != '' && row.recipient != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.recipient + '" onfocus="TUser.tooltip()">' + row.recipient + '</p>']
                }
                return btn;
            }
        },
        {title: '收货人<br/>手机', field: 'recipientPhone', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.recipientPhone != '' && row.recipientPhone != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.recipientPhone + '" onfocus="TUser.tooltip()">' + row.recipientPhone + '</p>']
                }
                return btn;
            }
        },
        {title: '起点', field: 'startAddress', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.startAddress != '' && row.startAddress != null) {
                    var str = row.startAddress;
                    var str1 = "";
                    var arr = "";
                    for(var i=0,len=str.length/15;i<len;i++) {
                        str1 = str.substr(0,15);
                        str = str.replace(str1,'');
                        arr += str1 + "<br>";
                    }
                    arr = arr.substring(0,arr.length-4);
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.startAddress + '" onfocus="TUser.tooltip()">' + arr + '</p>']
                }
                return btn;
            }
        },
        {title: '终点', field: 'endAddress', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.endAddress != '' && row.endAddress != null) {
                    var str = row.endAddress;
                    var str1 = "";
                    var arr = "";
                    for(var i=0,len=str.length/15;i<len;i++) {
                        str1 = str.substr(0,15);
                        str = str.replace(str1,'');
                        arr += str1 + "<br>";
                    }
                    arr = arr.substring(0,arr.length-4);
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.endAddress + '" onfocus="TUser.tooltip()">' + arr + '</p>']
                }
                return btn;
            }
        },
        {title: '接单司机', field: 'driver', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.driver != '' && row.driver != null) {
                    var driverName1 = row.driver.replace("-","<br>");
                    var driverName2 = row.driver.replace("-","&#10;");
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + driverName2 + '" onfocus="TUser.tooltip()">' + driverName1 + '</p>']
                }
                return btn;
            }
        },
        {title: '接单车辆', field: 'car', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.car != '' && row.car != null) {
                    var car1 = row.car.replace("-","<br>");
                    var car2 = row.car.replace("-","&#10;");
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + car2 + '" onfocus="TUser.tooltip()">' + car1 + '</p>']
                }
                return btn;
            }
        },
        {title: '订单金额', field: 'orderMoney', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "0";
                if(row.orderMoney != '' && row.orderMoney != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.orderMoney + '" onfocus="TUser.tooltip()">' + row.orderMoney + '</p>']
                }
                if(row.state == 10 && row.cancel_money != null){
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.cancel_money + '" onfocus="TUser.tooltip()">' + row.cancel_money + '</p>']
                }
                return btn;
            }
        },
        {title: '状态', field: 'state', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.state != '' && row.state != null) {
                    if (row.state == 1){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待接单" onfocus="TUser.tooltip()">待接单</p>']
                    } else if (row.state == 2){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待出发" onfocus="TUser.tooltip()">待出发</p>']
                    } else if (row.state == 3){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待到达预约地点" onfocus="TUser.tooltip()">待到达预约地点</p>']
                    } else if (row.state == 4){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待取货" onfocus="TUser.tooltip()">待取货</p>']
                    } else if (row.state == 5){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="服务中" onfocus="TUser.tooltip()">服务中</p>']
                    } else if (row.state == 6){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="完成服务" onfocus="TUser.tooltip()">完成服务</p>']
                    }else if (row.state == 8){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待评价" onfocus="TUser.tooltip()">待评价</p>']
                    }
                    else if (row.state == 7){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待支付" onfocus="TUser.tooltip()">待支付</p>']
                    } else if (row.state == 9){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="已完成" onfocus="TUser.tooltip()">已完成</p>']
                    } else if (row.state == 10){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="已取消" onfocus="TUser.tooltip()">已取消</p>']
                    }
                }
                return btn;
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
TOrderLogistics.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TOrderLogistics.seItem = selected[0];
        return true;
    }
};
 
/**
 * 打开查看小件物流订单详情
 */
TOrderLogistics.detail = function () {
    if(this.check()){
        var index = layer.open({
            type: 2,
            title: '小件物流订单详情',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tOrderLogistics/tOrderLogistics_detail/' + TOrderLogistics.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 取消订单
 */
TOrderLogistics.cancel = function(){
    if (this.check()) {
        var nickname = TOrderLogistics.seItem.orderNum;
        if (nickname == "" || nickname == null || nickname == undefined) {
            nickname = "该订单";
        } else {
            nickname = "【" + nickname + "】";
        }
        if (TOrderLogistics.seItem.state == 9 || TOrderLogistics.seItem.state == 10 ) {
            swal("取消失败", "【已完成】【已取消】状态下不能执行此操作", "warning");
            return;
        }
        swal({
            title: "您是否确认取消订单" + nickname + "?",
            text: "请谨慎操作,取消后数据无法恢复!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "取消订单",
            closeOnConfirm: false
        }, function () {
            var ajax = new $ax(Feng.ctxPath + "/tOrderLogistics/cancel", function (data) {
                swal("取消订单成功", "您已经成功取消了" + nickname + "。", "success");
                TOrderLogistics.table.refresh();
            }, function (data) {
                swal("取消订单失败", data.responseJSON.message + "!", "warning");
            });
            ajax.set("tOrderLogisticsId", TOrderLogistics.seItem.id);
            ajax.start();
        });
    }
}
 
/**
 * 删除小件物流订单
 */
TOrderLogistics.delete = function () {
    if (this.check()) {
        var orderNum = TOrderLogistics.seItem.orderNum;
        if (orderNum == "" || orderNum == null || orderNum == undefined) {
            orderNum = "该订单";
        } else {
            orderNum = "【" + orderNum + "】";
        }
        if (TOrderLogistics.seItem.state != 10) {
            swal("删除失败", "【已取消】状态下才能执行此操作", "warning");
            return;
        }
        swal({
            title: "您是否确认删除" + orderNum + "?",
            text: "请谨慎操作,删除后数据无法恢复!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "删除",
            closeOnConfirm: false
        }, function () {
            var ajax = new $ax(Feng.ctxPath + "/tOrderLogistics/delete", function (data) {
                swal("删除成功", "您已经删除了" + orderNum + "。", "success");
                TOrderLogistics.table.refresh();
            }, function (data) {
                swal("删除失败", data.responseJSON.message + "!", "warning");
            });
            ajax.set("tOrderLogisticsId", TOrderLogistics.seItem.id);
            ajax.start();
        });
    }
};
 
/**
 * 查询小件物流订单列表
 */
TOrderLogistics.search = function () {
    var queryData = {};
    queryData['insertTime'] = $("#insertTime").val();
    queryData['orderNum'] = $("#orderNum").val();
    queryData['type'] = $("#type").val();
    queryData['orderSource'] = $("#orderSource").val();
    queryData['userName'] = $("#userName").val();
    queryData['userPhone'] = $("#userPhone").val();
    queryData['recipient'] = $("#recipient").val();
    queryData['recipientPhone'] = $("#recipientPhone").val();
    queryData['driver'] = $("#driver").val();
    queryData['state'] = $("#state").val();
    TOrderLogistics.table.refresh({query: queryData});
};
 
TOrderLogistics.resetSearch = function () {
    $("#insertTime").val("");
    $("#orderNum").val("");
    $("#type").val("");
    $("#orderSource").val("");
    $("#userName").val("");
    $("#userPhone").val("");
    $("#recipient").val("");
    $("#recipientPhone").val("");
    $("#driver").val("");
    $("#state").val("");
    TOrderLogistics.search();
};
 
$(function () {
    var defaultColunms = TOrderLogistics.initColumn();
    var table = new BSTable(TOrderLogistics.id, "/tOrderLogistics/list", defaultColunms);
    table.setPaginationType("server");
    TOrderLogistics.table = table.init();
});