bklLiudl
2024-09-07 8c6e292c508312eca0aef4c203e5857c4fc3094c
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
<!DOCTYPE html>
<html>
 
<head>
    <meta name="viewport" content="user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta charset="UTF-8" />
    <!-- <meta name="viewport" content="width=device-width, initial-scale=0.665, minimum-scale=0.5, maximum-scale=1, user-scalable=no" /> -->
    <!-- <meta name="viewport" content="width=device-width, initial-scale=0.665" /> -->
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Boxline PDA</title>
 
    <link rel="stylesheet" href="/layui/css/layui.css" />
    <link rel="stylesheet" href="/css/style.css" />
    <script src="/js/adaptive.js"></script>
    <link rel="stylesheet" href="/css/my.css" />
    <style type="text/css">
        .layout-bill-info {
            height: auto;
            /* background-color: #009E94; */
        }
 
        .btn-ok-blue {
            border: none;
            color: #FFFFFF;
            background-color: #0a93e3;
            width: 48%;
            height: 36px;
            border-radius: 5px;
        }
 
        .btn-ok-red {
            border: none;
            color: #FFFFFF;
            background-color: #9f1707;
            width: 48%;
            height: 36px;
            border-radius: 5px;
        }
 
        .btn-ok-blue:active {
            opacity: 0.8;
        }
 
        .btn-ok-red:active {
            opacity: 0.8;
        }
 
        .foot-container {
            text-align: center;
            /* background-color: #007DDB; */
        }
    </style>
    <link rel="stylesheet" href="/css/adapter.css" />
</head>
 
