schangxiang@126.com
2024-11-21 60735779c303c2dd10feea45d7fd761103b225e0
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
<template>
    <!-- 添加、编辑 -->
    <el-dialog v-model="dialogVisible" width="95%" @close="closeDialog" :close-on-click-modal="false">
        <template #header>
            <div style="color: #fff">
                <span>完成质检</span>
            </div>
        </template>
        <!-- <el-form :model="addForm" ref="dialogRef" labelWidth="90" :rules="formRules">
            <el-row>
                <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20">
                    <el-form-item  label="业务类型" prop="businessType">
                        <el-select clearable v-model="addForm.businessType" placeholder="请选择业务类型">
                                <el-option v-for="(item,index) in  getEnumBusinessTypeData" :key="index" :value="item.value" :label="`${item.describe}`"></el-option>
                                
                            </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form> -->
        <div class="msi-content" style="margin-top: 10px">
            <!-- <div class="header" style="margin-bottom: 10px">
                <div>
                    <el-button v-show="isPoBox == true" type="primary" icon="el-icon-plus"
                        @click="addMaterialDialog('po')">关联ASN单</el-button>
 
                    <el-button icon="el-icon-delete" plain :disabled="checkedDetails.length == 0"
                        @click="delCheckedDetails">删除选中行</el-button>
                </div>
            </div> -->
            <el-table :data="warehousOrderDetails" border style="width: 100%" row-key="setRowKey" ref="detailRef"
                @selection-change="detailsCheckChange" max-height="480" @expand-change="getChildList">
                <!-- 子表 -->
                <el-table-column type="expand">
                    <template #default="scope">
                        <br />
                        <el-table :data="scope.row.children" border style="width: 95%;margin: 0 auto;" default-expand-all
                            min-height="200" row-key="wareMaterialCode">
                            <el-table-column label="序号" align="center" width="60" type="index" />
                            <el-table-column label="物料编号" min-width="140" prop="materialCode" align="center"
                                show-overflow-tooltip />
                            <el-table-column prop="materialName" min-width="110px" label="物料名称" show-overflow-tooltip="" />
                            <el-table-column prop="snCode" min-width="110px" label="跟踪码" show-overflow-tooltip="" />
                            <!-- <el-table-column prop="qcStatus" label="质检状态"  show-overflow-tooltip="" >
            <template #default="scope">
              <el-tag>{{ getEnumDesc(scope.row.qCStatus, getEnumQCStatusData_Index)}}</el-tag>
            </template>
          </el-table-column> -->
                            <el-table-column prop="quantityKc" label="数量" show-overflow-tooltip="" />
                        </el-table>
                        <br />
                    </template>
                </el-table-column>
                <!-- <el-table-column align="center" width="60" type="selection" /> -->
                <el-table-column label="序号" align="center" width="60" type="index" />
                <el-table-column label="物料编号" min-width="140" prop="materialCode" align="center" show-overflow-tooltip />
                <el-table-column prop="materialName" min-width="110px" label="物料名称" show-overflow-tooltip="" />
                <el-table-column prop="snCode" min-width="110px" label="跟踪码" show-overflow-tooltip="" />
                <el-table-column prop="qcQuantity" label="实检数量" show-overflow-tooltip="" />
                <!-- <el-table-column prop="qCStatus" label="质检状态"  show-overflow-tooltip="" >
            <template #default="scope">
              <el-tag>{{ getEnumDesc(scope.row.qCStatus, getEnumQCStatusData_Index)}}</el-tag>
            </template>
          </el-table-column> -->
                <el-table-column prop="qcStatus" label="质检状态" show-overflow-tooltip="">
                    <template #default="scope">
                        {{ scope.row.qcStatusName }}
                        <!-- <el-tag>{{ getEnumDesc(scope.row.qCStatus, getEnumQCStatusData_Index) }}</el-tag> -->
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="passQuantity" label="合格数量"  show-overflow-tooltip="" /> -->
                <!-- <el-table-column prop="rejectQuantity" label="不合格数量"  show-overflow-tooltip="" /> -->
                <!-- <el-table-column prop="goodsQuantity" label="已收数量" show-overflow-tooltip="" /> -->
 
                <el-table-column prop="rejectQuantity" label="不合格数量" show-overflow-tooltip="" />
                <el-table-column prop="passQuantity" label="合格数量" show-overflow-tooltip="" />
 
                <!-- <el-table-column label="合格数量" align="center" min-width="150">
                    <template #default="scope">
                        <el-input-number :precision="3" min="0" v-model="scope.row.passQuantity" size="small" />
                    </template>
                </el-table-column> -->
 
            </el-table>
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false">取消</el-button>
                <el-button type="primary" :disabled="disabled_btn" @click="confirm">确认</el-button>
            </span>
        </template>
    </el-dialog>
    <!-- 添加物料 -->
    <el-dialog v-model="addMaterialVisible" width="70%" @close="closeMaterialDialog">
        <template #header>
            <div style="color: #fff">
                <span v-if="isMaterialBox == 1">添加物料详情</span>
                <span v-if="isPoBox == 1">关联ASN单物料</span>
            </div>
        </template>
 
        <div class="msi-form" style="padding-top: 0px">
            <el-form :model="materialForm">
                <el-row>
                    <el-col :span="8" v-if="isMaterialBox == 1">
                        <el-form-item label="物料编号">
                            <el-input v-model="materialForm.Code" placeholder="请输入物料编号" clearable></el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="8" v-if="isPoBox == 1">
                        <el-form-item label="关联ASN单号:">
                            <el-input v-model="materialForm.poNo" placeholder="请输入关联ASN单号" clearable></el-input>
                        </el-form-item>
                    </el-col>
 
                    <el-col :span="8">
                        <el-form-item label-width="20px">
                            <el-button type="primary" icon="el-icon-search" @click="getMaterialList">查询</el-button>
                            <!-- <el-button icon="el-icon-refresh-right" @click="resetMaterialForm">重置</el-button> -->
                        </el-form-item>
                    </el-col>
                </el-row>
            </el-form>
        </div>
        <div class="msi-content" style="padding-top: 0; margin-top: 10px">
            <el-table :data="materialList" border style="width: 100%" row-key="id" ref="materialRef"
                @selection-change="materialSelectionChange" :max-height="480" v-if="isMaterialBox == 1">
                <el-table-column align="center" width="60" type="selection"  />
                <el-table-column label="序号" align="center" width="60" type="index" />
                <el-table-column label="物料编号" prop="materialCode" align="center" min-width="140" show-overflow-tooltip />
                <el-table-column label="物料名称" prop="materialName" align="center" min-width="140" show-overflow-tooltip />
 
                <el-table-column label="单位" prop="poUnit" align="center" min-width="140" show-overflow-tooltip />
            </el-table>
            <!-- ASN单 -->
            <el-table :data="materialList" border style="width: 100%" row-key="id" ref="materialRef"
                @selection-change="materialSelectionChange" :max-height="480" v-if="isPoBox == 1">
                <el-table-column align="center" width="60" type="selection"  />
                <el-table-column label="序号" align="center" width="60" type="index" />
                <el-table-column prop="poNo" label="PO单号" min-width="120px" show-overflow-tooltip="" />
                <el-table-column prop="poLineNumber" min-width="100px" label="PO行号" show-overflow-tooltip="" />
                <el-table-column prop="asnLineNumber" min-width="100px" label="ASN行号" show-overflow-tooltip="" />
                <el-table-column prop="materialCode" min-width="130px" label="物料编号" show-overflow-tooltip="" />
                <el-table-column prop="materialName" min-width="130px" label="物料名称" show-overflow-tooltip="" />
                <el-table-column prop="asnStatus" min-width="100px" label="单据状态" show-overflow-tooltip="">
                    <template #default="scope">
                        <el-tag :type="getTypeStatus(1, getEnumDesc(scope.row.asnStatus, getEnumAsnStatusData_Index))">
                            {{ getEnumDesc(scope.row.asnStatus, getEnumAsnStatusData_Index) }}
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="quantity" min-width="100px" label="送货数量" show-overflow-tooltip="" />
                <el-table-column prop="goodsQuantity" min-width="100px" label="已收数量" show-overflow-tooltip="" />
                <el-table-column prop="supplierCode" min-width="100px" label="供应商编号" show-overflow-tooltip="" />
                <el-table-column prop="supplierName" min-width="100px" label="供应商名称" show-overflow-tooltip="" />
                <el-table-column prop="supplierBatch" min-width="100px" label="供应商批次" show-overflow-tooltip="" />
                <el-table-column prop="unit" min-width="100px" label="单位" show-overflow-tooltip="" />
 
                <el-table-column prop="sN_1d" min-width="120px" label="一维条码" show-overflow-tooltip="" />
                <el-table-column prop="sN_2d" min-width="120px" label="二维条码" show-overflow-tooltip="" />
                <el-table-column prop="package" min-width="100px" label="包装名称" show-overflow-tooltip="" />
                <el-table-column prop="plannedStartTime" min-width="120px" label="计划开始时间" :formatter="formatDate_T_Date"
                    show-overflow-tooltip="" />
                <el-table-column prop="plannedEndTime" min-width="120px" label="计划结束时间" :formatter="formatDate_T_Date"
                    show-overflow-tooltip="" />
                <el-table-column prop="projectNo" min-width="100px" label="项目号" show-overflow-tooltip="" />
                <!-- <el-table-column prop="factoryName" min-width="100px" label="工厂名称" show-overflow-tooltip="" />
                <el-table-column prop="factoryCode" min-width="100px" label="工厂编号" show-overflow-tooltip="" /> -->
                <el-table-column prop="dock" min-width="100px" label="收货道口" show-overflow-tooltip="" />
 
 
                <el-table-column prop="batch" min-width="100px" label="批次" show-overflow-tooltip="" />
 
                <el-table-column prop="erpCode" min-width="100px" label="ERP库存地" show-overflow-tooltip="" />
                <el-table-column prop="erpOrderNo" min-width="100px" label="ERP单号" show-overflow-tooltip="" />
 
                <!-- <el-table-column prop="createTime" min-width="100px" label="创建时间" width="130"
                        :formatter="formatDate_T_Time" show-overflow-tooltip="" />
                    <el-table-column prop="updateTime" min-width="100px" label="修改时间" width="130"
                        :formatter="formatDate_T_Time" show-overflow-tooltip="" />
                    <el-table-column prop="createUserName" min-width="120px" label="创建人" show-overflow-tooltip="" />
                    <el-table-column prop="updateUserName" min-width="120px" label="修改人" show-overflow-tooltip="" /> -->
            </el-table>
 
            <Pagination :total="materialTotal" v-model:page="materialForm.Page" v-model:limit="materialForm.PageSize"
                @pagination="getMaterialList" style="margin-top: 20px; text-align: center"></Pagination>
        </div>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="addMaterialVisible = false">取消</el-button>
                <el-button type="primary" @click="confirmAddMaterial">确认</el-button>
            </span>
        </template>
    </el-dialog>
    <!-- 单详情 -->
    <el-drawer v-model="drawerVisible" :title="`${detailForm.asnId}订单详情`" direction="rtl" size="80%"
        @close="handleDrawerClose">
        <template #title>
            <div class="slot_title">
                <div class="title_orderNo">{{ title }}</div>
                <div>订单详情</div>
            </div>
        </template>
 
        <div class="detailBoxWrap">
            <!-- 详情组件 -->
            <open-details ref="propDetailRef"></open-details>
            <div class="msi-form">
                <el-form :model="detailForm">
                    <el-row>
                        <el-col :span="6">
                            <el-form-item label="物料编号">
                                <el-input v-model="detailForm.materialCode" clearable placeholder="请输入物料编号" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="2">
                            <el-form-item label-width="20px">
                                <el-button type="primary" icon="el-icon-search" @click="getDetail">查询</el-button>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
            </div>
            <div class="msi-content">
                <!-- <p style="margin-bottom: 10px">物料明细</p> -->
                <el-table :data="drawerList" border striped :max-height="480">
                    <el-table-column label="序号" align="center" width="60" type="index" />
 
 
                    <el-table-column prop="materialCode" min-width="130px" label="物料编号" show-overflow-tooltip="" />
                    <el-table-column prop="materialName" min-width="110px" label="物料名称" show-overflow-tooltip="" />
                    <el-table-column prop="qcQuantity" label="实检数量" show-overflow-tooltip="" />
                    <!-- <el-table-column prop="qCStatus" label="质检状态"  show-overflow-tooltip="" >
            <template #default="scope">
              <el-tag>{{ getEnumDesc(scope.row.qCStatus, getEnumQCStatusData_Index)}}</el-tag>
            </template>
          </el-table-column> -->
                    <el-table-column prop="qcStatus" label="质检状态" show-overflow-tooltip="">
                        <template #default="scope">
                            <el-tag>{{ getEnumDesc(scope.row.qCStatus, getEnumQCStatusData_Index) }}</el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="passQuantity" label="合格数量" show-overflow-tooltip="" />
                    <el-table-column prop="rejectQuantity" label="不合格数量" show-overflow-tooltip="" />
                    <el-table-column prop="goodsQuantity" label="已收数量" show-overflow-tooltip="" />
 
                    <el-table-column prop="businessTypeName" label="业务类型" show-overflow-tooltip="" />
                    <el-table-column prop="qCOrderStatus" label="单据状态" show-overflow-tooltip="">
                        <template #default="scope">
                            <el-tag>{{ getEnumDesc(scope.row.qcOrderStatus, getEnumAsnStatusData_Index) }}</el-tag>
                        </template>
                    </el-table-column>
                    <!-- <el-table-column prop="qcOrderStatusName" label="单据状态"  show-overflow-tooltip="" /> -->
 
                    <el-table-column prop="unit" label="单位" show-overflow-tooltip="" />
                    <el-table-column prop="supplierName" label="供应商名称" show-overflow-tooltip="" />
                    <el-table-column prop="supplierCode" label="供应商编号" show-overflow-tooltip="" />
                    <el-table-column prop="custCode" label="客户编号" show-overflow-tooltip="" />
                    <el-table-column prop="custChinaName" min-width="110px" label="客户中文名称" show-overflow-tooltip="" />
                    <el-table-column prop="custEnglishName" min-width="110px" label="客户英文名称" show-overflow-tooltip="" />
                    <el-table-column prop="relationNo" label="关联单号" show-overflow-tooltip="" />
                    <!-- <el-table-column prop="relationOrderType" label="关联单据类型"  show-overflow-tooltip="" /> -->
                    <el-table-column prop="relationOrderTypeName" min-width="110px" label="关联单据类型"
                        show-overflow-tooltip="" />
                    <!-- <el-table-column prop="factoryId" label="工厂ID"  show-overflow-tooltip="" /> -->
                    <!-- <el-table-column prop="factoryName" label="工厂名称" show-overflow-tooltip="" /> -->
                    <!-- <el-table-column prop="factoryCode" label="工厂编号" show-overflow-tooltip="" /> -->
                    <el-table-column prop="remarks" label="备注" show-overflow-tooltip="" />
                    <el-table-column prop="createTime" label="创建时间" width="130" :formatter="formatDate_T_Time"
                        show-overflow-tooltip="" />
                    <el-table-column prop="updateTime" label="修改时间" width="130" :formatter="formatDate_T_Time"
                        show-overflow-tooltip="" />
                    <el-table-column prop="createUserName" label="创建人" show-overflow-tooltip="" />
                    <el-table-column prop="updateUserName" label="修改人" show-overflow-tooltip="" />
 
                </el-table>
                <Pagination :total="detailCount" v-model:page="detailForm.PageNo" v-model:limit="detailForm.PageSize"
                    @pagination="getDetail" style="margin-top: 20px; text-align: center"></Pagination>
 
                <div></div>
            </div>
        </div>
    </el-drawer>
 
    <el-dialog v-model="outVisible2" title="SPA获取" width="20%" @close="closeOutDialog2">
        <el-form :model="outerForm2" label-width="120px">
            <el-row style="font-size: 16px">
                <el-col :span="23">
                    <el-form-item label="单号:" required>
                        <el-input v-model="outerForm2.purchaseNo" clearable placeholder="请输入单号" />
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
 
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="outVisible2 = false">取消</el-button>
                <el-button type="primary" @click="getSapOrderPO">确认</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script lang="ts" setup>
