xwt
2025-05-16 a67e7dede17a1720c5c26046799e562e546c8a1d
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
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
<template>
    <view class="inspection-sheet">
        <!-- 头部信息 -->
        <view class="sheet-header">
            <h1>来料检验单</h1>
            <view class="inspection-number">检验单号:{{formData.releaseNo}}</view>
            <!-- 造梦者特殊功能 -->
            <view style="text-align: right;" v-if="this.current"><a class="sysLike"
                    @click="toSysSubmitFrom(formData.releaseNo)">实验室送检</a></view>
        </view>
 
        <!-- 基本信息区 -->
        <view class="basic-info">
            <view class="info-row">
                <span class="info-label">到货单号:</span>
                <span class="info-value">{{formData.lotNo}}</span>
                <span class="info-label">创建人:</span>
                <span class="info-value">{{formData.createBy}}</span>
            </view>
            <view class="info-row">
                <span class="info-label">创建时间:</span>
                <span class="info-value">{{formData.createDate}}</span>
                <span class="info-label">&nbsp;负责人:</span>
                <span class="info-value">{{formData.userName}}</span>
            </view>
        </view>
 
        <!-- 物料信息区 -->
        <view class="material-info">
            <view class="info-block">
                <view class="info-label">物料编码:</view>
                <view class="info-value">{{formData.itemNo}}</view>
 
            </view>
            <view class="info-block">
                <view class="info-label">物料名称:</view>
                <view class="info-value">{{formData.itemName}}</view>
            </view>
            <view class="info-block">
                <view class="info-label">规格型号:</view>
                <view class="info-value">{{formData.itemModel}}</view>
            </view>
 
            <view class="info-block">
 
                <view class="info-label" v-if="formData.extendNo1!=null">技改状态:</view>
                <view class="info-value" v-if="formData.extendNo1!=null">{{formData.extendNo1}}</view>
 
 
                <view class="info-label">数量:</view>
                <view class="info-value highlight">{{formData.fcovertQty}}</view>
 
            </view>
            <view class="info-block" v-if="formData.fngDesc!=null">
                <view class="info-label">不良描述:</view>
                <view class="info-value">{{formData.fngDesc}}</view>
            </view>
            <view class="info-block" v-if="formData.newFngDesc!=null">
                <view class="info-label">上次不良:</view>
                <view class="info-value">{{formData.newFngDesc}}</view>
            </view>
        </view>
        <view class="dropdown-row">
            <view class="info-label">不良原因:</view>
            <select id="defect-reason" v-model="badreason" v-if="current">
                <option value=""></option>
                <option value="外观不良">外观不良</option>
                <option value="功能不良">功能不良</option>
            </select>
        </view>
        <view class="dropdown-row">
            <view class="info-label">所属车间:</view>
            <select id="defect-reason" v-model="WORKSHOP" v-if="current">
                <option value=""></option>
                <option value="生产一部">生产一部</option>
                <option value="生产二部">生产二部</option>
                <option value="注塑车间">注塑车间</option>
                <option value="其他">其他</option>
            </select>
        </view>
        <view class="dropdown-row">
            <view class="info-label">评审状态:</view>
            <select id="defect-reason" v-model="PSTYPE" v-if="current">
                <option value=""></option>
                <option value="特采/让步使用">特采/让步使用</option>
                <option value="挑选/返工使用">挑选/返工使用</option>
                <option value="退货">退货</option>
 
            </select>
        </view>
        <view class="dropdown-row">
            <view class="info-label">备注:</view>
            <input type="text" id="remark" v-model="REMARK" placeholder="请输入备注信息" />
        </view>
 
 
 
        <!-- 操作按钮区 -->
        <view class="action-buttons" v-if="this.current">
            <button class="secondary-btn" @click="getInspectionItems">获取检验项目</button>
        </view>
 
        <!-- 检验项目表格 -->
        <view class="inspection-table">
            <table>
                <thead>
                    <tr>
                        <th width="15%" style="text-align: center;">检验项目</th>
                        <th width="50%" style="text-align: center;">检验描述</th>
                        <th width="20%" style="text-align: center;">记录(点击)</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="(item, index) in tableData" :key="index">
                        <td>{{ item.fcheckItem }}</td>
                        <td>
                            <view v-if="item.fcheckResu=='合格'" class="watermark approved">
                                {{ getStatusText(item.fcheckResu) }}
                            </view>
                            <view v-if="item.fcheckResu=='不合格'" class="watermark rejected">
                                {{ getStatusText(item.fcheckResu) }}
                            </view>
                            <view v-if="item.fcheckResu==null" class="watermark pending">
                                {{ getStatusText(item.fcheckResu) }}
                            </view>
                            <view class="description-text">{{ item.fcheckItemDesc }}</view>
                        </td>
                        <td>
                            <button v-if="item.current" class="record-btn" @click="fillRecord(item,index)">填写</button>
                            <button v-if="!item.current" class="record-btn" @click="fillRecord(item,index)">查看</button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </view>
 
        <!-- 操作按钮区 -->
        <view class="action-buttons">
            <button class="secondary-btn" @click="uploadImages">上传/查看图片</button>
            <button class="secondary-btn" @click="fetchDrawingNumber">调取PLM图纸</button>
            <button class="secondary-btn" @click="addDefectDescription" v-if="this.current">添加不良描述</button>
            <button class="primary-btn" @click="submitInspection" v-if="this.current">检验提交</button>
        </view>
        <view v-if="remarksPopup" class="overlay">
            <view class="popup">
                <h3>修改不合格描述</h3>
                <form>
                    <view class="form-group">
                        <label class="form-label">不合格描述:</label>
                        <input class="form-input" type="text" v-model="remarks" />
                    </view>
 
                </form>
                <button class="updateBut" @click="editRemarks">修改</button>
                <button @click="remarksPopup = !remarksPopup">取消</button>
            </view>
        </view>
 
        <view class="barcode">
            <u-modal :show="drawingShow" title="图纸明细" @confirm="drawingConfirm" @cancel="drawingCancel"
                showCancelButton>
                <uni-table border stripe emptyText="暂无更多数据" style="margin-left: 5px;margin-right: 5px;height: 500px;">
                    <uni-tr>
                        <uni-th align="center">相关文档</uni-th>
                        <uni-th align="center" width="90">有无关联PDF文件</uni-th>
                        <uni-th align="center" width="90">能否打开文件</uni-th>
                        <uni-th align="center" width="150">操作(点击)</uni-th>
                    </uni-tr>
                    <uni-tr v-for="(item,index) in drawing" style="height: 100px;">
                        <uni-td align="center">{{item.fName}}</uni-td>
                        <uni-td align="center" style="font-size:25px;">
                            <div v-if="item.fRelevantObject==' '" style="color: #E47470;">×</div>
                            <div style="color: #90BA87;" v-else>√</div>
                        </uni-td>
                        <uni-td align="center" style="font-size:25px;">
                            <div v-if="item.isSupported || item.fRelevantObject!=' '" style="color: #90BA87;">√</div>
                            <div style="color: #E47470;" v-else>×</div>
                        </uni-td>
                        <uni-td align="center" class="click-wd">
                            <div @click="openDrawings(item)">打开文档</div>
                        </uni-td>
                    </uni-tr>
                </uni-table>
            </u-modal>
        </view>
 
    </view>
