1
chenjingwu
2024-05-24 ab5a982874f88556b72e02177fa88dedc2d56fe8
force-app/main/default/lwc/lexNewQuoteEntry/lexNexQuoteEntryUtil.js
@@ -4,7 +4,6 @@
export var DataStatus;
export var newQuoteFlagex;
export var MultiYearWarrantyTotalPriceExport;
export var ExtendedWarrantyAmountTotalPriceExport;
export var newQuoteFlagExp;
export var productStatusUpdatedExp;
export var quoExp;
@@ -14,7 +13,6 @@
export var ListPriceTotalExp; 
export var unitPriceTotalExp;
export var errorflg;
export var errorflgw;
export var StrExp;
export var IsQuoteTrialExp;
export var alertExp = '';
@@ -201,42 +199,10 @@
                class:{
                    fieldName:'Nameclass'
                },
                alignment: 'center'
            },
            hideDefaultActions: true,
            initialWidth: 300
        },
        // chenjingwu 3+2多年保修 20240318 start
        {
            label: '延保金额',
            fieldName: 'exPrice',
            // editable: true,
            cellAttributes: {
                class: {},
                alignment: 'right',
            },
            type: 'number',
            typeAttributes: {
                minimumFractionDigits: '2',
                maximumFractionDigits: '2'
            },
            hideDefaultActions: true,
            initialWidth: 150
        },
        {
            label: '延保年限',
            fieldName: 'Learning_Community',
            type: 'picklistColumn',
            editable: true,
            typeAttributes: {
                placeholder:'--无--',
                options:{fieldName: 'Learning_CommunityOptions'},
                value: { fieldName: 'Learning_Community' }
            },
            hideDefaultActions: true,
            initialWidth: 300
        }
        // chenjingwu 3+2多年保修 20240318 end
        
    ],
    sortInterfaces: false,
