wxw
2025-05-12 c7c2f7aa20427204944ba80a2704232b2f281582
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge"> 
    <title>物流信息</title>
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
     
</head>
 
<body>
    <div class="layui-fluid" style="padding-bottom: 0;">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto" style="border-bottom:1px solid #CCC">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 75px; padding-left: 0px;">运输公司</label>
                        <div class="layui-input-inline">
                            <input type="text" id="CarrierName" name="CarrierName" placeholder="运输公司"
                                autocomplete="off" class="layui-input"
                                onkeyup="this.value=this.value.replace(/[, ]/g,'')">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 45px;">联系人</label>
                        <div class="layui-input-inline">
                            <input type="text" id="LinkMan" name="LinkMan" placeholder="联系人" autocomplete="off"
                                class="layui-input" onkeyup="this.value=this.value.replace(/[, ]/g,'')">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 45px;">电话</label>
                        <div class="layui-input-inline">
                            <input type="text" id="Phone" name="Phone" placeholder="电话" autocomplete="off"
                                class="layui-input" onkeyup="this.value=this.value.replace(/[, ]/g,'')">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 65px;">车牌号</label>
                        <div class="layui-input-inline">
                            <input type="text" id="LicensePlate" name="LicensePlate" placeholder="车牌号"
                                autocomplete="off" class="layui-input"
                                onkeyup="this.value=this.value.replace(/[, ]/g,'')">
                        </div>
                    </div>
                    
                    <div class="layui-inline">
                        <label class="layui-form-label" style="width: 65px;">车辆类型</label>
                        <div class="layui-input-inline">
                            <select name="Type" id="Type" lay-filter="Type" lay-search>
                                <option value=""></option>
                                <option value="0">冷冻车</option>
                                <option value="1">大货车</option>
                                <option value="2">中货车</option>
                                <option value="3">小货车</option>
                                <option value="4">火车</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit
                            lay-filter="LAY-app-contlist-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>搜索
                        </button>
                    </div>
                </div>
            </div>
            <div class="layui-card-body" style="padding-top: 0;">
                <div style="padding-bottom: 5px;display: flex; flex-direction: row-reverse;">
                    <button style="margin-right: 10px;" class="layui-btn layui-btn-sm layuiadmin-btn-list addClass" data-type="add">
                        <i class="layui-icon">&#xe654;</i>添加
                    </button>
                </div>
                <table id="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
                    
                <!-- <script type="text/html" id="toolbarDemo">
                    
                </script> -->
                 
                <script type="text/html" id="table-content-list">
                    <a class="layui-btn layui-btn-normal layui-btn-xs editClass" lay-event="edit">
                        <i class="layui-icon layui-icon-edit"></i>编辑
                    </a>
                    <a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del">
                        <i class="layui-icon layui-icon-delete"></i>删除
                    </a>
                </script>
               
            </div>
        </div>
    </div>
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../js/public.js"></script>
    <script src="../../js/jquery-3.5.1.min.js"></script>
    <script src="../../js/jquery.cookie.js"></script>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'laypage', 'layer'], function () {
            var table = layui.table,
                form = layui.form,
                laypage = layui.laypage,
                layer = layui.layer;
 
            var xqid = "";
            refreshTable("","","","","");
            var tableIns;
            
            function refreshTable(CarrierName,LinkMan,Phone,LicensePlate,Type) {
                var param = {
                    CarrierName: CarrierName,
                    LinkMan: LinkMan,
                    Phone: Phone,
                    LicensePlate: LicensePlate,
                    Type: Type
                    //$("#CarrierName").val(), $("#LinkMan").val(), $("#Phone").val(), $("#LicensePlate").val(), $("#Type").val(),
                }; 
                table.render({
                    elem: '#LAY-app-content-list',
                    url: IP + "/Basis/GetLogisticsInfoList",
                    method: 'POST',
                    height: 'full-119',
                    id: 'LAY-app-content-list',
                    where: param,
                    contentType: 'application/json',
                    headers:{ToKen:$.cookie('token')},
                    toolbar:'#toolbarDemo',
                    defaultToolbar:  ['filter'], //'print', 'exports'
                    page: true,
                    limit: pageCnt,
                    limits: pageLimits,
                    cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    even: true,
                    done: function () {
                        initPermission();
                    },
                    cols: [
                        [{ 
                            title: '序号',
                            type: 'numbers',
                            width: 65,
                            align: 'center',
                            fixed: 'left'
                        }, {
                            field: 'CarrierName',
                            title: '运输公司', 
                            width: 160,
                            align: 'center',
                        }, {
                            field: 'Address',
                            title: '地址',
                            width: 160,
                            align: 'center',
                        }, {
                            field: 'LinkMan',
                            title: '联系人',
                            width: 100,
                            align: 'center',
                        }, {
                            field: 'Phone',
                            title: '电话',
                            width: 130,
                            align: 'center',
                        }, {
                            field: 'BankAccount',
                            title: '银行卡号',
                            width: 160,
                            align: 'center',
                        }, {
                            field: 'CreditRating',
                            title: '信用等级',
                            width: 100,
                            align: 'center',
                        }, {
                            field: 'LicensePlate',
                            title: '车牌号',
                            width: 130,
                            align: 'center',
                        }, {
                            field: 'Type',
                            title: '车辆类型',
                            width: 100,
                            align: 'center',
                            templet: function (d) {
                                if (d.Type == "0") {
                                    return "冷冻车";
                                }else if(d.Type =="1"){
                                    return "大货车";
                                }else if(d.Type =="2"){
                                    return "中货车";
                                }else if(d.Type =="3"){
                                    return "小货车";
                                }else if(d.Type =="4"){
                                    return "火车";
                                }else{
                                    return "";
                                }
                            },
                        }, {
                            field: 'Demo',
                            title: '备注',
                            width: 160,
                            align: 'center',
                        }, {
                            field: 'CreateUserName',
                            title: '创建人',
                            width: 100,
                            align: 'center',
                        }, {
                            field: 'CreateTime',
                            title: '创建时间',
                            width: 160,
                            align: 'center',
                            templet: function (d) {
                                return formatDate(d.CreateTime);
                            }
                        }, {
                            field: 'UpdateUserName',
                            title: '修改人',
                            width: 100,
                            hide:true,
                            align: 'center',
                        }, {
                            field: 'UpdateTime',
                            title: '修改时间',
                            width: 160,
                            align: 'center',
                            hide:true,
                            templet: function (d) {
                                return formatDate(d.UpdateTime);
                            }
                        }, {
                            title: '操作', 
                            fixed: 'right',
                            width: 200, 
                            align: 'center', 
                            toolbar: '#table-content-list'
                        }]
                    ],
                });
            }
            function initPermission(){
                $(function() {
                    $(".editClass").hide();
                    $(".delClass").hide();
                    $(".addClass").hide();
                });
                sendData(IP + "/Basis/GetRoleRightList", {}, 'get', function(res) {
                    if (res.code == 0) { //成功 
                        for (var k = 0; k < res.data.length; k++) {
                            if (res.data[k].MenuName == "编辑物流") {
                                $(".editClass").show();
                            }
                            if (res.data[k].MenuName == "删除物流") {
                                $(".delClass").show();
                            }
                            if (res.data[k].MenuName == "添加物流") {
                                $(".addClass").show();
                            }
                        }
                    } else { //不成功
                        layer.msg('获取权限信息失败', {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                    }
                }); 
            }
            //搜索按钮
            form.on('submit(LAY-app-contlist-search)', function (data) {
                // console.log($("#CarrierName").val())
                // $("#CarrierName").val()
                // $("#LinkMan").val(), $("#Phone").val(), $("#LicensePlate").val(), $("#Type").val()
                var CarrierName= $("#CarrierName").val();
                var LinkMan= $("#LinkMan").val();
                var Phone= $("#Phone").val();
                var LicensePlate= $("#LicensePlate").val();
                var Type= $("#Type").val();
                
                refreshTable(CarrierName,LinkMan,Phone,LicensePlate,Type);
               
            });
 
            var doing = true;
            active = {
                batchdel: function () {
                    var url = "";
                    var checkStatus;
                    var checkStatus = table.checkStatus('LAY-app-content-list'),
                    checkData = checkStatus.data; //得到选中的数据
                    
                    if (checkData.length === 0) {
                        return layer.msg('请选择数据');
                    }
 
                    layer.confirm('确定删除吗?', function (index) {
                        if (doing) {
                            doing = false;
 
                            console.log(checkData);
                            var msg = [];
                            for (var i = 0; i < checkData.length; i++) {
                                msg.push(checkData[i].Id);
                            }
                            var param = {
                                Ids: msg,
                            };
 
                            sendData(IP + "/Basis/DelsLogisticsInfo", param, 'post', function (res) {
                                console.log(res);
                                if (res.code == 0) { //成功
                                    layer.msg(res.msg, {
                                        icon: 1,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () {
                                        doing = true;
                                        refreshTable($("#CarrierName").val(), $("#LinkMan").val(), $("#Phone").val(), $("#LicensePlate").val(), $("#Type").val());
                                    });
                                } else { //不成功
                                    layer.msg(res.msg, {
                                        icon: 2,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () { doing = true; });
                                }
                            });
                        }
                    });
                },
                add: function () {
                    layer.open({
                        type: 2,
                        title: '添加物流信息',
                        content: 'LogisticsInfoFrom.html',
                        maxmin: true,
                        area: ['510px', '750px'],
                        btn: ['确定', '取消'],
                        yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index],
                                submitID = 'layuiadmin-app-form-submit',
                                submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                                if (doing) {
                                    doing = false;
 
                                    var field = data.field; //获取提交的字段
                                    console.log(field);
                                    //提交 Ajax 成功后,静态更新表格中的数据
                                    var param = { 
                                        CarrierName: field.CarrierName,
                                        Address: field.Address,
                                        LinkMan: field.LinkMan,
                                        Phone:field.Phone,
                                        
                                        BankAccount: field.BankAccount,
                                        CreditRating:field.CreditRating,
                                        LicensePlate:field.LicensePlate,
                                        Type:field.Type,
                                        Demo: field.Demo,
                                    };
                                    sendData(IP + "/Basis/AddLogisticsInfo", param, 'post', function (res) {
                                        console.log(res);
                                        if (res.code == 0) { //成功
                                            layer.msg(res.msg, {
                                                icon: 1,
                                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                            }, function () {
                                                refreshTable($("#CarrierName").val(), $("#LinkMan").val(), $("#Phone").val(), $("#LicensePlate").val(), $("#Type").val());
                                                layer.close(index); //关闭弹层
                                                doing = true;
                                            });
                                            console.log(1)
                                        } else if(res.code ==1) { //不成功
                                            layer.msg(res.msg, {
                                                icon: 2,
                                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                            }, function () { doing = true; });
                                            console.log(2)
                                        }else{
                                            layer.msg(res.statusText, {
                                                icon: 2,
                                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                            }, function () { doing = true; });
                                            console.log(3)
                                        }
                                    });
                                }
                            });
                            submit.trigger('click');
                        }
                    });
                }
            };
            $('.layui-btn.layuiadmin-btn-list').on('click', function () {
                var type = $(this).data('type');
                active[type] ? active[type].call(this) : '';
            });
 
           
 
            var cusid = "0";
            table.on('tool(LAY-app-content-list)', function (obj) {
                var data = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('确定删除选中的物流信息吗?', function (index) {
                        if (doing) {
                            doing = false;
 
                            cusid = data.Id;
                            var param = {
                                Id: cusid,
                            };
                            sendData(IP + "/Basis/DelLogisticsInfo", param, 'post', function (res) {
                                console.log(res);
                                if (res.code == 0) { //成功
                                    layer.msg(res.msg, {
                                        icon: 1,
                                        time: 1000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () {
                                        refreshTable($("#CarrierName").val(), $("#LinkMan").val(), $("#Phone").val(), $("#LicensePlate").val(), $("#Type").val());
                                        doing = true;
                                    });
                                } else { //不成功
                                    layer.msg(res.msg, {
                                        icon: 2,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () { doing = true; });
                                }
                            });
                        }
                    });
                } else if (obj.event === 'edit') {
                    cusid = data.Id;
                    layer.open({
                        type: 2,
                        title: '编辑物流信息',
                        content: 'LogisticsInfoFrom.html?id=' + cusid,
                        maxmin: true,
                        area: ['510px', '750px'],
                        btn: ['确定', '取消'],
                        yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index],
                                submitID = 'layuiadmin-app-form-edit',
                                submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (
                                data) {
                                if (doing) {
                                    doing = false;
 
                                    var field = data.field; //获取提交的字段
                                    console.log(field);
                                    //提交 Ajax 成功后,静态更新表格中的数据
                                    var param = {
                                        Id: cusid,
                                        CarrierName: field.CarrierName,
                                        Address: field.Address,
                                        LinkMan: field.LinkMan,
                                        Phone:field.Phone,
                                        
                                        BankAccount: field.BankAccount,
                                        CreditRating:field.CreditRating,
                                        LicensePlate:field.LicensePlate,
                                        Type:field.Type,
                                        Demo: field.Demo,
                                    };
                                    sendData(IP + "/Basis/EditLogisticsInfo", param, 'post',
                                        function (res) {
                                            console.log(res);
                                            if(res.code == 0) { //成功
                                                layer.msg(res.msg, {
                                                    icon: 1,
                                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                                }, function () {
                                                    refreshTable($("#CarrierName").val(), $("#LinkMan").val(), $("#Phone").val(), $("#LicensePlate").val(), $("#Type").val());
                                                    layer.close(index); //关闭弹层
                                                    doing = true;
                                                });
                                            }else if(res.code ==1) { //不成功
                                                layer.msg(res.msg, {
                                                    icon: 2,
                                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                                }, function () { doing = true; });
                                            }else { //不成功
                                                layer.msg(res.statusText, {
                                                    icon: 2,
                                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                                }, function () { doing = true; });
                                            }
                                        });
                                }//$.ajax({});
                            });
                            submit.trigger('click');
                        }
                    });
                }
                
            });
 
        });
    </script>
</body>
 
</html>