</template>
 
<script>
    export default {
        data() {
            return {
                formData: {
                    id: "",
                    releaseNo: "",
                    createBy: "",
                    createDate: "",
                    lotNo: "",
                    itemNo: "",
                    billNo: "",
                    fcovertQty: "",
                    detailMem: "",
                    taskNo: "",
                    fcheckResu: "",
                    boardModel: "",
                    planQty: "",
                    mocode: "",
                    boardStyle: "",
                    itemId: ""
                },
                tableData: [],
                remarksPopup: false,
                current: true,
                drawing: [],
                drawingShow: false,
                badreason: '',
                PSTYPE: '',
                WORKSHOP: '',
                REMARK: '',
                checkState: false,
                writeStatu: true,
                fileName:''
            }
        },
        onLoad(options) {
            //options中包含了url附带的参数
            let params = options;
 
            if (params["id"]) {
                this.formData.id = params["id"];
                this.formData.releaseNo = params["releaseNo"];
                this.formData.lotNo = params["lotNo"];
                this.msgId = params["msgId"];
 
                if (params["current"] === 'A') {
                    this.current = true;
                } else if (params["current"] === 'B') {
                    this.current = false;
                }
 
                if (this.msgId > 0) {
                    this.msgRead();
                }
 
            } else {
                //初始化检验单号
                this.$post({
                    url: "/LLJ/getMaxReleaseNo"
                }).then(res => {
                    this.formData.releaseNo = res.data.tbBillList;
                    this.formData.createBy = this.$loginInfo.account;
                    this.formData.createDate = this.$getDate("yyyy-mm-dd");
                });
 
            }
 
        },
        methods: {
            getStatusText(status) {
                const statusMap = {
                    approved: '合格',
                    rejected: '不合格',
                    pending: '待确认'
                }
                if (status == null) {
                    return statusMap['pending'] || ''
                } else if (status == '合格') {
                    return statusMap['approved'] || ''
                } else {
                    return statusMap['rejected'] || ''
                }
 
            },
            getInspectionItems() {
                // 获取检验项目的逻辑
                this.$post({
                    url: "/LLJ/setJYItem",
                    data: {
                        itemNo: this.formData.itemId,
                        quantity: this.formData.fcovertQty,
                        releaseNo: this.formData.releaseNo
                    }
                }).then(res => {
                    if (res.status == 0) {
                        uni.showToast({
                            title: res.message.toString(),
                            //将值设置为 success 或者直接不用写icon这个参数
                            icon: 'success',
                            //显示持续时间为 2秒
                            duration: 2000
                        })
                        // 如果有页面跳转,需要用定时器延迟
                        setTimeout(() => {
                            this.init();
                        }, 2000);
 
                    } else {
                        uni.showToast({
                            title: res.message.toString(),
                            //将值设置为 success 或者直接不用写icon这个参数
                            icon: 'error',
                            //显示持续时间为 2秒
                            duration: 2000
                        })
                    }
                });
            },
            fillRecord(item, index) {
                // 填写记录的逻辑
                uni.navigateTo({
                    url: 'detail?mainId=' + item.id + '&formID=' + this.formData.id + '&releaseNo=' + this.formData
                        .releaseNo + '&index=' + index + '&current=' + this.current
                });
            },
            uploadImages() {
                // 上传/查看图片的逻辑
                uni.navigateTo({
                    url: 'ImageItem?id=' + this.formData.id
                });
            },
            addDefectDescription() {
                // 添加不良描述的逻辑
                this.remarksPopup = !this.remarksPopup;
                this.remarks = this.formData.remarks;
            },
            submitInspection() {
                if (this.PSTYPE == '') {
                    this.writeStatu = false
                }
                if (this.badreason == '') {
                    this.writeStatu = false
                }
                if (this.DEPARTMENT == '') {
                    this.writeStatu = false
                }
 
                console.log(this.tableData)
                this.checkState = false;
                this.tableData.forEach((item) => {
                    if (item.fcheckResu == "不合格") {
                        this.checkState = true;
                    }
                })
                if (this.checkState) {
 
                    if (this.formData.fngDesc == '' || this.writeStatu == false) {
                        uni.showToast({
                            title: '未填写不良描述或三个选择框未选择完',
                            icon: 'none'
                        });
                    } else {
                        // 检验提交的逻辑
                        this.$post({
                            url: "/LLJ/IqcQaSubmit",
                            data: {
                                userNo: this.$loginInfo.account,
                                releaseNo: this.formData.releaseNo
                            }
                        }).then(res => {
                            if (res.status == 0) {
 
                                if(this.$loginInfo.account == 'PL017'){
                                    this.QcIssueResultDetailes = {
                                        fbatchQty: this.formData.fbatchQty,
                                        itemName: this.formData.itemName,
                                        itemNo: this.formData.itemNo,
                                        suppName: this.formData.suppName,
                                        appicationReason: this.formData.fngDesc,
                                        badReason: this.badreason,
                                        remark: this.REMARK,
                                        workShop: this.WORKSHOP,
                                        releaseNo: this.formData.releaseNo,
                                        staffNo: 'HMCS',
                                        // staffNo: this.$loginInfo.account,
                                        iqcStatus: this.PSTYPE,
                                        department: this.DEPARTMENT
                                    };
                                }
                                else{
                                    this.QcIssueResultDetailes = {
                                        fbatchQty: this.formData.fbatchQty,
                                        itemName: this.formData.itemName,
                                        itemNo: this.formData.itemNo,
                                        suppName: this.formData.suppName,
                                        appicationReason: this.formData.fngDesc,
                                        badReason: this.badreason,
                                        remark: this.REMARK,
                                        workShop: this.WORKSHOP,
                                        releaseNo: this.formData.releaseNo,
                                        // staffNo: 'HMCS',
                                        staffNo: this.$loginInfo.account,
                                        iqcStatus: this.PSTYPE,
                                        department: this.DEPARTMENT
                                    };
                                }
 
                                console.log(this.QcIssueResultDetailes)
 
                                const url = `http://192.168.1.22:10054/api/QcIssueResult/GetProcessNo`;
                                // 发送 POST 请求
                                uni.request({
                                    url: url, // 请求地址
                                    method: 'POST', // 请求方法
                                    data: this.QcIssueResultDetailes, // 请求体数据
                                    header: {
                                        'content-type': 'application/json' // 设置请求头,确保发送 JSON 格式的数据
                                    },
                                    success: (response) => {
                                        // 请求成功
                                        uni.showToast({
                                            title: '推送异常处置单成功',
                                            icon: 'none'
                                        });
 
                                        // 如果有页面跳转,需要用定时器延迟
                                        setTimeout(() => {
                                            uni.navigateTo({
                                                url: 'List'
                                            });
                                        }, 2000); // 保持与 duration 相同的时长
 
                                    },
                                    fail: (error) => {
                                        // 请求失败
                                        console.log('请求失败:', error);
                                        uni.showToast({
                                            title: '推送异常处置单失败',
                                            icon: 'none'
                                        });
                                    }
                                });
 
                                uni.showToast({
                                    title: res.message.toString(),
                                    icon: 'success',
                                    duration: 2000
                                })
 
 
                            } else {
                                uni.showModal({
                                    title: "提示",
                                    content: res.message.toString(),
                                    confirmText: "确定",
                                    showCancel: false,
                                    success: (res) => {
 
                                    }
                                })
                            }
                        })
                    }
                } else {
                    // 检验提交的逻辑
                    this.$post({
                        url: "/LLJ/IqcQaSubmit",
                        data: {
                            userNo: this.$loginInfo.account,
                            releaseNo: this.formData.releaseNo
                        }
                    }).then(res => {
                        if (res.status == 0) {
 
                            uni.showToast({
                                title: res.message.toString(),
                                icon: 'success',
                                duration: 2000
                            })
                            // 如果有页面跳转,需要用定时器延迟
                            setTimeout(() => {
                                uni.navigateTo({
                                    url: 'List'
                                });
                            }, 2000); // 保持与 duration 相同的时长
 
                        } else {
                            uni.showModal({
                                title: "提示",
                                content: res.message.toString(),
                                confirmText: "确定",
                                showCancel: false,
                                success: (res) => {
 
                                }
                            })
                        }
                    })
                }
            },
            onShow() {
                //每次进入页面都会执行的方法
                if (this.formData.id) {
                    this.init();
                }
            },
            init() {
                let userName = this.$loginInfo.account;
 
                this.$post({
                    url: "/LLJ/getPage",
                    data: {
                        id: this.formData.id,
                        createUser: userName,
                        pageIndex: 1,
                        limit: 1,
                    }
                }).then(res => {
                    let data = res.data.tbBillList[0];
                    if (data) {
                        this.formData = data;
 
                        this.$post({
                            url: "/LLJ/getJYItem",
                            data: {
                                id: this.formData.id,
                                releaseNo: this.formData.releaseNo
                            }
                        }).then(res1 => {
                            let tableData = res1.data.tbBillList
                            //当已检验个数都不为空时按照检测结构排序
                            tableData.sort((a, b) => {
                                if (a.result === '未完成' && b.result === '合格') {
                                    return -1;
                                } else if (a.result === '合格' && b.result === '未完成') {
                                    return 1;
                                } else {
                                    return 0;
                                }
                            });
                            this.tableData = tableData;
                            if (this.tableData.length === 0) {
                                this.isShowTable = true;
                            }
                            this.tableData.forEach((item, index) => {
                                this.$set(item, 'current', this.current);
 
                            });
 
                        })
                    }
                });
            },
            msgRead() {
                msgRead(this.msgId, this.$loginInfo.account);
            },
            //去文件列表页面(文件类型,物料编号)
            toFileUrlByU9List(type, u9No) {
                if (type === 1) {
                    uni.navigateTo({
                        url: 'FileUrlByU9List?type=' + type + '&itemID=' + u9No
                    });
                } else {
                    uni.navigateTo({
                        url: 'FileUrlByU9List2?type=' + type + '&itemID=' + u9No
                    });
                }
            },
            toSysSubmitFrom(releaseNo) {
                uni.navigateTo({
                    url: 'SysSubmitFrom?releaseNo=' + releaseNo + '&userID=' + this.$loginInfo.account
                });
            },
            editRemarks() {
                if (this.remarks) {
                    //saveRemarksGid
                    this.$post({
                        url: "/LLJ/saveRemarksGid",
                        data: {
                            gid: this.formData.id,
                            remarks: this.remarks,
                            releaseNo: this.formData.releaseNo,
                        }
                    }).then(res => {
                        if (res.data.tbBillList > 0) {
                            this.formData.remarks = this.remarks;
                            this.remarksPopup = !this.remarksPopup;
                            this.$showMessage("保存成功");
                            setTimeout(() => {
                                let pages = getCurrentPages();
                                let beforePage = pages[pages.length - 2];
                                uni.navigateBack({
                                    delta: 1, //返回的页面数,如果为1表示返回上一页
                                    success: (event) => {
                                        beforePage.$vm.reload()
                                    }
                                });
                            }, 2000);
                        }
                    })
                } else {
                    this.$post({
                        url: "/LLJ/saveRemarksGid",
                        data: {
                            gid: this.formData.id,
                            remarks: '',
                            releaseNo: this.formData.releaseNo,
                        }
                    }).then(res => {
                        if (res.data.tbBillList > 0) {
                            this.formData.remarks = this.remarks;
                            this.remarksPopup = !this.remarksPopup;
                            this.$showMessage("保存成功");
                            setTimeout(() => {
                                let pages = getCurrentPages();
                                let beforePage = pages[pages.length - 2];
                                uni.navigateBack({
                                    delta: 1, //返回的页面数,如果为1表示返回上一页
                                    success: (event) => {
                                        beforePage.$vm.reload()
                                    }
                                });
                            }, 2000);
                        }
                    })
                }
            },
 
            drawingConfirm() {
                this.drawingShow = false
                this.imageShow = false
                this.productionShow = false
            },
            drawingCancel() {
                this.drawingShow = false
                this.imageShow = false
                this.productionShow = false
            },
 
            fetchDrawingNumber() {
                // const item = '83040700101'
                const item = this.formData.itemNo;
                console.log(this.formData.itemNo)
                // console.log(item)
                const url = "http://192.168.1.22:10054/api/PLM/RetrieveDrawings?ItemNo=" + item
 
                // const item = '5.06.04.4002';
                // const url = "http://192.168.0.100:10054/api/PLM/RetrieveDrawings?ItemNo=" + item
 
                uni.request({
                    url: url,
                    method: 'POST',
                    success: (response) => {
                        console.log(response)
                        if (response.data.data == '返回结果为空') {
                            this.drawing = null
                        } else {
                            this.drawing = response.data.data
                            // 遍历数据,判断文件后缀并添加字段
                            this.drawing.forEach((file) => {
                                // 获取文件名的后缀
                                const fileExtension = file.fName.split('.').pop()
                                    .toLowerCase();
 
                                // 定义支持的文件类型
                                const supportedExtensions = ['jpg', 'pdf', 'xlsx', 'doc',
                                    'docx',
                                    'xls'
                                ];
 
                                // 判断是否支持该文件类型
                                file.isSupported = supportedExtensions.includes(fileExtension);
                            });
                        }
                    },
                    fail: (error) => {
                        uni.showToast({
                            title: '请求图纸链接失败',
                            icon: 'none'
                        });
                    }
                });
                this.drawingShow = true
            },
 
 
            //图纸相关文档
            openDrawings(item) {
                console.log("jkjoi", item)
                if (item.fRelevantObject.length > 2) {
                    // 生成请求URL(简化编码逻辑)
                    const encodedName = encodeURIComponent(item.fName); 
                    const url = `http://192.168.1.22:10054/api/PLM/OpenDrawingsGet?fileId=${item.fRelevantObject}&fName=${encodedName}`;
                    console.log('请求URL:', url);
                    
                    const now = new Date();
                    const timestamp = [
                      now.getFullYear(),
                      String(now.getMonth() + 1).padStart(2, '0'),
                      String(now.getDate()).padStart(2, '0'),
                      String(now.getHours()).padStart(2, '0'),
                      String(now.getMinutes()).padStart(2, '0'),
                      String(now.getSeconds()).padStart(2, '0')
                    ].join('');
                                    
                    // 生成新文件名(基础名_时间戳.后缀)
                    this.fileName = `${item.fName}_${timestamp}.pdf`;
                    console.log('新文件名:', this.fileName);
                    
                    uni.downloadFile({
                        url: url,
                        success: (res) => {
                            console.log(res);
                            let fileName = this.fileName;
                            let fileExt = fileName.split('.').pop();
                            // let newFilePath = "_doc/uniapp_temp_1742877118745/download" + "/" + fileName;
                            // console.log('newFilePath', newFilePath)
                            if (fileExt === 'xls' || fileExt === 'xlsx' || fileExt === 'pdf'|| fileExt === 'jpg'|| fileExt === 'png') {
                                plus.io.resolveLocalFileSystemURL(res.tempFilePath, (entry) => {
                                        // 获取文件所在的目录
                                        entry.getParent((parentEntry) => {
                                          let newFileName = this.fileName; // 新的文件名
                                
                                          // 移动并重命名文件
                                          entry.moveTo(
                                            parentEntry,
                                            newFileName,
                                            (newEntry) => {
                                              console.log('重命名成功:', newEntry.fullPath);
                                
                                              // 打开 Excel 文件
                                              plus.runtime.openFile(newEntry.fullPath, {}, (e) => {
                                                console.error('无法打开 Excel 文件:', e);
                                              });
                                              
                                              // let pages = getCurrentPages();
                                              // let beforePage = pages[pages.length - 2];
                                              // uni.navigateBack({
                                              //     delta: 1, //返回的页面数,如果为1表示返回上一页
                                              //     success: (event) => {
                                              //         beforePage.$vm.reload()
                                              //     }
                                              // });
                                              
                                            },
                                            (err) => {
                                              console.error('重命名失败:', err);
                                            }
                                          );
                                        }, (err) => {
                                          console.error('获取父目录失败:', err);
                                        });
                                      }, (err) => {
                                        console.error('获取文件失败:', err);
                                      });
                            } else {
                                console.error('文件格式不匹配:', fileExt);
                                uni.showToast({
                                    title: '文件格式不支持',
                                    icon: 'none'
                                });
                            }
                        }
                    })
                    
                    
                    // uni.downloadFile({
                    //     url: url,
                    //     responseType: 'arraybuffer', // 关键:指定响应数据类型为 ArrayBuffer
                    //     success: (res) => {
                    //         console.log(res)
                    //         if (res.statusCode === 200) {
                    //             // 获取 ArrayBuffer 数据
                    //             const arrayBuffer = res.data;
 
                    //             // 可选:验证文件类型(例如检查 PDF 文件头)
                    //             const header = new Uint8Array(arrayBuffer).subarray(0, 4);
                    //             const headerStr = Array.from(header).map(byte => byte.toString(16).padStart(2,
                    //                 '0')).join('').toUpperCase();
                    //             if (headerStr !== '25504446') { // PDF 文件头为 "%PDF" 的十六进制表示
                    //                 console.error('文件格式无效,非 PDF 文件');
                    //                 return;
                    //             }
 
                    //             // 保存为临时文件(确保扩展名为 .pdf)
                    //             const tempPath = `${wx.env.USER_DATA_PATH}/${Date.now()}.pdf`; // 微信小程序路径
                    //             uni.saveFile({
                    //                 tempFilePath: arrayBuffer, // 注意:部分平台可能需要转换 ArrayBuffer 为 Base64
                    //                 filePath: tempPath,
                    //                 success: () => {
                    //                     uni.openDocument({
                    //                         filePath: tempPath,
                    //                         fileType: 'pdf',
                    //                         success: () => console.log('文档打开成功'),
                    //                         fail: (err) => console.error('打开失败:', err)
                    //                     });
                    //                 },
                    //                 fail: (saveErr) => console.error('保存文件失败:', saveErr)
                    //             });
                    //         } else {
                    //             console.error('下载失败,状态码:', res.statusCode);
                    //         }
                    //     },
                    //     fail: (error) => {
                    //         console.error('下载请求失败:', error.errMsg);
                    //     }
                    // });
                    uni.request({
                        url: url,
                        method: 'POST',
                        responseType: 'arraybuffer',
                        success: (response) => {
                            console.log(response.data)
                            if (!response) {
                                uni.showToast({
                                    title: "协议预览失败",
                                    duration: 2000
                                });
                            }
                            
                            
                            
                            // const base64Data = uni.arrayBufferToBase64(response.data);
 
                            // // 构造一个可以用于预览的 Data URL
                            // const pdfUrl = `data:application/pdf;base64,${base64Data}`;
 
                            // // 使用 pdfUrl 作为预览路径
                            // console.log("PDF 预览路径:", pdfUrl);
 
                            // // 将 Base64 数据传递给另一个页面进行预览
                            // // 注意:直接传递 pdfUrl 可能会导致 URL 过长,建议使用其他方式传递
                            // uni.navigateTo({
                            //     url: `/pages/fileView/pdfView?url=${encodeURIComponent(pdfUrl)}`
                            // });
 
                            // const base64Data = uni.arrayBufferToBase64(response.data);
 
                            //     // 存储到全局变量(在App.vue中定义)
                            //     getApp().globalData.tempPDF = base64Data;
 
                            //     uni.navigateTo({
                            //       url: '/pages/fileView/pdfView'
                            //     });
 
                        },
                        fail: (error) => {
                            console.log(error)
                            uni.showToast({
                                title: '请求预览链接失败',
                                icon: 'none'
                            });
                        }
                    });
                } else if (item.fName && item.fName.toLowerCase().endsWith('.jpg')) {
                    const url = "http://192.168.1.22:10054/api/PLM/OpenDrawings?fileId=" + item.fFileId +
                        '&fName=' +
                        encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace(
                                /\#/g,
                                '%23')
                            .replace(/\?/g, '%3F').replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\&/g,
                                '%26'))
                    console.log('jpgurl: ' + url);
                    uni.request({
                        url: url,
                        method: 'POST',
                        responseType: 'arraybuffer',
                        success: (response) => {
                            console.log(response.data)
                            if (!response) {
                                uni.showToast({
                                    title: "协议预览失败",
                                    duration: 2000
                                });
                            }
                            const base64Data = uni.arrayBufferToBase64(response.data);
 
                            // 构造一个可以用于预览的 Data URL
                            const jpgUrl = `data:image/jpeg;base64,${base64Data}`;
 
                            // 使用 pdfUrl 作为预览路径
                            console.log("PDF 预览路径:", jpgUrl);
 
                            // 将 Base64 数据传递给另一个页面进行预览
                            // 注意:直接传递 jpgUrl 可能会导致 URL 过长,建议使用其他方式传递
                            uni.navigateTo({
                                url: `/pages/fileView/jpgView?url=${encodeURIComponent(jpgUrl)}`
                            });
                        },
                        fail: (error) => {
                            console.log(error)
                            uni.showToast({
                                title: '请求预览链接失败',
                                icon: 'none'
                            });
                        }
                    });
                } else if (item.fName && item.fName.toLowerCase().endsWith('.xlsx')) {
                    console.log(item);
                    const url = "http://192.168.1.22:10054/api/PLM/OpenDrawings?fileId=" + item.fFileId +
                        '&fName=' +
                        encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace(
                                /\#/g,
                                '%23')
                            .replace(/\?/g, '%3F').replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\&/g,
                                '%26'))
                    console.log('jpgurl: ' + url);
                    uni.request({
                        url: url,
                        method: 'POST',
                        responseType: 'arraybuffer',
                        success: (response) => {
                            console.log(response.data)
                            if (!response) {
                                uni.showToast({
                                    title: "协议预览失败",
                                    duration: 2000
                                });
                            }
                            // const base64Data = uni.arrayBufferToBase64(response.data);
 
                            // const excelUrl =
                            //     `data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,${base64Data}`;
 
                            // // 使用 pdfUrl 作为预览路径
                            // console.log("PDF 预览路径:", excelUrl);
 
                            // 将 ArrayBuffer 转换为 Base64 数据
                            const base64Data = uni.arrayBufferToBase64(response.data);
 
                            // 存储 Base64 数据到本地存储
                            uni.setStorageSync('excelBase64Data', base64Data);
                            // 将 Base64 数据传递给另一个页面进行预览
                            // 注意:直接传递 excelUrl 可能会导致 URL 过长,建议使用其他方式传递
                            // uni.navigateTo({
                            //     url: `/pages/fileView/excelView?url=${encodeURIComponent(excelUrl)}`
                            // });
                            uni.navigateTo({
                                url: `/pages/fileView/excelView`
                            });
                        },
                        fail: (error) => {
                            console.log(error)
                            uni.showToast({
                                title: '请求预览链接失败',
                                icon: 'none'
                            });
                        }
                    });
                }
                // else if (item.fName && item.fName.toLowerCase().endsWith('.doc') || item.fName && item.fName
                //     .toLowerCase().endsWith('.docx')) {
                // console.log(item);
                // const url = "http://192.168.0.100:10054/api/PLM/OpenDrawings?fileId=" + item.fFileId + '&fName=' +
                //     encodeURIComponent(item.fName.replace(/\%/g, '%25').replace(/\ /g, '%20').replace(/\#/g, '%23')
                //         .replace(/\?/g, '%3F').replace(/\+/g, '%2B').replace(/\//g, '%2F').replace(/\&/g, '%26'));
                // console.log('Word 文档 URL:' + url);
                // uni.request({
                //     url: url,
                //     method: 'POST',
                //     responseType: 'arraybuffer',
                //     success: (response) => {
                //         console.log(response.data);
                //         if (!response) {
                //             uni.showToast({
                //                 title: "文档预览失败",
                //                 duration: 2000
                //             });
                //         }
                //         const base64Data = uni.arrayBufferToBase64(response.data);
 
                //         // 构造一个可以用于预览的 Data URL
                //         const wordUrl = `data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64,${base64Data}`;
 
                //         // 使用 wordUrl 作为预览路径
                //         console.log("Word 文档预览路径:", wordUrl);
 
                //         // 将 Base64 数据传递给另一个页面进行预览
                //         // 注意:直接传递 wordUrl 可能会导致 URL 过长,建议使用其他方式传递
                //         uni.navigateTo({
                //             url: `/pages/fileView/wordView?url=${encodeURIComponent(wordUrl)}`
                //         });
                //     },
                //         fail: (error) => {
                //             console.log(error)
                //             uni.showToast({
                //                 title: '请求预览链接失败',
                //                 icon: 'none'
                //             });
                //         }
                //     });
                // } else {
                //     uni.showToast({
                //         title: '无对应PDF文件,打开失败',
                //         icon: 'none'
                //     });                // }
            }
        }
    }