import Pagination from '/@/components/Pagination/index.vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { ref, nextTick, computed, getCurrentInstance, watch, defineExpose, defineProps, onMounted } from 'vue';
 
import { formatDecimalData } from '/@/utils/formate';
 
import cache from '/@/utils/cache';
import { pageWmsMaterial } from '/@/api/main/WmsBase/wmsMaterial';
import {
    getTypeStatus
} from "/@/utils/formate";
import { getAPI } from '/@/utils/axios-utils';
import { SysEnumApi } from '/@/api-services/api';
import { addWmsOrderPurchase, updateWmsOrderPurchase, detailWmsOrderPurchase } from '/@/api/main/WmsOrder/wmsOrderPurchase';
import OpenDetails from '/@/components/openDetails/openDetails.vue';
import { pageBaseCustomer } from '/@/api/main/WmsBase/baseCustomer';
import { pageWmsOrderPurchaseDetails } from '/@/api/main/WmsOrder/wmsOrderPurchaseDetails';
import { pageWmsOrderAsnDetails, deleteWmsOrderAsnDetails } from '/@/api/main/WmsOrder/wmsOrderAsnDetails';
import commonFunction from '/@/utils/commonFunction';
import { addWmsOrderAsn, updateWmsOrderAsn, detailWmsOrderAsn } from '/@/api/main/WmsOrder/wmsOrderAsn';
 
