如洲 陈
2 天以前 900e4776223c2a42d8859fc8cd635c13ffcfb3b5
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
<template>
    <view>
        <view class="form-container">
            <form :modelValue="formData">
                <view class="form-group">
                    <label class="form-label">检验单号:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.releaseNo" />
                </view>
                <view class="form-group">
                    <label class="form-label">创建人:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.createBy" />
                </view>
                <view class="form-group">
                    <label class="form-label">创建时间:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.createDate" />
                </view>
                <view class="form-group">
                    <label class="form-label">客户名称:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.customerName"/>
                </view>
                <view class="form-group">
                    <label class="form-label">退货单号:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.returnOrderNo" />
                </view>
                <view class="form-group">
                    <label class="form-label">退货数量:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.returnQty" />
                </view>
                <view class="form-group">
                    <label class="form-label">退货原因:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.returnReason" />
                </view>
                <view class="form-group">
                    <label class="form-label">物料编码:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.itemNo" />
                </view>
                <view class="form-group">
                    <label class="form-label">物料名称:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.itemName" />
                </view>
                <view class="form-group">
                    <label class="form-label">检验人:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.statusUser" />
                </view>
                <view class="form-group">
                    <label class="form-label">检验状态:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.result" />
                </view>
                <view class="form-group">
                    <label class="form-label">不合格描述:</label>
                    <input class="form-input" disabled="true" type="text" v-model="formData.remarks" />
                </view>
 
 
 
            </form>
        </view>
 
 
        <view class="container">
            <view class="tab-bar">
                <view class="tab-item active">
                    检验项目明细
                </view>
            </view>
 
            <!-- 内容区域 -->
            <scroll-view class="content">
                <view class="tab-content">
                    <view class="list-container">
                        <uni-table ref="table" border emptyText="暂无更多数据">
                            <uni-tr>
                                <uni-th align="center" class="th" style="color: #FFFFFF;">检验项目</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF">是否合格</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF">记录(点击)</uni-th>
                            </uni-tr>
                            <uni-tr v-for="(item, index) in tableData" :key="index">
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.projName" />
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.result" />
                                </uni-td>
                                <uni-td>
                                    <view class="uni-group">
                                        <button v-if="(item.isCheck || 0) >= (item.levelNum || 0)" type="default"
                                            @click="toDetail(item)">
                                            {{ (item.levelNum || 0) + '/' + (item.isCheck || 0) }}
                                        </button>
                                        <button v-else type="warn" @click="toDetail(item)">
                                            {{ (item.levelNum || 0) + '/' + (item.isCheck || 0) }}</button>
                                    </view>
                                </uni-td>
                            </uni-tr>
                        </uni-table>
                    </view>
 
 
 
 
                    <view class="plus-button">
                        <button type="warn" v-if="!isUpdate && !isShowTable" @click="getTable">获取检验项目</button>
                    </view>
 
 
 
                    <view class="plus-button">
                        <button type="warn" v-if="!isUpdate && isShowTable" @click="toImage">上传/查看图片</button>
                    </view>
 
                    <view class="plus-button">
                        <button type="warn" v-if="!isUpdate && isShowTable" @click="getTable">重新获取检验项目</button>
                    </view>
 
 
                    <view class="plus-button">
                        <button type="warn" v-if="!isUpdate && isShowTable" @click="saveRemarks">添加不合格描述</button>
                    </view>
 
                    <view class="plus-button">
                        <button type="primary" v-if="!isUpdate && isShowTable" @click="submitTHJResult" :disabled="isSubmitting">
                            {{ isSubmitting ? '提交中...' : '提交检验结果' }}
                        </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>
                                <button type="warn" @click="editRemarks">修改</button>
                                <button @click="remarksPopup = !remarksPopup">取消</button>
                            </form>
                        </view>
                    </view>
                </view>
 
                <!-- <view v-if="currentTab === 1" class="tab-content">
                    <view class="list-container">
                        <uni-table ref="table" border emptyText="暂无更多数据">
                            <uni-tr>
                                <uni-th align="center" class="th" style="color: #FFFFFF;">退货单号</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF">产品名称</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF">退货数量</uni-th>
                                <uni-th align="center" class="th" style="color: #FFFFFF;">退货原因</uni-th>
                            </uni-tr>
                            <uni-tr v-for="(item, index) in tableReturnData" :key="index">
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text"
                                        v-model="item.returnOrderNo" />
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.itemName" />
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.returnQty" />
                                </uni-td>
                                <uni-td align="center">
                                    <input class="form-input" disabled="true" type="text" v-model="item.returnReason" />
                                </uni-td>
                            </uni-tr>
                        </uni-table>
                    </view>
 
                    <view class="plus-button-row">
                        <button type="warn" v-if="isUpdate && !isShowTable" @click="addReturnRow">新增</button>
                        <button type="warn" v-if="isUpdate && !isShowTable" @click="delReturnRow">删除</button>
                    </view>
 
                    <view class="plus-button">
                        <button type="warn" v-if="isUpdate && !isShowTable" @tap="saveReturnTable">保存</button>
                    </view>
 
                    <view class="plus-button">
                        <button type="warn" v-if="isUpdate && !isShowTable" @tap="showReturnSelect">批量选择</button>
                    </view>
 
                    <multiple-select v-model="show" :data="returnOrderList" :default-selected="defaultSelected"
                        @confirm="confirmReturn"></multiple-select>
 
 
                </view> -->
 
            </scroll-view>
 
        </view>
 
    </view>
 
