binxie
2024-01-18 b1d36ea3e6653e59bd767aa192c688ee0d9d4c58
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
// 报价js 工具类
import LightningConfirm from 'lightning/confirm';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
 
const toast = {
    // 提示信息
    showToast: function(_this, variant, msg) {
        if (variant == 'success') {
            const event = new ShowToastEvent({
                variant: variant,
                title: '',
                message: msg
            });
            _this.dispatchEvent(event);
        }else{
            const event = new ShowToastEvent({
                variant: variant,
                title: '',
                message: msg,
                mode:'sticky'
            });
            _this.dispatchEvent(event);
            
        }
    },
    //确认框
    handleConfirmClick: function(message) {
        console.log('handleConfirmClick');
        const result = LightningConfirm.open({
            message: message,
            variant: 'headerless',
            // variant: variant,
            // theme: 'shade',
            // setting theme would have no effect
        });
        //Confirm has been closed
        //result is true if OK was clicked
        console.log(result);
        return result;
        //and false if cancel was clicked
    },
    
    //页面对象跳转
    navigateToOtherObj: function(recordId){
        this.IsLoading = true;
        console.log('navigateToOtherObj');
        this[NavigationMixin.Navigate]({
            type:'standard__recordPage',
            attributes:{
                recordId:recordId,
                objectApiName:'Account',
                actionName:'view'
            }
        });
    },
};
 