import { addWmsQc, updateWmsQc, detailWmsQc, confirmWmsQc } from "/@/api/main/WmsQC/wmsOrderQc";
import { pageWmsQcDetails } from '/@/api/main/WmsQC/wmsOrderQcDetails';
const { proxy }: any = getCurrentInstance(); // 访问实例上下文 proxy同时支持开发 线上环境
const getEnumOrderTypeData = ref<any>([]);
const getEnumBusinessTypeData = ref<any>([]);
const getEnumPoStatusData = ref<any>([]);
const { getEnumDesc } = commonFunction();
const emits = defineEmits(['getTabelData']);
const getEnumAsnStatusData_Index = ref<any>([]);
const getEnumOrderTypeData_Index = ref<any>([]);
const getEnumQCStatusData_Index = ref<any>([]);
 
const getEnumDockData = ref<any>([]);
const props = defineProps({
    titleAuthor: {
        type: Number,
        required: true,
    },
    hexiao: {
        type: Number,
        default: 1,
        required: true,
    },
});
//控制订单类型 - 下拉菜单
const titleAuthor = computed(() => props.titleAuthor);
// 是否显示核销按钮
const hexiao = computed(() => props.hexiao);
const loading = ref(false);
 
// 登录用户id
// const LoginUserID = computed(() => store.state.login.userInfo.id || localCache.getCache("LoginUserID"))
 
