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
<!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">
        <style type="text/css">
            .layui-table-cell, .layui-table-box{
                overflow: visible;
            }
            td .layui-form-select {
                    margin-top: -10px;
                    margin-left: -15px;
                    margin-right: -15px;
                }
        </style>
    </head>
    <body>
 
        <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
            <div class="layui-form-item">
                <label class="layui-form-label">移库仓库:</label>
                <div class="layui-input-inline" style="width: 35%;">
                    <select name="WarehouseId" id="WarehouseId" 
                        lay-filter="getHouseId" lay-search>
                        <option value=""></option>
                    </select>
                </div>
                <label class="layui-form-label">移库巷道:</label>
                <div class="layui-input-inline" style="width: 35%;">
                    <select name="LanewayId" id="LanewayId" 
                        lay-filter="getLanwayId" lay-search>
                        <option value=""></option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">移出货位:</label>
                <div class="layui-input-inline" style="width: 35%;">
                    <select name="OutSlotId" id="OutSlotId" lay-filter="getOutSlotId" lay-search>
                        <option value=""></option>
                    </select>
                </div>
                <label class="layui-form-label">移入货位:</label>
                <div class="layui-input-inline" style="width: 35%;">
                    <select name="InSlotId" id="InSlotId"  lay-search>
                        <option value=""></option>
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-card">
                    <div class="layui-card-body">
                        <div style="padding-bottom: 6px;">
                        <button class="layui-btn layui-btn-sm layuiadmin-btn-list" data-type="add" id="approvalBtn">添加明细</button>
                        </div>
                        <table id="LAY-app-content-list" name="LAY-app-content-list" lay-filter="LAY-app-content-list"></table>
                        <script type="text/html" id="table-content-list">
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"> <i class="layui-icon layui-icon-delete"></i>删除</a>
                        </script>
                        <button type="submit" class="layui-btn layui-btn-sm layuiadmin-btn-list" lay-submit="" lay-filter="form1">立即提交</button>
                    </div>
                </div>
            </div>
            <div class="layui-form-item layui-hide">
                <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
                <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
            </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', 'form', 'layer', 'table'], function() {
                var $ = layui.$,
                    form = layui.form,
                    table = layui.table,
                    layer = layui.layer;
                var houseid = 0;
                var lanId = 0;
                var outSlotId = 0;
                var MoveBillCode = getQueryString('moveno');
                
                // function getOutSlotId(selectedvalue) {
                //     if (selectedvalue) {
                //         outSlotId = selectedvalue;
                //         refreshTable(outSlotId);
                //     } else {
                //         outSlotId = 0;
                //         refreshTable(outSlotId);
                //     }
                // }
                refreshTable(MoveBillCode);
                // form.on('select(getOutSlotId)', function(data) {
                //     getOutSlotId(data.value);
                // });
                function getHouseId(selectedvalue) {
                    if (selectedvalue) {
                        houseid = selectedvalue;
                        var param = {
                            LanewayWarehouseId: houseid,
                        };
                        sendData(IP + "/MoveNotify/GetWmsBaseLaneway", param, 'post', function(res) {
                            $("#LanewayId").empty();
                            $("#OutSlotId").empty();
                            $("#InSlotId").empty();
                            if (res.code == 1) { //成功
                                $("#LanewayId").append('<option value =""></option>');
                                for (var i = 0; i < res.data.length; i++) {
                                    var name = res.data[i].LanewayName;
                                    var id = res.data[i].Id;
                                    $("#LanewayId").append('<option value =' + id + '>' + name +
                                    '</option>');
                                }
                                form.render('select');
                            } else { //不成功
                                layer.msg('获取巷道信息失败', {
                                    icon: 2,
                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                }, function() {
                                    //回调
                                    form.render('select');
                                });
                            }
                        });
                    } else {
                        houseid = 0;
                        lanId = 0;
                        outSlotId = 0;
                        $("#LanewayId").empty();
                        $("#OutSlotId").empty();
                        $("#InSlotId").empty();
                        form.render('select');
                        //refreshTable(outSlotId);
                    }
                }
                form.on('select(getHouseId)', function(data) {
                    getHouseId(data.value);
                });
                function getLanwayId(selectedvalue) {
                    if (selectedvalue) {
                        lanId = selectedvalue;
                        var param = {
                            MoveLanewayCode: lanId
                        };
                        sendData(IP + "/MoveNotify/GetSlotIdHaveStock", param, 'post', function(res) {
                            $("#OutSlotId").empty();
                            $("#InSlotId").empty();
                            if (res.code == 1) { //成功
                                $("#OutSlotId").append('<option value =""></option>');
                                for (var i = 0; i < res.data.length; i++) {
                                    var name = res.data[i].SlotCode;
                                    var id = res.data[i].SlotId;
                                    $("#OutSlotId").append('<option value =' + id + '>' + name +
                                    '</option>');
                                }
                                sendData(IP + "/MoveNotify/GetEmptySlotId", param, 'post', function(res) {
                                    $("#InSlotId").empty();
                                    if (res.code == 1) { //成功
                                        $("#InSlotId").append('<option value =""></option>');
                                        for (var i = 0; i < res.data.length; i++) {
                                            var name = res.data[i].SlotCode;
                                            var id = res.data[i].SlotId;
                                            $("#InSlotId").append('<option value =' + id + '>' + name +
                                            '</option>');
                                        }
                                        form.render('select');
                                    } else { //不成功
                                        layer.msg('获取巷道信息失败', {
                                            icon: 2,
                                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                        }, function() {
                                            //回调
                                            //refreshTable(outSlotId);
                                        });
                                    }
                                });
                                form.render('select');
                            } else { //不成功
                                layer.msg('获取巷道信息失败', {
                                    icon: 2,
                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                }, function() {
                                    //回调
                                    form.render('select');
                                });
                            }
                        });
                        
                    } else {
                        lanId = 0;
                        outSlotId = 0;
                        $("#OutSlotId").empty();
                        $("#InSlotId").empty();
                        form.render('select');
                        //refreshTable(outSlotId);
                    }
                }
                form.on('select(getLanwayId)', function(data) {
                    
                    getLanwayId(data.value);
                });
                var param = {
                    id: $.cookie('userId'),
                };
                sendData(IP + "/MoveNotify/GetWareHouseList", param, 'post', function(res) {
                    if (res.code == 1) { //成功
                        for (var i = 0; i < res.data.length; i++) {
                            $("#WarehouseId").append('<option value =' + res.data[i].WarehouseId + '>' + res.data[i].WarehouseName +
                                '</option>');
                        }
                        form.render('select');
                    } else { //不成功
                        layer.msg(res.msg, {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                    }
                });
                function refreshTable(id) {
                    
                    var param = {
                        MoveBillCode: id
                    };
                    sendData(IP + "/MoveNotify/GetStockSlotListBySlotId", param, 'post', function(res) {
                        console.log(res);
                        if (res.code == 1) { //成功
                            var list = res.data;
                            $.extend(infoOptions, {
                                data: list
                            });
                            infoOptions.page = {
                                curr: 1
                            }
                            tableIns = table.render(infoOptions);
                        } else { //不成功
                            layer.msg('获取入库单信息失败!', {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            }, function() {});
                        }
                    });
                }
                var infoOptions = {
                    elem: '#LAY-app-content-list',
                    height: 'full-260',
                    id: 'LAY-app-content-list',
                    page: true,
                    limit: pageCnt,
                    limits: pageLimits,
                    cellMinWidth: 80, //全局定义常规单元格的最小宽度,layui 2.2.1 新增
                    cols: [
                        [  
                            {
                                field: 'StockStockCode',
                                title: '托盘条码',
                                align: 'center',
                                width: 100,
                            }, {
                            field: 'StockSlotCode',
                            title: '移出货位',
                            align: 'center',
                            
                            width: 120,
                            //fixed: 'left'
                        },{
                            field: 'MoveInSlotCode',
                            title: '移入货位',
                            align: 'center',
                            
                            width: 120,
                            //fixed: 'right'
                        },
                            {
                            field: 'GoodsCode',
                            title: '物品编码',
                            align: 'center',
                            
                            width: 120,
                            
                        }, {
                            field: 'GoodsName',
                            title: '物品名称',
                            align: 'center',
                            sort:true,
                            width: 200,
                        },
                        // {
                        //     field: 'GoodsStandard',
                        //     title: '物品规格',
                        //     align: 'center',
                        //     width: 100,
                        // },
                        {
                            field: 'StockLotNo',
                            title: '批次',
                            align: 'center',
                            width: 100,
                        }, 
                        // {
                        //     field: 'StockQuantity',
                        //     title: '库存数量',
                        //     align: 'center',
                        //     width: 105,
                        // }, 
                        // {
                        //     field: 'UnitName',
                        //     title: '物品单位',
                        //     align: 'center',
                        //     width: 100,
                        // },
                        
                        // {
                        //     field: 'StockProductionDate',
                        //     title: '生产日期',
                        //     align: 'center',
                        //     width: 120,
                        //     templet: function(d) {
                        //         return formatDate(d.StockProductionDate);
                        //     }
                        // },
                        {
                            field: 'StockDate',
                            title: '入库时间',
                            width: 180,
                            align: 'center',
                            templet: function(d) {
                                return formatDate(d.StockDate);
                            }
                        },
                         {
                            field: 'aaa',
                            title: '操作',
                            align:'center',
                            templet: '#table-content-list',
                            width: 100
                            //fixed: 'right'
                        }
                        ]
                    ],
                };
                var tableIns;
                var doing = true;
                form.on('submit(form1)', function(data) {
                    
                    if(infoOptions.data==null||infoOptions.data==""){
                        layer.msg("请添加数据!", {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                        return;
                    }
                    console.log(infoOptions.data);
                    console.log(table.cache["LAY-app-content-list"]);
                    var param={
                        options:infoOptions.data,
                        MoveBillCode:MoveBillCode,
                        CreateUser: $.cookie('userId') //当前登录人
                    };
                    if (doing) {
                        doing = false;
                        sendData(IP + "/MoveNotify/AddWmsMoveNotify", param, 'post', function(res) {
                            if (res.code == 1) { //成功
                                layer.msg(res.msg, {
                                    icon: 1,
                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                }, function() {
                                parent.location.reload();
                                parent.layer.close(layer.index);
                                doing = true;
                                    // table.reload('LAY-app-content-list'); //数据刷新
                                });
                            } else { //不成功
                                layer.msg(res.msg, {
                                    icon: 2,
                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                }, function() {doing=true;});
                            }
                        });
                    }
                 return false;
                });
                $('#approvalBtn').on('click', function() {
                    var arr = table.cache["LAY-app-content-list"];
                    var MoveWarehouseId = $('#WarehouseId').val();
                    var MoveLanewayCode = $('#LanewayId').val();
                    var MoveOutSlotCode = $('#OutSlotId').val();
                    var MoveInSlotCode = $('#InSlotId').find("option:selected").text();
                    var slot = true;
                    if(MoveWarehouseId==null || MoveWarehouseId==undefined ||MoveWarehouseId==""){
                        layer.msg("请选择仓库!", {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                        return;
                    }
                    if(MoveLanewayCode==null || MoveLanewayCode==undefined ||MoveLanewayCode==""){
                        layer.msg("请选择巷道!", {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                        return;
                    }
                    if(MoveOutSlotCode==null || MoveOutSlotCode==undefined ||MoveOutSlotCode==""){
                        layer.msg("请选择移出货位!", {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                        return;
                    }
                    if(MoveInSlotCode==null || MoveInSlotCode==undefined ||MoveInSlotCode==""){
                        layer.msg("请选择移入货位!", {
                            icon: 2,
                            time: 2000 //2秒关闭(如果不配置,默认是3秒)
                        }, function() {});
                        return;
                    }
                    for(var i=0;i<arr.length;i++)
                    {
                        if(arr[i].SlotCode==MoveOutSlotCode){
                            layer.msg("移出货位已经选择,请重新选择!", {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            }, function() {});
                        slot=false;
                            continue;
                        }else if(arr[i].MoveInSlotCode==MoveInSlotCode){
                            layer.msg("移入货位已经选择,请重新选择!", {
                                icon: 2,
                                time: 2000 //2秒关闭(如果不配置,默认是3秒)
                            }, function() {});
                            slot = false;
                            continue;
                        }
                        
                    }
                    if(slot){
                        var param = {
                            MoveOutSlotCode: MoveOutSlotCode,
                            
                        };
                        
                        synData(IP + "/MoveNotify/GetStockSlotListBySlotId", param, 'post', function(res) {
                        
                            if (res.code == 1) { //成功
                                var list = res.data;
                                if(list !=null){
                                    list[0].MoveInSlotCode=MoveInSlotCode;
                                        arr.push(list[0]);
                                }
                            
                                $.extend(infoOptions, {
                                    data: arr
                                });
                                infoOptions.page = {
                                    curr: 1
                                }
                                tableIns = table.render(infoOptions);
                            } else { //不成功
                                layer.msg('获取入库单信息失败!', {
                                    icon: 2,
                                    time: 2000 //2秒关闭(如果不配置,默认是3秒)
                                }, function() {});
                            }
                        });
                        
                    }
                    
                });
                
                table.on('tool(LAY-app-content-list)', function(obj) {
                        var data = obj.data;
                        var arr = table.cache["LAY-app-content-list"];
                        if (obj.event == 'del') {
                            var ii = -1;
                            for(var j in arr)
                            {
                                if(obj.data.SlotCode == arr[j].SlotCode){
                                    ii = j;
                                    break;
                                }
                            }
                            if(ii>-1)
                            {
                                arr.splice(ii, 1);
                            }
                            obj.del();
                            //console.log(infoOptions);
                        } 
                    });
                
                
            //获取浏览器参数
            function getQueryString(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }
        })
        </script>
    </body>
</html>