</template>
 
<script>
    import multipleSelect from "@/components/momo-multipleSelect/momo-multipleSelect";
    export default {
        components: {
            multipleSelect,
        },
        data() {
            return {
                formData: {
                    show: false,
                    id: "",
                    releaseNo: "", // 检验单号
                    returnNo: "", // 退货编号(用于参数传递)
                    createBy: "",
                    createDate: "",
                    customerNo: "", // 客户编号(兼容保留)
                    customerName: "", // 客户名称
                    returnOrderNo: "", // 退货单号
                    returnQty: "", // 退货数量
                    returnReason: "", // 退货原因
                    inspectStatus: "",
                    itemNo: "",
                    itemName: "", // 物料名称
                    statusUser: "", // 检验人
                    remarks: ""
                },
                tableReturnData: [],
                returnOrderList: [],
                defaultSelected: [],
                isShowTable: false,
                tableData: [],
                isSubmit: true,
                isUpdate: true,
                remarks: "",
                currentTab: 0,
                remarksPopup: false,
                show: false,
                isSubmitting: false,
            };
        },
        onLoad(options) {
            //options中包含了url附带的参数
            let params = options;
 
            // 监听检验数据更新事件
            uni.$on('inspectionDataUpdated', (data) => {
                if (this.formData.id && data.id && this.formData.id == data.id) {
                    // 如果当前页面的检验单ID与更新通知的ID匹配,则刷新数据
                    // 延迟一点时间确保后端数据已更新
                    setTimeout(() => {
                        this.init();
                    }, 300);
                }
            });
 
            if (params["id"]) {
                this.isUpdate = false;
                this.formData.id = params["id"];
                this.formData.returnNo = params["returnNo"];
                this.init();
            } else {
                //初始化检验单号
                this.$post({
                    url: "/THJ/getMaxReleaseNo",
                    data: {
                        type: "return"
                    }
                }).then(res => {
                    this.formData.releaseNo = res.data.tbBillList; // 检验单号
                    this.formData.returnNo = res.data.tbBillList; // 退货编号(保持兼容)
                    this.formData.createBy = this.$loginInfo.account;
                    this.formData.statusUser = this.$loginInfo.account; // 设置检验人为当前用户
                    this.formData.createDate = this.$getDate("yyyy-mm-dd");
                });
 
                //获取退货单列表
                this.$post({
                    url: "/THJ/getReturnOrders"
                }).then(res => {
                    this.returnOrderList = res.data.tbBillList.map(item => {
                        return {
                            value: item.returnOrderNo,
                            label: item.returnOrderNo,
                            itemName: item.itemName,
                            returnQty: item.returnQty,
                            returnReason: item.returnReason
                        };
                    });
                });
 
                this.currentTab = 1;
            }
        },
        methods: {
 
 
 
            changeTab(index) {
 
                this.currentTab = index;
            },
 
 
 
 
            init() {
                return this.$post({
                    url: "/THJ/getPage",
                    data: {
                        id: this.formData.id,
                        pageIndex: 1,
                        limit: 1,
                    }
                }).then(res => {
                    let data = res.data.tbBillList[0];
                    if (data) {
 
                        Object.assign(this.formData, data);
 
 
                        this.$post({
                            url: "/THJ/getQSItems",
                            data: {
                                pid: this.formData.id,
                                id: this.formData.id
                            }
                        }).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 = false;
                            } else {
                                this.isShowTable = true;
                            }
                        })
 
                        //获取对应退货明细信息
                        this.$post({
                            url: "/THJ/getReturnDetails",
                            data: {
                                pid: this.formData.id
                            }
                        }).then(res => {
                            this.tableReturnData = res.data.tbBillList;
 
                            // 同步退货明细信息到表单
                            if (this.tableReturnData && this.tableReturnData.length > 0) {
                                const firstDetail = this.tableReturnData[0];
 
                                // 直接使用后端返回的字段名
                                const returnType = firstDetail.returntype || '';
                                const returnNo = firstDetail.returnno || '';
                                const returnQty = firstDetail.quantity || '';
                                const returnReason = firstDetail.remarks || '';
                                const itemName = firstDetail.itemname || '';
                                const itemNo = firstDetail.itemno || '';
 
                                // 组合退货单号:单别-单号
                                const fullReturnOrderNo = returnType && returnNo ?
                                    `${returnType}-${returnNo}` : returnNo;
 
                                // 更新表单数据
                                this.formData.returnOrderNo = fullReturnOrderNo;
                                this.formData.returnQty = returnQty;
                                this.formData.returnReason = returnReason;
                                this.formData.itemName = itemName;
                                this.formData.itemNo = itemNo;
                            }
                        })
 
 
 
                    } else {
 
                    }
                }).catch(err => {
                    this.$showMessage("获取数据失败");
                    throw err; // 重新抛出错误,确保Promise链正确处理
                });
            },
            toDetail(item) {
 
                if (this.isUpdate) {
                    uni.showToast({
                        icon: "none",
                        title: "请先生成检验项目",
                        duration: 2000,
                    });
                } else {
                    uni.navigateTo({
                        url: '/pages/QC/THJ/detail?id=' + item.id + '&returnNo=' + this.formData.returnNo + '&gid=' + this
                            .formData
                            .id
                    });
                }
            },
            saveRemarks() {
                this.remarksPopup = !this.remarksPopup;
                this.remarks = this.formData.remarks;
            },
 
            editRemarks() {
                // 允许清空不合格描述:后端接收空字符串
                this.$post({
                    url: "/THJ/saveRemarksGid",
                    data: {
                        gid: this.formData.id,
                        remarks: this.remarks || ""
                    }
                }).then(res => {
                    if (res.data.tbBillList > 0) {
                        this.formData.remarks = this.remarks || "";
                        this.remarksPopup = !this.remarksPopup;
                        this.$showMessage("保存成功");
                    }
                })
            },
            toImage() {
                uni.navigateTo({
                    url: '/pages/QC/THJ/ImageItem?id=' + this.formData.id
                });
            },
            getTable() {
                this.$post({
                    url: "/THJ/setInspectItem",
                    data: {
                        gid: this.formData.id,
                        updateBy: this.$loginInfo.account
                    }
                }).then(res => {
                    this.init().then(() => {
                        this.$showMessage("检验项目已更新");
                    }).catch(error => {
                        this.$showMessage("检验项目已更新,但刷新数据失败");
                    }).finally(() => {
                        // 确保状态正确重置
                        this.isSubmitting = false;
                        this.$forceUpdate();
                    });
                }).catch(error => {
                    // 存储过程执行失败,显示错误信息
                    this.$showMessage(error.message || "获取检验项目失败");
                    // 不改变 isShowTable 状态,保持按钮可见
                    this.tableData = [];
                    // 确保状态正确重置
                    this.isSubmitting = false;
                    this.$forceUpdate();
                });
            },
 
            // ========== 销售退货检验相关方法 ==========
 
 
            confirmReturn(data) {
                this.tableReturnData = data.map(el => {
                    return {
                        returnOrderNo: el.label,
                        itemName: el.itemName,
                        returnQty: el.returnQty,
                        returnReason: el.returnReason
                    }
 
                });
 
                // 立即更新表单中的退货信息
                if (this.tableReturnData.length > 0) {
                    const firstDetail = this.tableReturnData[0];
                    this.formData.returnOrderNo = firstDetail.returnOrderNo;
                    this.formData.returnQty = firstDetail.returnQty;
                    this.formData.returnReason = firstDetail.returnReason;
                    this.formData.itemName = firstDetail.itemName;
 
 
                }
 
                this.returnOrderList = this.returnOrderList
                this.returnOrderList = this.returnOrderList.filter(item => !this.tableReturnData.some(row => String(row
                    .returnOrderNo) === String(item)));
 
 
 
            },
 
            saveReturnTable() {
                if (this.tableReturnData.length === 0) {
                    this.$showMessage("退货明细单据不能为空,请选择数据");
                    return;
                };
 
                if (this.tableReturnData.length > 0 &&
                    this.tableReturnData[this.tableReturnData.length - 1].returnOrderNo.trim() == '' &&
                    String(this.tableReturnData[this.tableReturnData.length - 1].returnQty).trim() == '0') {
 
                    //保存时最后一行空白默认删除
                    const lastIndex = this.tableReturnData.length - 1;
                    this.tableReturnData.splice(lastIndex, 1)
 
                }
 
                // 直接从退货明细数据中获取信息填充表单
                if (this.tableReturnData.length > 0) {
                    // 获取第一个有效的退货明细
                    const firstDetail = this.tableReturnData.find(item => item.returnOrderNo && item.returnOrderNo
                    .trim() !== '');
                    if (firstDetail) {
                        this.formData.returnOrderNo = firstDetail.returnOrderNo;
                        this.formData.returnQty = firstDetail.returnQty;
                        this.formData.returnReason = firstDetail.returnReason;
                        this.formData.itemNo = firstDetail.itemNo || '';
 
 
                    }
                }
 
                //表单中的部分字段赋值
                this.$post({
                    url: "/THJ/SaveReturnDetails",
                    data: {
                        returnDetails: this.tableReturnData
 
                    }
                }).then(res => {
                    let data = res.data.tbBillList[0];
 
                            if (!data) {
 
                                this.formData.customerName = "";
                        // 保持退货明细中的信息,不从后端覆盖
                        // this.formData.returnOrderNo = "";
                        // this.formData.returnQty = "";
                        // this.formData.returnReason = "";
                        this.formData.itemNo = "";
                        this.tableData = [];
                        return;
                    }
                            //不为空时赋值
                            this.formData.customerName = data.customerName || this.formData.customerName;
                    // 如果后端返回了更完整的信息,则使用后端的
                    if (data.returnOrderNo) this.formData.returnOrderNo = data.returnOrderNo;
                    if (data.returnQty) this.formData.returnQty = data.returnQty;
                    if (data.returnReason) this.formData.returnReason = data.returnReason;
                    if (data.itemNo) this.formData.itemNo = data.itemNo;
 
 
                    this.$post({
                        url: "/THJ/setInspectItem",
                        data: {
                            gid: this.formData.id,
                            updateBy: this.$loginInfo.account
                        }
                    }).then(res => {
                        if (res.data.tbBillList.length > 0) {
                            this.tableData = res.data.tbBillList; // 在箭头函数中,this 指向外层作用域的 this
                            this.isSubmit = false;
                        } else {
                            this.isSubmit = true;
                            this.tableData = [];
                        }
                    });
 
                });
 
                this.currentTab = 0;
 
            },
 
            // 提交检验结果
            submitTHJResult() {
                // 检查是否有检验项目
                if (!this.tableData || this.tableData.length === 0) {
                    this.$showMessage("请先生成检验项目");
                    return;
                }
 
                // 检查是否所有检验项目都已完成
                const uncompletedItems = this.tableData.filter(item => item.result === '未完成');
                if (uncompletedItems.length > 0) {
                    this.$showMessage("请完成所有检验项目后再提交");
                    return;
                }
 
                // 确认提交
                uni.showModal({
                    title: '确认提交',
                    content: '确定要提交检验结果吗?提交后将无法修改。',
                    success: (res) => {
                        if (res.confirm) {
                            this.performSubmit();
                        }
                    }
                });
            },
 
            // 执行提交
            performSubmit() {
                this.isSubmitting = true;
                
                // 获取当前用户,如果获取不到则使用默认值
                const currentUser = this.$loginInfo?.account || this.formData.createBy || "系统用户";
                
                // 直接使用API调用,不使用Promise.race
                const resetTimer = setTimeout(() => {
                    this.isSubmitting = false;
                    this.$forceUpdate();
                }, 1000);
                this.$post({
                    url: "/THJ/submitTHJResultByProcedure",
                    data: {
                        releaseNo: this.formData.releaseNo,
                        userNo: currentUser
                    }
                }).then(res => {
                    
                    // 检查多种可能的响应格式
                    let status = res.status;
                    let message = res.message;
                    
                    // 如果外层没有status,检查data中的status
                    if (status === undefined && res.data) {
                        status = res.data.status;
                        message = res.data.message || res.message;
                    }
                    
                    
                    if (status === 0) {
                        this.$showMessage("提交成功");
                        // 成功立即复位
                        this.isSubmitting = false;
                        this.$forceUpdate();
                    } else {
                        this.$showMessage("提交失败:" + (message || "未知错误"));
                        // 失败即时复位提交状态,避免按钮一直显示提交中
                        this.isSubmitting = false;
                        this.$forceUpdate();
                    }
                }).catch(error => {
                    
                    let errorMessage = "未知错误";
                    if (error.message) {
                        errorMessage = error.message;
                    } else if (typeof error === 'string') {
                        errorMessage = error;
                    } else if (error.response) {
                        errorMessage = `服务器错误: ${error.response.status}`;
                    }
                    
                    this.$showMessage("提交失败:" + errorMessage);
                    // 异常时也立即复位
                    this.isSubmitting = false;
                    this.$forceUpdate();
                    // 即使出现异常也刷新页面数据
                    this.init().catch(error => {
                    });
                }).finally(() => {
                    clearTimeout(resetTimer);
                    this.isSubmitting = false;
                    // 强制更新视图
                    this.$forceUpdate();
                    
                });
            },
        },
        onShow() {
            //每次进入页面都会执行的方法
            // 重置提交状态,防止状态卡住
            this.isSubmitting = false;
            
            // 如果formData.id为空,尝试从URL参数中获取
            if (!this.formData.id) {
                // 尝试从当前页面URL中获取id参数
                const pages = getCurrentPages();
                const currentPage = pages[pages.length - 1];
                const options = currentPage.options;
                
                if (options && options.id) {
                    this.formData.id = options.id;
                    this.formData.returnNo = options.returnNo;
                    this.isUpdate = false;
                }
            }
            
            if (this.formData.id) {
                // 如果有检验单ID,每次都重新初始化以获取最新数据
                // 确保能获取到最新的检验状态
                this.init();
            }
        },
        onUnload() {
            // 页面卸载时移除事件监听
            uni.$off('inspectionDataUpdated');
        }
    };
