buli
2023-06-05 125e6a5936a48d318603617d0df8ffcc2d129372
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
import { LightningElement, wire, track } from "lwc";
import { CurrentPageReference } from "lightning/navigation";
import { ShowToastEvent } from "lightning/platformShowToastEvent";
import { NavigationMixin } from "lightning/navigation";
import init from "@salesforce/apex/LexArriveGoodsController.init";
import searchProduct from "@salesforce/apex/LexArriveGoodsController.searchProduct";
import arriveGoodsConfim from "@salesforce/apex/LexArriveGoodsController.arriveGoodsConfim";
import updateGoodsOfReturn from "@salesforce/apex/LexArriveGoodsController.updateGoodsOfReturn";
//table css
import { loadStyle } from "lightning/platformResourceLoader";
import WrappedHeaderTable from "@salesforce/resourceUrl/lexdatatable";
 
export default class LexArriveGoods extends NavigationMixin(LightningElement) {
  //页面变量
  @track arrType;
  @track eSetId;
  @track returnFLGbln = false;
  @track saveFLGbln = false;
  @track barcode;
  @track arrController;
  stylesLoaded = false;
  @track showSpinner = true;
  @track showPage = false;
  //消耗品订单
  @track coc;
  @track cocId;
  //本次到货产品汇总
  @track detailsSummary = [];
  //到货明细
  @track consumableorderdetailsRecords = [];
  @track consumableorderdetailsRecordsview = [];
  //返品明细
  @track showGoodsofReturnList = [];
  @track showGoodsofReturnListView = [];
  //入库明细
  @track consumableInventory = [];
  //错误明细
  @track consumableorderdetailsRecordserror = [];
  //报错提醒
  @track errorMsgs = [];
  @track warningMsgs = [];
  //是否一直显示提示
  @track isNoteStay = true;
 
  //是否有警告
  get hasWarning() {
    if (this.warningMsgs == null || this.warningMsgs.length == 0) {
      return false;
    }
    if (this.warningMsgs.length > 0) {
      return true;
    }
  }
 
  //是否有错误
  get hasError() {
    if (this.errorMsgs == null || this.errorMsgs.length == 0) {
      return false;
    }
    if (this.errorMsgs.length > 0) {
      return true;
    }
  }
 
