puzhibing
2023-08-01 98bc380ae322eaac2ee7e21d0c565e30eacce2b5
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
/**
 * 跨城改派管理管理初始化
 */
var TCross = {
    id: "TCrossTable",    //表格id
    seItem: null,        //选中的条目
    table: null,
    layerIndex: -1
};
 
/**
 * 初始化表格的列
 */
TCross.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '主键ID', field: 'id', visible: false, align: 'center', valign: 'middle'},
        {title: '申请改<br/>派时间', 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: '申请司机id', field: 'originalDriverId', visible: false, align: 'center', valign: 'middle'},
        {title: '申请司机', field: 'originalDriver', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.originalDriver != '' && row.originalDriver != null) {
                    var driverName1 = row.originalDriver.replace("-","<br>");
                    var driverName2 = row.originalDriver.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: 'reason', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.reason != '' && row.reason != null) {
                    var str = row.reason;
                    if (str.length > 20){
                        str = str.substring(0,20)+'...<br><button class="btn btn-outline btn-primary" onclick="TReassign.buttonClick(' +  row.id + ',1)">查看更多</button>';
                    }
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.reason + '" onfocus="TUser.tooltip()">' + str + '</p>']
                }
                return btn;
            }
        },
        {title: '订单id', field: 'orderId', visible: false, align: 'center', valign: 'middle'},
        {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: 'addOrderUser', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.addOrderUser != '' && row.addOrderUser != null) {
                    var name1 = row.addOrderUser.replace("-","<br>");
                    var name2 = row.addOrderUser.replace("-","&#10;");
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + name2 + '" onfocus="TUser.tooltip()">' + name1 + '</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: '出发地', 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: '原始车辆id', field: 'originalCarId', visible: false, align: 'center', valign: 'middle'},
        {title: '原服务<br/>车辆', field: 'originalCar', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.originalCar != '' && row.originalCar != null) {
                    var car1 = row.originalCar.replace("-","<br>");
                    var car2 = row.originalCar.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: '改派<br/>处罚金', field: 'money', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.money != '' && row.money != null) {
                    btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="' + row.money + '" onfocus="TUser.tooltip()">' + row.money + '</p>']
                }
                return btn;
            }
        },
        {title: '改派后的司机id', field: 'nowDriverId', visible: false, align: 'center', valign: 'middle'},
        {title: '改派服<br/>务司机', field: 'nowDriver', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.nowDriver != '' && row.nowDriver != null) {
                    var driverName1 = row.nowDriver.replace("-","<br>");
                    var driverName2 = row.nowDriver.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: '改派后的车辆id', field: 'nowCarId', visible: false, align: 'center', valign: 'middle'},
        {title: '改派服<br/>务车辆', field: 'nowCar', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.nowCar != '' && row.nowCar != null) {
                    var car1 = row.nowCar.replace("-","<br>");
                    var car2 = row.nowCar.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: '订单当<br/>前状态', field: 'orderState', visible: true, align: 'center', valign: 'middle',
            formatter: function (value, row) {
                var btn = "";
                if(row.orderState != '' && row.orderState != null) {
                    if (row.orderState == 1){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待接单" onfocus="TUser.tooltip()">待接单</p>']
                    } else if (row.orderState == 2){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待出发" onfocus="TUser.tooltip()">待出发</p>']
                    } else if (row.orderState == 3){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待到达预约地点" onfocus="TUser.tooltip()">待到达预约地点</p>']
                    } else if (row.orderState == 4){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待乘客上车" onfocus="TUser.tooltip()">待乘客上车</p>']
                    } else if (row.orderState == 5){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="服务中" onfocus="TUser.tooltip()">服务中</p>']
                    } else if (row.orderState == 6){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="完成服务" onfocus="TUser.tooltip()">完成服务</p>']
                    } else if (row.orderState == 7){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待支付" onfocus="TUser.tooltip()">待支付</p>']
                    } else if (row.orderState == 8){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="待评价" onfocus="TUser.tooltip()">待评价</p>']
                    } else if (row.orderState == 9){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="已完成" onfocus="TUser.tooltip()">已完成</p>']
                    } else if (row.orderState == 10){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="已取消" onfocus="TUser.tooltip()">已取消</p>']
                    } else if (row.orderState == 11){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="改派中" onfocus="TUser.tooltip()">改派中</p>']
                    } else if (row.orderState == 12){
                        btn = ['<p class="toolTip" style="overflow:hidden;white-space:nowrap;text-overflow:ellipsis;" title="取消待支付" onfocus="TUser.tooltip()">取消待支付</p>']
                    }
                }
                return btn;
            }
        },
        {title: '改派<br/>状态', 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>']
                    }
                }
                return btn;
            }
        }
    ];
};
 
/**
 * 检查是否选中
 */
TCross.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录!");
        return false;
    }else{
        TCross.seItem = selected[0];
        return true;
    }
};
 
/**
 * 打开查看跨城改派管理详情
 */
TCross.reassignmentCross = function () {
    if (this.check()) {
        if (TCross.seItem.state != 2 ) {
            swal("改派失败", "【已支付】状态下才能执行此操作", "warning");
            return;
        }
        var index = layer.open({
            type: 2,
            title: '立即改派',
            area: ['100%', '100%'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/tReassign/tReassign_reassignmentCross/' + TCross.seItem.id
        });
        this.layerIndex = index;
    }
};
 
/**
 * 操作  1=拒绝 2=取消
 */
TCross.opt = function (type) {
    if (this.check()) {
        var confirm = "";
        if (1 == type){
            confirm = "拒绝改派";
        }else if (2 == type){
            confirm = "取消订单";
        }
        if (TCross.seItem.state != 2 ) {
            swal("操作失败", "【已支付】状态下才能执行此操作", "warning");
            return;
        }
        swal({
            title: "您是否确定" + confirm + "?",
            text: "请谨慎操作,操作后数据无法恢复!",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: confirm,
            closeOnConfirm: false
        }, function () {
            var ajax = new $ax(Feng.ctxPath + "/tReassign/optCross", function (data) {
                swal(confirm+"成功", "您已经成功" + confirm + "。", "success");
                TCross.table.refresh();
            }, function (data) {
                swal(confirm+"失败", data.responseJSON.message + "!", "warning");
            });
            ajax.set("tReassignId", TCross.seItem.id);
            ajax.set("optType", type);
            ajax.start();
        });
    }
};
 
/**
 * 查询跨城改派管理列表
 */
TCross.search = function () {
    var queryData = {};
    queryData['insertTime'] = $("#insertTime").val();
    queryData['originalDriverName'] = $("#originalDriverName").val();
    queryData['originalDriverPhone'] = $("#originalDriverPhone").val();
    queryData['orderNum'] = $("#orderNum").val();
    queryData['nowDriverName'] = $("#nowDriverName").val();
    queryData['nowDriverPhone'] = $("#nowDriverPhone").val();
    queryData['orderState'] = $("#orderState").val();
    queryData['state'] = $("#state").val();
    TCross.table.refresh({query: queryData});
};
 
TCross.resetSearch = function () {
    $("#insertTime").val("");
    $("#originalDriverName").val("");
    $("#originalDriverPhone").val("");
    $("#orderNum").val("");
    $("#nowDriverName").val("");
    $("#nowDriverPhone").val("");
    $("#orderState").val("");
    $("#state").val("");
    TCross.search();
};
 
$(function () {
    var defaultColunms = TCross.initColumn();
    var table = new BSTable(TCross.id, "/tReassign/listCross", defaultColunms);
    table.setPaginationType("server");
    TCross.table = table.init();
});