// const EnumWriteOffState = computed(
//   () => store.state.login.enums.enumWriteOffState
// );
 
let itemBtnArr = ['批量删除', '编辑', '新增'];
const boolEnum = ref([
    {
        title: '是',
        value: true,
    },
    {
        title: '否',
        value: false,
    },
]);
 
// form表单展开
 
const orderType = ref('');
const orderDoRuType = ref(); // 用于导入的变量
const itemBtn = ref(1);
// 控制bom物料权限
const isShowBomBtn = ref(0);
 
// 禁止之前的日期
const disabledDate = (time: Date) => {
    return time.getTime() + 3600 * 1000 * 24 < Date.now();
};
// 上传窗口
const uploadVisible = ref(false);
//打开导入窗口
const openUploadDialog = (param: any) => {
    orderDoRuType.value = param;
    uploadVisible.value = true;
};
//关闭窗口
const closeUploadDialog = () => {
    getTabelData();
};
//sap获取
const getSapOrder = () => {
    ElMessageBox.confirm('是否确认获取更新?', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
    }).then(() => {
        // getSapRkPurchase().then((res) => {
        //   if (res.code == 200) {
        //     ElMessage.success("已开始重新获取,请稍后查看结果!");
        //   } else {
        //     ElMessage.error(
        //       `sap获取失败${res.code}:${JSON.stringify(res.message)}`
        //     );
        //   }
        // })
    });
};
 
//------------sap获取PO单
const outVisible2 = ref(false);
const outerForm2 = ref({
    purchaseNo: '',
});
const getSapOrderPO = (param?: number) => {
    if (param && param == 1) {
        outVisible2.value = true;
        return;
    }
    if (outerForm2.value.purchaseNo == '') {
        ElMessage.warning('请输入单号');
        return;
    }
    // getSapPurchasePO({
    //   purchaseNo: outerForm2.value.purchaseNo
    // })
    //   .then((res) => {
    //     if (res.code == 200) {
    //       ElMessage.success("SAP获取成功");
    //       outVisible2.value = false;
    //     } else {
    //       ElMessage.error(
    //         `sap获取失败${res.code}:${JSON.stringify(res.message)}`
    //       );
    //     }
    //   })
    //   .catch((err) => ElMessage.error(err));
};
//关闭出库窗口的回调
const closeOutDialog2 = () => {
    outerForm2.value.purchaseNo = '';
};
 
//------------sap获取PO单
 
// --------------------PO单列表-----------------------------------
//查询
const formModel = ref({
    WareMaterialCode: '',
    WareMaterialName: '',
    PurchaseNo: '',
    CreatedUserName: '',
    CreatedTimeBegin: '',
    CreatedTimeEnd: '',
    CreateDate: [],
    IssueTimeBegin: '',
    IssueTimeEnd: '',
    IssueDate: [],
    MaterialTypeStaus: '',
    SourceBy: '',
    WriteOffState: '',
    signStatus: '',
    status: '',
    freeOrderType: '',
    IsQueryAll: false, //是否显示全部数据
    // LoginUserID: LoginUserID, //用户id
    OrderMenuType: '', //判断是哪个菜单入库
    Page: 1,
    PageSize: 10,
    poApprovalStatus: '',
    keyCode: '',
    IsDisable: '', //是否作废
});
 
//入库单列表数据
let tableData = ref([]);
const tableRef = ref();
 
//列表的数据条数
const totalItems = ref<number>(0);
 
