自动化立体仓库 - WMS系统
chen.lin
18 小时以前 38c0d1cb155b27fb8054d6b302df2669a5d6e10e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
<!DOCTYPE html>
<html lang="en">
 
<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, maximum-scale=1">
    <link rel="stylesheet" href="../../static/evn/index.css">
</head>
 
<body>
    <div id="app">
        <el-card>
        <el-form :inline="true">
            <el-form-item label="开工日期">
                <el-date-picker
                        v-model="tableSearchParam.fplancommitdate"
                        type="date"
                        placeholder="选择日期"
                        :default-value="defaultTime"
 
                />
            </el-form-item>
            <el-form-item label="生产单号">
                <el-input v-model="tableSearchParam.soCode" placeholder="请输入生产单号"></el-input>
            </el-form-item>
            <el-form-item label="车间">
                <el-select v-model="tableSearchParam.depId" placeholder="选择车间" style="width: 150px" >
                    <el-option
                            v-for="item in options"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                    />
                </el-select>
            </el-form-item>
            <el-form-item label="是否打印">
                <el-select v-model="tableSearchParam.izPrint" placeholder="是否打印" style="width: 150px" >
                    <el-option
                            v-for="item in printOptions"
                            :key="item.value"
                            :label="item.label"
                            :value="item.value"
                    />
                </el-select>
            </el-form-item>
            <el-form-item label="">
                <el-button type="primary" @click="page" circle >
                    <el-icon><Search /></el-icon>
                </el-button>
            </el-form-item>
        </el-form>
        <el-form :inline="true">
            <el-form-item label="">
               <el-button type="primary"  @click="fnPrintView('否')">打印预览</el-button>
            </el-form-item>
            <el-form-item label="">
               <el-button type="primary" @click="fnPrint('是')">打印</el-button>
            </el-form-item>
            <el-form-item label="">
               <el-button type="primary" @click="fnCanelPrint()">撤销生成</el-button>
            </el-form-item>
            <el-form-item label="">
               <el-button type="primary" @click="fnPrintRedView('否')">打印预览(红字)</el-button>
            </el-form-item>
            <el-form-item label="">
                <el-button type="primary" @click="fnPrintRed('是')">打印(红字)</el-button>
            </el-form-item>
            <el-form-item label="">
               <el-button type="primary" @click="fnCanelPrintRed()">撤销生成(红字)</el-button>
            </el-form-item>
            <el-form-item label="">
               <el-button type="success" @click="manualSync()">手动同步</el-button>
            </el-form-item>
        </el-form>
        <el-table :data="tableData" border style="width: 100%" row-key="finterid" @selection-change="handleSelectionChange" max-height="650">
            <el-table-column type="selection" >
            </el-table-column>
            <el-table-column type="index" width="50" >
            </el-table-column>
            <el-table-column prop="soCode" label="生产单号" >
            </el-table-column>
            <el-table-column prop="fbillno" label="任务单号">
            </el-table-column>
            <el-table-column prop="invCode" label="物料编码">
            </el-table-column>
            <el-table-column prop="invName" label="物料名称" width="250" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="invStd" label="规格" width="150" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="depName" label="车间" width="70">
            </el-table-column>
            <el-table-column prop="fauxqty" label="数量" width="90">
            </el-table-column>
            <el-table-column prop="fplancommitdate" label="计划开工时间">
            </el-table-column>
            <el-table-column prop="fplanfinishdate" label="计划完工时间">
            </el-table-column>
            <el-table-column prop="izPrint" label="是否打印" width="90">
            </el-table-column>
            <el-table-column prop="izPrintReturn" label="是否打印(红字)" width="90">
            </el-table-column>
        </el-table>