</script>
 
<style>
    /* 基础样式 */
    .inspection-sheet {
        font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
        max-width: 1000px;
        margin: 0 auto;
        padding: 20px;
        background-color: #fff;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    }
 
    /* 头部样式 */
    .sheet-header {
        text-align: center;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 2px solid #e0e0e0;
    }
 
    .sheet-header h1 {
        color: #2c3e50;
        font-size: 24px;
        margin-bottom: 5px;
    }
 
    .inspection-number {
        font-size: 16px;
        font-weight: bold;
        color: #3498db;
    }
 
    /* 基本信息区样式 */
    .basic-info,
    .material-info {
        margin-bottom: 20px;
    }
 
    .info-row {
        display: flex;
        margin-bottom: 10px;
        flex-wrap: wrap;
    }
 
    .info-label {
        font-weight: bold;
        color: #34495e;
        min-width: 80px;
        margin-right: 5px;
    }
 
    .info-value {
        color: #2c3e50;
        margin-right: 20px;
    }
 
    .highlight {
        font-weight: bold;
        color: #e74c3c;
    }
 
    /* 物料信息区样式 */
    .material-info {
        border: 1px solid #eee;
        padding: 15px;
        border-radius: 5px;
    }
 
    .info-block {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        flex-wrap: wrap;
    }
 
    .doc-links {
        margin-left: auto;
    }
 
    .doc-link {
        color: #3498db;
        text-decoration: none;
        margin-left: 15px;
        padding: 3px 8px;
        border: 1px solid #3498db;
        border-radius: 3px;
        font-size: 12px;
    }
 
    .sysLike {
        color: #3498db;
        text-decoration: none;
        margin-left: 15px;
        padding: 3px 8px;
        border-radius: 3px;
        font-size: 12px;
    }
 
    .doc-link:hover {
        background-color: #f0f8ff;
    }
 
    /* 表格样式 */
    .inspection-table {
        margin: 25px 0;
    }
 
    .inspection-table table {
        width: 100%;
        border-collapse: collapse;
    }
 
    .inspection-table th,
    .inspection-table td {
        padding: 12px 15px;
        border: 1px solid #ddd;
        text-align: left;
    }
 
    .inspection-table th {
        background-color: #f8f9fa;
        font-weight: bold;
        color: #34495e;
    }
 
    .inspection-table tr:nth-child(even) {
        background-color: #f9f9f9;
    }
 
    .inspection-table tr:hover {
        background-color: #f1f5f9;
    }
 
    /* 按钮样式 */
    .action-buttons {
        display: flex;
        justify-content: flex-end;
        gap: 10px;
        margin-top: 20px;
    }
 
    .primary-btn,
    .secondary-btn {
        padding: 10px 20px;
        border: none;
        border-radius: 4px;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.3s;
    }
 
    .primary-btn {
        background-color: #3498db;
        color: white;
    }
 
    .primary-btn:hover {
        background-color: #2980b9;
    }
 
    .secondary-btn {
        background-color: #ecf0f1;
        color: #7f8c8d;
    }
 
    .secondary-btn:hover {
        background-color: #d5dbdb;
    }
 
    .record-btn {
        padding: 6px 12px;
        background-color: #f8f9fa;
        border: 1px solid #ddd;
        /* border-radius: 3px; */
        cursor: pointer;
        transition: all 0.2s;
    }
 
    .record-btn:hover {
        background-color: #e9ecef;
    }
 
    /* 水印样式 */
    .watermark {
        position: absolute;
        font-size: 40px;
        font-weight: bold;
        opacity: 1;
        z-index: 1;
        pointer-events: none;
        transform: rotate(-15deg);
        width: 100%;
        text-align: center;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) rotate(-15deg);
    }
 
    .watermark.approved {
        color: #2ecc71;
        /* 绿色 */
    }
 
    .watermark.rejected {
        color: #e74c3c;
        /* 红色 */
    }
 
    .watermark.pending {
        color: #f39c12;
        /* 橙色 */
    }
 
    /* 描述文本容器 */
    .description-text {
        position: relative;
        z-index: 2;
        padding: 25px;
        background-color: rgba(255, 255, 255, 0.7);
    }
 
    /* 调整表格单元格 */
    .inspection-table td:nth-child(2) {
        position: relative;
        overflow: hidden;
        padding: 0;
    }
 
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        display: flex;
        justify-content: center;
        align-items: center;
        z-index: 10;
    }
 
    .popup {
        background-color: #fff;
        padding: 20px;
        border: 1px solid #ccc;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        width: 68vw;
        /* 设置宽度为视口宽度的80% */
        height: 25vh;
        /* 设置高度为视口高度的80% */
    }
 
    .form-group {
        display: flex;
        align-items: center;
        border-bottom: 1px solid #c9c9c9;
    }
 
    .updateBut {
        background-color: #3498db;
        color: white;
    }
 
    /* 响应式设计 */
    @media (max-width: 500px) {
 
        .info-row,
        .info-block {
            flex-direction: column;
            align-items: flex-start;
        }
 
        .doc-links {
            margin-left: 0;
            margin-top: 10px;
        }
 
        .action-buttons {
            flex-direction: column;
        }
 
        .inspection-table table {
            display: block;
            overflow-x: auto;
        }
 
        .click-wd {
            color: #056cba;
            font-size: 1.25rem;
            text-decoration: underline;
        }
 
    }
</style>