//缓存枚举
const enumList: any = cache.getCache('enumList');
console.log(enumList.inEnumOrderType);
 
// .inEnumOrderType
 
//获取PO单列表
const getTabelData = () => {
    //判断创建时间是否有选择
    if (formModel.value.CreateDate && formModel.value.CreateDate.length > 0) {
        formModel.value.CreatedTimeBegin = formModel.value.CreateDate[0];
        formModel.value.CreatedTimeEnd = ''; //addDate(formModel.value.CreateDate[1], 1); //日期查询 结束时间 需要加一天
    } else {
        // 日历清空 再查询bug
        if (formModel.value.CreatedTimeBegin || formModel.value.CreatedTimeEnd) {
            formModel.value.CreatedTimeBegin = '';
            formModel.value.CreatedTimeEnd = '';
        }
    }
    //判断下发时间是否有选择
    if (formModel.value.IssueDate && formModel.value.IssueDate.length > 0) {
        formModel.value.IssueTimeBegin = formModel.value.IssueDate[0];
        formModel.value.IssueTimeEnd = formModel.value.IssueDate[1];
    } else {
        // 日历清空 再查询bug
        if (formModel.value.IssueTimeBegin || formModel.value.IssueTimeEnd) {
            formModel.value.IssueTimeBegin = '';
            formModel.value.IssueTimeEnd = '';
        }
    }
 
    //其它入库入口
    // if (titleAuthor.value == 1) { //免费入库单管理
    // }
 
    // if (titleAuthor.value == 2) { //订单入库管理
    // }
 
    // getPurchasePageForAllData(formModel.value)
    //   .then((res) => {
    //     if (res.code == 200) {
    //       const { data } = res;
    //       const result = data;
    //       result.rows.map(
    //         (item: { hasChildren: boolean }) => (item.hasChildren = true)
    //       );
    //       tableData.value = result.rows;
    //       totalItems.value = result.totalRows;
    //       orderType.value = formModel.value.MaterialTypeStaus;
    //       // 清除选中
    //       nextTick(() => {
    //         if (tableRef.value && typeof tableRef.value.clearSelection === 'function') {
    //           checkRows.value = [];
    //           tableRef.value.clearSelection();
    //         }
    //       })
    //     } else {
    //       ;
    //     }
    //   })
    //   .catch((err) => {
    //     console.log(err);
    //     ElMessage.error(JSON.stringify(err));
    //   });
};
getTabelData();
 
//重置搜索
const resetForm = () => {
    formModel.value = {
        WareMaterialCode: '',
        WareMaterialName: '',
        PurchaseNo: '',
        CreatedUserName: '',
        CreatedTimeBegin: '',
        CreatedTimeEnd: '',
        CreateDate: [],
        IssueTimeBegin: '',
        IssueTimeEnd: '',
        IssueDate: [],
        MaterialTypeStaus: '',
        SourceBy: '',
        WriteOffState: '',
        signStatus: '',
        status: '',
        freeOrderType: '',
        IsQueryAll: false, //是否显示全部数据
        //  LoginUserID: LoginUserID, //用户id
        OrderMenuType: '', //判断是哪个菜单入库
        Page: 1,
        PageSize: 10,
        poApprovalStatus: '',
        keyCode: '',
        IsDisable: '', //是否作废
    };
    getTabelData();
};
// -----------------删除、导出操作--------------------------
//选中的行
const checkRows = ref<{ id: number }[]>([]);
// 选择
const handleSelectionChange = (val: any) => {
    checkRows.value = val;
};
//导出PO单详情
const handExport = () => {
    // rkExport(formModel.value)
    //   .then((res) => {
    //     const link = document.createElement("a"); //创建a标签
    //     let blob = new Blob([res], { type: "application/vnd.ms-excel" }); // response就是接口返回的文件流
    //     let objectUrl = URL.createObjectURL(blob);
    //     link.href = objectUrl;
    //     link.download = `入库管理导出${formatUtcToData(
    //       new Date().toString(),
    //       "YYYY-MM-DD hh:mm:ss"
    //     )}`; // 自定义文件名
    //     link.click(); // 下载文件
    //     URL.revokeObjectURL(objectUrl); // 释放内存
    //   }).catch((err) => ElMessage.error(JSON.stringify(err)));
    //导出调用接口
    // let entozh = entozhExcell
    //   const { PageNo, PageSize, ...rest } = formModel.value
    //   getPurchasePage({ Page: 1, PageSize: 1000000, ...rest }).then(res => {
    //     if(res.code==200){
    //       res.data.rows.forEach((item)=>{
    //         item.writeOffState = EnumWriteOffState.value.filter((v: any) => v.value == item.writeOffState)[0].title;
    //         item.sourceBy =  sourceEnum.value.filter((v: any) => v.value == item.sourceBy)[0].title;
    //       })
    //       exportExcel(res.data.rows, entozh, "xlsx", `入库管理表${formatUtcToData(new Date().toString(), 'YYYY-MM-DD hh:mm:ss')}`);
    //     }
    //   })
    // 后端导出-字段不全
    // if (checkRows.value.length <= 0) {
    //   ElMessage.warning("请选择一个订单!");
    //   return
    // }
    // const arr = checkRows.value.reduce((curr, item) => {
    //   curr.push(item.purchaseNo);
    //   return curr;
    // }, []);
    // puchaseExport({ PurchaseNo: arr })
    //   .then((res) => {
    //     const link = document.createElement("a"); //创建a标签
    //     let blob = new Blob([res], { type: "application/vnd.ms-excel" }); // response就是接口返回的文件流
    //     let objectUrl = URL.createObjectURL(blob);
    //     link.href = objectUrl;
    //     link.download = `入库管理导出${formatUtcToData(
    //       new Date().toString(),
    //       "YYYY-MM-DD hh:mm:ss"
    //     )}`; // 自定义文件名
    //     link.click(); // 下载文件
    //     URL.revokeObjectURL(objectUrl); // 释放内存
    //   })
    //   .catch((err) => ElMessage.error(JSON.stringify(err)));
};
 