  //本次到货产品汇总cols
  @track currentArrProdCols = [
    {
      label: "产品型号",
      fieldName: "assetModelNo",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 220
    },
    {
      label: "产品名称",
      fieldName: "prodName",
      hideDefaultActions: true,
      wrapText: true
    },
    {
      label: "到货数量",
      fieldName: "arrivedCount",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 220,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "到货金额",
      type: "number",
      typeAttributes: { minimumFractionDigits: 2 },
      fieldName: "arriveAmount",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 220,
      cellAttributes: { alignment: "right" }
    }
  ];
  //到货明细cols
  @track arrDetailCols = [
    {
      label: "消耗品名称",
      fieldName: "prodName",
      hideDefaultActions: true,
      wrapText: true
    },
    {
      label: "规格",
      fieldName: "productPackingListManual",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 120,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "CFDA状态",
      fieldName: "status",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 120
    },
    {
      label: "注册证编码号",
      fieldName: "reportProductApprobation",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 180
    },
    {
      label: "注册证效期",
      fieldName: "ReportProductExpirationDate",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 100
    },
    {
      label: "BarCode",
      fieldName: "barCode",
      hideDefaultActions: true,
      wrap: true,
      initialWidth: 400
    }
  ];
  //返品明细cols
  get returnDetailCols() {
    var cols = [];
    cols.push({
      label: "出库单",
      fieldName: "orderUrl",
      type: "url",
      typeAttributes: { label: { fieldName: "orderNo" }, target: "_blank" },
      hideDefaultActions: true,
      wrapText: true
    });
    // cols.push({label:'出库单' , fieldName:'orderNo', hideDefaultActions: true});
    cols.push({
      label: "出库日",
      fieldName: "prodOutDate",
      wrapText: true,
      hideDefaultActions: true,
      initialWidth: 110
    });
    cols.push({
      label: "消耗品名称",
      fieldName: "prodName",
      wrapText: true,
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 190
    });
    cols.push({
      label: "出库目的",
      fieldName: "summonsForDirctionDet",
      wrapText: true,
      hideDefaultActions: true,
      initialWidth: 130
    });
    cols.push({
      label: "客户名",
      fieldName: "hospitalName",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 130
    });
    cols.push({
      label: "经销商",
      fieldName: "orderDealer",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 100
    });
    cols.push({
      label: "BarCode",
      fieldName: "barCode",
      hideDefaultActions: true,
      wrap: true,
      initialWidth: 230
    });
    cols.push({
      label: "使用期限",
      fieldName: "sterilizationLimit",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 110
    });
    cols.push({
      label: "单位",
      fieldName: "boxPiece",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 50
    });
    cols.push({
      label: "返品数量",
      type: "customReturnGoodInput",
      typeAttributes: {
        inputValue: { fieldName: "returnCount" },
        boxPrice: { fieldName: "boxPiece" },
        recordId: { fieldName: "recordId" }
      },
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 100
    });
    cols.push({
      label: "返品原因",
      type: "customTableInput",
      typeAttributes: {
        recordId: { fieldName: "recordId" },
        inputValue: { fieldName: "returnReason" },
        valueType: "Text"
      },
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 100
    });
    // cols.push({label:'返品原因' , fieldName:'returnReason', hideDefaultActions: true});
    return cols;
  }
  //入库明细cols
  get inDetailCols() {
    var cols = [];
    cols.push({
      label: "消耗品名称",
      fieldName: "prodName",
      hideDefaultActions: true,
      wrapText: true
    });
    cols.push({
      label: "BarCode",
      fieldName: "barCodeNo",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 400
    });
    cols.push({
      label: "使用期限",
      fieldName: "sterilizationlimitDate",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 100
    });
    cols.push({
      label: "serialNoorLotNo",
      fieldName: "serialNoorLotNo",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 140
    });
    cols.push({
      label: "tracingCode",
      fieldName: "tracingCodeNo",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 140
    });
    if (this.returnFLGbln) {
      cols.push({
        label: "返品原因",
        fieldName: "ReturnReason",
        hideDefaultActions: true,
        wrapText: true,
        initialWidth: 150
      });
    }
    return cols;
  }
  //错误明细cols
  @track errorDetailCols = [
    // {label:'消耗品订单' , fieldName:'consumableOrderMinor', hideDefaultActions: true,wrapText:true},
    {
      label: "消耗品订单",
      fieldName: "consumableOrderUrl",
      type: "url",
      typeAttributes: {
        label: { fieldName: "consumableOrderMinorName" },
        target: "_blank"
      },
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 180
    },
    {
      label: "消耗品名称",
      fieldName: "prodName",
      hideDefaultActions: true,
      wrapText: true
    },
    {
      label: "BarCode",
      fieldName: "barCode",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 400
    },
    {
      label: "单位",
      fieldName: "boxPiece",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 60
    },
    {
      label: "数量",
      fieldName: "intMark",
      hideDefaultActions: true,
      wrapText: true,
      initialWidth: 100,
      cellAttributes: { alignment: "right" }
    },
    {
      label: "错误原因",
      fieldName: "ErrorReason",
      hideDefaultActions: true,
      initialWidth: 280,
      wrapText: true
    }
  ];
 
  // 获取参数
  @wire(CurrentPageReference)
  getStateParameters(currentPageReference) {
    console.log("CurrentPageReference");
    if (currentPageReference) {
      this.arrType = currentPageReference.state?.ArrType;
      this.eSetId = currentPageReference.state?.ESetId;
    }
  }
 
