buli
2023-07-14 e6068da47c1bef5517c9e5fdc8c726766867ad4e
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
import { LightningElement, wire, api, track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import initPage from '@salesforce/apex/LexTopPageController.initPage';
import initTotalNum from '@salesforce/apex/LexConsumableGoodsInfo.initTotalNum';
import initArrDet from '@salesforce/apex/LexConsumableGoodsInfo.initArrDet';
import initArrDetAll from '@salesforce/apex/LexConsumableGoodsInfo.initArrDetAll';
import initDeliveryDet from '@salesforce/apex/LexConsumableGoodsInfo.initDeliveryDet';
import initDeliveryDetAll from '@salesforce/apex/LexConsumableGoodsInfo.initDeliveryDetAll';
import initNotArrDet from '@salesforce/apex/LexConsumableGoodsInfo.initNotArrDet';
import initNotArrDetAll from '@salesforce/apex/LexConsumableGoodsInfo.initNotArrDetAll';
import initMoreThan7 from '@salesforce/apex/LexConsumableGoodsInfo.initMoreThan7';
import initMoreThan7All from '@salesforce/apex/LexConsumableGoodsInfo.initMoreThan7All';
//table css
import { loadStyle } from 'lightning/platformResourceLoader';
import WrappedHeaderTable from '@salesforce/resourceUrl/lexdatatable';
 
export default class LexTopPage extends NavigationMixin(LightningElement) {
    @track title = [];
    @track raesList = [];
    @track column = [];
    @track overlimitdateorderdetails = [];
    @track productLimitRecords = [];
    @track accountInfo;
    @track accountId;
    @track userPro_Type;
    @track pageRecords = [];
    @track csvData = [];
    @track product_Limit;
    @track over_view = false;
    @track overlimit = false;
    @track hasHos = false;
    @track activeSections = ['A', 'B', 'C'];
    @track isRender = false;
    @track consumableorderdetailsRecordsview;
    @track showSpinner = true;
    @track showPage = false;
    //
    @track showPop = false;
    @track popTitle;
    @track totalNum;
    @track orderNumberArrived;
    @track deliveryDetailCount;
    @track orderNumberNotarrive;
    @track moreThanSevenDays;
    stylesLoaded = false;
 
    @track showTable = false;
    @track hidecheckboxcolumn = true;
    //排序
    defaultSortDirection = 'asc';
    sortDirection = 'asc';
    sortedBy;
 
    //分页start
    @track sortBy = '';
    @track pageSize = 10;
    error;
    records;
    currentPageToken = 0;
    nextPageToken = this.pageSize;
    @track totalRecords = 0;
    @track loader = false;
    @track pageNumber = 1;
    @track paginationVisibility = false;
    @track totalPages = 1;
    pageSizeOptions = [10, 25, 50, 100];
    @track recordStart = 0;
    @track recordEnd = 0;
    //end
 
    //是否一直显示提示
    @track isNoteStay = true;
 
    //未全部发货订单明细col
    @track colms = [
        {
            label: '消耗品订单名称',
            type: 'customOutputGood',
            typeAttributes: {
                outputValue: { fieldName: 'Name' },
                type: 'Title',
                recordId: { fieldName: 'Id' }
            },
            hideDefaultActions: true,
            // initialWidth: 200,
            wrapText: true
        },
        {
            label: 'SAP合同号',
            fieldName: 'ContractNo__c',
            hideDefaultActions: true,
            wrapText: true,
            initialWidth: 180
        },
        {
            label: '订单总数',
            type: 'customOutputGood',
            typeAttributes: {
                outputValue: { fieldName: 'Total_num__c' },
                type: 'TotalNum',
                recordId: { fieldName: 'Id' }
            },
            hideDefaultActions: true,
            initialWidth: 100
        },
        {
            label: '已到货数量',
            type: 'customOutputGood',
            typeAttributes: {
                outputValue: { fieldName: 'OrderNumber_arrived__c' },
                type: 'ArrDet',
                recordId: { fieldName: 'Id' }
            },
            hideDefaultActions: true,
            initialWidth: 100
        },
        {
            label: '待系统操作入库数量',
            type: 'customOutputGood',
            typeAttributes: {
                outputValue: { fieldName: 'Delivery_detail_count__c' },
                type: 'DeliveryDet',
                recordId: { fieldName: 'Id' }
            },
            hideDefaultActions: true,
            initialWidth: 150
        },
        {
            label: '还没发货数量',
            type: 'customOutputGood',
            typeAttributes: {
                outputValue: { fieldName: 'OrderNumber_notarrive__c' },
                type: 'NotArrDet',
                recordId: { fieldName: 'Id' }
            },
            hideDefaultActions: true,
            initialWidth: 120
        },
        {
            label: '发货七天还未到货数',
            type: 'customOutputGood',
            typeAttributes: {
                outputValue: { fieldName: 'More_than_seven_days__c' },
                type: 'MoreThan7',
                recordId: { fieldName: 'Id' }
            },
            hideDefaultActions: true,
            initialWidth: 150
        },
        {
            label: '最新发货日期',
            fieldName: 'Shipment_date__c',
            hideDefaultActions: true,
            initialWidth: 105
        },
        {
            label: '首次发货日期',
            fieldName: 'First_Delivery__c',
            hideDefaultActions: true,
            initialWidth: 105
        }
    ];
 
    @track colms2 = [
        { label: '产品型号', fieldName: 'prodModel', hideDefaultActions: true },
        {
            label: '数量',
            fieldName: 'recordCount',
            hideDefaultActions: true,
            initialWidth: 60,
            cellAttributes: { alignment: 'center' }
        }
    ];
 
    //使用期限小于一年的产品col
    @track colm3 = [
        { label: '产品型号', fieldName: 'prodName', hideDefaultActions: true },
        {
            label: '数量',
            fieldName: 'countid',
            hideDefaultActions: true,
            cellAttributes: { alignment: 'left' }
        },
        {
            label: '单位',
            fieldName: 'BoxPiece',
            hideDefaultActions: true,
            cellAttributes: { alignment: 'left' }
        }
    ];
 
    //经销商库存上下限col
    @track colm4 = [
        { label: '产品型号', fieldName: 'prodName', hideDefaultActions: true },
        {
            label: '库存下限',
            fieldName: 'limitLow',
            hideDefaultActions: true,
            cellAttributes: { alignment: 'left' }
        },
        {
            label: '库存上限',
            fieldName: 'limitUp',
            hideDefaultActions: true,
            cellAttributes: { alignment: 'left' }
        }
    ];
    @track columns = [
        {
            label: '消耗品名称',
            fieldName: 'Name__c',
            type: 'Name',
            sortable: true,
            hideDefaultActions: true,
            wrapText: true,
            cellAttributes: { alignment: 'left' }
        },
        {
            label: '规格',
            fieldName: 'packing_list',
            cellAttributes: { alignment: 'right' },
            initialWidth: 50,
            wrapText: true,
            hideDefaultActions: true
        },
        {
            label: '第三分类',
            fieldName: 'Category3__c',
            initialWidth: 85,
            cellAttributes: { alignment: 'left' },
            hideDefaultActions: true,
            wrapText: true
        },
        {
            label: '第四分类',
            fieldName: 'Category4__c',
            cellAttributes: { alignment: 'left' },
            initialWidth: 85,
            hideDefaultActions: true,
            wrapText: true
        },
        {
            label: '第五分类',
            fieldName: 'Category5__c',
            cellAttributes: { alignment: 'left' },
            initialWidth: 85,
            hideDefaultActions: true,
            wrapText: true,
            sortable: true
        },
        {
            label: 'CFDA状态',
            fieldName: 'SFDA_Status__c',
            cellAttributes: { alignment: 'left' },
            initialWidth: 80,
            hideDefaultActions: true
        },
        {
            label: '注册证编码号',
            fieldName: 'approbation_No',
            cellAttributes: { alignment: 'left' },
            wrapText: true,
            initialWidth: 155,
            hideDefaultActions: true
        },
        {
            label: '注册证效期',
            fieldName: 'expiration_Date',
            cellAttributes: { alignment: 'left' },
            wrapText: true,
            hideDefaultActions: true,
            initialWidth: 100
        },
        {
            label: '产品数量下限',
            fieldName: 'lowerlimit',
            cellAttributes: { alignment: 'right' },
            wrapText: true,
            hideDefaultActions: true,
            initialWidth: 100
        },
        {
            label: '使用期限',
            fieldName: 'guaranteeperiod',
            cellAttributes: { alignment: 'left' },
            hideDefaultActions: true,
            initialWidth: 95
        },
 
        {
            label: '有效期内库存',
            type: 'customInventoryColor',
            cellAttributes: { alignment: 'right' },
            typeAttributes: {
                value: { fieldName: 'limitCount' },
                upperlimit: { fieldName: 'upperlimit' },
                lowerlimit: { fieldName: 'lowerlimit' },
                boxPrice: { fieldName: 'BoxPiece' }
            },
            hideDefaultActions: true,
 
            initialWidth: 95
        },
        {
            label: '过期库存',
            fieldName: 'overlimitCount',
            hideDefaultActions: true,
            cellAttributes: { alignment: 'right' },
            initialWidth: 75
        },
        {
            label: '单位',
            fieldName: 'BoxPiece',
            cellAttributes: { alignment: 'left' },
            initialWidth: 50,
            wrapText: true,
            hideDefaultActions: true
        }
    ];
 
    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() {
        this.loader = true;
        this.init();
    }
    init() {
        this.showSpinner = true;
        initPage({
            pageSizeLWC: this.pageSize,
            pageTokenLWC: this.currentPageToken
        })
            .then((result) => {
                this.isNoteStay = result.isNoteStay;
                console.log('isNoteStay:' + result.isNoteStay);
                if (result.result == 'Success') {
                    //分页start
                    this.nextPageToken = result.paginatedAccounts.nextPageToken;
                    this.totalRecords = result.paginatedAccounts.totalRecords;
                    this.recordStart = result.paginatedAccounts.recordStart;
                    this.recordEnd = result.paginatedAccounts.recordEnd;
                    this.totalPages = Math.ceil(
                        result.paginatedAccounts.totalRecords / this.pageSize
                    );
                    console.log('this.totalPages = ' + this.totalPages);
                    this.paginationVisibility =
                        this.totalPages > 1 ? true : false;
                    console.log('this.sortDirection = ' + this.sortDirection);
                    this.loader = false;
                    //分页end
                    this.title = result.title;
                    this.totalNum = result.totalNum;
                    this.orderNumberArrived = result.orderNumberArrived;
                    this.deliveryDetailCount = result.deliveryDetailCount;
                    this.orderNumberNotarrive = result.orderNumberNotarrive;
                    this.moreThanSevenDays = result.moreThanSevenDays;
                    this.raesList = result.raesList;
                    this.raesList.push({
                        Id: '1',
                        Name: '待操作入库订单汇总',
                        Total_num__c: this.totalNum,
                        OrderNumber_arrived__c: this.orderNumberArrived,
                        Delivery_detail_count__c: this.deliveryDetailCount,
                        OrderNumber_notarrive__c: this.orderNumberNotarrive,
                        More_than_seven_days__c: this.moreThanSevenDays
                    });
                    this.column = result.column;
                    this.accountInfo = result.accountInfo;
                    this.accountId = result.accountInfo.Id;
                    this.pageRecords = result.pageRecords;
                    this.overlimitdateorderdetails =
                        result.overlimitdateorderdetails;
                    this.over_view = result.over_view;
                    this.overlimit = result.overlimit;
                    this.hasHos = result.hasHos;
                    this.product_Limit = result.product_Limit;
                    console.log('result==>' + JSON.stringify(result));
                    for (var i in this.pageRecords) {
                        this.pageRecords[i]['Name__c'] =
                            this.pageRecords[i].Prod.Name__c;
                        this.pageRecords[i]['Category3__c'] =
                            this.pageRecords[i].Prod.Category3__c;
                        this.pageRecords[i]['Category4__c'] =
                            this.pageRecords[i].Prod.Category3__c;
                        this.pageRecords[i]['Category5__c'] =
                            this.pageRecords[i].Prod.Category3__c;
                        this.pageRecords[i]['SFDA_Status__c'] =
                            this.pageRecords[i].Prod.SFDA_Status__c;
                    }
                    //hasHos = true 医院特价
                    if (this.hasHos) {
                        let object1 = {
                            label: '医院特价',
                            fieldName: 'hospitalSpecialOffer',
                            hideDefaultActions: true,
                            type: 'boolean',
                            cellAttributes: { alignment: 'left' },
                            initialWidth: 75
                        };
                        this.columns.push(object1);
                        console.log(' this.columns' + this.columns);
                        for (var j in this.pageRecords) {
                            this.pageRecords[j]['Name__c'] =
                                this.pageRecords[j].Prod.Name__c;
                            this.pageRecords[j]['Category3__c'] =
                                this.pageRecords[j].Prod.Category3__c;
                            this.pageRecords[j]['Category4__c'] =
                                this.pageRecords[j].Prod.Category3__c;
                            this.pageRecords[j]['Category5__c'] =
                                this.pageRecords[j].Prod.Category3__c;
                            this.pageRecords[j]['SFDA_Status__c'] =
                                this.pageRecords[j].Prod.SFDA_Status__c;
                            this.pageRecords[j]['hospitalSpecialOffer__c'] =
                                this.pageRecords[j].hospitalSpecialOffer;
                        }
                    }
                    this.showTable = true;
                    if (
                        this.product_Limit != null &&
                        this.product_Limit != ''
                    ) {
                        var records = this.product_Limit.split(',');
                        for (var i in records) {
                            var parms = records[i].split('|');
                            var record = new Object();
                            record['prodName'] = parms[0];
                            record['limitLow'] = parms[1];
                            record['limitUp'] = parms[2];
                            this.productLimitRecords.push(record);
                        }
                    }
                    // this.productLimitRecords = records;
                    console.log(
                        'productLimitRecords:' +
                            JSON.stringify(this.productLimitRecords)
                    );
                    console.log('product_Limit:' + this.product_Limit);
                    this.consumableorderdetailsRecordsview =
                        result.consumableorderdetailsRecordsview;
                    //add by WangXueqin 2023/05/05
                    this.userPro_Type = result.userPro_Type;
                    console.log('this.accountId:' + this.accountId);
                    console.log(
                        'this.accountInfo:' + JSON.stringify(this.accountInfo)
                    );
                    this.showSpinner = false;
                    this.showPage = true;
                    // this.showMyToast('初始化页面成功', '', 'success');
                } else {
                    this.showPage = true;
                    this.showSpinner = false;
                    console.log('Error:' + result.errorMsg);
                    this.showMyToast(
                        '初始化页面失败',
                        result.errorMsg,
                        'error'
                    );
                }
            })
            .catch((error) => {
                this.showSpinner = false;
                console.log('Error:' + error);
                this.showMyToast(
                    '初始化页面失败',
                    JSON.stringify(error),
                    'error'
                );
            });
    }
 
    //点击链接
    clickLick(event) {
        var outputValue = event.detail.data.value;
        var outputType = event.detail.data.type;
        var recordId = event.detail.data.recordId;
        console.log(
            'click:' + outputValue + '---' + outputType + '---' + recordId
        );
        if (outputType == 'Title') {
            const config = {
                type: 'standard__webPage',
                attributes: {
                    url: '/lexarrivegoods?ESetId=' + recordId
                }
            };
            this[NavigationMixin.Navigate](config);
        } else if (outputType == 'TotalNum') {
            this.popTitle = '所有产品一览';
            initTotalNum({ ordId: recordId, type: '' }).then((result) => {
                if (result.result == 'Success') {
                    this.recordList = result.recordList;
                    console.log('data:' + JSON.stringify(this.recordList));
                    this.showPop = true;
                } else {
                    this.showMyToast(
                        '加载所有产品一览页面失败',
                        result.errorMsg,
                        'error'
                    );
                }
            });
        } else if (outputType == 'ArrDet') {
            if (recordId == '1') {
                this.popTitle = '所有已到货产品一览';
                initArrDetAll({ type: '' }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载所有已到货产品一览页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            } else {
                this.popTitle = '已到货产品一览';
                initArrDet({ orderId: recordId }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载已到货产品一览页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            }
        } else if (outputType == 'DeliveryDet') {
            if (recordId == '1') {
                this.popTitle = '所有已发货还没到货产品一览';
                initDeliveryDetAll({ type: '' }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载所有已发货还没到货产品一览页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            } else {
                this.popTitle = '未到货产品一览';
                initDeliveryDet({ orderId: recordId }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载未到货产品一览页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            }
        } else if (outputType == 'NotArrDet') {
            if (recordId == '1') {
                this.popTitle = '所有还没发货产品一览';
                initNotArrDetAll({ type: '' }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载所有还没发货产品一览页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            } else {
                this.popTitle = '还没发货数量';
                initNotArrDet({ orderId: recordId }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载还没发货数量页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            }
        } else if (outputType == 'MoreThan7') {
            if (recordId == '1') {
                this.popTitle = '所有发货七天还未到货数';
                initMoreThan7All({ type: '' }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载所有发货七天还未到货数页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            } else {
                this.popTitle = '发货七天还未到货数';
                initMoreThan7({ orderId: recordId }).then((result) => {
                    if (result.result == 'Success') {
                        this.recordList = result.recordList;
                        console.log('data:' + JSON.stringify(this.recordList));
                        this.showPop = true;
                    } else {
                        this.showMyToast(
                            '加载发货七天还未到货数页面失败',
                            result.errorMsg,
                            'error'
                        );
                    }
                });
            }
        }
    }
 
    //关闭弹窗
    closePop() {
        this.showPop = false;
    }
 
    editProductLimit(event) {
        //add by Wang Xueqin 2023/05/05
        //let url =
        // '/LexProductLimitEdit?accountid=' +
        // this.accountId +
        // '&userPro_Type=' +
        // this.userPro_Type;
        let url =
            '/lexproductlimitedit?accountid=' +
            this.accountId +
            '&userPro_Type=' +
            this.userPro_Type;
        const config = {
            type: 'standard__webPage',
            attributes: {
                url: url
            }
        };
        this[NavigationMixin.Navigate](config);
    }
 
    //新建消耗品订单
    newOrder() {
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Consumable_order__c',
                actionName: 'new'
            },
            state: {
                useRecordTypeCheck: 1
            }
        });
    }
 
    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);
    }
    //排序
 
    sortByMethod(field, reverse, primer) {
        const key = primer
            ? function (x) {
                  return primer(x[field]);
              }
            : function (x) {
                  return x[field];
              };
 
        return function (a, b) {
            a = key(a);
            b = key(b);
            return reverse * ((a > b) - (b > a));
        };
    }
 
    onHandleSort(event) {
        console.log('Sort');
        this.sortBy = event.detail.fieldName;
        this.sortDirection = event.detail.sortDirection;
        this.currentPageToken = 0;
        console.log('this.sortBy = ' + this.sortBy);
        console.log('this.sortDirection = ' + this.sortDirection);
        const { fieldName: sortedBy, sortDirection } = event.detail;
        const cloneData = [...this.pageRecords];
        cloneData.sort(
            this.sortByMethod(sortedBy, sortDirection === 'asc' ? 1 : -1)
        );
        this.pageRecords = cloneData;
        this.sortDirection = sortDirection;
        this.sortedBy = sortedBy;
    }
    //分页
    handlePaginatorChange(event) {
        this.recordsToDisplay = event.detail.recordsToDisplay;
        this.preSelected = event.detail.preSelected;
        if (this.recordsToDisplay && this.recordsToDisplay > 0) {
            this.rowNumberOffset = this.recordsToDisplay[0].rowNumber - 1;
        } else {
            this.rowNumberOffset = 0;
        }
    }
    handlePrevious() {
        this.currentPageToken =
            Number(this.currentPageToken) - Number(this.pageSize);
        this.init();
    }
 
    handleNext() {
        this.currentPageToken =
            Number(this.currentPageToken) + Number(this.pageSize);
        this.init();
    }
    handleFirst() {
        this.currentPageToken = 0;
        this.init();
    }
 
    handleLast() {
        this.currentPageToken =
            this.totalPages > 1 ? (this.totalPages - 1) * this.pageSize : 0;
        this.init();
    }
 
    handlePageschange(event) {
        console.log(event.detail);
        this.pageSize = event.detail;
        this.currentPageToken = 0;
        this.init();
    }
    get previousButtonDisabled() {
        return this.currentPageToken === 0;
    }
 
    get nextButtonDisabled() {
        return this.nextPageToken === undefined;
    }
}