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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; 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, maximum-scale=1">
    <!--引用layui样式文件-->
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <!--引用layui js文件-->
    <script src="../../layuiadmin/layui/layui.js"></script>
    <script src="../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <style>
        .layui-col-xs8 {
            width: 55.666667%;
        }
    </style>
</head>
<body>
    <div class="layui-fluid" style="padding:0">
        <div class="layui-card" style="padding: 1px">
            <div class="layui-card-body" style="padding: 0px; height:800px;">
                <form class="layui-form" action="" lay-filter="component-form-group">
                    <div style="background-color:#0085E8;">
                        <span style="color: white;"><i class="layui-icon layui-icon-form"></i>手工抄包</span>
                    </div>
                    <div class="layui-form-item" style="padding:15px;margin:0px">
                        <div class="layui-row">
                            <div class="layui-col-xs2">
                                <label class="layui-form-label" style="width:60px;padding-left:0px;">条形码</label>
                            </div>
                            <div class="layui-col-xs10">
                                <div class="layui-col-xs10">
                                    <input type="text" name="HBarCode" id="HBarCode" lay-verify="HBarCode" onkeyup="value=value.replace(/\s+/g,'')" autocomplete="off" class="layui-input" onfocus="this.select();">
                                </div>
                                <div class="layui-col-xs2">
                                    <button type="button" lay-submit="" style="float: right " lay-filter="HBarCode-BT" class="layui-btn" id="HBarCode-BT">确定</button>
                                </div>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-col-xs2">
                                <label class="layui-form-label" style="width:60px;padding-left:0px;">物料编码</label>
                            </div>
                            <div class="layui-col-xs10">
                                <input type="text" name="HMaterNumber" id="HMaterNumber" lay-verify="HMaterNumber" autocomplete="off" class="layui-input" style="border-radius: 5px;background-color:#efefef4d;" readonly>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-col-xs2">
                                <label class="layui-form-label" style="width:60px;padding-left:0px;">物料名称</label>
                            </div>
                            <div class="layui-col-xs10">
                                <input type="text" name="HMaterName" id="HMaterName" lay-verify="HMaterName" autocomplete="off" class="layui-input" style="border-radius: 5px;background-color:#efefef4d;" readonly>
                            </div>
                        </div>
                        <div class="layui-row">
                            <div class="layui-col-xs2">
                                <label class="layui-form-label" style="width:60px;padding-left:0px;">数量</label>
                            </div>
                            <div class="layui-col-xs10">
                                <div class="layui-col-xs10">
                                    <input type="number" name="HQty" id="HQty" lay-verify="HQty" onkeyup="if(!this.value.match(/^[\+\-]?\d*?\.?\d*?$/)){if(!this.t_value>0){this.value=''}else{this.value=this.t_value;}}else this.t_value=this.value;if(this.value.match(/^(?:[\+\-]?\d+(?:\.\d+)?)?$/))this.o_value=this.value" autocomplete="off" class="layui-input" onfocus="this.select();">
                                </div>
                                <div class="layui-col-xs2">
                                    <button type="button" lay-submit="" style="float: right " lay-filter="cmdAdd" class="layui-btn" id="cmdAdd">添加</button>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab layui-col-xs12" lay-filter="tab-Kf_ChaoBaoEditDlg">
                            <ul class="layui-tab-title" lay-filter="tab-all">
                                <li lay-id="1" style="padding:1px;">条码信息</li>
                            </ul>
                            <div class="layui-tab-content">
                                <!--条码信息-->
                                <div class="layui-tab-item layui-show" >
                                    <div class="layui-row">
                                        <div class="layui-col-xs12">
                                            <div class="layui-form-item" style="padding:0px;margin:0px"></div>
                                            <table class="layui-hide" id="wl-table" lay-filter="wl-table"></table>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="layer-footer" style="z-index: 10; position: fixed; text-align: center; bottom: 0; width:100%; height:50px">
                            <button type="button" lay-submit="" lay-filter="cmdDelete" class="layui-btn" id="cmdDelete">删除</button>
                            <button type="button" lay-submit="" lay-filter="cmdCancel" class="layui-btn" id="cmdCancel">退出</button>
                        </div>
                    </div>
 
                    <!--隐藏字段-->
                    <input type="hidden" name="HBillType" id="HBillType">
                    <input type="hidden" name="HBillerID" id="HBillerID">
                    <input type="hidden" name="HRedBlueFlag" id="HRedBlueFlag">
                    <!--失败提示音-->
                    <div id="" style="display:none;">
                        <audio id="cs" hidden controls>
                            <source src="../video/jingbao.wav" type="audio/ogg">
                        </audio>
                    </div>
                    <!--成功提示音-->
                    <div id="" style="display:none;">
                        <audio id="cs2" hidden controls>
                            <source src="../video/success.wav" type="audio/ogg">
                        </audio>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script>
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
 
            //#region 公共变量
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
                , table = layui.table
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
            var HMaker = sessionStorage["HUserName"]
            var HStockOrgID = sessionStorage["OrganizationID"]  //组织ID
            var HSourceFlag = true     //是否已扫码标志
            var listOption = [];
            var columns = "";
            var HModName = "Kf_ChaoBaoEditDlg";
            var titleData = [];     //不需要显示的字段
 
            //#endregion
 
            ////判断是否登录 未登录则跳到登录页
            //if (sessionStorage.login != "login") {
            //    layer.confirm("登录失效,请重新登录!", {
            //        icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
            //    }, function () { window.location.href = "../../user/login.html"; });
            //}
 
            //失败提示音
            function playSound() {
                console.log("playSound");
                var audio = document.getElementById("cs");
                audio.play();
            }
            //成功提示音
            function playSound_OK() {
                console.log("playSound_OK");
                var audio = document.getElementById("cs2");
                audio.play();
            }
 
            //#region 初始化界面
 
            set_ClearBill();
 
            function set_ClearBill() {
                set_InitGrid();     //初始化表格
 
                //光标默认在条码位置上
                var pFocus = $("#HQty");
                pFocus.focus();     //获取光标
                pFocus.select();
            }
 
            //初始化表格
            function set_InitGrid() {
                //条码信息
                listOption = {
                    elem: '#wl-table'
                    //, toolbar: '#toolbarDemo'
                    , totalRow: true
                    , height: 'full-50'
                    , cellMinWidth: 90
                    , limit: 50
                };
            }
 
            //#region   从扫码模块跳转返回信息
            function getUrlVars() {
                var vars = [], hash;
                var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
                for (var i = 0; i < hashes.length; i++) {
                    hash = hashes[i].split('=');
                    vars.push(hash[0]);
                    vars[hash[0]] = hash[1];
                }
                return vars;
            }
            var params = getUrlVars();
            var HInterID = params[params[0]];           //单据ID
            var HBillType = params[params[1]];          //单据类型
            var HBillNo = params[params[2]];            //单据号
            var sHWHID = params[params[3]];             //仓库ID
            var sHSPID = params[params[4]];             //仓位ID
            var HRedBlueFlag = params[params[5]];       //红蓝字
            var sSourceBillNo = params[params[6]];      //源单号
            var sSourceBillType = params[params[7]];    //源单类型
            var HMaterID = params[params[8]];           //物料ID
 
            //#endregion
 
            if (HInterID != 0) {
                //返回物料信息
                $("#HBarCode").val(HMaterID);
                var sBarCode = $('#HBarCode').val()
                if (sBarCode == 0) {
                    $('#HBarCode').val("");
                    $("#HBarCode").select();
                    $("#HBarCode").focus();     //获取光标
                }
                else {
                    GetBarCode();
                    $("#HQty").focus();     //获取光标
                }
                //显示表体明细
                DisBillEntryList();
            }
            else {
                playSound();
                layer.msg("单据内码获取失败,请返回界面重新点击手工抄包按钮!", { icon: 0, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return;
            }
 
            //#endregion
 
 
            //#region 功能控件
 
            //#region 删除
 
            form.on('submit(cmdDelete)', function () {
                var checkStatus = table.checkStatus('wl-table')
                    , data = checkStatus.data;
                if (checkStatus.data.length == 1) {
                    layer.confirm("确认要删除选中条码扫码记录?删除后将不可恢复!", { title: "删除确认" }, function (index) {
                        var HItemID = data[0].HItemID
 
                        layer.load(3)
                        $.ajax(
                            {
                                type: "Get",
                                url: GetWEBURL() + "/WEBSController/set_DelPonderationBillMain_Temp_HItemID_Json",
                                async: false,    //async用于控制(false)同步和(true)异步,默认的是true,即请求默认的是异步请求
                                data: { "HInterID": HInterID, "HBillType": HBillType, "HItemID": HItemID },
                                dataType: "json",
                                success: function (data) {
                                    if (data.count == 1) {
                                        layer.msg(data.Message, { time: 1 * 1000, icon: 1 }, function () {
                                            //显示表体明细
                                            DisBillEntryList();
                                        });
                                    }
                                    else {
                                        playSound();
                                        layer.msg(data.Message, { icon: 2, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                                    }
                                },
                                error: function (err) {
                                    layer.msg('错误' + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                                }
                            });
                        layer.closeAll("loading");
                    })
                }
                else {
                    layer.msg('请选择一行记录,进行删除!');
                }
            });
 
            //#endregion
 
            //#region 退出
 
            form.on('submit(cmdCancel)', function () {
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            })
 
            //#endregion
 
            //#endregion
 
            //#region 扫描物料条码
 
            //扫描条码
            $('#HBarCode').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    GetBarCode();
                    $("#HQty").select();
                    $("#HQty").focus();     //获取光标
                    layer.closeAll("loading");
                }
            });
 
            //条码按钮
            form.on('submit(HBarCode-BT)', function (data) {
                GetBarCode();
                $("#HQty").select();
                $("#HQty").focus();     //获取光标
                layer.closeAll("loading");
            });
 
            //扫条码
            function GetBarCode(obj) {
                var sBarCode = $('#HBarCode').val()
                if (sBarCode == '') {
                    playSound();
                    layer.msg("条码为空,请扫描条码!", {
                        icon: 0, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                    }, function () {
                        $("#HBarCode").select();
                        $("#HBarCode").focus();
                    });
                    return;
                }
                layer.load(3)
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/WEBSController/GetBarCode_Json",
                    async: false,    //async用于控制(false)同步和(true)异步,默认的是true,即请求默认的是异步请求
                    data: { "HBarCode": sBarCode },
                    success: function (result) {
                        if (result.count == 1) {
                            $("#HMaterNumber").val(result.data[0].HMaterNumber);
                            $("#HMaterName").val(result.data[0].HMaterName);
                            HMaterID = result.data[0].HMaterID;
                            //清空数量
                            $("#HQty").val("");
                            //显示表体明细
                            DisBillEntryList();
                        }
                        else {
                            playSound();
                            layer.msg(result.Message, {
                                icon: 5, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                            }, function () {
                                $("#HBarCode").select();
                                $("#HBarCode").focus();
                            });
                        }
                    },
                    error: function (err) {
                        playSound();
                        layer.msg("错误!" + err, {
                            icon: 5, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                        }, function () {
                            $("#HBarCode").select();
                            $("#HBarCode").focus();
                        });
                    }
                });
                layer.closeAll("loading");
            }
 
            //#endregion
 
            //#region 添加
 
            //添加按钮
            form.on('submit(cmdAdd)', function (data) {
                GetMeesageByBarCode();
            });
 
            //将条码信息写入条码临时表
            function GetMeesageByBarCode(obj) {
                var sHQty = $("#HQty").val()
                var sBarCode = $('#HBarCode').val()
                if (sBarCode == '') {
                    playSound();
                    layer.msg("条码为空,请扫描条码!", {
                        icon: 0, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                    }, function () {
                        $("#HBarCode").select();
                        $("#HBarCode").focus();
                    });
                    return;
                }
                if (sHQty == "" || sHQty <= 0 || sHQty > 100) {
                    playSound();
                    layer.msg("数量不允许小于0,大于100,请重新输入数量!", {
                        icon: 0, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                    }, function () {
                        $("#HQty").select();
                        $("#HQty").focus();
                    });
                    return;
                }
                layer.load(3)
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/WEBSController/Get_BarCode_Json",
                    async: false,    //async用于控制(false)同步和(true)异步,默认的是true,即请求默认的是异步请求
                    data: { "sBarCode": sBarCode, "HInterID": HInterID, "HBillType": HBillType, "HBillNo": HBillNo, "HMaker": HMaker, "HWhID": sHWHID, "HSPID": sHSPID, "HQty": sHQty, "HRedBlueFlag": HRedBlueFlag, "SourceFlag": HSourceFlag, "HSourceBillNo": sSourceBillNo, "HSourceBillType": sSourceBillType, "HStockOrgID": HStockOrgID, "HScanStyle": "", "HCustom1": "", "HCustom2": "" },
                    success: function (result) {
                        if (result.count == 1) {
                            playSound_OK();
                            //清空数量
                            $("#HQty").val("");
                            $("#HQty").select();
                            $("#HQty").focus();
                            //显示表体明细
                            DisBillEntryList();
                        }
                        else {
                            playSound();
                            layer.msg(result.Message, {
                                icon: 5, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                            }, function () {
                                $("#HBarCode").select();
                                $("#HBarCode").focus();
                            });
                        }
                    },
                    error: function (err) {
                        playSound();
                        layer.msg("错误!" + err, {
                            icon: 5, time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                        }, function () {
                            $("#HBarCode").select();
                            $("#HBarCode").focus();
                        });
                    }
                });
                layer.closeAll("loading");
            }
 
            //#endregion
 
 
            //#region 显示物料列表信息
 
            function DisBillEntryList() {
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + '/WEBSController/GetBarCodeByMaterID_Temp_Json',
                    async: false,    //async用于控制(false)同步和(true)异步,默认的是true,即请求默认的是异步请求
                    data: { "HInterID": HInterID, "HBillType": HBillType, "HMaterID": HMaterID },
                    success: function (result) {
                        if (result.count == 1) { // 说明验证成功了,
                            var data = [];
                            var col = [];
                            //给空的数组赋值
                            for (var key in result.list) {
                                //动态获取列表所有列名
                                data.push({ "id": result.list[key].ColmCols, "name": result.list[key].ColmCols, "Type": result.list[key].ColmType });
                                //获取不需要显示的列(H开头的列不显示)
                                var patrn = new RegExp(/^h/i);
                                if (patrn.test(result.list[key].ColmCols)) {
                                    titleData[key] = result.list[key].ColmCols;
                                }
                            }
 
                            //在列表左边添加勾选框
                            col.push({ type: 'radio', fixed: 'left', totalRowText: '合计' });
                            for (var i = 0; i < data.length; i++) {
                                if ($.inArray(data[i].name, titleData) > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true }); //隐藏id列
                                }
                                else {
                                    switch (data[i].Type) {
                                        //int
                                        case 'DateTime':
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, templet: "<div>{{d." + data[i].name + " ==null ?'':layui.util.toDateString(d." + data[i].name + ", 'yyyy-MM-dd')}}</div>", width: 200 });
                                            break;
                                        default:
 
                                            if (data[i].name == '米数' || data[i].name == '件数') {
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', totalRow: true });
                                        }
                                        else {
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', width: 150 });
                                        }
                                    }
                                }
                            }
                            columns = col;
                            listOption.cols = [columns];
                            listOption.data = result.data;
                            listOption.totalRow = true;
                            table.render(listOption);
                        }
                        else {
                            listOption.cols = [columns];
                            listOption.data = result.data;
                            listOption.totalRow = true;
                            table.render(listOption);
                            //layer.msg(result.Message);
                            //layer.msg(result.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        }
                    }
                });
            }
 
            //#endregion
 
 
            
        });
 
        //以上为layui模块
        //此处方法涉及到被外部页面parent.方法名调用的必须放在Layui方法外部
 
 
    </script>
 
</body>
</html>