  get showOrderDetail() {
    if (this.eSetId != "" && this.eSetId != null) {
      return true;
    } else {
      return false;
    }
  }
 
  renderedCallback() {
    if (!this.stylesLoaded) {
      Promise.all([loadStyle(this, WrappedHeaderTable)])
        .then(() => {
          console.log("Custom styles loaded");
          this.stylesLoaded = true;
        })
        .catch((error) => {
          console.error("Error loading custom styles");
        });
    }
  }
 
  //初始化
  connectedCallback() {
    init({ arrType: this.arrType, eSetId: this.eSetId })
      .then((result) => {
        this.isNoteStay = result.isNoteStay;
        this.arrController = result.arrGoodCon;
        console.log("this.arrController:" + this.arrController);
        if (result.result == "Success") {
          this.saveFLGbln = result.saveFLGbln;
          this.returnFLGbln = result.returnFLGbln;
          this.coc = result.coc;
          this.cocId = result.coc.Id;
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          this.showSpinner = false;
          this.showPage = true;
        } else {
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          this.showSpinner = false;
          this.showPage = true;
          console.log("error:" + result.errorMsg);
          this.showMyToast("初始化页面失败", result.errorMsg, "error");
        }
      })
      .catch((error) => {
        this.showSpinner = false;
        this.showPage = true;
        console.log("error:" + JSON.stringify(error));
        this.showMyToast("初始化页面失败", JSON.stringify(error), "error");
      });
  }
 
  //barcode change
  barcodeChange(event) {
    this.barcode = event.detail.value;
  }
 