<!--            <div style="margin-top: 10px">-->
<!--                <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"-->
<!--                               :current-page="currentPage" :page-sizes="pageSizes" :page-size="pageSize"-->
<!--                               layout="total, sizes, prev, pager, next, jumper" :total="pageTotal">-->
<!--                </el-pagination>-->
<!--            </div>-->
 
            
        </el-card>
    </div>
    
    <script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
    <script src="../../static/evn/vue.global.js"></script>
    <script src="../../static/evn/element-plus.js"></script>
    <script src="../../static/evn/icons-vue.js"></script>
    <script src='../../static/js/erp/LodopFuncs.js'></script>
    <script type="module">
        // 导入中文语言包
        import zhCn from '../../static/js/erp/zh-cn.js';
        
        const { createApp, ref, onMounted, onBeforeMount ,watchEffect} = Vue;
       
 
        const app = createApp({
            setup() {
                const currentPage = ref(1)
                const pageSizes = ref([15,20, 30, 50, 100, 200])
                const pageSize = ref(15)
                const pageTotal = ref(0)
                const tableSearchParam = ref({
                    soCode: null,
                    fplancommitdate: new Date(),
                    depId:null
                })
                const tableData = ref([])
                const defaultTime = ref(new Date())
                const fullscreenLoading = ref(false)
 
                const depName = ref('')
 
                const options = ref([])
 
                watchEffect(() =>{
                     options.value.map(item =>{
                        if (item.value === tableSearchParam.value.depId){
                            depName.value = item.label
                        }
                    })
 
                })
 
                const printOptions = [
                    {
                        value: '否',
                        label: '否'
                    },
                    {
                        value: '是',
                        label: '是'
                    },
 
                ]
 
                const selectList = ref([])
                
                function page(){
                    let data = JSON.parse(JSON.stringify(tableSearchParam.value))
                    data.curr = currentPage.value
                    data.limit = pageSize.value
                    if (tableSearchParam.value.datetime != null) {
                        data.datetime = null
                        data.create_time = tableSearchParam.value.datetime[0] + " - " + tableSearchParam.value.datetime[1]
                    }
                    const loading = ElementPlus.ElLoading.service({
                        lock: true,
                        text: 'Loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    })
                    $.ajax({
                        url: "http://127.0.0.1:8133/mo/materialreceive/getList",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: data,
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function(res) {
                            loading.close()
                            if (res.code == 200) {
                                tableData.value = res.data
                                ElementPlus.ElMessage({
                                    message: "拉取数据完成",
                                    type: 'success'
                                });
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                ElementPlus.ElMessage({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                }
 
                function fnCanelPrint(){
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择",
                            type: 'error'
                        });
                        return ;
                    }
                    const loading = ElementPlus.ElLoading.service({
                        lock: true,
                        text: 'Loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    })
                    $.ajax({
                        url:"http://127.0.0.1:8133/mo/materialuse/canelprint",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: JSON.stringify(selectList.value),
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function(res) {
                            loading.close();
                            if (res.code == 200) {
                                ElementPlus.ElMessage({
                                    message: "撤销成功",
                                    type: 'success'
                                });
                                page()
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                ElementPlus.ElMessage({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                }
 
                function fnCanelPrintRed(){
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择",
                            type: 'error'
                        });
                        return ;
                    }
                    const loading = ElementPlus.ElLoading.service({
                        lock: true,
                        text: 'Loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    })
                    $.ajax({
                        url:"http://127.0.0.1:8133/mo/materialuse/canelprint1",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: JSON.stringify(selectList.value),
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function(res) {
                            loading.close();
                            if (res.code == 200) {
                                ElementPlus.ElMessage({
                                    message: "撤销红字成功",
                                    type: 'success'
                                });
                                page()
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                ElementPlus.ElMessage({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                }
 
                function getDepOptions(){
                    $.ajax({
                        url: "http://127.0.0.1:8133/basicinfo/departmentl/getlistfordropdown",
                        contentType: 'application/json;charset=UTF-8',
                        method: 'GET',
                        success: function(res) {
                            if (res.code == 200) {
                                res.data.map(item => {
                                    options.value.push({
                                        value: item.depId, label: item.depName
                                    })
                                })
                            } else {
                                ElementPlus.ElMessage({
                                    message: res.msg,
                                    type: 'error'
                                });
                            }
                        }
                    });
                }
                function fnPrint(izPrint) {
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择",
                            type: 'error'
                        });
                        return ;
                    }
                    // 打印前确认
                    if (izPrint === '是') {
                        ElementPlus.ElMessageBox.confirm('确定打印吗?')
                            .then(() => {
                                print(izPrint, 0);
                            })
                            .catch(() => {
                                // 取消
                            });
                    } else {
                        print(izPrint, 0);
                    }
                }
                
                // 手动同步
                function manualSync() {
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择要同步的数据",
                            type: 'error'
                        });
                        return ;
                    }
                    
                    ElementPlus.ElMessageBox.confirm('确定要同步选中的数据到WMS吗?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        const loading = ElementPlus.ElLoading.service({
                            lock: true,
                            text: '同步中...',
                            background: 'rgba(0, 0, 0, 0.7)',
                        });
                        
                        // 构建同步参数(传递选中的数据)
                        const syncParams = {
                            icmoDTOS: JSON.stringify(selectList.value)
                        };
                        
                        $.ajax({
                            url: "http://127.0.0.1:8133/api/materialReceive/sync/manual",
                            headers: {
                                'token': localStorage.getItem('token')
                            },
                            data: JSON.stringify(syncParams),
                            contentType: 'application/json;charset=UTF-8',
                            method: 'POST',
                            success: function(res) {
                                loading.close();
                                if (res.code == 200) {
                                    ElementPlus.ElMessage({
                                        message: res.data.message || "同步任务已提交",
                                        type: 'success'
                                    });
                                    // 刷新列表
                                    setTimeout(() => {
                                        page();
                                    }, 2000);
                                } else {
                                    ElementPlus.ElMessage({
                                        message: res.msg || "同步失败",
                                        type: 'error'
                                    });
                                }
                            },
                            error: function() {
                                loading.close();
                                ElementPlus.ElMessage({
                                    message: "同步请求失败",
                                    type: 'error'
                                });
                            }
                        });
                    }).catch(() => {
                        // 取消
                    });
                }
 
                function fnPrintView(izPrint){
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择",
                            type: 'error'
                        });
                        return ;
                    }
                    // 打印预览直接调用打印接口(后端不校验出库完成状态)
                    print(izPrint, 0);
                }
 
                function fnPrintRedView(izPrint) {
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择",
                            type: 'error'
                        });
                        return ;
                    }
                    // 打印预览直接调用打印接口(后端不校验出库完成状态)
                    print(izPrint, 1);
                }
 
                function fnPrintRed(izPrint) {
                    if (selectList.value.length === 0){
                        ElementPlus.ElMessage({
                            message: "请先选择",
                            type: 'error'
                        });
                        return ;
                    }
                    // 打印前确认
                    if (izPrint === '是') {
                        ElementPlus.ElMessageBox.confirm('确定打印吗?')
                            .then(() => {
                                print(izPrint, 1);
                            })
                            .catch(() => {
                                // 取消
                            });
                    } else {
                        print(izPrint, 1);
                    }
                }
 
                function print(izPrint,izRed){
                    const LODOP = getLodop()
                    const loading = ElementPlus.ElLoading.service({
                        lock: true,
                        text: 'Loading',
                        background: 'rgba(0, 0, 0, 0.7)',
                    })
                    $.ajax({
                        url:"http://127.0.0.1:8133/mo/materialuse/print",
                        headers: {
                            'token': localStorage.getItem('token')
                        },
                        data: JSON.stringify({
                            icmoDTOS : JSON.stringify(selectList.value),
                            izPrint : izPrint,
                            izRed : izRed
                        }),
                        dataType: 'json',
                        contentType: 'application/json;charset=UTF-8',
                        method: 'POST',
                        success: function(res) {
                            loading.close()
                            if (res.code == 200) {
                                ElementPlus.ElMessage({
                                    message: "获取数据完成,等待唤起打印",
                                    type: 'success'
                                });
                                page()
                                LODOP.PRINT_INITA(0,0,800,1100,"生成领料单");
                                LODOP.SET_PRINT_PAGESIZE(1,0,0,"A4");
                                LODOP.SET_PRINT_MODE("PRINT_NOCOLLATE",1);
                                
                                // 收集二维码单号:优先使用生产单号,但如果生产单号没有被全部选中,则使用任务单号
                                var barcodeCodeSet = new Set();
                                if (selectList.value && selectList.value.length > 0 && tableData.value && tableData.value.length > 0) {
                                    // 按生产单号分组,统计每个生产单号的总行数和选中行数
                                    var soCodeGroups = {};
                                    tableData.value.forEach(function(item) {
                                        if (item.soCode) {
                                            if (!soCodeGroups[item.soCode]) {
                                                soCodeGroups[item.soCode] = {
                                                    total: 0,
                                                    selected: 0,
                                                    soCode: item.soCode
                                                };
                                            }
                                            soCodeGroups[item.soCode].total++;
                                        }
                                    });
                                    
                                    // 统计每个生产单号的选中行数
                                    selectList.value.forEach(function(item) {
                                        if (item.soCode && soCodeGroups[item.soCode]) {
                                            soCodeGroups[item.soCode].selected++;
                                        }
                                    });
                                    
                                    // 根据是否全部选中决定使用生产单号还是任务单号
                                    selectList.value.forEach(function(item) {
                                        if (item.soCode && soCodeGroups[item.soCode]) {
                                            var group = soCodeGroups[item.soCode];
                                            // 如果该生产单号的所有行都被选中,使用生产单号
                                            if (group.selected === group.total) {
                                                barcodeCodeSet.add(item.soCode);
                                            } else {
                                                // 如果该生产单号只有部分行被选中,使用任务单号
                                                if (item.fbillno) {
                                                    barcodeCodeSet.add(item.fbillno);
                                                }
                                            }
                                        }
                                    });
                                }
                                var barcodeCodeStr = Array.from(barcodeCodeSet).join('|');
                                
                                // 定义添加条形码的函数
                                function addBarcodeToPrint() {
                                    // 在右上角添加条形码(如果有单号)
                                    if (barcodeCodeStr) {
                                        // 将所有单号用竖线连接,用于条形码(Code128支持竖线)
                                        var barcodeCodeArray = barcodeCodeStr.split('|');
                                        // 使用所有单号拼接,用竖线分隔
                                        var barcodeValue = barcodeCodeStr; // 直接使用拼接后的字符串,已经是用竖线分隔的
                                        
                                        // 控制台打印参数
                                        // console.log("条形码编码的真实字符(生产单号/任务单号):", barcodeValue);
                                        // console.log("单号数组:", barcodeCodeArray);
                                        // console.log("单号数组长度:", barcodeCodeArray.length);
                                        
                                        // 使用后端接口生成条形码图片,先加载图片转换为base64
                                        // type=1表示条形码,type=2表示二维码
                                        // 将所有单号都编码到条形码中
                                        // 固定二维码尺寸,保持正方形比例,避免挤占打印文本和被拉长
                                        var barcodeWidth = 130; // 固定宽度130px,不根据数量动态调整
                                        var barcodeHeight = 130; // 固定高度130px,保持正方形比例
                                        var barcodeUrl = baseUrl + "/file/barcode/qrcode/auth?type=2&param=" + encodeURIComponent(barcodeValue) + "&width=" + barcodeWidth + "&height=" + barcodeHeight;
                                        
                                        // console.log("条形码宽度(固定):", barcodeWidth);
                                        // console.log("条形码编码内容(生产单号/任务单号):", barcodeValue);
                                        
                                        // 控制台打印条形码的真实字符(编码的数据内容)
                                        // console.log("=== 条形码信息 ===");
                                        // console.log("条形码编码的真实字符(生产单号/任务单号,用|分隔):", barcodeValue);
                                        // console.log("条形码字符长度:", barcodeValue.length);
                                        // console.log("条形码字符编码(UTF-8):", encodeURIComponent(barcodeValue));
                                        // console.log("条形码URL参数部分:", "type=1&param=" + encodeURIComponent(barcodeValue) + "&width=130&height=40");
                                        
                                        // 创建一个临时img元素加载图片,然后转换为base64
                                        var img = new Image();
                                        img.crossOrigin = 'anonymous';
                                        img.onload = function() {
                                            try {
                                                // 创建canvas将图片转换为base64
                                                var canvas = document.createElement('canvas');
                                                canvas.width = img.width;
                                                canvas.height = img.height;
                                                var ctx = canvas.getContext('2d');
                                                ctx.drawImage(img, 0, 0);
                                                var base64Image = canvas.toDataURL('image/png');
                                                
                                                // 控制台打印条形码图片信息
                                                // console.log("条形码图片已生成");
                                                // console.log("条形码图片base64前50个字符:", base64Image.substring(0, 50) + "...");
                                                // console.log("条形码图片base64总长度:", base64Image.length);
                                                // console.log("条形码图片尺寸:", img.width + "x" + img.height);
                                                // console.log("条形码编码内容确认(生产单号/任务单号):", barcodeValue);
                                                // console.log("=== 条形码信息结束 ===");
                                                
                                                // LODOP添加图片,使用base64格式
                                                // ADD_PRINT_IMAGE参数:Top, Left, Width, Height, ImageURL或ImageData
                                                // 条形码位置:右上角,Top: 20, Left: 650 (页面宽度800,右边留50像素边距)
                                                // 固定显示尺寸,保持正方形比例,避免挤占打印文本和被拉长
                                                var displayWidth = barcodeWidth; // 固定宽度130px
                                                var displayHeight = barcodeHeight; // 固定高度130px,保持正方形
                                                var displayLeft = 800 - displayWidth - 20; // 右对齐,留20px边距
                                                try {
                                                    LODOP.ADD_PRINT_IMAGE(20, displayLeft, displayWidth, displayHeight, base64Image);
                                                    console.log("条形码图片已添加到打印页面(ADD_PRINT_IMAGE方式),位置:", displayLeft + ", 宽度:", displayWidth);
                                                } catch(e) {
                                                    // 如果ADD_PRINT_IMAGE失败,使用HTML方式
                                                    console.log("ADD_PRINT_IMAGE失败,尝试HTML方式");
                                                    var htmlContent = '<img src="' + base64Image + '" style="width:' + displayWidth + 'px;height:' + displayHeight + 'px;" />';
                                                    LODOP.ADD_PRINT_HTM(20, displayLeft, displayWidth, displayHeight, htmlContent);
                                                    console.log("条形码图片已添加到打印页面(ADD_PRINT_HTM方式),位置:", displayLeft + ", 宽度:", displayWidth);
                                                }
                                                
                                                // 如果有多个单号,在条形码下方显示所有单号的文本(方便人工识别)
                                                // 已注释:二维码底下不显示字符串
                                                // if (barcodeCodeArray.length > 1) {
                                                //     LODOP.ADD_PRINT_TEXT(65, 650, 130, 20, barcodeCodeStr);
                                                //     LODOP.SET_PRINT_STYLEA(0, "FontSize", 9);
                                                //     LODOP.SET_PRINT_STYLEA(0, "Alignment", 2); // 居中对齐
                                                // }
                                                
                                                // 图片加载完成后,执行打印或预览
                                                executePrint();
                                            } catch(e) {
                                                console.error("转换图片失败:", e);
                                                // 如果转换失败,只显示文本(生产单号/任务单号)
                                                var displayWidth = barcodeWidth; // 固定宽度130px
                                                var displayHeight = barcodeHeight; // 固定高度130px
                                                var displayLeft = 800 - displayWidth - 20;
                                                LODOP.ADD_PRINT_TEXT(20, displayLeft, displayWidth, displayHeight, barcodeValue);
                                                LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
                                                LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                                executePrint();
                                            }
                                        };
                                        img.onerror = function() {
                                            console.error("加载条形码图片失败");
                                            // 如果加载失败,只显示文本(生产单号/任务单号)
                                            var displayWidth = barcodeWidth; // 固定宽度130px
                                            var displayHeight = barcodeHeight; // 固定高度130px
                                            var displayLeft = 800 - displayWidth - 20;
                                            LODOP.ADD_PRINT_TEXT(20, displayLeft, displayWidth, displayHeight, barcodeValue);
                                            LODOP.SET_PRINT_STYLEA(0, "FontSize", 12);
                                            LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
                                            executePrint();
                                        };
                                        img.src = barcodeUrl;
                                    } else {
                                        // 没有单号,直接执行打印
                                        executePrint();
                                    }
                                }
                                
                                // 定义执行打印的函数
                                function executePrint() {
                                    // 计算表格的起始位置:如果有二维码,表格需要向下移动
                                    var tableTop = 96; // 默认表格起始位置
                                    var qrCodeTop = 20; // 二维码顶部位置
                                    var qrCodeHeight = 130; // 二维码高度
                                    var qrCodeBottom = qrCodeTop + qrCodeHeight; // 二维码底部位置:150
                                    var spacing = 10; // 二维码和表格之间的间距
                                    
                                    // 如果有二维码,且表格原始位置会被二维码覆盖,则向下移动表格
                                    if (barcodeCodeStr && tableTop < qrCodeBottom) {
                                        tableTop = qrCodeBottom + spacing; // 表格从二维码下方开始,留10px间距
                                    }
                                    
                                    if(izRed==1)
                                    {
                                        LODOP.ADD_PRINT_TEXT(28,268,331,36,"生成领料单(红字)");
                                    }
                                    else{
                                        LODOP.ADD_PRINT_TEXT(28,268,331,36,"生成领料单");
                                    }
                                    LODOP.SET_PRINT_STYLEA(0,"FontSize",20);
                                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                                    LODOP.ADD_PRINT_TEXT(69,21,213,25,"生产线:"+depName.value);
                                    LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                                    LODOP.ADD_PRINT_TEXT(70,268,213,25,"计划开工日期:"+tableSearchParam.value.fplancommitdate.toLocaleString('zh-CN', {
                                        timeZone: 'Asia/Shanghai',
                                        year: 'numeric',
                                        month: '2-digit',
                                        day: '2-digit',
                                        hour: '2-digit',
                                        minute: '2-digit',
                                        second: '2-digit',
                                        hour12: false
                                    }).slice(0, 10));
                                    LODOP.SET_PRINT_STYLEA(0,"FontSize",12);
                                    LODOP.SET_PRINT_STYLEA(0,"ItemType",1);
                                    LODOP.ADD_PRINT_TABLE(tableTop,16,2000,960,CreateTable(res.data));
                                    LODOP.SET_PRINT_STYLEA(0,"TableHeightScope",1);
                                    LODOP.SET_PRINT_MODE("FULL_WIDTH_FOR_OVERFLOW",true);
                                    if(izPrint=="是")
                                    {
                                        LODOP.PRINT();
                                    }
                                    else{
                                        LODOP.PREVIEW();
                                    }
                                }
                                
                                // 开始加载条形码图片
                                addBarcodeToPrint();
                            } else if (res.code === 403) {
                                top.location.href = baseUrl + "/";
                            } else {
                                // 后端返回错误信息(校验失败)
                                ElementPlus.ElMessageBox.alert(res.msg || "打印失败", '错误', {
                                    confirmButtonText: '确定',
                                    type: 'error'
                                });
                            }
                        },
                        error: function(xhr, status, error) {
                            loading.close()
                            ElementPlus.ElMessage({
                                message: "打印请求失败,请稍后重试",
                                type: 'error'
                            });
                        }
                    });
                }
 
                function  CreateTable(result) {
//        var css =" <style> table,td,th {border: 1px solid black;border-style: solid;border-collapse: collapse;font-size: 15px;}</style><table border=1>";
                    var css = "<style> table,td,th {table-layout: fixed;border: 1px black solid;border-collapse: collapse;font-size: 13px;}</style><table>";
                    //第一行
                    var th = "<thead><tr style='height:20px'>" +
                        "<th  >序号</th>" +
                        "<th  >物料编码</th>" +
                        "<th  >物料名称</th>" +
                        "<th >规格</th>" +
                        "<th  >单位</th>" +
                        "<th  >应发数量</th>" +
                        "<th  >实发数量</th>" +
                        "<th  >生产单号</th>" +
                        "</tr></thead>";
 
                    var td="";
                    var row=1;
                    for (var i = 0; i <result.length; i++) {
 
                        td = td+"<tr style='height:20px'><td style='width:30px;' align='center' >"+(row)+"</td><td style='width:80px;'  align='left'  >" + result[i].invCode + "</td><td style='width:250px;word-wrap:break-word;word-break:break-all;'  align='left'  >" + result[i].invName + "</td>  <td style='width:50px;'  align='left'  >" + result[i].invStd + "</td> <td style='width:35px;'  align='left'  >" + result[i].unit + "</td><td style='width:60px;'  align='left'  >" + result[i].fqty + "</td><td style='width:60px;'  align='left'  ></td>  <td style='width:120px;word-wrap:break-word;word-break:break-all;'  align='left'  >" + result[i].soCode + "</td>   </tr>"
                        row++;
                    }
 
                    var txt = css +th+ td +"</table>";
                    return txt;
 
                }
 
 
                
                function handleSizeChange(val) {
                    pageSize.value = val
                    currentPage.value = 1 // 重置到第一页
                    page()
                }
                
                function handleCurrentChange(val) {
                    currentPage.value = val
                    page()
                }
                function handleSelectionChange(val) {                    
 
                    selectList.value = val
                }
 
                onMounted(() => {
                    page()
                })
 
                onBeforeMount(() => {
                    getDepOptions()
 
                })
 
                return {
                    tableData,
                    currentPage,
                    pageSizes,
                    pageSize,
                    pageTotal,
                    tableSearchParam,
                    defaultTime,
                    options,
                    printOptions,
                    page,
                    fnPrint,
                    fnPrintView,
                    fnCanelPrint,
                    fnCanelPrintRed,
                    fnPrintRed,
                    fnPrintRedView,
                    manualSync,
                    handleSizeChange,
                    handleCurrentChange,
                    handleSelectionChange
                    
                }
            }
        });
        
        app.use(ElementPlus, {
            locale: zhCn.default || zhCn
        });
        for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
            app.component(key, component)
        }
        app.mount('#app');
    </script>
 
</body>
 
</html>