@@ -696,7 +662,6 @@
    maxLineNo += 1; 
    // var newvalueList = [];
    selectvlue.forEach(selectv=>{
        console.log('123');
        debugger
        alertExp = '';
        // var newvalue = {...{},...selectv};
@@ -773,8 +738,7 @@
    } 
function SetProductId(lineno,selectv){
    console.log(selectv);
    //fy DB202312538864 2024.02.02 start
   //fy DB202312538864 2024.02.02 start
    // var Product2 = {};
    // var PricebookEntry = {Product2:Product2};
    // var pageObject = {};
@@ -810,22 +774,13 @@
    var Intra_Trade_Gurantee_USD = selectv.Product2.Intra_Trade_Foreign_RMB__c;
    var Intra_Trade_Service_USD = selectv.Product2.NoDiscount_Foreign__c;
    var Maintenance_Price_Year_USD = selectv.Product2.Repair_Contract_USD__c;
    //fy DB202312538864 2024.02.02 start
    // addobj.PricebookEntry.Product2.StorageStatus__c = StorageStatus__c;
    addobj.pageObject.PricebookEntry.Product2.StorageStatus__c = StorageStatus__c;
    addobj.pageObject.PricebookEntry.Id = PricebookEntryId;
    addobj.pageObject.PricebookEntry.Product2Id = Product2Id;
    addobj.pageObject.Asset_Model_No__c = Asset_Model_No__c;
    addobj.pageObject.PricebookEntry.Product2.LastbuyProductFLG__c = selectv.Product2.LastbuyProductFLG__c;
    addobj.pageObject.PricebookEntry.Product2.whetherOldCode_PrePro__c = selectv.Product2.whetherOldCode_PrePro__c;
    //fy DB202312538864 2024.02.02 end
    // chenijngwu 20240319 start
    // chenijngwu 20240319 SP主机 start
    addobj.pageObject.PricebookEntry.Product2.ProductCategory__c = selectv.Product2.ProductCategory__c;
    if(addobj.pageObject.PricebookEntry.Product2.ProductCategory__c == 'SP主机'){
        addobj.SPAssistantFlag = true;
    }
    // chenijngwu 20240319 end
    // chenijngwu 20240319 SP主机 end
    addobj.PricebookEntry.Product2.StorageStatus__c = StorageStatus__c;
    addobj.StorageStatus = StorageStatus__c;
    addobj.lineNo = parseInt(lineno);
    addobj.Asset_Model = Asset_Model_No__c;
@@ -1110,38 +1065,18 @@
    debugger
    console.warn(JSON.stringify(quoteLineItem));
    quoteLineItem.forEach(quotltiem=>{
        // chenjingwu 3+2 start
        // quotltiem.Learning_CommunityOptions =  [
        //     { label: '--无--', value: '' },
        //     { label: '主机', value: '主机' },
        //     { label: '镜子', value: '镜子' },
        //     { label: '洗消机', value: '洗消机' },
        //     { label: '小镜种', value: '小镜种' },
        //     { label: '能量', value: '能量' },
        //     { label: '光源', value: '光源' },
        //     { label: '其他', value: '其他' }
        // ];
        // chenjingwu 3+2 end
        //fy DB202312538864 2024.02.02 start
        if(quotltiem.PricebookEntry === undefined){
          quotltiem.PricebookEntry = {Product2:{}};
        }else{
            if(quotltiem.PricebookEntry.Product2 === undefined){
                quotltiem.PricebookEntry.Product2 = {};
            }
        }
        if(quotltiem.lastbuyProductFLGc !== undefined && quotltiem.lastbuyProductFLGc !== null){
            quotltiem.PricebookEntry.Product2.LastbuyProductFLG__c = quotltiem.lastbuyProductFLGc;
        }
        // chenjingwu 20240411 start
        if(quotltiem.PricebookEntry === undefined){
            quotltiem.PricebookEntry = {Product2:{}};
          }else{
              if(quotltiem.PricebookEntry.Product2 === undefined){
                  quotltiem.PricebookEntry.Product2 = {};
              }
          }
        if(quotltiem.ProductCategory !== undefined && quotltiem.ProductCategory !== null){
            quotltiem.PricebookEntry.Product2.ProductCategory__c = quotltiem.ProductCategory;
        }
         // chenjingwu 20240411 end
        if(quotltiem.whetherOldCode_PreProc !== undefined && quotltiem.whetherOldCode_PreProc !== null){
            quotltiem.PricebookEntry.Product2.whetherOldCode_PrePro__c = quotltiem.whetherOldCode_PreProc;
        }
        //fy DB202312538864 2024.02.02 end
        // chenjingwu 20240411 end
        quotltiem.Quantity__c = quotltiem.pageObject.Quantity__c;
        quotltiem.UnitPrice_Page__c = quotltiem.pageObject.UnitPrice_Page__c;
        // quotltiem.UnitPrice_Page__c = toNumComma(quotltiem.UnitPrice_Page__c);
@@ -1276,7 +1211,6 @@
        contractmultiYearWarranty = quo.multiYearWarranty__c;
    }
    var MultiYearWarrantyTotalPrice__c = 0.00;
    var  ExtendedWarrantyAmountTotalPrice__c = 0.00;
    jzDataToBeproduct.forEach(jzdtbt=>{
        var GuranteeType =jzdtbt.pageObject.GuranteeType__c;
        // 保修类型
@@ -1310,7 +1244,6 @@
            warrantyType = '市场多年保修';
            var Quantity =jzdtbt.Quantity__c;
            MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c + localParseFloat(ServicePrice) * localParseFloat(Quantity);
            ExtendedWarrantyAmountTotalPrice__c = ExtendedWarrantyAmountTotalPrice__c + localParseFloat(jzdtbt.exPrice) * localParseFloat(Quantity);
            NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity);
        }
        else if (GuranteeType == '市场' && contractmultiYearWarranty && CanNotCancelledGurantee) {
@@ -1321,7 +1254,6 @@
            // 数量
            var Quantity = jzdtbt.Quantity__c;
            MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c + localParseFloat(ServicePrice) * localParseFloat(Quantity);
            ExtendedWarrantyAmountTotalPrice__c = ExtendedWarrantyAmountTotalPrice__c + localParseFloat(jzdtbt.exPrice) * localParseFloat(Quantity);
            NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity);
        }
        else if (GuranteeType == '市场') {
@@ -1394,7 +1326,6 @@
    });
    MultiYearWarrantyTotalPriceExport = MultiYearWarrantyTotalPrice__c;
    ExtendedWarrantyAmountTotalPriceExport= ExtendedWarrantyAmountTotalPrice__c;
    return jzDataToBeproduct;
}
export function initQuoteLineItemcheck(quoteLineItem,productStatusUpdated){
@@ -1889,9 +1820,12 @@
    jzDataToBeproduct.forEach(jzdtbt=>{
        // 保修
        var multiYearWarranty = true;
        if (jzdtbt.multiYearWarranty__c) {
            multiYearWarranty = jzdtbt.multiYearWarranty__c;
        }
        //fy 3+2项目发现的问题0425 satrt
        // if (jzdtbt.multiYearWarranty__c) {
            if (jzdtbt.multiYearWarranty__c !== undefined) {
                //fy 3+2项目发现的问题0425 end
                    multiYearWarranty = jzdtbt.multiYearWarranty__c;
                }
        // 保修类型
        var warrantyType = jzdtbt.warrantyType__c;
        // 产品保修类型
@@ -1929,6 +1863,7 @@
}
export function PrintCustomerNameoptionsvlue(options_hp,selection_hp,quo,options_hpflg,accs){
    if (JSON.stringify(accs) != "{}" && JSON.stringify(accs) != "[]") {
        debugger
        if (accs[0].Name) {
            var options_hpvalue = {};
            options_hpvalue.label = accs[0].Name;
@@ -2193,7 +2128,7 @@
    var fag = false;
    data.forEach(item=>{
        var key = Number(item.lineNo);
        var value = {Quantity__c:'',UnitPrice_Page__c:'',Learning_Community:''}
        var value = {Quantity__c:'',UnitPrice_Page__c:''}
        if(item.Quantity__c != undefined){
            value.Quantity__c = item.Quantity__c;
            fag = true;
@@ -2201,13 +2136,10 @@
        if(item.UnitPrice_Page__c != undefined){
            value.UnitPrice_Page__c = item.UnitPrice_Page__c;
        }
        if(item.Learning_Community != undefined){
            value.Learning_Community = item.Learning_Community;
        }
        dataMap.set(key,value);
    });
    jzDataToBeproduct.forEach(jzdtbt=>{
        var x, y, z, c ,e;
        var x, y, z, c;
        if(dataMap.has(jzdtbt.lineNo)){
            var datavaue = dataMap.get(jzdtbt.lineNo);
            if(datavaue.Quantity__c){
@@ -2217,24 +2149,9 @@
                // jzdtbt.UnitPrice_Page__c = toNumComma(datavaue.UnitPrice_Page__c);
                jzdtbt.UnitPrice_Page__c = datavaue.UnitPrice_Page__c;
            }
            console.log("saf");
            console.log(jzdtbt);
            if(datavaue.Learning_Community){
                jzdtbt.Learning_Community = datavaue.Learning_Community;
                jzdtbt.multiYearWarrantyList.forEach(item=>{
                    if('' + (item.AgeLimit__c) == jzdtbt.Learning_Community){
                        jzdtbt.exPrice = item.MultiOneYearWarrantyPrice__c;
                    }
                });
                if(jzdtbt.exPrice == null || jzdtbt.exPrice == '' || jzdtbt.exPrice == undefined){
                    jzdtbt.exPrice = 0;
                }
            }
            console.log("saf");
            x = localParseInt(jzdtbt.Quantity__c);
            y = localParseFloat(jzdtbt.UnitPrice_Page__c);
            c = localParseFloat(jzdtbt.Cost_c);
            e = localParseFloat(jzdtbt.exPrice);
            z = x * y;
            // jzdtbt.Subtotal__c = toNumComma(z)
            jzdtbt.Subtotal__c = z
@@ -2291,10 +2208,6 @@
        errorflg = true;
        alertExp = Setmap.get('errormessage');
    }else{
        if(Setmap.has('warn')){
            errorflgw = true;
            alertExp = Setmap.get('warn');
        }
        if(Setmap.has('quoId')){
            quoId = Setmap.get('quoId');
        }
@@ -2635,7 +2548,9 @@
}
export function  checkch(jzDataToBeproduct){
    var activities = [];
    // sp主机 cjw start
    var flag = false;
    // sp主机 cjw start
    jzDataToBeproduct.forEach(jzdtbt=>{
        var lineId = jzdtbt.pageObject.PricebookEntryId;
        if (lineId) {
@@ -2650,18 +2565,22 @@
            //DB202312560765 you 否有EndoRapid资质检查 start 
            item.IFEndoRapidFlag = jzdtbt.IFEndoRapidFlag;
            //DB202312560765 you 否有EndoRapid资质检查 end
            // sp主机 cjw start
            var qwe = jzdtbt.PricebookEntry ? jzdtbt.PricebookEntry.Product2.ProductCategory__c : jzdtbt.pageObject.PricebookEntry.Product2.ProductCategory__c;
            if(qwe == 'SP主机'){
                item.SPAssistantFlag = true;
                flag = true;
            }
            // sp主机 cjw start
            activities.push(item);
        }
    });
    // sp主机 cjw start
    var maps = new Map();
    maps.set('activities',activities);
    maps.set('flag',flag);
    return maps;
    // sp主机 cjw end
}
export function  Agent1comput(quo,Saleslet,oppInfo){
    var z = quo.Estimation_List_Price__c;