  //根据barcode搜索
  barcodeEntrys() {
    this.showSpinner = true;
    searchProduct({
      barcode: this.barcode,
      arrControllerStr: this.arrController
    })
      .then((result) => {
        this.arrController = result.arrGoodCon;
        if (result.result == "Success") {
          this.saveFLGbln = result.saveFLGbln;
          this.returnFLGbln = result.returnFLGbln;
          this.coc = result.coc;
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          this.consumableInventory = result.consumableInventory;
          this.detailsSummary = result.detailsSummary;
          for (var i in this.detailsSummary) {
            if (this.detailsSummary[i].Prod != null) {
              this.detailsSummary[i]["recordId"] =
                this.detailsSummary[i].Prod.Id;
              this.detailsSummary[i]["assetModelNo"] =
                this.detailsSummary[i].Prod.Asset_Model_No__c;
              this.detailsSummary[i]["prodName"] =
                this.detailsSummary[i].Prod.Name__c;
            }
          }
          console.log(
            "this.detailsSummary:" + JSON.stringify(this.detailsSummary)
          );
          this.consumableorderdetailsRecords =
            result.consumableorderdetailsRecords;
          var consumableorderdetailsRecordsview = [];
          for (var i in this.consumableorderdetailsRecords) {
            consumableorderdetailsRecordsview.push(
              this.consumableorderdetailsRecords[i]
            );
          }
          for (var i in this.consumableInventory) {
            consumableorderdetailsRecordsview.push(this.consumableInventory[i]);
          }
          this.consumableorderdetailsRecordsview =
            consumableorderdetailsRecordsview;
          for (var i in this.consumableorderdetailsRecordsview) {
            if (this.consumableorderdetailsRecordsview[i].Prod != null) {
              this.consumableorderdetailsRecordsview[i]["recordId"] =
                this.consumableorderdetailsRecordsview[i].Prod.Id;
              this.consumableorderdetailsRecordsview[i]["prodName"] =
                this.consumableorderdetailsRecordsview[i].Prod.Name__c;
            }
            if (this.consumableorderdetailsRecordsview[i].esd != null) {
              this.consumableorderdetailsRecordsview[i][
                "productPackingListManual"
              ] =
                this.consumableorderdetailsRecordsview[
                  i
                ].esd.ProductPacking_list_manual__c;
              this.consumableorderdetailsRecordsview[i]["status"] =
                this.consumableorderdetailsRecordsview[i].esd.CFDA_Status__c;
              this.consumableorderdetailsRecordsview[i][
                "reportProductApprobation"
              ] =
                this.consumableorderdetailsRecordsview[
                  i
                ].esd.Report_Product_Approbation__c;
              this.consumableorderdetailsRecordsview[i]["barCode"] =
                this.consumableorderdetailsRecordsview[i].esd.Bar_Code__c;
            }
          }
          console.log("len1:" + this.consumableorderdetailsRecords.length);
          console.log("len2:" + this.consumableorderdetailsRecordsview.length);
          console.log(
            "this.consumableorderdetailsRecordsview:" +
              JSON.stringify(this.consumableorderdetailsRecordsview)
          );
          this.showGoodsofReturnList = result.showGoodsofReturnList;
          var showGoodsofReturnListView = [];
          for (var i in this.showGoodsofReturnList) {
            showGoodsofReturnListView.push(this.showGoodsofReturnList[i]);
          }
          for (var i in this.consumableInventory) {
            showGoodsofReturnListView.push(this.consumableInventory[i]);
          }
          this.showGoodsofReturnListView = showGoodsofReturnListView;
          for (var i in this.showGoodsofReturnListView) {
            if (this.showGoodsofReturnListView[i].Prod != null) {
              this.showGoodsofReturnListView[i]["prodName"] =
                this.showGoodsofReturnListView[i].Prod.Name__c;
            }
            if (this.showGoodsofReturnListView[i].esd != null) {
              if (
                this.showGoodsofReturnListView[i].esd
                  .Consumable_Shipment_order__c != "" &&
                this.showGoodsofReturnListView[i].esd
                  .Consumable_Shipment_order__c != null
              ) {
                this.showGoodsofReturnListView[i]["recordId"] =
                  this.showGoodsofReturnListView[
                    i
                  ].esd.Consumable_Shipment_order__c;
                this.showGoodsofReturnListView[i]["orderUrl"] =
                  "/lexsummonscreat?ESetid=" +
                  this.showGoodsofReturnListView[i].esd
                    .Consumable_Shipment_order__c;
                this.showGoodsofReturnListView[i]["orderNo"] =
                  this.showGoodsofReturnListView[
                    i
                  ].esd.Consumable_Shipment_order__r.Name;
              } else if (
                this.showGoodsofReturnListView[i].esd
                  .Consumable_Sale_order__c != "" &&
                this.showGoodsofReturnListView[i].esd
                  .Consumable_Sale_order__c != null
              ) {
                this.showGoodsofReturnListView[i]["recordId"] =
                  this.showGoodsofReturnListView[
                    i
                  ].esd.Consumable_Sale_order__c;
                this.showGoodsofReturnListView[i]["orderUrl"] =
                  "/lexsummonscreat?ESetid=" +
                  this.showGoodsofReturnListView[i].esd
                    .Consumable_Sale_order__c;
                this.showGoodsofReturnListView[i]["orderNo"] =
                  this.showGoodsofReturnListView[
                    i
                  ].esd.Consumable_Sale_order__r.Name;
              }
              this.showGoodsofReturnListView[i]["prodOutDate"] =
                this.showGoodsofReturnListView[i].esd.Product_OutDate__c;
              this.showGoodsofReturnListView[i]["summonsForDirctionDet"] =
                this.showGoodsofReturnListView[i].esd.SummonsForDirction_det__c;
              this.showGoodsofReturnListView[i]["hospitalName"] =
                this.showGoodsofReturnListView[i].esd.HospItal_Name__c;
              this.showGoodsofReturnListView[i]["orderDealer"] =
                this.showGoodsofReturnListView[i].esd.Order_Dealer_Info__c;
              this.showGoodsofReturnListView[i]["barCode"] =
                this.showGoodsofReturnListView[i].esd.Bar_Code__c;
              this.showGoodsofReturnListView[i]["sterilizationLimit"] =
                this.showGoodsofReturnListView[i].esd.Sterilization_limit__c;
              this.showGoodsofReturnListView[i]["boxPiece"] =
                this.showGoodsofReturnListView[i].esd.Box_Piece__c;
              this.showGoodsofReturnListView[i]["returnCount"] =
                this.showGoodsofReturnListView[i].esd.Rrturn_count__c;
              console.log(
                "returnCount:" +
                  this.showGoodsofReturnListView[i].esd.Rrturn_count__c
              );
              this.showGoodsofReturnListView[i]["returnReason"] =
                this.showGoodsofReturnListView[i].esd.Return_reason__c;
            }
          }
          console.log("len1:" + this.showGoodsofReturnList.length);
          console.log("len2:" + this.showGoodsofReturnListView.length);
          console.log(
            "this.showGoodsofReturnListView:" +
              JSON.stringify(this.showGoodsofReturnListView)
          );
          // this.consumableInventory = result.consumableInventory;
          // for(var i in this.consumableInventory){
          //     if(this.consumableInventory[i].Prod != null){
          //         this.consumableInventory[i]['recordId'] = this.consumableInventory[i].Prod.Id;
          //         this.consumableInventory[i]['prodName'] = this.consumableInventory[i].Prod.Name__c;
          //     }
          // }
          console.log(
            "this.consumableInventory:" +
              JSON.stringify(this.consumableInventory)
          );
          this.consumableorderdetailsRecordserror =
            result.consumableorderdetailsRecordserror;
          for (var i in this.consumableorderdetailsRecordserror) {
            if (this.consumableorderdetailsRecordserror[i].Prod != null) {
              this.consumableorderdetailsRecordserror[i]["recordId"] =
                this.consumableorderdetailsRecordserror[i].Prod.Id;
              this.consumableorderdetailsRecordserror[i]["prodName"] =
                this.consumableorderdetailsRecordserror[i].Prod.Name__c;
            }
            if (this.consumableorderdetailsRecordserror[i].esd != null) {
              this.consumableorderdetailsRecordserror[i][
                "consumableOrderMinor"
              ] =
                this.consumableorderdetailsRecordserror[
                  i
                ].esd.Consumable_order_minor__c;
              if (
                this.consumableorderdetailsRecordserror[i].esd
                  .Consumable_order_minor__c != null
              ) {
                this.consumableorderdetailsRecordserror[i][
                  "consumableOrderMinorName"
                ] =
                  this.consumableorderdetailsRecordserror[
                    i
                  ].esd.Consumable_order_minor__r.Name;
                this.consumableorderdetailsRecordserror[i][
                  "consumableOrderUrl"
                ] =
                  "/s/detail/" +
                  this.consumableorderdetailsRecordserror[i].esd
                    .Consumable_order_minor__c;
              }
              this.consumableorderdetailsRecordserror[i]["barCode"] =
                this.consumableorderdetailsRecordserror[i].esd.Bar_Code__c;
              this.consumableorderdetailsRecordserror[i]["boxPiece"] =
                this.consumableorderdetailsRecordserror[i].esd.Box_Piece__c;
            }
          }
          console.log(
            "this.consumableorderdetailsRecordserror:" +
              JSON.stringify(this.consumableorderdetailsRecordserror)
          );
          this.showSpinner = false;
          this.showMyToast("获取成功", "", "success");
        } else {
          this.showSpinner = false;
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          console.log("error:" + result.errorMsg);
          this.showMyToast("获取失败", result.errorMsg, "error");
        }
      })
      .catch((error) => {
        this.showSpinner = false;
        console.log("error:" + error);
        this.showMyToast("获取失败", error, "error");
      });
  }
 