// -------------------获取PO单下物料详情-----------------------------------
//入库单下物料详情请求
const detailForm = ref({
    materialCode: '',
    Page: 1,
    PageSize: 10,
});
 
// 物料详情抽屉
const drawerVisible = ref(false);
const drawerType = ref('drawerAll');
// const
//单号
const purchaseNo = ref('');
const detailCount2 = ref(0);
const detailForm2 = ref({
    Page: 1,
    PageSize: 10,
    qcOrderId: '',
    IsConfirmQC: true, //质检单确认传参:1质检状态不是待检验  2单据状态是新建
});
const getEnumPoDetailStatusData_Index = ref<any>([]);
 
const drawerList2 = ref<DetailType[]>([]);
//------------------获取物料列表物料明细
const getDetail = async () => {
    loading.value = true;
    var res = await pageWmsQcDetails(Object.assign(detailForm.value));
    var listD = res.data.result?.items ?? [];
    drawerList.value = listD;
    detailCount.value = res.data.result?.total;
    loading.value = false;
    getEnumPoDetailStatusData_Index.value = (await getAPI(SysEnumApi).apiSysEnumEnumDataListGet('OrderStatusEnum')).data.result ?? [];
 
    getEnumAsnStatusData_Index.value = (await getAPI(SysEnumApi).apiSysEnumEnumDataListGet('OrderStatusEnum')).data.result ?? [];
};
 
//----------------物料明细
//打开抽屉
const openDrawer = async (type: number, scope: any = {}, entozhExcell?: any) => {
    detailForm.value.PageNo = 1;
    detailForm.value.PageSize = 10;
    if (scope.asnNo) {
        title.value = `${scope.asnNo}`;
    }
    drawerType.value = 'drawerAll';
    drawerVisible.value = true;
    //当前入库单号id
    detailForm.value.asnId = scope.id;
    //入库单
    purchaseNo.value = scope.purchaseNo;
    detailForm2.value.asnId = scope.id;
    //获取物料列表
    if (detailForm2.value.asnId == '') {
        drawerList2.value = [];
        detailCount2.value = 0;
        return;
    }
    // 获取物料列表物料明细
    getDetail();
 
    getEnumPoDetailStatusData_Index.value =
        (await getAPI(SysEnumApi).apiSysEnumEnumDataListGet("OrderStatusEnum")).data.result ??
        [];
 
 
    // 根据状态转中文 保留3位小数
    let scopetrans = JSON.parse(JSON.stringify(scope));
    // scopetrans.totalquantity = Number(scopetrans.totalquantity).toFixed(3);
    scopetrans.qcOrderStatus = getEnumDesc(scopetrans.qcOrderStatus, getEnumPoDetailStatusData_Index.value);
    
    nextTick(() => {
        proxy.$refs['propDetailRef'].openADialog(scopetrans, entozhExcell);
    });
};
 
//关闭抽屉
const handleDrawerClose = () => {
    detailForm.value = {
        materialCode: '',
        asnId: '',
        Page: 1,
        PageSize: 10,
    };
    deltailList.value = [];
    detailCount.value = 0;
    drawerList.value = [];
    drawerList2.value = [];
    detailCount2.value = 0;
    drawerList2.value = [];
};
 
//物料详情类型
interface DetailType {
    id: number;
    barCode: string;
    wareMaterialCode: string;
    name: string;
    signStatus: string;
    category: string;
    materialTypeName: string;
    specificationModel: string;
    long: number;
    width: number;
    high: number;
    weight: number;
    unit: string;
    createdTime: string;
    purchaseNo: string;
    quantity: number;
    goodsquantity: number;
    surplusquantity: number;
    poLineNumber: string;
}
 
//入库单详情列表
const deltailList = ref<DetailType[]>([]);
//弹出层数据
const drawerList = ref<DetailType[]>([]);
 
//入库单详情列表数据条数
const detailCount = ref(0);
 
//弹出层标题
let title = ref('');
 
// ----------------新增、编辑-------------------------------
//窗口类型
const dialogType = ref('add');
 
const dialogVisible = ref(false);
 
//添加编辑表单ref
const dialogRef = ref();
 
//添加/编辑参数
let addForm = ref({
    hasTMCode: false,
    asnType: '',
    dock: '',
    projectNo: '',
    OrderDetails: [] as any[],
});
 
