From cc914d1a68f71cf0b8fe7f1c4bfac9fc1e54e3d8 Mon Sep 17 00:00:00 2001
From: chenjingwu <chenjingwu@prec-tech.com>
Date: 星期二, 16 四月 2024 11:26:10 +0800
Subject: [PATCH] 123

---
 force-app/main/default/lwc/lexNewQuoteEntry/lexNewQuoteEntry.js |  111 +++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 82 insertions(+), 29 deletions(-)

diff --git a/force-app/main/default/lwc/lexNewQuoteEntry/lexNewQuoteEntry.js b/force-app/main/default/lwc/lexNewQuoteEntry/lexNewQuoteEntry.js
index f17d5fc..6f246c3 100644
--- a/force-app/main/default/lwc/lexNewQuoteEntry/lexNewQuoteEntry.js
+++ b/force-app/main/default/lwc/lexNewQuoteEntry/lexNewQuoteEntry.js
@@ -84,7 +84,7 @@
 import selectUpdateFiexedpriceData from '@salesforce/apex/QuoteTrialController.selectUpdateFiexedpriceData';
 import selectUpdateQuoteLineItemData from '@salesforce/apex/QuoteTrialController.selectUpdateQuoteLineItemData';
 import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
-import {yingYanCheck,qwe,lineDown,lineUp,localParseInt,toNum,initDataTableToBeproductConfig,saveEvoluationLogic,oppInfosave,quoLineItemsave,filterNameoptionList,initDataSetProductTablefig,quoteTotalPriceActionLogic,CheckForCost,actState,tStringe,Agent1comput,
+import {ExtendedWarrantyAmountTotalPriceExport,yingYanCheck,qwe,lineDown,lineUp,localParseInt,toNum,initDataTableToBeproductConfig,saveEvoluationLogic,oppInfosave,quoLineItemsave,filterNameoptionList,initDataSetProductTablefig,quoteTotalPriceActionLogic,CheckForCost,actState,tStringe,Agent1comput,
 toNumComma,localParseFloat,NewQcopyLogic,productCompareLogic,bflag,jzProductsearchLogic,additionaljzProductLogic,initDataProductTablefig,checkNMPA,saveQuotel,CheckForListPrice,calGuranteePeriodLogic,EstimationL,checkch,
 additionabuttonLoc,DataStatus,InitializeProductAssignment,PriceStatusUpdateLogic,newQuoteFlagex,calGuranteeAllFieldsLogic,MultiYearWarrantyTotalPriceExport,newQuoteFlagExp,AlertForCFDA,UnitPriceUpdateLogic,nafgExp,flg,errorflgw,
 PrintCustomerNameoptionsvlue,selection_hpExp,options_hpflgExp,initquoassignment,initquoassignmentcopy,salesProfit1Logic,salesCalculation1Logic,salesProfit2Logic,salesCalculation2Logic,SubtotalupdateLogic,alfExp,resultFlag,
@@ -580,6 +580,7 @@
         this.jzDataToBeproduct =[].concat(this.jzDataToBeproduct);
         this.hidden_MultiYearWarrantyTotalPrice = MultiYearWarrantyTotalPriceExport;
         this.quo.MultiYearWarrantyTotalPrice__c = toNumComma(MultiYearWarrantyTotalPriceExport);
+        this.quo.ExtendedWarrantyAmountTotalPrice__c = toNumComma(ExtendedWarrantyAmountTotalPriceExport);
     }
     EstimationListPrice() {
         this.jzDataToBeproduct = EstimationL(this.jzDataToBeproduct,this.quo);
@@ -1454,15 +1455,19 @@
         this.quo.Quote_Adjust_Amount_Page__c = toNumComma(y);
         y=localParseFloat(y);
         var noDiscountPriceTotal = this.hidden_MultiYearWarrantyTotalPrice;
+        var exPriceTotal = this.quo.ExtendedWarrantyAmountTotalPrice__c;
         noDiscountPriceTotal=localParseFloat(noDiscountPriceTotal);
-        this.quo.QuoteTotal_Page__c=toNumComma(y + x + noDiscountPriceTotal);
+        exPriceTotal = localParseFloat(exPriceTotal);
+        this.quo.QuoteTotal_Page__c=toNumComma(y + x + noDiscountPriceTotal + exPriceTotal);
         var z=this.quo.Estimation_List_Price__c;
         var id=this.quoId;
         // if(!id){
             var IsQuoteTrial=this.quo.IsQuoteTrial__c;
             if(!IsQuoteTrial){
                 var mp=this.quo.MultiYearWarrantyTotalPrice__c;
+                var ex =this.ExtendedWarrantyAmountTotalPrice__c;
                 mp=localParseFloat(mp);
+                ex=localParseFloat(ex);
                 var num=this.quo.Quote_Adjust_Calculate__c;
                 num=localParseFloat(num);
                 this.quo.Quote_Adjust_Calculate__c=toNumComma(num);
@@ -1471,7 +1476,7 @@
                 var rh=this.oppInfo.rate_hospital;
                 var ra=this.oppInfo.rate_agency1;
                 this.quo.Dealer_Final_Price_Page__c=toNumComma(z*rh);
-                this.quo.OCM_Agent1_Price_Page__c=this.Saleslet ? toNumComma(z*num*ra+mp) : '';
+                this.quo.OCM_Agent1_Price_Page__c=this.Saleslet ? toNumComma(z*num*ra+mp+ex) : '';
                 this.setOCMAmount();
                 this.calFromContactPrice();
             }
@@ -1660,12 +1665,16 @@
         var data=event.detail.rows;
         console.log('data==>> ' + JSON.stringify(data));
         this.jzDataToBeproduct=onsaveToBeproductLoc(data,this.jzDataToBeproduct);
+        debugger
         if(fagExp){
             this.quo.IsQuoteTrial__c=false;
             this.quoteAgencyTotalPriceAction();
             this.AgencyDiscountCalculation1();
         }
         this.updateNoDiscountPricetotal();
+        // chenjingwu 
+        this.updateExPricetotal()
+        // chenjingwu 
         this.EstimationListPrice();
         this.calUnitPriceTotal();
         this.quoteTotalPrice();
@@ -1689,6 +1698,17 @@
         this.jzDataToBeproduct =[].concat(this.jzDataToBeproduct);
         this.hidden_MultiYearWarrantyTotalPrice=noDiscountPriceTotal;
         this.quo.MultiYearWarrantyTotalPrice__c=toNumComma(noDiscountPriceTotal);
+    }
+    updateExPricetotal() {
+        var ExPricetotal=0;
+        this.jzDataToBeproduct.forEach(jzdtbt=>{
+            var exPrice=jzdtbt.exPrice;
+            exPrice=localParseFloat(exPrice);
+            var Quantity=jzdtbt.Quantity__c;
+            Quantity=localParseFloat(Quantity);
+            ExPricetotal=ExPricetotal + exPrice * Quantity;
+        });
+        this.quo.ExtendedWarrantyAmountTotalPrice__c=toNumComma(ExPricetotal);
     }
     handleRowAction(event){
         const actionName=event.detail.row;
@@ -1779,21 +1799,21 @@
                 console.log(reslut);
                 console.log(this.jzDataToBeproduct);
                 this.jzDataToBeproduct.forEach(item=>{
-                    idList.push(item.pageObject.PricebookEntry.Product2Id);
+                    idList.push(item.pageObject.Id__c);
                 });
                 addOptions({idList: idList}).then(result=>{
                     this.addOptionsLogic(result);
+                    if(quoteLineItem.length!=num){
+                        this.quo.IsQuoteTrial__c=false;
+                    }
+                    this.calPriceAll();
+                    if(errormessage.indexOf('鎴愬姛') >= 0){
+                        this.Alert(errormessage,'success');
+                    }else{
+                        this.Alert(errormessage,'error');
+                    }
+                    this.OnLoading(false);
                 });
-                if(quoteLineItem.length!=num){
-                    this.quo.IsQuoteTrial__c=false;
-                }
-                this.calPriceAll();
-                if(errormessage.indexOf('鎴愬姛') >= 0){
-                    this.Alert(errormessage,'success');
-                }else{
-                    this.Alert(errormessage,'error');
-                }
-                this.OnLoading(false);
             });
             this.cancelsetProduct();
         }