const handleInfo = {
    //合同对象设备 参保修理金额 更新后触发
    changeAsset(_this,cnt,checkedAssets,PageDisabled,approvalDate,allData) {
        //封装返回数据
        var returnData = {};
    
        // 提交后就页面不计算了
        var isDisabled = PageDisabled;
        // 合同总理
        var newCount = 0;
        var isresduce = 0;
        var oyearCount = 0;
        var firstCCount = 0;
        var conCCount = 0;
        // row金額合計
        var repairSum = 0;
        var listSum = 0;
        // 新品合同 判断
        var newCon = true;
        var contractStartDate = new Date(allData.estimate.Contract_Start_Date__c);
        //多年保续签合同数量 thh 20220316 start
        var GuranteeCount = 0;
        //多年保续签合同数量 thh 20220316 end
        //2022故障品加费 获取userInfo简档名称 是否为FSE start
        var isFSE = allData.isFSE;
        //2022故障品加费 获取userInfo简档名称 end
        // 预定开始日
        var startdate = new Date(allData.estimate.Contract_Esti_Start_Date__c);
        // 预定开始日-6个月
        startdate.setMonth(startdate.getMonth() - 6);
        //补充使用变量
        // 申请日 当前日期
        if(approvalDate != ''){
            //申请日
            approvalDate = new Date(approvalDate.toLocaleDateString());
            if (Date.parse(approvalDate) < Date.parse(startdate)) {
                newCon = false;
            }
        }
        // 最高、最低价格合计
        var downPriceSum = 0;
        var upPriceSum = 0;
        // 合同月数乗算  parseFloat(null.'',undefined) 为NAN  补充判断
        var month = parseFloat(allData.estimate.Contract_Range__c);
        if (month == undefined || month == "" || isNaN(month)) {
            month = 1;
        }
        var month2 = 0;
        if (month > 12) {
            month2 = month - 12;
            month = 12;
        }
        for (var i = 0; i < cnt; i++) {
            //字段按钮 默认可用
            checkedAssets[i].ShowAssetSituation = true;
            var strMoney = 0;
            var repairMoney = 0;
            // 行项目 最高、最低价格合计
            // 续签价格取联动价格页面计算,首签或产品取 实际价格
            // 下线价格
            var downPrice = 0;
            // 上线价格
            var upPrice = 0;
            // 12个月合同金额
            var Price_YearTXT = 0;
            var isManual = checkedAssets[i].isManual; //return boolean
            var isnew = checkedAssets[i].mcae.IsNew__c; //return boolean
            var assetListmonth = checkedAssets[i].mcae.Estimate_List_Price__c; 
            //市场多年保修价格开发 DC 2023/02/09 start 
            var VMassetListmonth = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Price_Year__c : '') : '';
            //市场多年保修价格开发 DC 2023/02/09 end 
            if (isManual) {
                var a = checkedAssets[i].mcae.Product_Manual__c ? checkedAssets[i].mcae.Product_Manual__c : ''; 
                if (a != '') {
                    strMoney = assetListmonth; 
                    var LastMContractRecord = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.RecordType_DeveloperName__c : '') : '';
                    Price_YearTXT = strMoney * 12;
                    if (isnew) {
                        newCount ++;
                        strMoney = month * strMoney + month2 * strMoney / allData.isNewPriceAdj;
                    } else {
                        newCon = false;
                        strMoney = month * strMoney + month2 * strMoney;
                    }
                    //补充空指针
                    var b = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Contract_No_F__c : '') : '';
                    // var LastMContractRecord = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.RecordType_DeveloperName__c : '') : ''; 
                    if(b != ''){
                        conCCount ++;
                        // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。)
                        // 2.一年以上的合同,在结束前6个月开始可以开放续签报价。
                        var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_End_Date__c);
                        var lastContRange = 0;
                        if(LastMContractRecord == 'VM_Contract'){
                            newCount++;
                            //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
                            GuranteeCount++;
                            newCon = false;
                            //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
                            lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
                            lastContRange = 36;
                        }else{
                            lastContRange = checkedAssets[i].rec.CurrentContract_F__r.Contract_Range__c; 
                        }
                        //最后结束日+1年
                        lastendDate.setMonth(lastendDate.getMonth() + 12);
                        if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
                            oyearCount ++;
                        }
                        // 取联动价格
                        // 上一期合同实际报价月额
                        // * 1 避免 parseFloat(null) ->NAN
                        var LastMContract_Price = parseFloat(checkedAssets[i].mcae.LastMContract_Price__c  * 1);
                        var Adjustment_ratio_Lower = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Lower__c   * 1);
                        var Adjustment_ratio_Upper = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Upper__c   * 1);
                        //计算惩罚率
                        var Punish = handleInfo.calculateNtoMRatio(_this,lastContRange,(month + month2),allData);
                        if(Punish == 0){
                            return;
                        }
                        // 判断有无报价:没有按照标准价格实际联动
                        var Estimate_Num = checkedAssets[i].rec.CurrentContract_F__r.Estimate_Num__c ;
                        if(Estimate_Num == 0){
                            if(LastMContractRecord == 'VM_Contract'){
                                // gzw 20220630  实际联动6个月价格区分
                                var nowdate = new Date();
                                lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
                                nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
                                //市场多年保修价格开发 DC 2023/1/30 start 
                                var Maxcoefficient =0;
                                var Mincoefficient =0;
                                var ContractMonth = handleInfo.localParseFloat(allData.estimate.Contract_Range__c);
                                var AssetRate = handleInfo.localParseFloat(checkedAssets[i].rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c);
                                checkedAssets[i].mcae.Asset_Consumption_rate__c = AssetRate;
                                if(AssetRate<= 50){
                                    Maxcoefficient = (1-0.3);
                                    Mincoefficient = (1-0.4);
                                }else if(AssetRate>50 &&AssetRate<=60){
                                    Maxcoefficient = (1-0.2);
                                    Mincoefficient = (1-0.3);
                                }else if(AssetRate>60 &&AssetRate<=70){
                                    Maxcoefficient = (1-0.15);
                                    Mincoefficient = (1-0.25);
                                }else if(AssetRate>70 &&AssetRate<=80){
                                    Maxcoefficient = (1-0.1);
                                    Mincoefficient = (1-0.2);
                                    
                                }else if(AssetRate>80 &&AssetRate<=90){
                                    Maxcoefficient = (1-0.05);
                                    Mincoefficient = (1-0.15);
                                }else if(AssetRate>90 &&AssetRate<=100){
                                    Maxcoefficient = 1;
                                    Mincoefficient = (1-0.05);
                                }else if(AssetRate>100 &&AssetRate<=110){
                                    Maxcoefficient = (1+0.05);
                                    Mincoefficient = 1;
                                }else if(AssetRate>110 &&AssetRate<=120){
                                    Maxcoefficient = (1+0.1);
                                    Mincoefficient = 1;
                                }else if(AssetRate>120 &&AssetRate<=130){
                                    Maxcoefficient = (1+0.2);
                                    Mincoefficient = (1+0.1);
                                }else if(AssetRate>130 &&AssetRate<=140){
                                    Maxcoefficient = (1+0.25);
                                    Mincoefficient = (1+0.15);
                                }else if(AssetRate>140){
                                    Maxcoefficient = (1+0.3);
                                    Mincoefficient = (1+0.2);
                                }
                                //市场多年保修价格开发 DC 2023/1/30 end 
                                if(nowdate < Date.parse(lastendDate)){
                                    // 市场多年保修价格开发 start DC 2023/01/19  
                                    //市场多年保设备小于2年半
                                    var AssetModelNo = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Asset_Model_No__c : 0;
                                    var Category4 = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Category4__c : ''; 
                                    //设备设备消费率小于1.4
                                    if(AssetRate<140){
                                        upPrice = VMassetListmonth * ContractMonth /12;
                                        if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
                                            downPrice = upPrice;
                                        }else{
                                            downPrice = upPrice * 0.8;
                                        }
                                    }else{
                                        upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                        downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;   
                                    }
                                    // 市场多年保修价格开发 end DC 2023/01/19  
                                }else{
                                    //市场多年保修价格开发 DC 2023/1/30 start  设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
                                    upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                    downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                    //市场多年保修价格开发 DC 2023/1/30 end 
                                }
                                // gzw 20220630  实际联动6个月价格区分
                            }else{
                                upPrice = strMoney;
                                downPrice = strMoney * 0.8;
                            }
                        }else{
                            upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
                            downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
                        }
                    }else{
                        upPrice = strMoney;
                        downPrice = strMoney * 0.8;
                    }
                    // 上下限四舍五入
                    upPrice = upPrice.toFixed(2);
                    downPrice = downPrice.toFixed(2);
                    // 12个月合同金额                    
                    if (!isDisabled) {
                        // 实际联动价格 start
                        //*1 转化为Number类型
                        checkedAssets[i].mcae.Adjustment_Lower_price__c = (downPrice*1).toFixed(2);
                        checkedAssets[i].mcae.Adjustment_Upper_price__c = (upPrice*1).toFixed(2);
                        // 实际联动价格 end
                    }
                    checkedAssets[i].mcae.Estimate_List_Price_Page__c = strMoney * 1;
                    //Repair_Price__c null Number类型  .trim()
                    repairMoney = (checkedAssets[i].mcae.Repair_Price__c == undefined ? null : checkedAssets[i].mcae.Repair_Price__c ) *1;
                } else {
                    // TODO 一時的な対応、なんで別行の金額リフレッシュされた?
                    checkedAssets[i].mcae.Estimate_List_Price_Page__c = '';
                    // 12个月合同金额
                    if (!isDisabled) {
                        // 实际联动价格 start
                        checkedAssets[i].mcae.Adjustment_Lower_price__c = '';
                        checkedAssets[i].mcae.Adjustment_Upper_price__c = '';
                        // 实际联动价格 end
                     }
                }
            }
            else {
                // 所有设备按安装日、发货日(最早的),距离合同开始日6个月内都是新品合同
                var isNewDate = new Date( checkedAssets[i].rec.isNewDate_use__c);
                isNewDate.setMonth(isNewDate.getMonth() + 6);
                if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
                    newCon = false;
                }
                strMoney = assetListmonth ; 
                Price_YearTXT = strMoney * 12;
                if (isnew) {
                    strMoney = month * strMoney + month2 * strMoney / allData.isNewPriceAdj;
                } else {
                    strMoney = month * strMoney + month2 * strMoney;
                }
 
                var b = checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Contract_No_F__c : ''; 
                var LastMContractRecord = checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.RecordType_DeveloperName__c : '';
                if(b != ''){
                    conCCount ++;
                    // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。)
                    // 2.一年以上的合同,在结束前6个月开始可以开放续签报价。
                    var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_End_Date__c);
                    var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F__r.Contract_End_Date__c);
                    var lastContRange = 0;
                    if(LastMContractRecord == 'VM_Contract'){
                        newCount++;
                        //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
                        GuranteeCount++;
                        newCon = false;
                        //多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
                        lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c) ;
                        lastContRange = 36;
                    }else{
                        lastContRange = checkedAssets[i].rec.CurrentContract_F__r.Contract_Range__c; 
                    }
                    //最后结束日+1年
                    lastendDate.setMonth(lastendDate.getMonth() + 12);
                    if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
                        oyearCount ++;
                    }
                    // 取联动价格
                    // 上一期合同实际报价月额
                    var LastMContract_Price = parseFloat(checkedAssets[i].mcae.LastMContract_Price__c * 1);
                    var Adjustment_ratio_Lower = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Lower__c * 1);
                    var Adjustment_ratio_Upper = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Upper__c * 1);
                    //计算惩罚率
                    var Punish = handleInfo.calculateNtoMRatio(_this, lastContRange,(month + month2),allData);
                    if(Punish == 0){
                        return;
                    }
                    // 判断有无报价:没有按照标准价格实际联动
                    var Estimate_Num = checkedAssets[i].rec.CurrentContract_F__r.Estimate_Num__c ;
                    if(Estimate_Num == 0){
                        if(LastMContractRecord == 'VM_Contract'){
                            // gzw 20220630  实际联动6个月价格区分
                            var nowdate = new Date();
                            lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
                            nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
                            //市场多年保修价格开发 DC 2023/1/30 start 
                            var Maxcoefficient =0;
                            var Mincoefficient =0;
                            var ContractMonth = handleInfo.localParseFloat(allData.estimate.Contract_Range__c);
                            var AssetRate = handleInfo.localParseFloat(checkedAssets[i].rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c);
                            checkedAssets[i].mcae.Asset_Consumption_rate__c = AssetRate;
                            if(AssetRate<= 50){
                                Maxcoefficient = (1-0.3);
                                Mincoefficient = (1-0.4);
                            }else if(AssetRate>50 &&AssetRate<=60){
                                Maxcoefficient = (1-0.2);
                                Mincoefficient = (1-0.3);
                            }else if(AssetRate>60 &&AssetRate<=70){
                                Maxcoefficient = (1-0.15);
                                Mincoefficient = (1-0.25);
                            }else if(AssetRate>70 &&AssetRate<=80){
                                Maxcoefficient = (1-0.1);
                                Mincoefficient = (1-0.2);
                            }else if(AssetRate>80 &&AssetRate<=90){
                                Maxcoefficient = (1-0.05);
                                Mincoefficient = (1-0.15);
                            }else if(AssetRate>90 &&AssetRate<=100){
                                Maxcoefficient = 1;
                                Mincoefficient = (1-0.05);
                            }else if(AssetRate>100 &&AssetRate<=110){
                                Maxcoefficient = (1+0.05);
                                Mincoefficient = 1;
                            }else if(AssetRate>110 &&AssetRate<=120){
                                Maxcoefficient = (1+0.1);
                                Mincoefficient = 1;
                            }else if(AssetRate>120 &&AssetRate<=130){
                                Maxcoefficient = (1+0.2);
                                Mincoefficient = (1+0.1);
                            }else if(AssetRate>130 &&AssetRate<=140){
                                Maxcoefficient = (1+0.25);
                                Mincoefficient = (1+0.15);
                            }else if(AssetRate>140){
                                Maxcoefficient = (1+0.3);
                                Mincoefficient = (1+0.2);
                            }
                            //市场多年保修价格开发 DC 2023/1/30 end 
                            if(nowdate < Date.parse(lastendDate)){
                                // 市场多年保修价格开发 start DC 2023/01/19  
                                //市场多年保设备小于2年半
                                var AssetModelNo = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Asset_Model_No__c : 0;
                                var Category4 = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Category4__c : '';
                                //设备设备消费率小于1.4
                                if(AssetRate<140){
                                    upPrice = VMassetListmonth *ContractMonth / 12;
                                    if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
                                        downPrice = upPrice;
                                    }else{
                                        downPrice = upPrice * 0.8;
                                    }
                                }else{
                                    upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                    downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;   
                                }
                                // 市场多年保修价格开发 end DC 2023/01/19    
                            }else{
                                //市场多年保修价格开发 DC 2023/1/30 start  设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
                                upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
                                downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
                                //市场多年保修价格开发 DC 2023/1/30 end 
                            }
                            // gzw 20220630  实际联动6个月价格区分
                        }else{
                            upPrice = strMoney;
                            downPrice = strMoney * 0.8;
                        }
                    }else{
                        upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
                        downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
                    }
                }else{
 
                    if (isnew) {
                        newCount ++;
                    } else {
                        newCon = false;
                        firstCCount ++;
                    }
                    upPrice = strMoney;
                    downPrice = strMoney * 0.8;
                }
                // 上下限四舍五入
                upPrice = upPrice.toFixed(2);
                downPrice = downPrice.toFixed(2);
 
                if (!isDisabled) {
                    // 实际联动价格 start
                    checkedAssets[i].mcae.Adjustment_Lower_price__c = (downPrice*1).toFixed(2);
                    checkedAssets[i].mcae.Adjustment_Upper_price__c = (upPrice*1).toFixed(2);
                    // 实际联动价格 end
                }
                checkedAssets[i].mcae.Estimate_List_Price_Page__c = strMoney * 1;
                //<!-- (2022年12月上线)故障品加费 start -->  
                let Repair_Price_Auto = checkedAssets[i].Repair_Price_Auto;
                // Repair_Price_Auto = Repair_Price_AutoPrice.value(); 避免下面条件误判
                repairMoney = checkedAssets[i].mcae.Repair_Price__c == undefined  ? null : checkedAssets[i].mcae.Repair_Price__c;
                
                let repairMoney1 = parseFloat(repairMoney * 1);
                
                //在该部分js代码 未使用变量
 
                var ISReduced = allData.estimate.IS_Reduced_price_approval__c; 
                var Repair_Price_pass1 = checkedAssets[i].mcae.Repair_Price_pass__c;
                var Repair_Price_pass2 = handleInfo.localParseFloat(Repair_Price_pass1);
                if (repairMoney1> 0 && repairMoney1<(Repair_Price_Auto*0.80) && Repair_Price_Auto != null && isFSE == true) {
                     if (Repair_Price_pass1!=null && repairMoney1<Repair_Price_pass2) {
                        // alert('由于存在折扣率超过20%以上的修理加费减价申请,请先点击“提交RC评估”按钮,待RC评估后服务管理部会推进审批');
                        toast.handleConfirmClick('由于存在折扣率超过20%以上的修理加费减价申请,请先点击“提交RC评估”按钮,待RC评估后服务管理部会推进审批');
                        repairMoney = Repair_Price_pass2;
                        checkedAssets[i].mcae.Repair_Price__c = Repair_Price_pass2;
                     }
                }
                 
                var repairMoney2 = checkedAssets[i].mcae.Repair_Price__c;
                var repairMoney3 = handleInfo.localParseFloat(repairMoney2);
                 if (repairMoney3> 0 && (repairMoney3 <Repair_Price_Auto*0.80)) {
                    if (Repair_Price_pass1!=null && repairMoney3<Repair_Price_pass2) {
                             isresduce = isresduce+1;
                    }
                }
                //在该部分js代码 未使用变量
            }
            repairSum = repairSum + parseFloat(repairMoney* 1);
            listSum = listSum + parseFloat(strMoney* 1);
            downPriceSum = downPriceSum + parseFloat(downPrice* 1);
            upPriceSum =  upPriceSum + parseFloat(upPrice* 1);
        }
        if (isresduce!=0) {
            //前台处理后台事件
            allData.estimate.IS_Reduced_price_approval__c = '审批中';
        }else{
            if(ISReduced !='' ){
               allData.estimate.IS_Reduced_price_approval__c = '无八折以下';
            }
        }
        returnData.assetRepairSumNum = repairSum * 1;
        if (!isDisabled) {
            allData.estimate.GuidePrice_Up__c = Math.round(upPriceSum) * 1;
            allData.estimate.GuidePrice_Down__c = Math.round(downPriceSum) * 1;
        }
        allData.estimate.Asset_Repair_Sum_Price__c = repairSum * 1;
        var allcount = allData.productCount3 ;
        var result = '';
        if (allcount == 0) {
            result = null;
        //如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 start
        }else if(GuranteeCount > 0 && GuranteeCount == allcount){
            result = '市场多年保续签合同';
        //如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 end
        }else if (newCount > 0 && newCount == allcount && newCon == true) {
            result = '新品合同';
        }else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
            result = '首签合同';
        }else if(firstCCount > 0 && firstCCount == allcount){
            result = '首签合同';
        // 20220328 ljh update  LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备 start
        // }else if(oyearCount > 0 && oyearCount == conCCount){
        }else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
        // 20220328 ljh update  LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备 start
            result = '非续签合同(空白期一年以上)';
        }else{
            result = '续签合同';
        }
        allData.estimate.New_Contract_Type_TxT__c = result;
        allData.typeresult = result;
 
        //剩余内容前端处理
        allData.checkedAssets = checkedAssets;
        returnData.allData = allData;
        returnData.approvalDate = approvalDate;
        return returnData;
    },
 
    calculateNtoMRatio(_this,lastContRange, month,allData){
        var lastContRangeYear = Math.ceil(parseFloat(lastContRange* 1)/12);
        var currentMonthYear = Math.ceil(parseFloat(month* 1)/12);
        //if(!lastendDate || currentMonthYear <= lastContRangeYear){
        // calculateNtoMRatio报价规则改善新增 +-   
        // var rateF = allData.estimate.Consumption_rate_Forecast__c;      
        // var coefficient = allData.coefficient;  
        // if (handleInfo.localParseFloat(rateF) * handleInfo.localParseFloat(coefficient) < 100) {       
        //     return month;        
        // }        
        // 报价规则改善新增
 
        if(currentMonthYear == lastContRangeYear || currentMonthYear == 1){
            return month;
        }else if(month <= 24) {
            return 12+ (month- 12) *1.1;
        }else if(month <= 36) {
            return 25.2 + (month- 24) *1.21;
        }else if(month <= 48) {
            return 39.72 + (month- 36) *1.331;
        }else if(month <= 60) {
            return 55.692 + (month- 48) *1.4641;
        }else {
            toast.showToast(_this, 'error', '合同期最长只能选择60个月!');
            return 0;
        }
 
    },
    // 报价规则改善 20230310 start
    addMonths(yearMonthDay ,monthNum){
        if (!yearMonthDay) {
            return '';
        }
        console.log('yearMonthDay',yearMonthDay);
        yearMonthDay = yearMonthDay.replace(new RegExp("/", "g"),'-');
        console.log('yearMonthDay',yearMonthDay);
 
        //lwc 日期显示:2022-12-12
        var arr=yearMonthDay.split('-');
        var year=parseInt(arr[0]);
        var month=parseInt(arr[1]);
        var day=parseInt(arr[2]);
        month=month+monthNum;
        if(month>12){//月份加
            var yearNum=parseInt( (month-1)/12);
            month=month%12==0?12 :month%12;
            year+=yearNum;
        }else if(month<=0){//月份减
            month=Math.abs( month);
            var yearNum=parseInt( (month+12)/12);
            year-=yearNum;
        }
        month=month<10?"0"+month :month;
        return year+"-"+month+"-"+day;
    },
    //parseFloat 避免NAN
    localParseFloat(val){
        val = val == undefined ? null : val;
        return parseFloat(val*1);
    },
    seamlessRenew(_this,cnt,allData,checkedAssets,PageDisabled,IsContractEstiStartDateDisabled){
        var returnData = {};
        // 2023/09/18 原有值返回
        returnData.IsContractEstiStartDateDisabled = IsContractEstiStartDateDisabled;
        var startdatetime = allData.estimate.Contract_Esti_Start_Date__c;
        allData.startdateaddsix4 = startdatetime;
        // 报价规则改善 20230309 start 
        var isSeamlessRenew = 0;
        var isSeamlessRenew1 = 0;
        var isSeamlessRenew3 = 0;
        var isSeamlessRenew4 = 0;
        // 报价规则改善 20230309 end
        // 报价规则改善 20230310 start
        var downPriceSum = 0;
        var upPriceSum = 0;
        var tag1 = 0;
        var downPriceSum1 = 0;
        var upPriceSum1 = 0;
        var downPriceSum3 = 0;
        var upPriceSum3 = 0;
        var downPriceSum4 = 0;
        var upPriceSum4 = 0;
        // 报价规则改善 20230310 end
        // 报价规则改善 20230310 start
        var renewTenOFF = allData.estimate.renewTen_OFF__c;
        if (renewTenOFF == true) {
            returnData.IsContractEstiStartDateDisabled = true; 
        }
        // 2023/09/06 报价规则改善新增      
        var contrNew  = allData.estimate.New_Contract_Type_TxT__c;    
        // 2023/09/20 新增条件
        var pastime = allData.Past_Contract_end_day;  
        if (contrNew =='新品合同' || contrNew =='首签合同' || pastime== '') {        
            isSeamlessRenew++;       
            allData.startdateaddsix1 = startdatetime;           
            allData.startdateaddsix2 = startdatetime;         
            allData.startdateaddsix3 = startdatetime;      
        }else{
            allData.startdateaddsix1 = handleInfo.addMonths(allData.Past_Contract_end_day ,6);
            allData.startdateaddsix2 = handleInfo.addMonths(allData.Past_Contract_end_day ,6);
            allData.startdateaddsix3 = handleInfo.addMonths(allData.Past_Contract_end_day ,12);
        }        
       // 报价规则改善新增
        var ProductCountAll = 0;
        var VMProductCountAll = 0;
        // 报价规则改善 20230310 end
        for (var i = 0; i < cnt; i++) {
            console.log('seamlessRenew i',i);
            // 报价规则改善 20230310 start
            var  downPrice = checkedAssets[i].mcae.Adjustment_Lower_price__c;
            console.log('seamlessRenew downPrice',downPrice);
 
            var  downPrice1 = 0;
            var  upPrice = checkedAssets[i].mcae.Adjustment_Upper_price__c;
            var  upPrice1 = 0;
            var  downPrice3 = 0;
            var  upPrice3 = 0;
            var  downPrice4 = 0;
            var  upPrice4 = 0;
            var Price_YearTXT = 0;
            var LastMContract_Price = handleInfo.localParseFloat(checkedAssets[i].mcae.LastMContract_Price__c);
            var isnew = checkedAssets[i].mcae.IsNew__c; 
            // 合同月数乗算
            var month = handleInfo.localParseFloat(allData.estimate.Contract_Range__c);
            // 0 == '' --true
            if (month == undefined || month == "") {
                month = 1;
            }
            var month2 = 0;
            if (month > 12) {
                month2 = month - 12;
                month = 12;
            }
            var b = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Contract_No_F__c : '') : '';
            if (b != '') {
                ProductCountAll++;
            }
            var LastMContractRecord = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.RecordType_DeveloperName__c : '') : ''; 
            if (LastMContractRecord == 'VM_Contract') {
                VMProductCountAll++;
            }
            if(b != ''){
                var lastContRange = 0;
                if(LastMContractRecord == 'VM_Contract'){
                    lastContRange = 36;
                }else{
                    lastContRange = checkedAssets[i].mcae.Asset_Consumption_rate__c;
                }
            }     
            var Punish = handleInfo.calculateNtoMRatio(_this, lastContRange,(month + month2),allData);
            // 报价规则改善 20230310 end
            // if (!isDisabled) {
            var Adjustment_ratio_Lower = handleInfo.localParseFloat(checkedAssets[i].mcae.Adjustment_ratio_Lower__c );
            var Adjustment_ratio_Upper = handleInfo.localParseFloat(checkedAssets[i].mcae.Adjustment_ratio_Upper__c );
            var strMoney = checkedAssets[i].mcae.Estimate_List_Price__c;
            Price_YearTXT = strMoney * 12;
            console.log('isnew',isnew);
 
            if (isnew == true) {
                strMoney = month * strMoney + month2 * strMoney / allData.isNewPriceAdj;
            } else {
                strMoney = month * strMoney + month2 * strMoney;
            }
            console.log('strMoney',strMoney);
            // 服务合同报价规则改善 20230227 start
            var LastMContractID =  checkedAssets[i].rec ? checkedAssets[i].rec.CurrentContract_F__c : ''; 
            var ISStandardPricing = checkedAssets[i].rec ? checkedAssets[i].rec.IS_StandardPricing__c+'' : '';
            // <!-- // 首签设备逻辑补充 start -->
            var ProductISStandardPricing = checkedAssets[i].ProductISStandardPricing+'';
            // <!-- // 首签设备逻辑补充 start -->
            // 缺少首签设备逻辑
            if ((ISStandardPricing == 'true' || ProductISStandardPricing == 'true' ) && (LastMContractID == '' || LastMContractID == undefined) &&  LastMContractRecord != 'VM_Contract') {
                console.log('strMoney = >downprice');
                tag1 = 1;
                upPrice = strMoney;
                downPrice = strMoney;
                // isSeamlessRenew+;
                checkedAssets[i].mcae.Adjustment_Lower_price__c = isNaN(strMoney*1) ? '' : (strMoney*1).toFixed(2); 
                checkedAssets[i].mcae.Adjustment_Upper_price__c = isNaN(strMoney*1) ? '' : (strMoney*1).toFixed(2);
            }
            console.log('LastMContractID',LastMContractID);
            // classic != '',undefined 同样未进入逻辑
            if (LastMContractID) {
                 // 服务合同报价规则改善 20230227 end
                var startdate11 = allData.Past_Contract_end_day;
                var startdate1 = allData.estimate.Contract_Esti_Start_Date__c;
                // new Date('')会异常
                var startdate = new Date(startdate1);
                console.log('startdate1',startdate1);
                console.log('startdate11',startdate11);
                var startdatesix1 = new Date(handleInfo.addMonths(startdate11,6));
                console.log('startdatesix1',startdatesix1);
                startdatesix1.setDate(startdatesix1.getDate()-1);
                console.log('startdatesix1 setDate',startdatesix1);
 
                var startdatesix2 = new Date(handleInfo.addMonths(startdate11,6));
                startdatesix2.setDate(startdatesix2.getDate()+1);
                var startdatesix3 = new Date(handleInfo.addMonths(startdate11,12));
                startdatesix3.setDate(startdatesix3.getDate()+1);
                // 第一个日期
                var result1 = handleInfo.Blankperiod(startdate,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,1,LastMContractRecord,checkedAssets,allData,PageDisabled);
                console.log('result1',result1);
                //todo 可能 null
                var arr=result1.split('/');
                downPrice=parseInt(arr[0]);
                upPrice=parseInt(arr[1]);
                isSeamlessRenew=isSeamlessRenew+parseInt(arr[2]);
                // 第二个日期
                var result2 = handleInfo.Blankperiod(startdatesix1,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,2,LastMContractRecord,checkedAssets,allData,PageDisabled);
                console.log('result2',result2);
                
                var arr2=result2.split( '/');
                downPrice1=parseInt(arr2[0]);
                upPrice1=parseInt(arr2[1]);
                isSeamlessRenew1=isSeamlessRenew1+parseInt(arr2[2]);
                
                // 第三个日期
                var result3 = handleInfo.Blankperiod(startdatesix2,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,2,LastMContractRecord,checkedAssets,allData,PageDisabled);
                var arr3=result3.split( '/');
                downPrice3=parseInt(arr3[0]);
                upPrice3=parseInt(arr3[1]);
                isSeamlessRenew3=isSeamlessRenew3+parseInt(arr3[2]);
                // 第四个日期
                var result4 = handleInfo.Blankperiod(startdatesix3,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,2,LastMContractRecord,checkedAssets,allData,PageDisabled);
                var arr4=result4.split( '/');
                downPrice4=parseInt(arr4[0]);
                upPrice4=parseInt(arr4[1]);
                isSeamlessRenew4=isSeamlessRenew4+parseInt(arr4[2]);
            }else{
                var assN = checkedAssets[i].rec ? checkedAssets[i].rec.Name : '';
                if (assN !=null&&assN != '') {
                    isSeamlessRenew++;
                    isSeamlessRenew1++;
                    isSeamlessRenew4++;
                    isSeamlessRenew3++;
                }    
            }
            //方法内定义变量
            // 报价规则改善 20230308 end
            // 报价规则改善 20230310 start
            console.log('downPrice',downPrice);
            downPriceSum = downPriceSum + handleInfo.localParseFloat(downPrice);
            upPriceSum =  upPriceSum + handleInfo.localParseFloat(upPrice);
            console.log('downPrice1',downPrice1);
 
            if (downPrice1 ==0) {
                downPriceSum1 = downPriceSum1 + handleInfo.localParseFloat(downPrice);
            }else{
                downPriceSum1 = downPriceSum1 + handleInfo.localParseFloat(downPrice1);
            }
            if (upPrice1 ==0) {
                upPriceSum1 = upPriceSum1 + handleInfo.localParseFloat(upPrice);
            }else{
                upPriceSum1 = upPriceSum1 + handleInfo.localParseFloat(upPrice1);
            }
            if (downPrice3 ==0) {
                downPriceSum3 = downPriceSum3 + handleInfo.localParseFloat(downPrice);
            }else{
                downPriceSum3 = downPriceSum3 + handleInfo.localParseFloat(downPrice3);
            }
            if (upPrice3 ==0) {
                upPriceSum3 = upPriceSum3 + handleInfo.localParseFloat(upPrice);
            }else{
                upPriceSum3 = upPriceSum3 + handleInfo.localParseFloat(upPrice3);
            }
            if (downPrice4 ==0) {
                downPriceSum4 = downPriceSum4 + handleInfo.localParseFloat(downPrice);
            }else{
                downPriceSum4 = downPriceSum4 + handleInfo.localParseFloat(downPrice4);
            }
            if (upPrice4 ==0) {
                upPriceSum4 = upPriceSum4 + handleInfo.localParseFloat(upPrice);
            }else{
                upPriceSum4 = upPriceSum4 + handleInfo.localParseFloat(upPrice4);
            }
        }
        // 报价规则改善 20230309 start
        if (isSeamlessRenew==0) {
            allData.Is_Blank_period = true;
        }else{
            allData.Is_Blank_period = false;
        }
        //Past_Contract_end_day = null->startime1=Thu Jan 01 1970 08:00:00 GMT+0800
        // result 目前未涉及其他逻辑,暂不处理  Past_Contract_end_day没有值转为''?-》invalid Date
        var startime1 =  new Date(allData.Past_Contract_end_day);
        var startime2 = new Date(allData.estimate.Contract_Esti_Start_Date__c);
        var result = (startime2-startime1)/(3600*24*1000);
        // Is_Blank_period1,Cost_rate_ForecastF 定义变量未使用
        var Is_Blank_period1 =  allData.Is_Blank_period;
        var Cost_rate_ForecastF =  allData.Cost_rate_ForecastF;
        // 2023/09/20 补充 价格处理(4个标准价格的最低/高价总额)
        var GuidePriceUp1 = allData.estimate.GuidePrice_Up1__c +'';
        var GuidePriceUp2 = allData.estimate.GuidePrice_Up2__c +''; 
        var GuidePriceUp3 = allData.estimate.GuidePrice_Up3__c +'';
        // 2023/08/31 添加逻辑判断  页面可编辑时重新计算,不可编辑时,没有值则重新计算
        if (!PageDisabled) {
            //round 为整数,toFixed 保留两位小数无意义
            allData.estimate.GuidePrice_Up__c = Math.round(upPriceSum)*1;
            allData.estimate.GuidePrice_Down__c = Math.round(downPriceSum)*1;
            allData.estimate.GuidePrice_Up1__c = Math.round(upPriceSum1)*1;
            allData.estimate.GuidePrice_Down1__c = Math.round(downPriceSum1)*1;
            allData.estimate.GuidePrice_Up2__c = Math.round(upPriceSum3)*1;
            allData.estimate.GuidePrice_Down2__c = Math.round(downPriceSum3)*1;
            allData.estimate.GuidePrice_Up3__c = Math.round(upPriceSum4)*1;
            allData.estimate.GuidePrice_Down3__c = Math.round(downPriceSum4)*1;
        }else{
            // 字符串.trim()
            if (GuidePriceUp1.trim() == '' || GuidePriceUp2.trim() == '' || GuidePriceUp3.trim() == '') {
                allData.estimate.GuidePrice_Up1__c = Math.round(upPriceSum1)*1;
                allData.estimate.GuidePrice_Down1__c = Math.round(downPriceSum1)*1;
                allData.estimate.GuidePrice_Up2__c = Math.round(upPriceSum3)*1;
                allData.estimate.GuidePrice_Down2__c = Math.round(downPriceSum3)*1;
                allData.estimate.GuidePrice_Up3__c = Math.round(upPriceSum4)*1;
                allData.estimate.GuidePrice_Down3__c = Math.round(downPriceSum4)*1;
            }
        }
        //未找到 id GuidePriceDown5 GuidePriceUp5  -- 该字段移到estimate对象上
        // allData.GuidePriceDown4 = Math.round(downPriceSum1)*1;
        // allData.GuidePriceUp4 = Math.round(upPriceSum1)*1;
        // allData.GuidePriceDown3 = Math.round(downPriceSum3)*1;
        // allData.GuidePriceUp3 = Math.round(upPriceSum3)*1;
        // allData.GuidePriceDown2 = Math.round(downPriceSum4)*1;
        // allData.GuidePriceUp2 = Math.round(upPriceSum4)*1;
        allData.VMProductCountAll = VMProductCountAll;
        var allcount = VMProductCountAll;
        allData.ProductCountAll = ProductCountAll;
        var allcount1 = ProductCountAll;
 
        returnData.checkedAssets = checkedAssets;
        returnData.allData = allData;
        // 报价规则改善 20230309 end
        return returnData;
 
    },
    Blankperiod(startdate,i,LastMContract_Price,Punish,Adjustment_ratio_Upper,Adjustment_ratio_Lower,strMoney,type,LastMContractRecord,checkedAssets,allData,PageDisabled){
        console.log('开始时间='+startdate);
        var  downPrice = 0;
        var  upPrice = 0;
        var today = new Date();
        var  isSeamlessRenew = 0;
        console.log('lastendDate1',checkedAssets[i].rec.Id);
        if(LastMContractRecord == 'VM_Contract'){
           var lastendDate1 = checkedAssets[i].rec ? checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c : '';
        }else{
           var lastendDate1= checkedAssets[i].rec ? checkedAssets[i].rec.CurrentContract_End_Date__c : '';
        }
        // 2023/09/06
        var renewcontractstartdate = allData.renewcontractstartdate;   
        var renewcontractstartdate1 = new Date(renewcontractstartdate);
 
        var Blank_period = checkedAssets[i].mcae.Blank_period__c;
        console.log('lastendDate1',lastendDate1);
        var lastendDate = new Date(lastendDate1);
        var lastendDateAddSix = new Date(lastendDate1);
        lastendDateAddSix.setMonth(lastendDateAddSix.getMonth() + 6);
        console.log('lastendDateAddSix',lastendDateAddSix);
        var lastendDateAddTw = new Date(lastendDate1);
        lastendDateAddTw.setMonth(lastendDateAddTw.getMonth() + 12);
        var lastendDateAddFiv = new Date(lastendDate1);
        lastendDateAddFiv.setDate(lastendDateAddFiv.getDate() + 15);
        console.log('结束时间+15天 lastendDateAddFiv',lastendDateAddFiv);
        // 2023/09/06
        var renewtime = lastendDateAddFiv.getFullYear()+'/'+(lastendDateAddFiv.getMonth()+1)+'/'+lastendDateAddFiv.getDate();
        if (renewcontractstartdate == '' ) {         
            allData.renewcontractstartdate = renewtime;    
            console.log('添加完成');         
        }        
        // del 变量未使用
        var renewcontractstartdate222 = allData.renewcontractstartdate;        
        if (lastendDateAddFiv < renewcontractstartdate1 ) {    
            allData.renewcontractstartdate =   renewtime;      
        }
 
        //add 空指针判断
        if (lastendDate1 && lastendDate1.length !=0) {
            console.log('startdate',startdate.getFullYear()+'-'+startdate.getMonth()+'-'+startdate.getDate());
            if (startdate == null) {
                // 2023/09/06
                 if (today<=lastendDateAddFiv) {
                    Blank_period = '无缝续签';
                 }
                 if (today>lastendDateAddFiv && today<=lastendDateAddSix) {
                    Blank_period = '6个月以内非无缝续签';
                 }
                 if (today>lastendDateAddSix && today<=lastendDateAddTw) {
                    Blank_period = '6个月-12个月';
                 }
                 if (today>lastendDateAddTw) {
                    Blank_period = '12个月以上';
                 }
            }else{
                if (startdate<=lastendDateAddFiv) {
                    Blank_period = '无缝续签';
                 }
                 if (startdate>lastendDateAddFiv && startdate<=lastendDateAddSix) {
                    Blank_period = '6个月以内非无缝续签';
                 }
                 if (startdate>lastendDateAddSix && startdate<=lastendDateAddTw) {
                    Blank_period = '6个月-12个月';
                 }
                 if (startdate>lastendDateAddTw) {
                    Blank_period = '12个月以上';
                 }
            }
            checkedAssets[i].mcae.Blank_period__c = Blank_period;
        }
        console.log('Blank_period',Blank_period);
        var Blank_period1 = Blank_period;
        var aId = checkedAssets[i].recId;
        if (Blank_period1 != '无缝续签' && aId !=null && aId != '') {
            isSeamlessRenew++;
        }
        // 1.实绩连动价格和设备参保定价 逻辑查看
        // 2023/09/15 逻辑调整 取refreshAsset 计算后值 start 
        var b = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Contract_No_F__c : '') : '';
        if(LastMContractRecord == 'VM_Contract'){
            var upPrice1 = checkedAssets[i].mcae.Adjustment_Upper_price__c *1;
            var downPrice1 = checkedAssets[i].mcae.Adjustment_Lower_price__c *1;
        }else{
            if (b != '') {
               var upPrice1 = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
               var downPrice1 = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
            }
        }
        // 2023/09/15 逻辑调整  取refreshAsset 计算后值 end
        // 定价8折
        var downPrice2 = strMoney * 0.8;
        console.log('upPrice1',upPrice1);
 
        upPrice1 = upPrice1.toFixed(2);
        var upPrice2 = strMoney.toFixed(2);
        downPrice1 = downPrice1.toFixed(2);
        downPrice2 = downPrice2.toFixed(2);
        upPrice1 = parseInt(upPrice1);
        upPrice2 = parseInt(upPrice2);
        downPrice1 = parseInt(downPrice1);
        downPrice2 = parseInt(downPrice2);
        if (!Blank_period1) {
            downPrice = downPrice2;
            upPrice = upPrice2;
        }
        if (Blank_period1 && Blank_period1.length!=0 && Blank_period1 == '6个月以内非无缝续签' || Blank_period1 == '无缝续签' ) {
            if (type == 1 &&!PageDisabled) {
                checkedAssets[i].mcae.Adjustment_Lower_price__c = isNaN(downPrice1*1) ? '' : (downPrice1*1).toFixed(2);
                checkedAssets[i].mcae.Adjustment_Upper_price__c = isNaN(upPrice1*1) ? '' : (upPrice1*1).toFixed(2);
            }
             downPrice = downPrice1;
             upPrice = upPrice1;
        }
        console.log('upPrice2',upPrice2);
        console.log('downPrice1',downPrice1);
        console.log('downPrice2',downPrice2);
        console.log('type',type);
        // Blank_period1 != '无缝续签' &&  条件无意义
        if (Blank_period1 == '6个月-12个月') {
            if (downPrice1<downPrice2) {
                if (type == 1  &&!PageDisabled) {
                    checkedAssets[i].mcae.Adjustment_Lower_price__c = isNaN(downPrice2*1) ? '' : (downPrice2*1).toFixed(2);
                    checkedAssets[i].mcae.Adjustment_Upper_price__c = isNaN(upPrice2*1) ? '' : (upPrice2*1).toFixed(2);
                }
                downPrice = downPrice2;
                upPrice = upPrice2;
            }else{
                 if (type == 1  &&!PageDisabled) {
                    checkedAssets[i].mcae.Adjustment_Lower_price__c = isNaN(downPrice1*1) ? '' : (downPrice1*1).toFixed(2);
                    checkedAssets[i].mcae.Adjustment_Upper_price__c = isNaN(upPrice1*1) ? '' : (upPrice1*1).toFixed(2);
                  }
                downPrice = downPrice1;
                upPrice = upPrice1;
            }
        }
        // Blank_period1 != '无缝续签' &&  条件无意义
        if (Blank_period1 == '12个月以上' &&!PageDisabled) {
 
            if (downPrice1<upPrice2) {
                if (type == 1) {
                    checkedAssets[i].mcae.Adjustment_Lower_price__c = isNaN(upPrice2*1) ? '' : (upPrice2*1).toFixed(2);
                    checkedAssets[i].mcae.Adjustment_Upper_price__c = isNaN(upPrice2*1) ? '' : (upPrice2*1).toFixed(2);
                }
                downPrice = upPrice2;
                upPrice = upPrice2;
            }else{
                if (type == 1 &&!PageDisabled) {
                    checkedAssets[i].mcae.Adjustment_Lower_price__c = isNaN(downPrice1*1) ? '' : (downPrice1*1).toFixed(2);
                    checkedAssets[i].mcae.Adjustment_Upper_price__c = isNaN(upPrice1*1) ? '' : (upPrice1*1).toFixed(2);
                }
                downPrice = downPrice1;
                upPrice = upPrice1;
            }
        }
        return downPrice+"/"+upPrice+"/"+isSeamlessRenew;
    },
    checkDiscount(_this,val,allData,IsContractEstiStartDateDisabled,IsContractstartdateDisabled,IsRequestQuotationAmountDisabled,refreshAssetBtn,AgreeRenewTenDisabled,isAgreeRenew) {
        console.log('checkDiscount',val);
        let returnData = {};
 
        //returnData 原始值
        returnData.IsContractEstiStartDateDisabled = IsContractEstiStartDateDisabled;
        returnData.IsContractstartdateDisabled = IsContractstartdateDisabled;
        returnData.IsRequestQuotationAmountDisabled = IsRequestQuotationAmountDisabled;
        returnData.refreshAssetBtn = refreshAssetBtn;
        returnData.AgreeRenewTenDisabled = AgreeRenewTenDisabled;
        returnData.isAgreeRenew = isAgreeRenew;
 
        var alerts = 0;
        // 报价规则改善 20230314 start 
        val = val.replace(",", "");//del lwc 直接数值
        var startime1 =  new Date(allData.Past_Contract_end_day);
        var startime2 = new Date(allData.estimate.Contract_Esti_Start_Date__c);
 
        // gzw add 日期差时间取值造成数据不准问题 20231103修复 start
        var year1 = startime1.getFullYear();
        var month1 = startime1.getMonth();
        var day1 = startime1.getDate();
        month1 = (month1 > 9) ? month1 : ("0" + month1);
        day1 = (day1 < 10) ? ("0" + day1) : day1;
        var startime1 = year1 + "-" + month1 + "-" + day1;
        var year2 = startime2.getFullYear();
        var month2 = startime2.getMonth();
        var day2 = startime2.getDate();
        month2 = (month2 > 9) ? month2 : ("0" + month2);
        day2 = (day2 < 10) ? ("0" + day2) : day2;
        var startime2 = year2 + "-" + month2 + "-" + day2;
        var result = daysBetween(startime1,startime2);
        // var result = (startime2-startime1)/(3600*24*1000);
        // gzw add 日期差时间取值造成数据不准问题 20231103修复 end
        var VMProductCountAll = allData.VMProductCountAll ; 
        var ProductCountAll = allData.ProductCountAll;
        if (VMProductCountAll ==ProductCountAll) {
            result = 0;
        }
        var Is_Blank_period1 =  allData.Is_Blank_period;
        //预测成本率计算 天修理实绩汇总*合同月数*30/申请报价金额
        var MonthlyCostSUM = handleInfo.localParseFloat(allData.estimate.Monthly_Repair_Cost_SUM__c); 
        var months      = handleInfo.localParseFloat(allData.estimate.Contract_Range__c);
        console.log('MonthlyCostSUM',MonthlyCostSUM);
        console.log('months',months);
        var Cost_rate_ForecastF =  ((MonthlyCostSUM*months*30)/(val*0.9))*0.75;
        console.log('Cost_rate_ForecastF',Cost_rate_ForecastF);
        var downprice = allData.estimate.GuidePrice_Down__c; 
        var upprice = allData.estimate.GuidePrice_Up__c;
        var renewTenOFF = allData.estimate.renewTen_OFF__c;
        var AgreerenewTenOFF = allData.estimate.AgreeRenewTen_OFF__c;
        // 2023/09/06 报价规则改善新增      
        var Limit_PriceHidden2 =  allData.isLimitPrice;
        var isFSE = allData.isFSE;
 
        console.log('Is_Blank_period1',Is_Blank_period1);
        console.log('downprice',downprice);
        // console.log('downprice replace',downprice.replace(",", ""));
        console.log('result',result);
        console.log('result localParseFloat',handleInfo.localParseFloat(result));
        if (Is_Blank_period1 == true && (Cost_rate_ForecastF<1) && (0<Cost_rate_ForecastF) && result <=1 && handleInfo.localParseFloat(downprice) <=parseInt(val == undefined ? 0 : val*1)) {
           alerts = 1;
        }
        // gzw 无缝续签标识初始化
        allData.estimate.renewTen_OFF__c = false;
        console.log('alerts',alerts);
        console.log('AgreerenewTenOFF',AgreerenewTenOFF);
        console.log('Limit_PriceHidden2',Limit_PriceHidden2);
 
        //直接取值
        //2023/08/15 新增判断 allData.isLimitPrice 
        if (alerts == 1 && !AgreerenewTenOFF && Limit_PriceHidden2 ==false) {
            // 报价规则改善新增
            if (toast.handleConfirmClick("本单合同无缝续签可以继续申请10%折扣,请确认是否申请,如果申请先联系服务管理部张栩榕、张晶,不申请请点击【取消】")) {
            // allData.estimate.renewTen_OFF__c = true; 注释内容暂不补充
            } else {
            }
        }
        if (AgreerenewTenOFF && alerts == 1) {
            allData.estimate.renewTen_OFF__c = true;
            returnData.isAgreeRenew = true;
            val = val*0.9;
            val = handleInfo.localParseFloat(val);
            val = Math.round(val);
            allData.estimate.Request_quotation_Amount__c = val*1;
            returnData.IsContractEstiStartDateDisabled = true;
            returnData.IsContractstartdateDisabled = true;
            returnData.IsRequestQuotationAmountDisabled = true;
            returnData.refreshAssetBtn = true;
 
            returnData.AgreeRenewTenDisabled = true;
        }else{
        }
        // 报价规则改善 20230314 end
        val = handleInfo.localParseFloat(val);
        val = Math.round(val);
        console.log('checkDiscount val',val);
        allData.estimate.Request_quotation_Amount__c  = val*1;
        //上限合同 20230117 HQL start
        var RequestquotationAmount = val*1;
        var AssetRepairSumPrice    = allData.estimate.Asset_Repair_Sum_Price__c;
        var Limit_Price_Amount = (handleInfo.localParseFloat(AssetRepairSumPrice)+handleInfo.localParseFloat(RequestquotationAmount))*1.3;
        Limit_Price_Amount = Math.round(Limit_Price_Amount);
        //del 未使用变量
        var Limit_Price_AmountOne =  allData.estimate.Limit_Price_Amount__c; 
        var Limit_PriceHidden =  allData.OldLimitPrice;
        allData.estimate.Limit_Price_Amount__c = Limit_Price_Amount;
        var Limit_PriceHidden2 =  allData.isLimitPrice;
        if (Limit_PriceHidden2 == false) {
            allData.estimate.Limit_Price_Amount__c = '';
        }
        var amount = allData.estimate.Limit_Price_Amount__c;
        //上限合同 20230117 HQL end 原js处理
        returnData.allData = allData;
        return returnData;
    }
};
 
 
// Export any function here that u wanna use in another files
export default {
    toast,
    handleInfo,
}
// gzw add 日期差时间取值造成数据不准问题 20231103修复 start
function daysBetween(DateOne,DateTwo)
{    
    var OneMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));   
    var OneDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);   
    var OneYear = DateOne.substring(0,DateOne.indexOf ('-'));   
   
    var TwoMonth = DateTwo.substring(5,DateTwo.lastIndexOf ('-'));   
    var TwoDay = DateTwo.substring(DateTwo.length,DateTwo.lastIndexOf ('-')+1);   
    var TwoYear = DateTwo.substring(0,DateTwo.indexOf ('-'));   
   
    var cha=((Date.parse(OneMonth+'/'+OneDay+'/'+OneYear)- Date.parse(TwoMonth+'/'+TwoDay+'/'+TwoYear))/86400000);    
    return Math.abs(cha);   
}
// gzw add 日期差时间取值造成数据不准问题 20231103修复 end