// 特殊字符的验证
// 包含特殊字符返回true,不包含特殊字符返回false
const checkEspcial = (rule: any, value: any, callback: any) => {
    if (!value) {
        callback();
    } else {
        const reg = /[@$%*^:;:;~+=!!#^{}><.,,。]/g;
        if (!reg.test(value.trim())) {
            callback();
        } else {
            return callback(new Error('不能存在特殊符号'));
        }
    }
};
 
// 验证角色编号
var validatorCode = (rule: any, value: any, callback: any) => {
    if (!value) {
        callback();
    } else {
        const reg = /[\u4E00-\u9FA5]/g;
        if (!reg.test(value)) {
            callback();
        } else {
            return callback(new Error('单号不能存在汉字'));
        }
    }
};
 
//rules
const formRules = {
    // businessType: [{ required: true, message: '请选择订单类型!', trigger: 'change' }],
    orderTypeName: [{ required: true, message: '请输入订单类型名称!', trigger: 'blur' }],
    businessType: [{ required: true, message: '请选择业务类型!', trigger: 'change' }],
    businessTypeName: [{ required: true, message: '请输入业务类型名称!', trigger: 'blur' }],
    orderSocure: [{ required: true, message: '请输入单据来源!', trigger: 'blur' }],
    poStatus: [{ required: true, message: '请选择单据状态!', trigger: 'change' }],
    poStatusName: [{ required: true, message: '请输入单据状态名称!', trigger: 'blur' }],
    supplierCode: [{ required: true, message: '请输入供应商编号!', trigger: 'blur' }],
    supplierName: [{ required: true, message: '请输入供应商名称!', trigger: 'blur' }],
    factoryId: [{ required: true, message: '请输入工厂ID!', trigger: 'blur' }],
    // purchaseNo: [
    //   { required: true, message: "单号不能为空", trigger: "blur" },
    //   { validator: validatorCode, trigger: "blur" },
    //   { validator: checkEspcial, trigger: "blur" }
    // ],
};
//打开
const openDialog = async (type: number, scope: any = {}) => {
    detailForm2.value.PageSize = 100000;
    addForm.value = { ...scope };
 
    console.log(addForm.value);
    detailForm2.value.qcOrderId = scope.id;
 
    //------------------获取物料列表物料明细
    loading.value = true;
    var res = await pageWmsQcDetails(Object.assign(detailForm2.value));
    var listD = res.data.result?.items ?? [];
    listD.forEach((item: any) => {
        item.children = []
    });
    listD.forEach((item: any) => {
        if (item.passQuantity > 0) {
            //实检 == 合格数
            if (item.qcQuantity == item.passQuantity) {
                item.children.push({
                    materialCode: item.materialCode,
                    materialName: item.materialName,
                    quantityKc: item.passQuantity,
                    snCode: item.snCode || item.id
                })
            } else {
                //实检 > 合格数
                var qYes = Number(item.passQuantity).toFixed(3);
                var qNo = Number(item.qcQuantity - item.passQuantity).toFixed(3);
                item.children.push({
                    // ...item,
                    materialCode: item.materialCode,
                    materialName: item.materialName,
                    quantityKc: qYes,
                    snCode: item.snCode
                })
                item.children.push({
                    // ...item,
                    materialCode: item.materialCode,
                    materialName: item.materialName,
                    quantityKc: qNo,
                    snCode: item.snCode + "_1"
                })
            }
        }
        //不合格
        if (item.passQuantity == 0) {
            item.children.push({
                materialCode: item.materialCode,
                materialName: item.materialName,
                quantityKc: item.qcQuantity,
                snCode: item.snCode
            })
        }
    });
    warehousOrderDetails.value = listD;
    loading.value = false;
    if (warehousOrderDetails.value.length > 0 && warehousOrderDetails.value[0].poNo) {
        isPoBox.value = 1;
        isMaterialBox.value = 0;
 
    } else {
        isPoBox.value = 0;
        isMaterialBox.value = 1;
    }
 
    //----------------物料明细
    dialogVisible.value = true;
    disabled_btn.value = false;
    //清除选中项
    // nextTick(() => {
    //     dialogRef.value.clearValidate();
    // });
};
 
//物料详情的table ref
const detailRef = ref();
const setRowKey = (row: any) => {
    return row.id + row.asnLineNumber;
};
//关闭窗口
const closeDialog = () => {
    addForm.value = {
        hasTMCode: false,
        asnType: '',
        dock: '',
        projectNo: '',
        OrderDetails: [] as any[],
    };
    warehousOrderDetails.value = [];
    checkedDetails.value = [];
    deltailList.value = [];
    detailCount.value = 0;
    disabled_btn.value = false;
    detailRef.value.clearSelection();
};
 
//添加编辑窗口物料列表
const warehousOrderDetails = ref<any[]>([]);
 
//物料详情列表选中的物料
const checkedDetails = ref<any[]>([]);
 
//物料详情列表中勾选事件
const detailsCheckChange = (val: any) => {
    checkedDetails.value = val;
};
 
//删除选中的物料详情
const delCheckedDetails = () => {
    ElMessageBox.confirm('是否确认删除?', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning',
    })
        .then(() => {
            let arr = [];
            if (checkedDetails.value[0].diRelationID) {
                checkedDetails.value.forEach((item) => {
                    console.log(item);
                    let index = warehousOrderDetails.value.findIndex((detail) => detail.materialCode== item.materialCode && detail.diRelationID == item.diRelationID);
                    if (index > -1) {
                        warehousOrderDetails.value.splice(index, 1);
                    }
                });
            } else {
                checkedDetails.value.forEach((item) => {
                    let index = warehousOrderDetails.value.findIndex((detail) => detail.materialCode== item.materialCode && detail.asnLineNumber == item.asnLineNumber);
                    warehousOrderDetails.value.splice(index, 1);
                });
            }
            arr = warehousOrderDetails.value;
            warehousOrderDetails.value = [];
            //bug 相同物料 不同Bom
            nextTick(() => {
                warehousOrderDetails.value = arr;
                checkedDetails.value = [];
                detailRef.value.clearSelection();
            });
        })
        .catch(() => ElMessage.info('已取消删除'));
};
//编辑、添加提交
const disabled_btn = ref(false);
const confirm = async () => {
    console.log('确认');
    if(warehousOrderDetails.value.length <= 0){
        ElMessage.warning('没有需要完成质检的物料!');
        return
    }
    addForm.value.OrderDetails = [];
    warehousOrderDetails.value.forEach((item) => {
        const obj = {
            ...item,
            QCQuantity: item.quantity,
            asnLineNumber: item.asnLineNumber,
        };
        addForm.value.OrderDetails.push(obj);
    });
    disabled_btn.value = true; 
    let res = await confirmWmsQc(addForm.value);
    if (res.data && res.data.code == 200) {
        ElMessage.success('完成质检成功');
        dialogVisible.value = false;
        emits('getTabelData');
    } 
    disabled_btn.value = false; 
};
// -----------------添加物料操作-------------------------
//物料基础数据窗口
const addMaterialVisible = ref(false);
 