@@ -1830,27 +1850,31 @@
                     var errormessage = tempArr[0];
                     var quoteLineItem = JSON.parse(tempArr[1]);
                     quoteLineItem = InitializeProductAssignment(quoteLineItem);
+                    this.tobeflag=false;
                     this.jzDataToBeproduct = quoteLineItem;
                     // cjw
+                    console.log('xxx');
+                    console.log(this.jzDataToBeproduct);
                     var idList = [];
                     this.jzDataToBeproduct.forEach(item=>{
-                        idList.push(item.pageObject.PricebookEntry.Product2Id);
+                        idList.push(item.pageObject.Id__c);
                     });
                     addOptions({idList: idList}).then(result=>{
                         this.addOptionsLogic(result);
+                        if(quoteLineItem.length!=num){
+                            this.quo.IsQuoteTrial__c = false;
+                        }
+                        this.calPriceAll();
+                        if(errormessage.indexOf('鎴愬姛') >= 0){
+                            this.Alert(errormessage,'success');
+                        }else{
+                            this.Alert(errormessage,'error');
+                        }
+                        
+                        this.OnLoading(false);
+                        this.cancelQuoteExcelImport();
+                        this.tobeflag=true;
                     });
-                    if(quoteLineItem.length!=num){
-                        this.quo.IsQuoteTrial__c = false;
-                    }
-                    this.calPriceAll();
-                    if(errormessage.indexOf('鎴愬姛') >= 0){
-                        this.Alert(errormessage,'success');
-                    }else{
-                        this.Alert(errormessage,'error');
-                    }
-                    
-                    this.OnLoading(false);
-                    this.cancelQuoteExcelImport();
             });
     }
     @track