</script>
 
<style>
    .form-group {
        display: flex;
        align-items: center;
        border-bottom: 1px solid #c9c9c9;
    }
 
    .form-label {
        margin-bottom: 0;
        padding: 5px;
    }
 
    .form-input {
        flex: 1;
        margin-bottom: 0;
        padding: 5px;
    }
 
    .container {
        display: flex;
        flex-direction: column;
    }
 
    .picker {
        flex: 1;
        margin-bottom: 0;
        padding: 5px;
        font-size: 12px;
    }
 
    .uni-form-item {
        display: flex;
        border-bottom: 1px solid #c9c9c9;
    }
 
    .edit {
        background-color: white;
    }
 
    .tab-bar {
        display: flex;
        justify-content: space-around;
        background-color: #f5f5f5;
        padding: 10px;
        border-bottom: 1px solid #ccc;
    }
 
    .tab-item {
        flex: 1;
        text-align: center;
        padding: 10px;
        border-radius: 5px;
        background-color: #fff;
        color: #007aff;
        cursor: pointer;
        font-size: 16px;
        transition: background-color 0.3s, color 0.3s;
    }
 
    .tab-item.active {
        background-color: #007aff;
        color: #fff;
        font-weight: bold;
    }
 
    /* 默认样式 */
    .list-container {
        height: 60vh;
        /* 设置列表容器的高度为剩余空间,并减去表单容器的高度 */
        overflow-y: auto;
        /* 允许列表容器垂直滚动 */
        padding: 10px;
        /* 可选:添加一些内边距,使列表内容更美观 */
    }
 
    /* 在小屏幕设备上,重置高度为适应屏幕 */
    @media (max-width: 768px) {
        .list-container {
            height: calc(100vh - 505px);
            /* 适当调整高度 */
        }
    }
 
 
    .form-container {
        padding: 10px;
        /* 可选:添加一些内边距,使表单内容更美观 */
    }
 
    .th {
        background-color: lightskyblue;
        color: #FFFFFF;
    }
 
 
    .plus-button {
        line-height: 59px;
        font-size: 24px;
        cursor: pointer;
        z-index: 1000;
        margin-bottom: 10px;
    }
 
    .plus-button-row {
        display: flex;
        align-items: center;
        margin-bottom: -10px;
    }
 
    .plus-button-row button {
        flex-grow: 1;
        /* 使按钮填充可用空间 */
        margin-right: 10px;
        /* 按钮之间的间隔 */
        padding: 0px 20px;
        /* 根据需要调整内边距 */
        font-size: 18px;
        /* 根据需要调整字体大小 */
    }
 
    .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;
    }
 
    .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% */
    }
</style>