  //返品数量change
  returnCountChange(event) {
    var value = event.detail.data.value;
    var boxPrice = event.detail.data.boxPrice;
    var recordId = event.detail.data.recordId;
    console.log("返品数量:" + value + boxPrice + "---" + recordId);
    for (var i in this.showGoodsofReturnList) {
      if (this.showGoodsofReturnList[i]["recordId"] == recordId) {
        if (this.showGoodsofReturnList[i].canEdit) {
          this.showGoodsofReturnList[i].esd.Rrturn_count__c = 1;
          this.showGoodsofReturnList[i]["returnCount"] =
            this.showGoodsofReturnList[i].esd.Rrturn_count__c;
        } else {
          this.showGoodsofReturnList[i].esd.Rrturn_count__c = value;
          this.showGoodsofReturnList[i]["returnCount"] =
            this.showGoodsofReturnList[i].esd.Rrturn_count__c;
        }
      }
    }
  }
 
  //返品原因change
  returnReasonChange(event) {
    var recordId = event.detail.data.recordId;
    var value = event.detail.data.value;
    console.log("返品原因:" + value + "---" + recordId);
    for (var i in this.showGoodsofReturnList) {
      if (this.showGoodsofReturnList[i]["recordId"] == recordId) {
        this.showGoodsofReturnList[i].esd.Return_reason__c = value;
        this.showGoodsofReturnList[i]["returnReason"] =
          this.showGoodsofReturnList[i].esd.Return_reason__c;
      }
    }
  }
 