@@ -1888,7 +1912,7 @@
             var idList = [];
             // cjw
             this.jzDataToBeproduct.forEach(item=>{
-                idList.push(item.pageObject.PricebookEntry.Product2Id);
+                idList.push(item.pageObject.Id__c);
             });
             addOptions({idList: idList}).then(result=>{
                 this.addOptionsLogic(result);
@@ -1913,11 +1937,40 @@
         key.forEach(item=>{
             Setmap.set(item,result[item]);
         });
+        var optionMap = new Map();
+        var map1 = Setmap.get('optionMap');
+        var key1 = Object.keys(map1)
+        key1.forEach(item=>{
+            optionMap.set(item,map1[item]);
+        });
+        var priceMap = new Map();
+        var map2 = Setmap.get('priceMap');
+        var key2 = Object.keys(map2)
+        key2.forEach(item=>{
+            priceMap.set(item,map2[item]);
+        });
+        console.log('loh');
+        console.log(this.jzDataToBeproduct);
         this.jzDataToBeproduct.forEach(item=>{
             if(result){
-                item.Learning_CommunityOptions = Setmap.get(item.pageObject.PricebookEntry.Product2Id);
+                item.Learning_CommunityOptions = optionMap.get(item.pageObject.Id__c);
+                item.multiYearWarrantyList = priceMap.get(item.pageObject.Id__c);
+                if(item.Learning_Community){
+                    item.multiYearWarrantyList.forEach(it=>{
+                        if('' + (it.AgeLimit__c) == item.Learning_Community){
+                            item.exPrice = it.MultiOneYearWarrantyPrice__c;
+                        }
+                    });
+                    if(item.exPrice == null || item.exPrice == '' || item.exPrice == undefined){
+                        item.exPrice = 0;
+                    }
+                }else{
+                    item.Learning_Community = item.multiYearWarrantyList[item.multiYearWarrantyList.length -1].AgeLimit__c;
+                    item.exPrice = item.multiYearWarrantyList[item.multiYearWarrantyList.length -1].MultiOneYearWarrantyPrice__c;
+                }
             }
         });
+        console.log(this.jzDataToBeproduct);
     }
     // cjw
     //鏂板鎶ヤ环浜у搧妯℃�佹鍙栨秷鎸夐挳

--
Gitblit v1.9.1