1
wangyi
2026-04-02 96785ebcfe1bc9210f3d9d4056f4ec29fb60d810
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
<!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">
    <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/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/grwebapp.js"></script>
    <style type="text/css">
 
        /*begin 此样式用于消除行元素中布局宽度不够的问题*/
        .layui-form-item .layui-inline {
            margin-top: 5px;
            margin-bottom: 5px;
            margin-right: 0px;
        }
        /*end*/
        .layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
            margin-left: 35%;
        }
 
        .layui-input-block {
            margin-left: 0px;
        }
    </style>
</head>
<body>
    <div id="layout1" class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <form id="form0" class="layui-form" lay-filter="component-form-group" action="">
                        <div class="layui-card-header">
                            <div class="layui-input-block">                               
                                <button type="button" class="layui-btn" id="ToolExit" lay-submit="" lay-filter="ToolExit">退出</button>
                            </div>
                        </div>
                        <div class="layui-card-body">
                            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                                <h1 style="text-align:center;"><b>标签补打</b></h1>
                                <ul class="layui-tab-title">
                                    <li lay-id="1" class="layui-this">SN码补打</li>
                                    <li lay-id="2">中箱码补打</li>
                                    <li lay-id="3">栈板码补打</li>
                                </ul>
                                <div class="layui-tab-content">
                                    <div class="layui-tab-item layui-show">
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">SN模板</label>
                                                <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                                    <select name="HPrintTemplate" id="HPrintTemplate" class="ForFilteringSchemes" lay-filter="HPrintTemplate"
                                                            lay-verify="HPrintTemplate">
                                                        <!--动态渲染组织-->
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">SN码</label>
                                                <div class="layui-input-inline" style="width:600px;">
                                                    <input class="layui-input" name="HBarCode" id="HBarCode" autocomplete="off" style="float:left;width:410px;" onfocus="this.select();" placeholder="请输入单个补打条码编号,不支持批量补打">
                                                    <button type="button" class="layui-btn" id="PrintBarCode" lay-submit="" lay-filter="PrintBarCode" style="float:left;">补打条码</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-tab-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">中箱模板</label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                                <select name="HPrintTemplate_ZX" id="HPrintTemplate_ZX" class="ForFilteringSchemes" lay-filter="HPrintTemplate_ZX"
                                                        lay-verify="HPrintTemplate_ZX">
                                                    <!--动态渲染组织-->
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">中箱码</label>
                                            <div class="layui-input-inline" style="width:600px;">
                                                <input class="layui-input" name="HBarCode_ZX" id="HBarCode_ZX" autocomplete="off" style="float:left;width:410px;" onfocus="this.select();" placeholder="请输入单个补打条码编号,不支持批量补打">
                                                <button type="button" class="layui-btn" id="PrintBarCode_ZX" lay-submit="" lay-filter="PrintBarCode_ZX" style="float:left;">补打条码</button>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-tab-item">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">栈板模板</label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 185px;">
                                                <select name="HPrintTemplate_ZB" id="HPrintTemplate_ZB" class="ForFilteringSchemes" lay-filter="HPrintTemplate_ZB"
                                                        lay-verify="HPrintTemplate_ZB">
                                                    <!--动态渲染组织-->
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">栈板码</label>
                                            <div class="layui-input-inline" style="width:600px;">
                                                <input class="layui-input" name="HBarCode_ZB" id="HBarCode_ZB" autocomplete="off" style="float:left;width:410px;" onfocus="this.select();" placeholder="请输入单个补打条码编号,不支持批量补打">
                                                <button type="button" class="layui-btn" id="PrintBarCode_ZB" lay-submit="" lay-filter="PrintBarCode_ZB" style="float:left;">补打条码</button>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>                
                    </form>
                </div>
            </div>
        </div>
    </div>
    <script type="text/html" id="barDemo">
        <!--<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script>
        //获取参数
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
            var closeType = 2;  //关闭类型
        } else {
            debugger;
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSouceBillType = params[params[2]];//源单类型
            var closeType = params[params[3]];  //关闭类型
        }
 
        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 option = [];
            var option_New = [];
            var sWhere = "";
            var HModName = "Cj_BarCodePrint";
            var titleData = [];//不需要显示的字段 可扩展
            var HWhetherToPrint = true; //是否打印
            var ModRightName = "Gy_BarCodeBillList";    //模块权限参数
            var HMaker = sessionStorage["HUserName"]
            //#endregion                                 
              
            //#region 进入页面既加载
 
            //#region   用户模块权限判断
 
            //用户模块权限判断
            CheckModRight();
 
            function CheckModRight() {
                layer.load(3);
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/WEBSController/CheckModRight_Json",
                    async: false,    //async用于控制(false)同步和(true)异步,默认的是true,即请求默认的是异步请求
                    data: { "ModRightName": ModRightName, "HUserName": HMaker },
                    success: function (d) {
                        if (d.count == 1) {
                        }
                        else {
                            layer.msg(d.Message, {
                                icon: 0, time: 3000, offset: 'auto', skin: 'layui-layer-lan', title: "温馨提示", btn: ['确认']
                            }, function () {
                                if (linterid == undefined) {
                                    //关闭页签
                                    Pub_Close(2);
                                }
                                else {
                                    //关闭页签
                                    Pub_Close(1);
                                }
                            });
                        }
                    },
                    complete: function (XHR, TS) { XHR = null }//回收资源
                });
                layer.closeAll("loading");
            }
            //#endregion
 
            //获取SN打印模板
            getTem_SN();
            //获取中箱打印模板
            getTem_ZX();
            //获取栈板打印模板
            getTem_ZB();
            //#endregion                     
                      
            //补打SN条码
            form.on('submit(PrintBarCode)', function (data) {
                PrintBarCode();
            })
            //补打中箱条码
            form.on('submit(PrintBarCode_ZX)', function (data) {
                PrintBarCode_ZX();
            })
            //补打栈板条码
            form.on('submit(PrintBarCode_ZB)', function (data) {
                PrintBarCode_ZB();
            })
 
            form.on('select(HPrintTemplate)', function (data) {
                // 2. 获取选中的值
                const selectedValue = data.value;
 
                // 3. 保存到 localStorage(键名为 "BlueToothselectedTemplate")
                localStorage.setItem('SNselectedTemplate', selectedValue);
 
                console.log('已保存选择的模板:', selectedValue);
            });
 
            form.on('select(HPrintTemplate_ZX)', function (data) {
                // 2. 获取选中的值
                const selectedValue = data.value;
 
                // 3. 保存到 localStorage(键名为 "BlueToothselectedTemplate")
                localStorage.setItem('ZXselectedTemplate', selectedValue);
 
                console.log('已保存选择的模板:', selectedValue);
            });
 
            form.on('select(HPrintTemplate_ZB)', function (data) {
                // 2. 获取选中的值
                const selectedValue = data.value;
 
                // 3. 保存到 localStorage(键名为 "BlueToothselectedTemplate")
                localStorage.setItem('ZBselectedTemplate', selectedValue);
 
                console.log('已保存选择的模板:', selectedValue);
            });
 
            //SN条码编号回车方法
            $('#HBarCode').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    PrintBarCode();
                }
            });
 
            //中箱条码编号回车方法
            $('#HBarCode_ZX').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    PrintBarCode_ZX();
                }
            });
 
            //栈板条码编号回车方法
            $('#HBarCode_ZB').on('keydown', function (event) {
                if (event.keyCode == 13) {
                    PrintBarCode_ZB();
                }
            });
                      
            //退出
            form.on('submit(ToolExit)', function (data) {
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
 
            //#endregion
 
            //#region 此页面所有方法
           
            //#region 获取打印模板
            function getTem_SN() {
                $.ajax({
                    type: "get",
                    async: false,
                    url: GetWEBURL() + "/Open_PrintTem/GetOpenTmpList_Json",
                    data: { "HNumber": "HGy_BarCodeBill" },
                    success: function (result) {
                        var template = "";
                        if (result.count == 1) { // 说明验证成功了,
                            var data = result.data;
                            for (var i = 0; i < data.length; i++) {
                                template += '<option  style="color:blue;" value="' + data[i].HName + '">' + data[i].HName + '</option>';
                            }
                            $("#HPrintTemplate").append(template);
                            $("#HPrintTemplate").val(localStorage.getItem('SNselectedTemplate'))
                            form.render('select');
                        }
                        layer.closeAll("loading");
                    }
                })
            }
 
            function getTem_ZX() {
                $.ajax({
                    type: "get",
                    async: false,
                    url: GetWEBURL() + "/Open_PrintTem/GetOpenTmpList_Json",
                    data: { "HNumber": "HGy_BarCodeBill_MiddleBox" },
                    success: function (result) {
                        var template = "";
                        if (result.count == 1) { // 说明验证成功了,
                            var data = result.data;
                            for (var i = 0; i < data.length; i++) {
                                template += '<option  style="color:blue;" value="' + data[i].HName + '">' + data[i].HName + '</option>';
                            }
                            $("#HPrintTemplate_ZX").append(template);
                            $("#HPrintTemplate_ZX").val(localStorage.getItem('ZXselectedTemplate'))
                            form.render('select');
                        }
                        layer.closeAll("loading");
                    }
                })
            }
 
            function getTem_ZB() {
                $.ajax({
                    type: "get",
                    async: false,
                    url: GetWEBURL() + "/Open_PrintTem/GetOpenTmpList_Json",
                    data: { "HNumber": "HGy_BarCodeBill_ZB" },
                    success: function (result) {
                        var template = "";
                        if (result.count == 1) { // 说明验证成功了,
                            var data = result.data;
                            for (var i = 0; i < data.length; i++) {
                                template += '<option  style="color:blue;" value="' + data[i].HName + '">' + data[i].HName + '</option>';
                            }
                            $("#HPrintTemplate_ZB").append(template);
                            $("#HPrintTemplate_ZB").val(localStorage.getItem('ZBselectedTemplate'))
                            form.render('select');
                        }
                        layer.closeAll("loading");
                    }
                })
            }
            //#endregion
 
 
            
            //补打SN条码
            function PrintBarCode() {
                var HBarCode = $("#HBarCode").val();
 
                var sWhere = "select top 1 a.HItemID,HBarCode 条码编号,isnull(ms.HCusRelationNumber,'') SKU from Gy_BarCodeBill a with(nolock) left join Gy_Material m with(nolock) on a.HMaterID = m.HItemID left join Gy_MateNumRelation_Sec ms with(nolock) on m.HMASTERID = ms.HMaterID where a.HBarCode = '" + HBarCode + "'";
 
                if ($("#HPrintTemplate").val().indexOf("闻献") !== -1) {
                    sWhere = "exec h_p_IF_BarCodeBillList_XWPrint '" + HBarCode + "'"
                }
 
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Gy_SOPBillList/WindowPrintList", //方法所在页面和方法名
                    async: false,
                    data: { "sWhere": sWhere },
                    success: function (data) {
                        if (data.count == 1) { // 说明验证成功了,
 
                            if (data.data.length != 0) {
                                if (data.data[0].SKU == "") {
                                    layer.msg("物料SKU未维护,请联系管理员确认!");
                                    return;
                                }
 
                                var dataPrint = [];
                                for (var i = 0; i < data.data.length; i++) {
                                    dataPrint.push(data.data[i])
                                }
 
                                var Customer = {
                                    "Table": dataPrint
                                }
 
                                var args = {
                                    type: "print",//打印模式
                                    //type: "preview",//预览模式
                                    showOptionDlg: false, //如果不显示打印对话框而直接打印,将此行注释去掉即可
                                    report: urlAddRandomNo("../../grf/" + $("#HPrintTemplate").val() + ".grf"),
                                    data: Customer
                                };
 
                                console.log("打印SN条码:" + data.data[0].条码编号);
  
                                webapp_ws_ajax_run(args);                                                             
 
                            } else {
                                layer.msg("查无数据!");
                            }
                        }
                        else {
                            layer.msg(data.Message, { icon: 5 });
                        }
                        layer.closeAll("loading");
                    },
                    error: function (err) {
                        layer.msg("错误:" + err, { icon: 5 });
                    }
                })
            }
 
            //补打中箱条码
            function PrintBarCode_ZX() {
                var HBarCode = $("#HBarCode_ZX").val();
 
                var sWhere = "exec h_p_Gy_GetCaseCodeInfo '" + HBarCode + "'";
 
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Gy_SOPBillList/WindowPrintList", //方法所在页面和方法名
                    async: false,
                    data: { "sWhere": sWhere },
                    success: function (data) {
                        if (data.count == 1) { // 说明验证成功了,
 
                            if (data.data.length != 0) {
                           
                                var dataPrint = [];
                                for (var i = 0; i < data.data.length; i++) {
                                    dataPrint.push(data.data[i])
                                }
 
                                var Customer = {
                                    "Table": dataPrint
                                }
 
                                var args = {
                                    type: "print",//打印模式
                                    //type: "preview",//预览模式
                                    showOptionDlg: false, //如果不显示打印对话框而直接打印,将此行注释去掉即可
                                    report: urlAddRandomNo("../../grf/" + $("#HPrintTemplate_ZX").val() + ".grf"),
                                    data: Customer
                                };
 
                                console.log("打印中箱条码:" + data.data[0].条码编号);
 
                                webapp_ws_ajax_run(args);
                              
                            } else {
                                layer.msg("查无数据!");
                            }
                        }
                        else {
                            layer.msg(data.Message, { icon: 5 });
                        }
                        layer.closeAll("loading");
                    },
                    error: function (err) {
                        layer.msg("错误:" + err, { icon: 5 });
                    }
                })
            }
 
            //补打栈板条码
            function PrintBarCode_ZB() {
                var HBarCode = $("#HBarCode_ZB").val();
 
                var sWhere = "exec h_p_Gy_GetPalletBarInfo '" + HBarCode + "'";
 
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Gy_SOPBillList/WindowPrintList", //方法所在页面和方法名
                    async: false,
                    data: { "sWhere": sWhere },
                    success: function (data) {
                        if (data.count == 1) { // 说明验证成功了,
 
                            if (data.data.length != 0) {
 
                                var dataPrint = [];
                                for (var i = 0; i < data.data.length; i++) {
                                    dataPrint.push(data.data[i])
                                }
 
                                var Customer = {
                                    "Table": dataPrint
                                }
 
                                var args = {
                                    type: "print",//打印模式
                                    //type: "preview",//预览模式
                                    showOptionDlg: false, //如果不显示打印对话框而直接打印,将此行注释去掉即可
                                    report: urlAddRandomNo("../../grf/" + $("#HPrintTemplate_ZB").val() + ".grf"),
                                    data: Customer
                                };
 
                                console.log("打印栈板条码:" + data.data[0].条码编号);
 
                                webapp_ws_ajax_run(args);
 
                            } else {
                                layer.msg("查无数据!");
                            }
                        }
                        else {
                            layer.msg(data.Message, { icon: 5 });
                        }
                        layer.closeAll("loading");
                    },
                    error: function (err) {
                        layer.msg("错误:" + err, { icon: 5 });
                    }
                })
            }
 
         
            //#endregion
        });
    </script>
</body>
</html>