  // 到货确认
  arriveGoodsConfim() {
    this.showSpinner = true;
    arriveGoodsConfim({ arrControllerStr: this.arrController })
      .then((result) => {
        this.arrController = result.arrGoodCon;
        if (result.result == "Success") {
          this.showSpinner = false;
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          var url = result.url;
          const config = {
            type: "standard__webPage",
            attributes: {
              url: url
            }
          };
          this[NavigationMixin.Navigate](config);
        } else {
          this.showSpinner = false;
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          console.log("error1:" + result.errorMsg);
          this.showMyToast("到货确认失败", result.errorMsg, "error");
        }
      })
      .catch((error) => {
        this.showSpinner = false;
        console.log("error2:" + error);
        this.showMyToast("到货确认失败", error, "error");
      });
  }
 
  // 登录返品
  updateGoodsOfReturn() {
    this.showSpinner = true;
    updateGoodsOfReturn({
      arrControllerStr: this.arrController,
      showGoodsofReturnListStr: JSON.stringify(this.showGoodsofReturnList)
    })
      .then((result) => {
        this.showSpinner = false;
        this.arrController = result.arrGoodCon;
        if (result.result == "Success") {
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          var url = result.url;
          const config = {
            type: "standard__webPage",
            attributes: {
              url: url
            }
          };
          this[NavigationMixin.Navigate](config);
        } else {
          this.showSpinner = false;
          this.warningMsgs = result.warningMsgList;
          this.errorMsgs = result.errorMsgList;
          console.log("error1:" + result.errorMsg);
          this.showMyToast("登录返品失败", result.errorMsg, "error");
        }
      })
      .catch((error) => {
        this.showSpinner = false;
        console.log("error2:" + JSON.stringify(error));
        this.showMyToast("登录返品失败", error, "error");
      });
  }
 
  showMyToast(title, message, variant) {
    console.log("show custom message");
    var iconName = "";
    var content = "";
    if (variant == "success") {
      iconName = "utility:check";
    } else {
      iconName = "utility:error";
    }
    if (message != "") {
      content =
        "<h2><strong>" + title + "<strong/></h2><h5>" + message + "</h5>";
    } else {
      content = "<h2><strong>" + title + "<strong/></h2>";
    }
    this.template
      .querySelector("c-common-toast")
      .showToast(variant, content, iconName, 10000);
    // var mode;
    // if(this.isNoteStay){
    //     mode ='sticky';
    // }else{
    //     mode = 'dismissable';
    // }
    // const evt = new ShowToastEvent({
    //     title: title,
    //     message: message,
    //     variant: variant,
    //     mode: mode
    // });
    // this.dispatchEvent(evt);
  }
}