//物料基础数据列表
const materialList = ref([]);
 
//物料基础数据条数
const materialTotal = ref(0);
 
//物料基础数据form
const materialForm = ref({
    poNo: '',
    Code: '',
    Page: 1,
    PageSize: 10,
});
 
//获取物料基础列表
const getMaterialList = async () => {
    if (isPoBox.value == 1) {
        if (materialForm.value.poNo) {
            loading.value = true;
            var res = await pageWmsOrderAsnDetails(Object.assign(materialForm.value));
            materialList.value = res.data.result?.items ?? [];
            materialTotal.value = res.data.result?.total;
            loading.value = false;
        }
    }
    if (isMaterialBox.value == 1) {
        loading.value = true;
        var res = await pageWmsMaterial(Object.assign(materialForm.value));
        materialList.value = res.data.result?.items ?? [];
        materialTotal.value = res.data.result?.total;
        loading.value = false;
    }
};
 
//重置物料
const resetMaterialForm = () => {
    materialForm.value = {
        poNo: '',
        Code: '',
        Page: 1,
        PageSize: 10,
    };
    getMaterialList();
};
 
//选中的基础物料数据
const checkedMaterial = ref<any[]>([]);
 
//物料基础数据勾选
const materialSelectionChange = (val: any) => {
    checkedMaterial.value = val;
};
const isMaterialBox: any = ref(true);
const isPoBox: any = ref(true);
//打开新增物料窗口
const addMaterialDialog = (param?: any) => {
    if (param && param == 'po') {
        isPoBox.value = 1;
        isMaterialBox.value = 0;
    } else {
        isPoBox.value = 0;
        isMaterialBox.value = 1;
    }
    getMaterialList();
    addMaterialVisible.value = true;
};
 
//基础物料table的ref对象
const materialRef = ref();
 
//确认添加材料
const confirmAddMaterial = () => {
    //物料列表没数据,直接添加
    if (warehousOrderDetails.value.length == 0) {
        // 自动给行号复值
        checkedMaterial.value.forEach((item, index) => {
            item.unit = item.poUnit || item.unit;
            item.asnLineNumber = index + 1;
            if (!item.asnLineNumber) {
                item.asnLineNumber = index + 1 + warehousOrderDetails.value.length;
            }
        });
 
        warehousOrderDetails.value.push(...checkedMaterial.value);
    } else {
        for (let i = 0; i < checkedMaterial.value.length; i++) {
            let idx = warehousOrderDetails.value.findIndex(
                (item: { poLineNumber: any; code: any }) => item.code == checkedMaterial.value[i].materialCode && item.asnLineNumber == checkedMaterial.value[i].asnLineNumber
            );
            if (idx > -1) {
                return ElMessage.warning(`物料编号${checkedMaterial.value[i].materialCode},ASN行号:${checkedMaterial.value[i].asnLineNumber || ''}在物料列表中已存在,请去除勾选`);
            }
        }
 
        // 自动给行号复值
        checkedMaterial.value.forEach((item, index) => {
            item.unit = item.poUnit || item.unit;
            if (!item.asnLineNumber) {
                item.asnLineNumber = index + 1 + warehousOrderDetails.value.length;
            }
        });
        warehousOrderDetails.value.push(...checkedMaterial.value);
    }
 
    addMaterialVisible.value = false;
};
 
//关闭新增物料窗口
const closeMaterialDialog = () => {
    materialForm.value = {
        poNo: '',
        Code: '',
        Page: 1,
        PageSize: 10,
    };
    materialList.value = [];
    checkedMaterial.value = [];
    materialRef.value.clearSelection();
};
 
// 页面加载时
onMounted(async () => {
});
 
//================
const arrTdp = ref<any[]>([]);
const queryParamsW = ref<any>({});
const tableParamsW = ref({
    page: 1,
    pageSize: 200,
    total: 0,
    custType: '供应商',
});
 
//-----------------远程搜索----------------
const handleQueryTdp = async () => {
    var res = await pageBaseCustomer(Object.assign(queryParamsW.value, tableParamsW.value));
    arrTdp.value = res.data.result?.items ?? [];
};
const changeXmbh = async (query?: any) => {
        loading.value = true;
        var res = await pageBaseCustomer({
            page: 1,
            pageSize: 200,
            custCode: query,
            custType: '供应商',
        });
        loading.value = false;
        arrTdp.value = res.data.result?.items ?? [];
};
// 远程搜索  输入关键字以从远程服务器中查找数据。
const remoteMethod = async (query: string) => {
        loading.value = true;
        var res = await pageBaseCustomer({
            page: 1,
            pageSize: 200,
            custCode: query,
            custType: '供应商',
        });
        loading.value = false;
        arrTdp.value = res.data.result?.items ?? [];
};
//-----------------远程搜索----------------
const getChildList = (item?: any) => {
    // console.log("4")
}
// 暴露方法
defineExpose({ openDialog, openDrawer });
</script>
<style lang="less" scoped>
.detailBoxWrap {
    margin: 10px;
}
 
.msi-form {
    margin-top: 10px;
}
 
.msi-form {
    margin-bottom: 10px;
}
 
.slot_title {
    display: flex;
    align-items: center;
 
    // margin-left: 20px;
    .title_orderNo {
        font-size: 18px;
        color: #F18201;
        font-weight: bold;
        margin-right: 5px;
    }
}
</style>