<body>
    <div id="" class="main-content">
        <div id="" class="layout-title">
            <table border="" cellspacing="" cellpadding="">
                <tr>
                    <td class="img-back"><a href="../index.html"><img src="/assets/back.jpg"></a></td>
                    <td class="title-text" lang>平库出库</td>
                    <td class="title-menu-icon"><img id="menuImg" src="/assets/menu.jpg"></td>
                </tr>
            </table>
        </div>
        <div id="" class="layout-sub-content">
            <div id="menuList" class="menu">
                <ul class="" style="text-align: center;">
                    <li><a href="../index.html" lang>主页</a></li>
                    <!-- <li><a href="productEnterConfirm.html">入库信息确认</a></li> -->
                    <li><a href="../login.html" lang>重新登录</a></li>
                </ul>
            </div>
 
            <div id="" class="layout-bill-info">
                <form class="layui-form" action="" style="height: auto;">
                    <div id="" class="layui-form-item layout-dropdownlist">
                        <label class="layui-form-label" lang>出库单:</label>
                        <div class="layui-input-block" id="selectDiv">
                            <select id="bar" lay-filter="getbar" lay-search>
                                <option value=""></option>
                            </select>
                            <img src="/assets/down_arraw.png">
                        </div>
                    </div>
                    <div class="layui-form-item layout-dropdownlist" style="margin-top: 10px;">
                        <label class="layui-form-label">物料-批次:</label>
                        <div class="layui-input-block" id="goodDiv">
                            <select id="goodSelect" lay-filter="goodSelect" lay-search>    
                                <option value=""></option>
                            </select>
                            <img src="/assets/down_arraw.png">
                        </div>
                    </div>
                    <!-- <div id="" class="layui-form-item layout-input">
                            <label class="layui-form-label" lang>库位地址:</label>
                            <div class="layui-input-block">
                                <input id="LocatNo" type="text" langholder placeholder="请扫描库位条码"
                                    autocomplete="off" class="layui-input">
                            </div>
                        </div> -->
                    <div id="" class="layui-form-item layout-input">
                        <label class="layui-form-label" lang>托盘条码:</label>
                        <div class="layui-input-block">
                            <input id="PalletNo" type="text" lay-verify="stock" lang langholder placeholder="请扫描托盘条码"
                                autocomplete="off" class="layui-input">
                        </div>
                    </div>
 
                </form>
                <div id="" style="text-align: center;">
                    <button class="btn-ok-blue" type="button" lay-submit lay-filter="formBind">确认出库</button>
                    <!-- <button class="btn-ok-red" type="button" lay-submit lay-filter="formCancel">取消出库</button> -->
                </div>
            </div>
 
            <div id="" class="cut-line" style="display: none;">
                <img src="/assets/fengexian.png">
            </div>
 
            <div class="layout-tbl-paging" id="" >
 
                <table id="tableBoxList" class="tbl-box-list" border="" cellspacing="" cellpadding="">
                    <tr>
                        <th lang>托盘码</th>
                        <!-- <th lang>物料号</th>
                        <th lang>物料名称</th>
                        <th lang>批次号</th> -->
                        <th lang>所属仓库</th>
                        <th lang>所属区域</th>
                        <th lang>库位地址</th>
                        
                    </tr>
                    <tr id="boxCell" style="display: none">
                        <td name="PalletNo">托盘码</td>
                        <td name="WareHouseName">所属仓库</td>
                        <td name="AreaName">所属区域</td>
                        <!-- <td name="SkuNo">物料号</td>
                        <td name="SkuName">物料名称</td>
                        <td name="LotNo">批次号</td> -->
                        <td name="LocatNo">库位地址</td>
                        <!-- <td name="del">
                                <div id="" class="tbl-btn-del" lang>
                                    删除
                                </div>
                            </td> -->
                    </tr>
                </table>
 
                <!-- 分页 -->
                <table id="tableBoxPages" class="tbl-box-pages" border="" cellspacing="" cellpadding="">
                    <tr>
                        <td class="page-prev" lang>上一页</td>
                        <td class="page-num page-num-select">1</td>
                        <td class="page-num">2</td>
                        <td class="page-num">3</td>
                        <td class="page-num">4</td>
                        <td class="page-num">5</td>
                        <td class="page-next" lang>下一页</td>
                    </tr>
                </table>
            </div>
        </div>
 
    </div>
    <script src="/js/jquery-3.5.1.min.js"></script>
    <script src="/layui/layui.js"></script>
    <script src="/js/public.js"></script>
    <script src="/js/language.js"></script>
    <script src="/js/jquery.cookie.js"></script>
    <script>
        layui.use(['form', 'jquery'], function () {
            var form = layui.form
 
            initLanguage()
            setLanguage()
 
            //当前分页
            var curPageIndex = 1
            var billList = null
            var tableData = null
 
            function clear() {
                $("#BOXCODE").val("");
            }
 
            form.on('select(getbar)', function (data) {
                //console.log();
                if (data.value == "") {
                    return;
                }
                GetBoxInfo();
            });
 
            form.on('select(goodSelect)', function (data) {
                console.log($("#goodSelect").val());
                if (data.value == "") {
                    return;
                }
                var skuno = $("#goodSelect").val().substring(0,6);
                var lotNo = $("#goodSelect").val().substring(12);
                console.log("skuno:"+skuno);
                console.log("lotNo:" + lotNo);
                loadlocatinfo(skuno, lotNo);
            });
 
            $("#selectDiv").click(function () {
                var input = $('select[id="bar"]').next().find('.layui-select-title input')
                var val = input.val()
                //先更新一下出库单
                updateBillList(function (data) {
                    $('select[id="bar"]').next().addClass('layui-form-selected')
                    $('select[id="bar"]').next().find('.layui-select-title input').val(val)
                })
            })
            //初始化渲染 出库单
            function updateBillList(callback) {
                var input = $('select[id="bar"]').next().find('.layui-select-title input')
                var val = input.val()
                $("#bar").empty()
                $("#bar").append('<option value =>' + '</option>');
                var PalletNo =  $("#PalletNo").val();
                if(PalletNo.length != 8){ //下拉框获取平库出库单
                    var param = {
                        Type: "1",
                    };
                    synData(IP + "/PdaSo/GetRunNoticeList", param,'post', function (res) {
                        //console.log(res);
                        if (res.code == 0) { //成功
                            for (var i = 0; i < res.data.length; i++) {
                                $("#bar").append('<option value =' + res.data[i] + '>' + res.data[i]
                                     +
                                    '</option>');
                            }
                            form.render('select');
 
                            if (!val) {
                                $('#bar').siblings("div.layui-form-select").find('dl').find('.layui-select-tips').addClass('layui-this')
                            } else {
                                var sel = 'dd[lay-value=' + val + ']';
                                $('#bar').siblings("div.layui-form-select").find('dl').find(sel).addClass('layui-this')
                            }
 
                            callback(res.data)
 
                        } else { //不成功
                            layer.msg(res.msg, {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            });
                        }
                    });
                }else{//根据托盘号获取出库单
                    var param = {
                        PalletNo: $("#PalletNo").val(),
                        Type: "1",
                    };
                    synData(IP + "/PdaSo/GetRunSoNoticeList", param, 'post', function (res) {
                        console.log(res);
 
                        if (res.code == 0) { //成功
                            console.log(res.data);
                            for (var i = 0; i < res.data.length; i++) {
                                if (i == 0) {
                                    $("#bar").append('<option value =' + res.data[i] + ' selected>' + res.data[i] + '</option>');
                                } else {
                                    $("#bar").append('<option value =' + res.data[i] + '>' + res.data[i] + '</option>');
                                }
                            }
                            form.render('select');
 
                        } else { //不成功
                            layer.msg(res.msg, {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            });
                        }
                    });
                }
            }
 
            //获取托盘物料名细
            function GetBoxInfo() {
                let param2 = {
                    "PalletNo": $("#PalletNo").val(),
                    "SoNo": $("#bar").val(),
                }
                synData(IP + "/PdaSo/GetPingKuInfoByPallet", param2, 'get', function (res) {
                    if (res.code == 0) {
                        updateGoodList(res.data);//物料批次信息
                        var skuno = res.data[0].SkuNo;
                        var lotNo = res.data[0].LotNo;
                        loadlocatinfo(skuno, lotNo);//获取托盘位置信息
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function () { });
                    }
                });
            }
 
            //获取托盘位置信息并更新表单
            function loadlocatinfo(skuno, lotNo){
                let param3 = {
                    "SoNo": $("#bar").val(),
                    "SkuNo": skuno,
                    "LotNo": lotNo
                }
                synData(IP + "/PdaSo/GetPingKuLocationInfo", param3, 'get', function (res) {//获取托盘明细
                    if (res.code == 0) {
                        tableData = deepCopy(res.data)
                        refreshTable(tableData)
                    } else {
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function () { });
                    }
                })
            }
 
              /* 物料及批次下拉框 */
            function updateGoodList(data) {
                var input = $('select[id="goodSelect"]').next().find('.layui-select-title input')
                var val = input.val()
                $("#goodSelect").empty()
                $("#goodSelect").append('<option value =>' + '</option>');
 
                for (var i = 0; i < data.length; i++) {
                    
                    if (data[i].LotNo == '' || data[i].LotNo == null) {
                        $("#goodSelect").append('<option value =' + data[i].SkuNo + ' selected>' + data[i]
                            .SkuName +
                            '</option>');
                    } else {
                        $("#goodSelect").append('<option value =' + data[i].SkuNo  + data[i].SkuName + "-" + 
                        data[i].LotNo + ' selected>' + data[i]
                            .SkuNo + data[i].SkuName + "-" + data[i].LotNo +
                            '</option>');
                    }
                }
                form.render('select');
                
            }
 
            function clearTable() {
                $("#palletCode").val('')
                $("#boxNum").val('')
                let trs = $("#tableBoxList tr")
                let len = trs.length
                //console.log("tr 数量 + " + trs.length)
                for (i = len - 1; i >= 2; i--) {
                    trs[i].remove();
                }
            }
 
            //获取当前托盘的物料信息
            function refreshTable(list) {
                //先清空一下箱子列表
                let trs = $("#tableBoxList tr")
                let len = trs.length
                //console.log("tr 数量 + " + trs.length)
                for (i = len - 1; i >= 2; i--) {
                    trs[i].remove();
                }
                var arrTrs = new Array()
                let idx = 0
                for (var i in list) {
                    // list[i].BoxCode
                    var tr = $("#boxCell").eq(0).clone();
                    tr.appendTo("#tableBoxList");
                    // tr.attr('id', list[i].BoxCode)
                    idx++;
                    tr.attr('index', idx)
                    tr.find("td[name='PalletNo']").html(list[i].PalletNo);
                    //tr.find("td[name='SkuNo']").html(list[i].SkuNo);
                    //tr.find("td[name='SkuName']").html(list[i].SkuName);
                    //tr.find("td[name='LotNo']").html(list[i].LotNo);
                    tr.find("td[name='WareHouseName']").html(list[i].WareHouseName);
                    tr.find("td[name='AreaName']").html(list[i].AreaName);
                    tr.find("td[name='LocatNo']").html(list[i].LocatNo);
                    // var code = list[i].BoxCode
                    // //console.log("code is "+code)
 
                    // //console.log("boxcode is "+tr.find("td[name='boxcode']").html())
                    tr.show();
                    arrTrs[i] = tr
                }
 
                //设置分页
                setPages(1, list.length)
 
            }
 
 
            //检查托盘状态
            function checkPalletState() {
                var param = {
                    "PalletNo": $("#PalletNo").val()
                }
                synData(IP + "/PdaSo/IsEnableOkPalletNo", param, 'post', function (res) {
                    
 
                    if (res.code == 0) { //成功 
                        updateBillList();
                        if ($('#bar').val() == "") {
                            return;
                        } else {
                            GetBoxInfo();
                        }
 
                    } else { //不成功
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function () { });
                    }
                });
            }
 
            //当托盘条码输入框失去焦点时,检查一下托盘状态
            $("#PalletNo").blur(function () {
                if ($("#PalletNo").val().length == 8) {
                    checkPalletState()
                }
                
            })
 
            $("#PalletNo").keydown(function (e) {
                if (e.keyCode === 13) {
                    if ($("#PalletNo").val().length != 8) {
                        layer.msg('请输入正确的托盘条码', {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        });
                        return;
                    }
                    checkPalletState();
                }
            });
 
            form.on('submit(formBind)', function (data) {
 
                if (!$("#PalletNo").val()) {
                    layer.msg('请扫描托盘条码', {
                        icon: 2,
                        time: 2000 //2秒关闭(如果不配置,默认是3秒)
                    });
                    return;
                }
 
                var param = {
                    SoNo: $("#bar").val(),
                    PalletNo: $("#PalletNo").val(),
                }
                sendData(IP + "/PdaSo/PlaneExportSuccess", param, 'get', function (res) {
                    if (res.code == 0) { //成功 
                        layer.msg(res.msg, {
                            icon: 1,
                            time: 1000 //2秒关闭(如果不配置,默认是3秒)
                        }, function () {
 
                            clearTable()
                            $("#PalletNo").val('')
                        });
                    } else { //不成功
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function () {
                            //回调
                        });
                    }
                });
                return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
            });
            form.on('submit(formCancel)', function (data) {
                clearTable()
                $("#PalletNo").val('')
                return false; //阻止表单跳转。如果需要表单跳转,去掉这段即可。
            });
            form.verify({
                stock: [/^[\S]{8}$/, '托盘条码必须为八位字符']
            });
            //-------------------------------------------------------------------------------------------------
 
            $("#menuImg").click(function (e) {
                //console.log("menuImg")
                e.stopPropagation()
 
                if ($("#menuList").is(":hidden")) {
                    $("#menuList").show()
                } else {
                    $("#menuList").hide()
                }
            })
            $('body').click(function () {
                // //console.log("body")
                $("#menuList").hide()
            })
 
            //设置分页
            function setPages(pageIndex, boxNum) {
                if (boxNum <= 0) {
                    //列表为空,隐藏分页页码
                    $("#tableBoxPages").hide()
                    return
                }
 
                let pageNum = Math.floor(boxNum / 10);
                if (boxNum % 10 > 0) {
                    pageNum += 1;
                }
                //console.log("pageNum is " + pageNum)
 
                $("#tableBoxPages").find("tr").remove()
                let table = $("#tableBoxPages")
                $("<tr></tr>").appendTo("#tableBoxPages")
 
                // let newTr = table.append("<tr></tr>")
                // newTr.append("<td class='page-prev'>上一页</td>")
                $("<td id='prevPage' class='page-prev'>上一页</td>").appendTo("#tableBoxPages tr")
                $("#tableBoxPages tr").eq(0).find("td[id^='prevPage']").click(function () {
                    onClickPrevPage()
                })
                for (i = 1; i < pageNum + 1; i++) {
                    // newTr.append("<td class='page-num'>"+ i +"</td>")
                    $("<td class='page-num'>" + i + "</td>").appendTo("#tableBoxPages tr")
                }
                // newTr.append("<td class='page-next'>下一页</td>")
                $("<td id='nextPage' class='page-next'>下一页</td>").appendTo("#tableBoxPages tr")
                $("#tableBoxPages tr").eq(0).find("td[id^='nextPage']").click(function () {
                    onClickNextPage()
                })
                // pages.show()
                $("#tableBoxPages").show()
 
                setCurPage(1)
            }
 
            //设置当前分页
            function setCurPage(pageIndex) {
                let totalTrNum = $("#tableBoxList tr").length
                if (totalTrNum <= 2) {
                    //console.log("tableBoxList 为空 totalTrNum: " + totalTrNum)
                    //curPageIndex = 1
                    return
                }
 
                let pageNum = getBoxPageNum()
                if (pageIndex > pageNum) {
                    //console.log("设置的页码超出页数, pageIndex : " + pageIndex)
                    //curPageIndex = 1
                    return
                }
 
                let startIndex = (pageIndex - 1) * 10 + 1
                let n = totalTrNum - startIndex
                let endIndex = 0
                if (n > 9) {
                    endIndex = startIndex + 9
                } else {
                    endIndex = startIndex + n
                }
                //console.log("startIndex is "+startIndex)
                //console.log("endIndex is "+endIndex)
                //startIndex =2
                //endIndex = 2
                let trs = $("#tableBoxList tr")
                //console.log("行数 "+trs.length)
                let d = 0
                for (let i = 2; i < trs.length; i++) {
                    //console.log("行索引 " + trs.eq(i).attr('index'))
                    let t = trs.eq(i)
                    d = t.attr('index')
                    if (d >= startIndex && d <= endIndex) {
                        //console.log("需要显示")
                        //显示行
                        t.show()
                    } else {
                        //隐藏行
                        t.hide()
                    }
                }
 
                curPageIndex = pageIndex
 
                let ptr = $("#tableBoxPages tr")
                for (let i = 1; i < pageNum + 1; i++) {
                    ptr.eq(0).find("td").eq(i).removeClass("page-num-select")
                    if (i == curPageIndex) {
                        ptr.eq(0).find("td").eq(i).addClass("page-num-select")
                    }
                }
                //console.log("totalTrNum is " + totalTrNum)
            }
 
            function onClickPrevPage() {
                //console.log("上一页按钮被点击")
                if (curPageIndex == 1) {
                    return
                }
                setCurPage(curPageIndex - 1)
            }
 
            function onClickNextPage() {
                //console.log("下一页按钮被点击")
                let n = getBoxPageNum()
                if (curPageIndex == n) {
                    return
                }
                setCurPage(curPageIndex + 1)
            }
 
            function getBoxPageNum() {
                let num = $("#tableBoxList tr").length
                if (num <= 2) {
                    return 0
                }
 
                let pageNum = Math.floor(num / 10);
                if (num % 10 > 0) {
                    pageNum += 1;
                }
 
                return pageNum
            }
 
        })
    </script>
</body>
 
</html>