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
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<!DOCTYPE html>
<html>
 
<head>
    <meta charset="utf-8">
    <title>新增组盘信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style>
        .rightMargin {
            margin-right: 0px;
        }
 
        .buJu {
            margin-top: 10px;
            display: flex;
            flex-direction: row-reverse;
        }
 
        .beiJing {
            background-color: #fafafa;
            padding-top: 5px;
            border-radius: 3px;
            box-shadow: inset 0 0 3px 1px #ccc;
        }
 
        /* 表格下拉小箭头隐藏 */
        .layui-table-grid-down {
            display: none;
        }
    </style>
</head>
 
<body>
 
    <div class="layui-fluid" style="padding: 3px;">
        <div class="layui-card">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">箱 号</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <input type="text" id="BoxNo" name="BoxNo" placeholder="箱号" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">盒 号</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <input type="text" id="BoxNo2" name="BoxNo2" placeholder="盒号" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">支 号</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <input type="text" id="BoxNo3" name="BoxNo3" placeholder="支号" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">物品编号</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <input type="text" id="SkuNo" name="SkuNo" placeholder="物料编号" autocomplete="off"
                                class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">批次号</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <div class="layui-input-inline" style="margin-right: 0;">
                                <input type="text" id="LotNo" name="LotNo" placeholder="批次号" autocomplete="off"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">批次描述</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <div class="layui-input-inline" style="margin-right: 0;">
                                <input type="text" id="LotText" name="LotText" placeholder="批次描述" autocomplete="off"
                                    class="layui-input">
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">实际数量</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <input type="number" id="Qty" name="Qty" placeholder="实际数量" autocomplete="off"
                                class="layui-input" min="0" value="0" oninput="value=value.replace(/^(0+)|[^\d]+/g,'')">
                        </div>
                    </div>
 
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label">生产日期</label>
                        <div class="layui-input-inline">
                            <input type="text" autocomplete="off" name="ProductionTime" id="ProductionTime"
                                class="layui-input" placeholder="生产日期">
                        </div>
                    </div>
 
 
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label">检验标记</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <div class="layui-input-inline" style="margin-right: 0;">
                                <select name="InspectMark" id="InspectMark" lay-filter="InspectMark" lay-search>
                                    <option value=""></option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
 
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-right: 0;">
                        <label class="layui-form-label" style="width: 60px;">零箱标记</label>
                        <div class="layui-input-inline" style="margin-right: 0;">
                            <div class="layui-input-inline" style="margin-right: 0;">
                                <select name="BitBoxMark" id="BitBoxMark" lay-filter="BitBoxMark" lay-search>
                                    <option value=""></option>
                                    <option value="0">否</option>
                                    <option value="1">是</option>
                                </select>
                            </div>
                        </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">
                <!-- <button type="button" class="layui-btn layui-btn-sm" id="daoru1">
                    导入
                </button> -->
                <table id="Box-list" lay-filter="Box-list"></table>
 
                <script type="text/html" id="toolbarDemo">
                    <button style="margin-right: 5px;" class="layui-btn layui-btn-sm layuiadmin-btn-list addClass" lay-event="add" >
                        <i class="layui-icon">&#xe654;</i>添加
                    </button>
 
                    <button style="margin-right: 5px;" id="daoru" class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-event="import" >
                        <i class="layui-icon">&#xe654;</i>导入
                    </button>
                </script>
 
                <script type="text/html" id="toolbarDemoList">
                    {{# function GetBtn2(d){
                            var html = '';
                            if(d.Origin == "录入" || d.Origin == "导入"){ 
                                html = `<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"> 
                                    <i class="layui-icon layui-icon-delete"></i>删除</a>`; 
                                
                            }
                            return html;
                        } 
                    }}
                    {{ GetBtn2(d) }}
                </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.extend({
            excel: '../../layuiadmin/layui/layui_exts/excel' // {/}的意思即代表采用自有路径,即不跟随 base 路径
        })
 
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'layer', 'table', 'laydate', 'upload', 'excel'], function () {
            var form = layui.form,
                table = layui.table,
                layer = layui.layer,
                laydate = layui.laydate;
            var upload = layui.upload;
 
            laydate.render({
                elem: '#ProductionTime'
                , format: 'yyyy-MM-dd' //可任意组合
            });
 
            // 页面加载绑定Table
            bindTable();
 
            // 搜索方法
            form.on('submit(LAY-app-contlist-search)', function (data) {
                bindTable(); 
                
            });  
            // 添加导入按钮单机事件
            table.on('toolbar(Box-list)', function (obj) {
                switch (obj.event) {
                    case 'add':    // 添加箱支关系
                        // 代码区域
                        var param = getBoxInforVlues();
                        if (param != "") {
                            console.log(param);
                            sendData(IP + "/BllAsn/AddBllBoxInfo", param, 'post', function (res) {
                                if (res.code == 0) { //成功
                                    layer.msg(res.msg, {
                                        icon: 1,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () {
                                        bindTable();
                                    });
                                } else { //不成功
                                    layer.msg(res.msg, {
                                        icon: 2,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () { doing = true });
                                } 
                            });
                        }
                        break;
                    
                    default: break;
                }
            });
 
 
            // 删除箱支信息
            table.on('tool(Box-list)', function (obj) {
                var data = obj.data;
                switch (obj.event) {
                    case "del":
                        layer.confirm('确定删除箱支明细吗?', function (index) {
                            // 代码区域
                            var param = {
                                Id: data.Id,
                                Status: "0",
                            };
                            console.log(param);
                            sendData(IP + "/BllAsn/DelBllBoxInfo", param, 'post', function (res) {
                                if (res.code == 0) { //成功
                                    layer.msg(res.msg, {
                                        icon: 1,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () {
                                        bindTable();
                                        doing = true
                                    });
                                } else { //不成功
                                    layer.msg(res.msg, {
                                        icon: 2,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () { doing = true });
                                }
                            });
                        });
 
                        break;
                    default: break;
                }
            });
 
            //#region 事件方法
            // 查询录入的箱支关系
            function bindTable() {
                var param = {
                    BoxNo: $("#BoxNo").val(),
                    BoxNo2: $("#BoxNo2").val(),
                    BoxNo3: $("#BoxNo3").val(),
                    SkuNo: $("#SkuNo").val(),
                    LotNo: $("#LotNo").val(),
                    LotText: $("#LotText").val(),
                    ProductionTime: $("#ProductionTime").val(),
                    InspectMark: $("#InspectMark").val(),
                    BitBoxMark: $("#BitBoxMark").val(),
                    // Origin: "录入",
                };
 
                table.render({
                    elem: '#Box-list',
                    url: IP + "/BllAsn/GetBllBoxInfoList",
                    method: 'POST',
                    height: 'full-136',
                    id: 'Box-list',
                    where: param,
                    contentType: 'application/json',
                    toolbar: '#toolbarDemo',
                    defaultToolbar: ['filter'], //'print', 'exports'
                    headers: { ToKen: $.cookie('token') },
                    page: true,
                    even: true,
                    limit: pageCnt,
                    limits: pageLimits,
                    cellMinWidth: 60, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    done: function (res) {
                        setRight();
                    },
                    cols: [
                        [{
                            field: 'BoxNo',
                            title: '箱号',
                            align: 'center',
                            fixed: 'left'
                        }, {
                            field: 'BoxNo2',
                            title: '盒号',
                            align: 'center',
                            fixed: 'left'
                        }, {
                            field: 'BoxNo3',
                            title: '支号',
                            align: 'center',
                            fixed: 'left'
                        }, {
                            field: 'SkuNo',
                            title: '物料编码',
                            align: 'center',
                            fixed: 'left'
                        }, {
                            field: 'SkuName',
                            title: '物料名称',
                            align: 'center',
                            fixed: 'left'
                        }, {
                            field: 'LotNo',
                            title: '批次号',
                            align: 'center',
                            width: 100,
                        }, {
                            field: 'Qty',
                            title: '数量',
                            align: 'center',
                            width: 80,
                        }, {
                            field: 'LotText',
                            title: '批次描述',
                            align: 'center',
 
                        }, {
                            field: 'ProductionTime',
                            title: '生产日期',
                            align: 'center',
                            width: 160,
                            templet: function (d) {
                                return formatDate(d.ProductionTime);
                            }
                        }, {
                            field: 'ExpirationTime',
                            title: '过期日期',
                            align: 'center',
                            width: 160,
                            templet: function (d) {
                                return formatDate(d.ExpirationTime);
                            }
                        }, {
                            field: 'SupplierLot',
                            title: '供货批次',
                            align: 'center',
                        }, {
                            field: 'InspectMark',
                            title: '检验标记',
                            align: 'center',
                            templet: function (d) {
                                switch (d.InspectMark) {
                                    case "0": return "否";
                                    case "1": return "是";
                                    default: return "";
                                }
                            }
                        }, {
                            field: 'BitBoxMark',
                            title: '零箱标记',
                            align: 'center',
                            templet: function (d) {
                                switch (d.BitBoxMark) {
                                    case "0": return "否";
                                    case "1": return "是";
                                    default: return "";
                                }
                            }
                        }, {
                            field: 'Origin',
                            title: '来源',
                            align: 'center',
                        }, {
                            field: 'CreateUserName',
                            title: '创建人',
                            align: 'center',
                            width: 100
                        }, {
                            field: 'CreateTime',
                            title: '创建时间',
                            align: 'center',
                            width: 160,
                            templet: function (d) {
                                return formatDate(d.CreateTime);
                            }
                        }, {
                            title: '操作',
                            fixed: 'right',
                            width: 100,
                            align: 'center',
                            toolbar: '#toolbarDemoList'
                        }]
                    ],
 
                });
                
                upload.render({
                    elem: '#daoru' //绑定元素
                    , url: '' //上传接口
                    , auto: false  //是否选完文件后自动上传。如果设定 false,那么需要设置 bindAction 参数来指向一个其它按钮提交上传
                    , exts: 'slx|excel|xlsx'  //允许上传的文件后缀 
                    , accept: 'file' //指定允许上传时校验的文件类型
                    //, bindAction: '#daoru' //指向一个按钮触发上传
                    , choose: function (obj) {// 选择文件回调
                        console.log(obj);
                        var files = obj.pushFile(); //将每次选择的文件追加到文件队列
                        var fileArr = Object.values(files);// 注意这里的数据需要是数组,所以需要转换一下
                        console.log(fileArr)
                        // 用完就清理掉,避免多次选中相同文件时出现问题
                        for (var index in files) {
                            console.log(index);
                            if (files.hasOwnProperty(index)) {
                                delete files[index];
                            }
                        }
                        console.log("abs");
                        uploadExcel(fileArr); // 如果只需要最新选择的文件,可以这样写: uploadExcel([files.pop()])
                    }
                    , done: function (res) {
                        console.log(res);
                        //上传完毕回调
                    }
                    , error: function (res) {
                        console.log(res);
                        //请求异常回调
                    }
                }); 
            }
 
            // 权限设置
            function setRight() {
                $(function () {
                    $(".addClass").hide();
                    $(".editClass").hide();
                    $(".delClass").hide();
                    $(".delMxClass").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 == "添加入库单") {
                                $(function () {
                                    $(".addClass").show();
                                });
                            }
                            if (res.data[k].MenuName == "编辑入库单") {
                                $(function () {
                                    $(".editClass").show();
                                });
                            }
                            if (res.data[k].MenuName == "删除入库单") {
                                $(function () {
                                    $(".delClass").show();
                                    $(".delMxClass").show();
                                });
                            }
                        }
                    } else { //不成功
                        layer.msg('获取权限信息失败', {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function () { });
                    }
                });
            }
 
            // 获取箱支信息
            function getBoxInforVlues() {
                var msg = "";
                if ($("#BoxNo").val() == "") {
                    layer.msg("请输入箱码!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                    });
                    return msg;
                }
                // if ($("#BoxNo2").val() == "") {
                //     layer.msg("请输入盒码!", {
                //         icon: 2,
                //         time: 2000 //2秒关闭(如果不配置,默认是3秒)
                //     });
                //     return msg;
                // }
                if ($("#BoxNo3").val() == "") {
                    layer.msg("请输入支码!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                    });
                    return msg;
                }
                if ($("#SkuNo").val() == "") {
                    layer.msg("请输入物料编码!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                    });
                    return msg;
                }
                if ($("#LotNo").val() == "") {
                    layer.msg("请输入批次号!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                    });
                    return msg;
                }
                if ($("#Qty").val() == "") {
                    layer.msg("请输入实际数量!", {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                    });
                    return msg;
                }
 
                var param = {
                    BoxNo: $("#BoxNo").val(),
                    BoxNo2: $("#BoxNo2").val(),
                    BoxNo3: $("#BoxNo3").val(),
                    SkuNo: $("#SkuNo").val(),
                    LotNo: $("#LotNo").val(),
                    LotText: $("#LotText").val(),
                    Qty: parseInt($("#Qty").val()),
                    ProductionTime: $("#ProductionTime").val(),
                    InspectMark: $("#InspectMark").val(),
                    BitBoxMark: $("#BitBoxMark").val(),
                    Origin: "录入",
                };
 
                return param;
            }
 
            // 导入箱支关系
            function uploadExcel(files) {
                console.log("123");
                var list = [];
                try {
                    var excel = layui.excel;
                    excel.importExcel(files, {
                        // 读取数据的同时梳理数据
                        fields: {
                            'BoxNo': 'A',
                            'BoxNo2': 'B',
                            'BoxNo3': 'C',
                            'Qty': 'D',
                            'SkuNo': 'E',
                            'LotNo': 'F',
                            'LotText': 'G',
                            'ProductionTime': 'H',
                            'InspectMark': 'I',
                            'BitBoxMark': 'J',
                        }
                    },
                        function (data) {
                            console.log(data);
                            // var arr = new Array();
                            //excel第一行不读取、设置为标题
                            for (i = 1; i < data[0].Sheet1.length; i++) {
 
                                var Qty = 0;
                                if (isIntNum(data[0].Sheet1[i].Qty)) {
                                    Qty = parseInt(data[0].Sheet1[i].Qty);
                                }
 
                                var InspectMark = "0";
                                var BitBoxMark = "0";
                                if (data[0].Sheet1[i].InspectMark == "是") {
                                    InspectMark = "1";
                                }
                                if (data[0].Sheet1[i].BitBoxMark == "是") {
                                    BitBoxMark = "1";
                                }
                                var tt = {
                                    BoxNo: data[0].Sheet1[i].BoxNo,
                                    BoxNo2: data[0].Sheet1[i].BoxNo2,
                                    BoxNo3: data[0].Sheet1[i].BoxNo3,
                                    Qty: Qty,
                                    SkuNo: data[0].Sheet1[i].SkuNo,
                                    LotNo: data[0].Sheet1[i].LotNo,
                                    LotText: data[0].Sheet1[i].LotText,
                                    ProductionTime: data[0].Sheet1[i].ProductionTime,
                                    InspectMark: InspectMark,
                                    BitBoxMark: BitBoxMark,
                                };
                                list.push(tt);
                                console.log(data[0].Sheet1[i].ProductionTime);
                            }
                            console.log(list);
                            var param = {
                                "OperType": "Add",
                                "ListBoxInfo": list,
                            }
 
                            sendData(IP + "/BllAsn/ImportBllBoxInfo", param, 'post', function (res) {
                                if (res.code == 0) { //成功
                                    layer.msg(res.msg, {
                                        icon: 1,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () {
                                        bindTable();
                                        doing = true
                                    });
                                } else { //不成功
                                    layer.msg(res.msg, {
                                        icon: 2,
                                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                    }, function () { bindTable();doing = true });
                                }
                            });
                        });
                } catch (e) {
                    layer.alert(e.message);
                }
 
            }
            //#endregion
        })
    </script>
</body>
 
</html>