import { LightningElement, track } from 'lwc'; //引入后台方法 import GetPromotionDefalut from '@salesforce/apex/QuoteTrialController.GetPromotionDefalut'; import GetPromotionPromotionSearch from '@salesforce/apex/QuoteTrialController.GetPromotionPromotionSearch'; import GetNormalProductSearch from '@salesforce/apex/QuoteTrialController.GetNormalProductSearch'; import GetAuthorizerSearch from '@salesforce/apex/QuoteTrialController.GetAuthorizerSearch'; import GetSearchProductById from '@salesforce/apex/QuoteTrialController.GetSearchProductById'; import saveAllDataProduct from '@salesforce/apex/QuoteTrialController.saveAllDataProduct'; import GetParamToId from '@salesforce/apex/QuoteTrialController.GetParamToId'; import SelectAllDataProduct from '@salesforce/apex/QuoteTrialController.selectAllDataProduct'; import SelectAllDataDiscount from '@salesforce/apex/QuoteTrialController.selectAllDataDiscount'; import GetQuoteData from '@salesforce/apex/QuoteTrialController.GetQuoteData'; import GetAgencyRName from '@salesforce/apex/QuoteTrialController.GetAgencyRName'; import selectUpdateFiexedpriceData from '@salesforce/apex/QuoteTrialController.selectUpdateFiexedpriceData'; import selectUpdateQuoteLineItemData from '@salesforce/apex/QuoteTrialController.selectUpdateQuoteLineItemData'; import ClipboardJS from '@salesforce/resourceUrl/clipboardminjs'; import Please_Save_Quote from '@salesforce/label/c.Please_Save_Quote'; import Check_Your_Clipboard from '@salesforce/label/c.Check_Your_Clipboard'; import { arrTempsss, arrProductTempsss, initDataTableProduct2, initDataTable2, initSearchForm2, initDataTableFix2, initSearchFormFix2, getQueryVariable, ChangeFiexedData, GetUUID, initDataTableDefault2, initSearchFormDefalt2, initSearchFormFixedPrice2, initDataTableFixedPrice2, initSearchFormDiscount2, initDataTableDiscount2, initSearchFormSpecial2, initDataTableSpecial2, initSearchFormOtherData2, initDataTableOtherData2, initSearchFormCommonly2, initDataTableCommonly2, ConsolidationScheme, MergeProducts, ProductAssignmentSelect, ProductSelected, UnselectedScheme, SelectedScheme, commonlyDiscountLogic, PriceConsolidation, contributingDiscountLogic, ReplacementUnitPriceLogic, ConsolidatedDiscountDetailsLogic, ConsolidatedDiscountPolicyLogic, partPromotionSchemeLogical, partGeneralDiscountLogical, ComputationalLogic, addOfferLogic, ReverseCalculationModifyDiscountLogic, HeTongPriceComputeLogic, InverseCalculationTiShi, ContractPriceComputeLogic, SpecialPriceComputeReverse, GeneralDiscountContractSummaryLogic, SpecialSavesChangePartLogic, NewDefaultDatass, AddProductDatass, jzDataFixedPriceTemps, jzDataDiscountTemps, updatesNumsLogic, IfCopyProperties, PathJump, ContractPriceComputeReverse, copyLogic, updateCDLogic, DeftCopyQtyLists, countListAndNodLogic } from "./quoteTrialUtil.js"; export default class Test02 extends LightningElement { //全局加载 IsLoading = false; //加载的标识 //加载提示框 OnLoading(flag) { this.IsLoading = flag; } label = { Please_Save_Quote, Check_Your_Clipboard }; //价格政策表单开关标识符 jzDataTableFixedPriceIsShow = false; //折扣政策表单开关 jzDataTableDiscountIsShow = false; //报价Decied后只读标识符,并控制按钮是否隐藏 buttonIsShow = false; // ===============通用的方法 ==================== //获取报价试算页面地址栏中的报价Id ParamIdStr = ''; //页面初始化加载数据 ScreenWidth = '' connectedCallback() { var paramId = getQueryVariable('Id'); if (paramId == null || paramId == '') { return; } this.ParamIdStr = paramId; GetParamToId({ Param: paramId }).then(result => { if (result) { console.warn("ID OK"); } }) this.ScreenWidth = "height:" + (window.screen.availHeight - 120) + "px;overflow:scroll;"; //加载数据 this.OnLoading(true); setTimeout(() => { this.ItmeOutFn(); }, 1000); this.OnLoadSavesDatas(); this.OnLoadQuoteData(this.ParamIdStr); var event = { page: 1, pageLimit: 10, search: "", sortOrder: "asc", sortPlus: undefined, fag: true }; setTimeout(() => { this.getTableDataFix(event); this.getTableData(event); }, 1000); } //检查保存数据是否改变 ItmeOutFn() { this.OnLoading(false); if (this.Complate) { this.Alert("保存数据发生改变,已加载最新数据!", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); } } //加载报价数据 QuoteData = []; OnLoadQuoteData(idStr) { //idStr 报价id GetQuoteData({ QuoteID: idStr }).then(result => { var responseObj = JSON.parse(result); this.QuoteData = responseObj; if(this.QuoteData[0].Dealer_Final_Price_F__c==undefined||this.QuoteData[0].Dealer_Final_Price_F__c==''){ this.QuoteData[0].Dealer_Final_Price_F__c=0 } if(this.QuoteData[0].Agent1_Agent2_Price__c==undefined||this.QuoteData[0].Agent1_Agent2_Price__c==''){ this.QuoteData[0].Agent1_Agent2_Price__c=null; } debugger if (this.QuoteData[0].Quote_Decision__c != "√") { this.buttonIsShow = true; this.initDataTableFixedPrice.columns[7].editable = true; this.initDataTableFixedPrice.columns[10].editable = true; this.initDataTableDiscount.columns[2].editable = true; this.initDataTableDiscount.columns[3].editable = true; this.initDataTableDiscount.columns[4].editable = true; this.initDataTableDiscount.columns[5].editable = true; this.initDataTableOtherData.columns[3].editable = true; this.initDataTableCommonly.columns[3].editable = true; } this.jzDataTableFixedPriceIsShow = true; this.jzDataTableDiscountIsShow = true; }) } OnLoadProduct = []; //未选择产品 OnLoadSaveProduct = []; //已选择产品 OnLoadDiscount = []; //折扣政策 OnLoadFixDiscount = []; //价格政策 flagall = false; //加载保存的数据 OnLoadSavesDatas() { //获取产品数据 SelectAllDataDiscount({ ParamIdStr: this.ParamIdStr }).then(result => { result.forEach(item => { //item已选产品查询的结果的一个对象 if (item.ismatch__c == "0") { //待选产品数据变化字段赋值 item = ProductAssignmentSelect(item); this.OnLoadProduct.push(item); } else if (item.ismatch__c == "1") { //已选产品数据变化字段赋值 item = ProductSelected(item); this.OnLoadSaveProduct.push(item); } }) // var arrss = [...[], ...this.OnLoadSaveProduct];//20230214 var arrss = [].concat(this.OnLoadSaveProduct);//20230214 //合并上一次试算的报价行 this.addOffer(arrss); //处理报价数据改动后试算界面的变化 this.comparisonUniqueKey(); if (this.OnLoadProduct != undefined && this.OnLoadProduct.length > 0) { this.flagall = true; this.jzDataDefault = this.OnLoadProduct; //更新数据 UpdateBy 2021 06 29 if (this.jzDataDefault != undefined && this.jzDataDefault.length > 0) { this.UpdateSaveDataQuoteLineItemSelectByID(0); } } if (this.OnLoadSaveProduct != undefined && this.OnLoadSaveProduct.length > 0) { this.flagall = true; this.jzDataProduct = this.OnLoadSaveProduct; //更新数据 UpdateBy 2021 06 29 if (this.jzDataProduct != undefined && this.jzDataProduct.length > 0) { this.UpdateSaveDataQuoteLineItemSelectByID(1); } //TODU 这里的逻辑需要重新计算 this.updateIdStr("1"); //合同价格汇总 this.ContractPriceCompute(); } }) //获取 折扣方案数据 UpdateBy 2021 06 29 SelectAllDataProduct({ ParamIdStr: this.ParamIdStr }).then(result => { //已选方案表中查询的数据 result.forEach(items => { if (items.typess__c == "折扣政策") { //折扣方案数据变化字段赋值 items = UnselectedScheme(items); this.OnLoadDiscount.push(items); } else if (items.typess__c == "价格政策") { //价格方案数据变化字段赋值 items = SelectedScheme(items) this.OnLoadFixDiscount.push(items); } }) //处理报价数据改动后试算界面的变化 this.comparisonUniqueKey(); if (this.OnLoadFixDiscount != undefined && this.OnLoadFixDiscount.length > 0) { this.jzDataFixedPrice = this.OnLoadFixDiscount; // this.updateIdStr("3"); //更新数据 UpdateBy 2021 06 29 if (this.jzDataFixedPrice != undefined && this.jzDataFixedPrice.length > 0) { this.UpdateSaveDataFixedPriceSelectByID(); } } if (this.OnLoadDiscount != undefined && this.OnLoadDiscount.length > 0) { this.jzDataDiscount = this.OnLoadDiscount; this.updateIdStr("2"); } }) } //合并上一次的报价行 lastQuotation = []; addOffer(TrialLine) { // this.lastQuotation = [...[], ...addOfferLogic(TrialLine)]; //合并上一次的报价行的逻辑//20230214 this.lastQuotation = [].concat(addOfferLogic(TrialLine));//20230214 } Complate = false; //从数据库更新已保存的数据 方案 UpdateBy 2021 06 29 UpdateSaveDataFixedPriceSelectByID() { var idArr = []; this.jzDataFixedPrice.forEach(item => { //价格政策集合 idArr.push(item.Id); }) selectUpdateFiexedpriceData({ ProId: idArr }).then(result => { //促销方案主数据 var newArr = []; this.jzDataFixedPrice.forEach(dp => { //价格政策集合 var temp = { ...{}, ...dp }; result.forEach(item => { if (item.Id == temp.Id) { var keys = Object.keys(temp); keys.forEach(k => { var flag = ChangeFiexedData(k); if (flag && item[k] != undefined && item[k] != temp[k]) { temp[k] = item[k]; this.Complate = true; } }) } }) newArr.push(temp); }) this.jzDataFixedPrice = newArr; this.updateIdStr("3"); }) } //产品需要更新的字段 ChangeProductData(key) { var keyArr = ['']; var flag = false; keyArr.forEach(item => { if (item == key) { flag = true; } }) return flag; } //从数据库更新已保存的数据 产品 UpdateBy 2021 06 29 UpdateSaveDataQuoteLineItemSelectByID(flag) { //flag 识别数字 // flag 0 默认产品 flag 1 已选产品 if (flag == 0) { var idArr = []; this.jzDataDefault.forEach(item => { //待选产品 idArr.push(item.QuiteLineitem__c); }) selectUpdateQuoteLineItemData({ ItemId: idArr }).then(result => { //报价行项目主数据 var newArr = []; this.jzDataDefault.forEach(dp => { //待选产品 var temp = { ...{}, ...dp }; result.forEach(item => { if (item.Id == temp.QuiteLineitem__c) { var keys = Object.keys(temp); keys.forEach(k => { var flag = this.ChangeProductData(k); if (flag && item[k] != undefined && item[k] != temp[k]) { this.Complate = true; temp[k] = item[k]; } }) } }) newArr.push(temp); }) this.jzDataDefault = newArr; }) } if (flag == 1) { var idArrPro = []; this.jzDataProduct.forEach(item => { //产品明细 idArrPro.push(item.QuiteLineitem__c); }) selectUpdateQuoteLineItemData({ ItemId: idArrPro }).then(result => { //报价行项目主数据 var newArr = []; this.jzDataProduct.forEach(dp => { //产品明细 var temp = { ...{}, ...dp }; result.forEach(item => { if (item.Id == temp.QuiteLineitem__c) { var keys = Object.keys(temp); keys.forEach(k => { var flag = this.ChangeProductData(k); if (flag && item[k] != undefined && item[k] != temp[k]) { this.Complate = true; temp[k] = item[k]; } }) } }) newArr.push(temp); }) this.jzDataProduct = newArr; //解决删除样式不更新问题 this.updateIdStr("1"); //合同价格汇总 this.ContractPriceCompute(); }) } } // ==== 特约与一般折扣添加 价格= jzDataFixedPrice 折扣=jzDataDiscount 已选择的= jzDataProduct //折扣政策匹配规则 SpecialSavesChange(SaveName, SelectedData, IdStr, CompareId) { //SelectedData 选中的数据 IdStr 选中的数据Id CompareId 方案中用到的uuid var DefalutQuantity = 0; var jzDataDefaultList = this.jzDataDefault//待选产品 var jzDataDiscountList = this.jzDataDiscount//折扣政策 var newDicountData = []; newDicountData=SpecialSavesChangePartLogic(jzDataDefaultList,SaveName, SelectedData, IdStr, CompareId,DefalutQuantity,newDicountData,jzDataDiscountList); this.jzDataDefault = NewDefaultDatass; // this.jzDataProduct = [...this.jzDataProduct, ...AddProductDatass]; //产品明细//20230213 this.jzDataProduct =this.jzDataProduct.concat(AddProductDatass);//20230213 console.warn('newDicountData'+ newDicountData[0].Id); console.warn('AddProductDatass'+AddProductDatass[0]); console.warn('this.jzDataProduct'+this.jzDataProduct[0]); //合同价格汇总 this.ContractPriceCompute(); this.jzDataDiscount = newDicountData; } //价格政策匹配 //idStr 选中的数据ID jzDataProductParam 选中的数据对象 TypeName 方案类型 arrData 选中的数据集合 GetSearchProductByIdFn(idStr, jzDataProductParam, TypeName, jzDataDefaultToTemps, arrData, isShow = true) { //dddd var SeachData = { SearchId: idStr }; GetSearchProductById(SeachData).then(result => { var tempObject = { ...{}, ...jzDataProductParam } jzDataProductParam = this.countListAndNod(tempObject, result); // arrData = [...[], jzDataProductParam];//20230214 arrData = [].concat(jzDataProductParam);//20230214 //返回数据比较规则 this.CompareData(result, idStr, jzDataProductParam, TypeName, jzDataDefaultToTemps, arrData, isShow); }) } //计算listPrice的和以及nod和 //item 选中的对象 result 查出的方案关联的产品 countListAndNod(item, result) { var ifTrade = this.QuoteData[0].Opportunity.Trade__c; //内外贸信息 var copydate=this.jzDataDefaultCopy; var DeftCopyQtyList = this.jzDataDefaultCopyQuantityList; //计算list和nod合计逻辑 item=countListAndNodLogic(ifTrade,copydate,item,result,DeftCopyQtyList); this.jzDataDefaultCopyQuantityList=DeftCopyQtyLists; var arr = { ...{}, ...item }; return arr; } //匹配价格政策时数据比较规则 //list 查出的方案关联的产品 idStr 选中的数据ID jzDataProductParam 选中的数据对象 TypeName 方案类型 arrData 选中的数据集合 isShow 识别符 CompareData(list, idStr, jzDataProductParam, TypeName, jzDataDefaultToTemps, arrData, isShow) { var isChange = false; var TempsJzData = [] // TempsJzData = [...[], ...this.jzDataDefault]; //待选产品//20230214 TempsJzData = [].concat(this.jzDataDefault);//20230214 var TempsJzDataToCompare = [] TempsJzData.forEach(item => { list.forEach(element => { //促销方案主数据关联产品 if (element.Asset_Model_No__c == item.Product2.MDM_Model_No__c) { if (item.Quantity >= element.Quantity__c) { isChange = true; let CompareTemp = { item: item, element: element } TempsJzDataToCompare.push(CompareTemp); } } }); }) //add 0602 var CheckMinNum = 0; var newTempsJzDataToCompare = [] TempsJzDataToCompare.forEach(item => { //符合规则的产品 var intNum = parseInt(item.item.Quantity / item.element.Quantity__c); if (CheckMinNum == 0) { CheckMinNum = intNum; } if (intNum < CheckMinNum) { CheckMinNum = intNum; } }) TempsJzDataToCompare.forEach(item => { var newItem = { ...{}, ...item.item }; var newElement = { ...{}, ...item.element }; newItem.Quantity = item.element.Quantity__c * CheckMinNum; var newObj = {}; newObj.item = newItem; newObj.element = newElement; newTempsJzDataToCompare.push(newObj); }) // TempsJzDataToCompare = [...[], ...newTempsJzDataToCompare];//20230214 TempsJzDataToCompare = [].concat(newTempsJzDataToCompare);//20230214 //End if (TempsJzDataToCompare.length == list.length&&list.length!=0) { TempsJzDataToCompare.forEach(TempsItems => { this.ComparePushData(TempsItems.item.Quantity, TempsItems.element.Quantity__c, TempsItems.element.Asset_Model_No__c, idStr, jzDataProductParam, TypeName); }); //判断是否显示 提示框 if (isShow) { if (this.ifqianpi) { this.Alert("促销方案选择完成", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); } } } else { if (isShow) { if (this.ifqianpi) { this.Alert("促销方案不满足,请重新选择", true, true); } } return; } if (isChange) { this.ChangeNumZeroTrueChanges(); } var temps = this.CompareFullData; //添加 this.UpdateJZData(arrData); //更新次数 this.updatesNums(); //合并重复价格政策方案 // var jzarr = [...[], ...this.jzDataFixedPrice];//20230214 var jzarr = [].concat(this.jzDataFixedPrice);//20230214 this.MergeDuplicateSchemes(jzarr); //保存最大次数 this.savecount(idStr); //计算价格 this.ComputeData(idStr, '价格政策'); } //合并重复价格政策方案 MergeDuplicateSchemes(SchemeSet) { var a = this.CompareFullData; var CompareFullDataedit = []; var Setmap = new Map(); var arr = []; var arr2 = SchemeSet; arr2.forEach(arrs => { var object = {}; if (Setmap.has(arrs.Id)) { object = { ...{}, ...Setmap.get(arrs.Id) }; object.Counts = object.Counts + arrs.Counts; object.determine = ''; a.forEach(editnum => { if (editnum.Id == object.Id) { editnum.num = object.Counts; CompareFullDataedit.push(editnum); } else { CompareFullDataedit.push(editnum); } }); // this.CompareFullData = [...[], ...CompareFullDataedit];//20230214 this.CompareFullData = [].concat(CompareFullDataedit);//20230214 Setmap.set(arrs.Id, object); } else { object = { ...{}, ...arrs }; Setmap.set(arrs.Id, object); } }); for (let [k, v] of Setmap) { arr.push(v); } // this.jzDataFixedPrice = [...[], ...arr]//20230214 this.jzDataFixedPrice = [].concat(arr);//20230214 this.ConsolidationProgramProducts(arr); } //归并相同价格政策方案的产品 ConsolidationProgramProducts(arrSchemes) { // var jzdataList = [...[], ...this.jzDataProduct];//20230214 var jzdataList = [].concat(this.jzDataProduct);//20230214 this.jzDataProduct = PriceConsolidation(arrSchemes, jzdataList); } //保存最大次数 savecount(idStr) { //idStr 选中的数据ID var arr = [] this.jzDataFixedPrice.forEach(item => { //价格政策 if (idStr == item.Id) { item.maxCounts = item.Counts arr.push(item); } else { arr.push(item); } }); this.jzDataFixedPrice = arr; } //替换listprice单价 ReplacementUnitPrice() { var ifTrade = this.QuoteData[0].Opportunity.Trade__c; //内外贸 // var arr = [...[], ...this.jzDataProduct];//20230214 var arr = [].concat(this.jzDataProduct);//20230214 // this.jzDataProduct = [...[], ...ReplacementUnitPriceLogic(arr, ifTrade)]; //替换listprice单价逻辑//20230214 this.jzDataProduct = [].concat(ReplacementUnitPriceLogic(arr, ifTrade));//20230214 //合同价格汇总 this.ContractPriceCompute(); } //计算价格政策价格 ComputeData(id, category) { //id 选中的数据ID category 方案类型 //调用替换listprice单价 this.ReplacementUnitPrice(); //数据 this.updateIdStr("3"); var arrTemp = this.jzDataFixedPrice; // id 价格政策 this.updateIdStr("1"); var arrProductTemp = this.jzDataProduct; // PromotionId 产品明细 // this.updateIdStr("2"); // var arrTemp1 = this.jzDataDiscount; //折扣政策 var arrTemp2 = this.jzDataDefault; //待选产品 if (category == '价格政策') { arrTemp.forEach(item => { // item价格政策 if (id == item.Id) { item.Total = item.Counts * item.Price_CNY__c; item.sumNoDiscountTotal = item.sumNoDiscount * item.Counts; //计算促销总价&& item.HeTongTotal == undefined if (item.Price_CNY__c != undefined) { if (item.determine != '改过') { if (item.if_Contain_Nod__c) { item.HeTongTotal = item.Total; } else { item.HeTongTotal = item.Total + item.sumNoDiscountTotal; } } } //计算选择促销政策的经销商单价和小计 var PromotionHeadRecordId = item.recordTypeName__c; if (PromotionHeadRecordId == "Promotion") { //促销方案 this.newArrsTemp3 = []; //需要计算的产品明细的数据 this.newArrsTemp4 = []; //不需要计算的产品明细的数据 var newArrsTemp5 = []; var newArrsTemp6 = []; arrProductTemp.forEach(itemsss => { //itemsss产品明细 if (itemsss.PromotionId == item.Id) { if (item.determine == '改过') { var flag = true; var b = this.jzDataDefaultCopyQuantityList; //获取方案中的产品数量 arrTemp2.forEach(datedefault => { //datedefault待选产品 var quantity = 0; if (datedefault.Id == itemsss.Id) { b.forEach(iem => { //iem方案中的产品数量 if (iem.Asset_Model_No__c == datedefault.Product2.MDM_Model_No__c && iem.Id_H == item.PromotionNo__c) { quantity = (itemsss.Quantity - iem.Quantity__c__c * item.Counts) + datedefault.Quantity; datedefault.Quantity = quantity; itemsss.Quantity = iem.Quantity__c__c * item.Counts; } }); flag = false; } }); if (flag) { this.jzDataDefaultCopy.forEach(add => { //add报价行项目主数据 var quantity = 0; if (add.Id == itemsss.Id) { b.forEach(iems => { //iems方案关联产品数量 if (iems.Asset_Model_No__c == add.Product2.MDM_Model_No__c && iems.Id_H == item.PromotionNo__c) { quantity = itemsss.Quantity - iems.Quantity__c__c * item.Counts; add.Quantity = quantity; itemsss.Quantity = iems.Quantity__c__c * item.Counts; arrTemp2.push(add); } }); flag = true; } }); } } itemsss = partPromotionSchemeLogical(itemsss, item,this.QuoteData[0].multiYearWarranty__c); this.newArrsTemp3.push(itemsss); } else if (itemsss.PromotionId != item.Id) { this.newArrsTemp4.push(itemsss); } }); if (item.determine == '改过') { arrTemp2.forEach(itsss => { //itsss待选产品 if (itsss.Quantity != 0) { newArrsTemp6.push(itsss); } }); // newArrsTemp5 = [...[], ...newArrsTemp6];//20230214 newArrsTemp5 = [].concat(newArrsTemp6);//20230214 this.jzDataDefault = newArrsTemp5; } this.jzDataProduct = arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); } else if (PromotionHeadRecordId == "NormalProduct") { //一般产品 //todu3 this.newArrsTemp3 = []; //需要计算的产品明细的数据 this.newArrsTemp4 = []; //不需要计算的产品明细的数据 var newArrsTemp5 = []; var newArrsTemp6 = []; arrProductTemp.forEach(itemsss => { //itemsss产品明细 var flag = true; if (itemsss.PromotionId == item.Id) { if (item.determine == '改过') { var b = this.jzDataDefaultCopyQuantityList; //获取方案中的产品数量 var jzDataDefaultCopy = this.jzDataDefaultCopy; arrTemp2.forEach(datedefault => { //datedefault待选产品 var quantity = 0; if (datedefault.Id == itemsss.Id) { b.forEach(iem => { //iem方案中的产品数量 if (iem.Asset_Model_No__c == datedefault.Product2.MDM_Model_No__c && iem.Id_H == item.PromotionNo__c) { quantity = (itemsss.Quantity - iem.Quantity__c__c * item.Counts) + datedefault.Quantity; datedefault.Quantity = quantity; itemsss.Quantity = iem.Quantity__c__c * item.Counts; } }); flag = false; } }); if (flag) { jzDataDefaultCopy.forEach(add => { //add报价行项目主数据 var quantity = 0; if (add.Id == itemsss.Id) { b.forEach(iems => { //iems方案关联产品数量 if (iems.Asset_Model_No__c == add.Product2.MDM_Model_No__c && iems.Id_H == item.PromotionNo__c) { quantity = itemsss.Quantity - iems.Quantity__c__c * item.Counts; add.Quantity = quantity; itemsss.Quantity = iems.Quantity__c__c * item.Counts; arrTemp2.push(add); } }); } }); } } if(this.QuoteData[0].multiYearWarranty__c){ itemsss.AgencyUnitPrice__c = (item.HeTongTotal / item.Counts) * (itemsss.ListPrice / item.sumListPrice); }else{ itemsss.AgencyUnitPrice__c = ((item.HeTongTotal / item.Counts) - item.sumNoDiscount) * (itemsss.ListPrice / item.sumListPrice) + itemsss.ServicePrice__c; } if (item.HeTongTotal == undefined || item.HeTongTotal == "") { itemsss.AgencyUnitPrice__c = 0; } itemsss = partGeneralDiscountLogical(itemsss, item); this.newArrsTemp3.push(itemsss); } else if (itemsss.PromotionId != item.Id) { this.newArrsTemp4.push(itemsss); } }); if (item.determine == '改过') { arrTemp2.forEach(itsss => { //待选产品 if (itsss.Quantity != 0) { newArrsTemp6.push(itsss); } }); // newArrsTemp5 = [...[], ...newArrsTemp6];//20230214 newArrsTemp5 = [].concat(newArrsTemp6);//20230214 this.jzDataDefault = newArrsTemp5; } this.jzDataProduct = arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); } } }); // this.jzDataFixedPrice = [...[], ...arrTemp];//20230214 this.jzDataFixedPrice = [].concat(arrTemp);//20230214 } } //计算折扣政策 ComputeDiscount(id, NormalDiscount__c_Input, GuaranteeDiscount__c_Input, Category__c, JxsType) { //todu2 //数据 // this.updateIdStr("3"); // var arrTemp = this.jzDataFixedPrice; // id 价格政策 this.updateIdStr("1"); var arrProductTemp = this.jzDataProduct; // PromotionId 产品明细 this.updateIdStr("2"); var arrTemp1 = this.jzDataDiscount; //折扣政策 // var arrTemp2 = this.jzDataDefault; //待选产品 arrTemp1.forEach(item => { //item折扣政策 if (JxsType == '特约折扣') { if (item.JxsType == '特约折扣') { if (id == item.Id) { if (item.iftrue != "改过" && item.GuaranteeDiscount__c_Input == undefined && item.NormalDiscount__c_Input == undefined) { item.GuaranteeDiscount__c_Input = item.GuaranteeDiscount__c; item.NormalDiscount__c_Input = item.NormalDiscount__c; } if (NormalDiscount__c_Input == item.NormalDiscount__c_Input && //非对象品折扣录入 GuaranteeDiscount__c_Input == item.GuaranteeDiscount__c_Input) { //对象品折扣录入 this.newArrsTemp = []; this.newArrsTemp2 = []; arrProductTemp.forEach(itemss => { //itemss产品明细 var Discount__c_Input = 0; if (itemss.warrantyType__c=="市场多年保修") { Discount__c_Input = item.GuaranteeDiscount__c_Input; Discount__c_Input = parseFloat(Discount__c_Input); debugger // item.GuaranteeDiscount__c_Input = (Discount__c_Input*100).toFixed(0)+"%"; } else { Discount__c_Input = item.NormalDiscount__c_Input; Discount__c_Input = parseFloat(Discount__c_Input); // item.NormalDiscount__c_Input = (Discount__c_Input*100).toFixed(0)+"%"; } if (itemss.PromotionId == item.Id && //方案Id itemss.GuaranteeDiscount__c_Input == item.GuaranteeDiscount__c_Input && //对象品折扣录入 itemss.NormalDiscount__c_Input == item.NormalDiscount__c_Input) { //非对象品折扣录入 itemss = contributingDiscountLogic(itemss, Discount__c_Input, item); //特约折扣计算逻辑 this.newArrsTemp.push(itemss); } else if (itemss.PromotionId != item.Id || itemss.GuaranteeDiscount__c_Input != item.GuaranteeDiscount__c_Input || itemss.NormalDiscount__c_Input != item.NormalDiscount__c_Input) { this.newArrsTemp2.push(itemss); } }); this.jzDataProduct = arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); } } } } else if (JxsType == '一般折扣') { if (item.JxsType == '一般折扣') { if (NormalDiscount__c_Input == item.NormalDiscount__c_Input && Category__c == item.Category__c) { this.newArrsTemp = []; this.newArrsTemp2 = []; arrProductTemp.forEach(itemss => { //itemss产品明细 if (itemss.NormalDiscount__c_Input == item.NormalDiscount__c_Input && itemss.Category__c == item.Category__c) { itemss = commonlyDiscountLogic(itemss, item); //一般折扣计算逻辑 this.newArrsTemp.push(itemss); } else if (itemss.Category__c != item.Category__c || itemss.NormalDiscount__c_Input != item.NormalDiscount__c_Input) { this.newArrsTemp2.push(itemss); } }); this.jzDataProduct = arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); } } } }); this.jzDataDiscount = [...[], ...arrTemp1];//20230214 // this.jzDataDiscount = [].concat(arrTemp1);//20230214 console.warn('this.jzDataDiscountceshi1234567890'+this.jzDataDiscount); } //一般折扣更改过合同价格计算 updateCommonlyDiscountLogic(Id,JxsType,GuaranteeDiscount__c_Input,NormalDiscount__c_Input,Category__c,jzDataDiscount) { //todu13 console.warn('jzDataDiscount'+jzDataDiscount); this.updateIdStr("1"); var arrProductTemp = this.jzDataProduct; // PromotionId 产品明细 this.jzDataProduct=updateCDLogic(Id,JxsType,GuaranteeDiscount__c_Input,NormalDiscount__c_Input,Category__c,jzDataDiscount,arrProductTemp); this.GeneralDiscountContractSummary(); } //计算一般折扣非对象品折扣 ComouteProductDiscount(Id,Category__c,GuaranteeDiscount__c_Input, NormalDiscount__c_Input,GuaranteeDiscount_H_Money__c, NormalDiscount_H_Money__c, item) { //todu12 console.warn('this.jzDataDiscountxxx1'+this.jzDataDiscount); this.updateIdStr("2"); var arrTemp1 = this.jzDataDiscount; //折扣政策 console.warn('this.jzDataDiscountxxx2'+this.jzDataDiscount); this.updateIdStr("1"); var arrProductTemp = this.jzDataProduct; // PromotionId 产品明细 var reslut=ReverseCalculationModifyDiscountLogic(arrTemp1,arrProductTemp,Id,Category__c,GuaranteeDiscount__c_Input, NormalDiscount__c_Input,GuaranteeDiscount_H_Money__c, NormalDiscount_H_Money__c, item); // var ceshi = arrTempsss;//20230214 // this.jzDataDiscount=[...[], ...ceshi];//20230214 this.jzDataDiscount=[...[], ...arrTempsss];//20230214 // this.jzDataDiscount=[].concat(arrTempsss);//20230214 // console.warn('ceshi'+ceshi); console.warn('this.jzDataDiscountxxx3+++'+this.jzDataDiscount); var ceshi2 = arrProductTempsss; this.jzDataProduct =[...[], ...ceshi2];//20230214 // this.jzDataProduct=[].concat(arrProductTempsss);//20230214 return reslut; } //todu //删除价格的listprice和 ComputeListPrice(PromotionId) { //PromotionId 方案id var sum = 0; this.jzDataProduct.forEach(jzdp => { //jzdp产品明细 if (jzdp.PromotionId == PromotionId) { sum = sum + jzdp.ListPrice * jzdp.Quantity; } }); return sum; } //删除价格计算 delectComputeData(item) { //item 产品明细的一条数据 var sum = this.ComputeListPrice(item.PromotionId); // var jzProductarry = [...[], ...this.jzDataProduct];//20230214 var jzProductarry = [].concat(this.jzDataProduct);//20230214 console.warn('ceshiasdfasdfsdfasdjzProductarry'+arrss); console.warn('sfgssgfgthis.jzDataProduct'+this.jzDataProduct); jzProductarry.forEach(japdt => { //japdt产品明细 if (item.PromotionId == japdt.PromotionId) { japdt.AgencySubtotal__c = japdt.AgencySubtotal__c + item.AgencySubtotal__c * (japdt.ListPrice * japdt.Quantity / sum); japdt.AgencyUnitPrice__c = japdt.AgencySubtotal__c / japdt.Quantity; japdt.AgencySubtotal__c = Math.round(japdt.AgencySubtotal__c * 100) / 100; japdt.AgencyUnitPrice__c = Math.round(japdt.AgencyUnitPrice__c * 100) / 100; } }); // this.jzDataProduct = [...[], ...jzProductarry];//20230214 this.jzDataProduct = [].concat(jzProductarry);//20230214 //合同价格汇总 this.ContractPriceCompute(); } //length 数量 Quantity 数量 Asset_Model_No__c 产品型号 Id 选中的数据ID jzDataProductParam 选中的数据对象 TypeName 方案类型 ComparePushData(length, Quantity, Asset_Model_No__c, Id, jzDataProductParam, TypeName) { //修改 产品明细 let num = parseInt(length / Quantity); let addArr = []; // var newss = [...[], ...this.jzDataDefault];//20230214 var newss = [].concat(this.jzDataDefault);//20230214 var newDataDefault = newss.map(item => { if (item == undefined) { console.warn("undefined!!"); } if (item.Product2.MDM_Model_No__c == Asset_Model_No__c) { let ItemTemp = { ...{}, ...item }; ItemTemp.Quantity = Quantity * num ItemTemp.PromotionNo__c = jzDataProductParam.PromotionNo__c; ItemTemp.Name = jzDataProductParam.Name; ItemTemp.TypeName = TypeName; ItemTemp.PromotionId = Id; addArr.push(ItemTemp); item.Quantity -= num * Quantity; } return item; }) // this.jzDataProduct = [...this.jzDataProduct, ...addArr];//20230213 this.jzDataProduct = this.jzDataProduct.concat(addArr);//20230213 //合同价格汇总 this.ContractPriceCompute(); this.jzDataDefault = newDataDefault; //判断是否有 full的值 this.ChangeNumZeroTrue(); //追加次数 this.AddNums(TypeName, Asset_Model_No__c, num, Id); } // ======================== 追加次数 //用于填充次数 CompareFullData = [] //ListName 方案类型 Asset_Model_No__c 产品型号 Id 选中的数据ID AddNums(ListName, Asset_Model_No__c, addNums, Id) { //TODO 用find var FilterList = this.CompareFullData.filter(item => { if (item.ListName == ListName && item.Id == Id) { return true; } else { return false; } }) if (FilterList == undefined || FilterList.length <= 0) { var newTemp = { ListName: ListName, Asset_Model_No__c: Asset_Model_No__c, Id: Id, num: addNums } this.CompareFullData.push(newTemp); } else { FilterList[0].Asset_Model_No__c += Asset_Model_No__c + "||"; FilterList[0].num = addNums; } } // =======更新促销方案次数数据 updatesNums() { // var jzDataFixedPriceTemp = [...[], ...this.jzDataFixedPrice];//20230214 var jzDataFixedPriceTemp = [].concat(this.jzDataFixedPrice);//20230214 // var jzDataDiscountTemp = [...[], ...this.jzDataDiscount];//20230214 var jzDataDiscountTemp = [].concat(this.jzDataDiscount);//20230214 var CompareFullData = this.CompareFullData; updatesNumsLogic(jzDataFixedPriceTemp,jzDataDiscountTemp,CompareFullData); this.jzDataFixedPrice = jzDataFixedPriceTemps; this.jzDataDiscount = jzDataDiscountTemps; } // ====================== 判断是否为0 ChangeNumZeroTrueData = [] ChangeNumZeroTrue() { // this.ChangeNumZeroTrueData = [...[], ...this.jzDataDefault];//20230214 this.ChangeNumZeroTrueData = [].concat(this.jzDataDefault);//20230214 var newJzDataDefault = this.ChangeNumZeroTrueData.filter(item => { if (item.Quantity > 0) { return true; } else { return false; } }) this.ChangeNumZeroTrueData = newJzDataDefault; } ChangeNumZeroTrueChanges() { if (this.jzDataDefault.length != this.ChangeNumZeroTrueData) { this.jzDataDefault = this.ChangeNumZeroTrueData; } } // --- 删除匹配规则 jzDataProduct jzDataDefaultNotChange(初始产品列表) jzDataDefault(当前产品列表) CompareFullData(保存的次数) DeleteChangesFn(ids, TypeName) { // ids 选中的方案Id TypeName 方案类型 var CompareFullDataTemp = []; ids.forEach(id => { //删除 规则数量 this.CompareFullData.forEach(cItem => { if (cItem.Id == id && cItem.ListName == TypeName) { console.warn("CompareFullData 删除"); } else { CompareFullDataTemp.push(cItem); } }) //删除 已选产品 var CurrentTemp = {}; if (TypeName == "价格政策") { CurrentTemp = this.jzDataFixedPrice.filter(fItem => { if (fItem.Id == id) { return true; } return false; })[0]; } if (TypeName == "折扣政策") { CurrentTemp = this.jzDataDiscount.filter(fItem => { if (fItem.Id == id) { return true; } return false; })[0]; } //匹配需要删除产品 var ProductNumsTemp = []; var NewjzDataProduct = [];; if (TypeName == "价格政策") { this.jzDataProduct.forEach(proItem => { if (proItem.PromotionNo__c == CurrentTemp.PromotionNo__c) { ProductNumsTemp.push({ Id: proItem.Id, num: proItem.Quantity }) } else { NewjzDataProduct.push(proItem); } }); } else if (TypeName == "折扣政策") { this.jzDataProduct.forEach(proItem => { if (proItem.CompareId == CurrentTemp.CompareId) { ProductNumsTemp.push({ Id: proItem.Id, num: proItem.Quantity }) } else { NewjzDataProduct.push(proItem); } }); } // 执行删除 this.jzDataProduct = NewjzDataProduct; //合同价格汇总 this.ContractPriceCompute(); // 添加数量 var newjzDataDefaults = []; var AddnumsTemp = []; this.jzDataDefault.forEach(defItem => { var defItemTemp = { ...{}, ...defItem }; ProductNumsTemp.forEach(pTempItem => { if (pTempItem.Id == defItem.Id) { defItemTemp.Quantity += pTempItem.num; AddnumsTemp.push(pTempItem.Id); } }); newjzDataDefaults.push(defItemTemp); }) this.jzDataDefault = newjzDataDefaults; //添加整条数据 var PFTempArr = ProductNumsTemp.filter(pTempItem => { var flag = true; AddnumsTemp.filter(addItem => { if (addItem == pTempItem.Id) { flag = false; } }) return flag; }) this.jzDataDefaultNotChange.forEach(noChangeItem => { PFTempArr.forEach(pftItem => { if (pftItem.Id == noChangeItem.Id) { let newChangeItem = { ...{}, ...noChangeItem }; newChangeItem.Quantity = pftItem.num; this.jzDataDefault.push(newChangeItem); } }) }) }); this.CompareFullData = CompareFullDataTemp; } //todu6 //================删除已选产品========== DeleteIsChangesFnSingle(list) { //list选中的产品明细 let num = 0; list.forEach(item => { num++; var falg = true; if (item.TypeName == "价格政策") { this.DeleteIsChangelogic(item, item.TypeName, num, list); // var arrTemp = [...[], ...this.jzDataFixedPrice]; //价格政策//20230214 var arrTemp = [].concat(this.jzDataFixedPrice);//20230214 var TempItem = {}; arrTemp.forEach(atItem => { if (atItem.Id == item.PromotionId) { TempItem = atItem; return; } }) this.jzDataProduct.forEach(ite => { //ite产品明细 if (ite.PromotionId == TempItem.Id) { falg = false; } }); if (TempItem != undefined && falg) { this.SelectedFnDataFixedPrice.push(TempItem); this.deleteFixedPriceTemp(); } } else if (item.TypeName == "折扣政策") { this.DeleteIsChangelogic(item, item.TypeName, num, list); // var arrTempTOName = [...[], ...this.jzDataDiscount]; //折扣政策//20230214 var arrTempTOName = [].concat(this.jzDataDiscount);//20230214 var TempItemTOName = {}; var PromotionHeadRecordId = item.recordTypeName__c; if (PromotionHeadRecordId == "Authorizer") { arrTempTOName.forEach(atItem => { if (atItem.Id == item.PromotionId && //方案Id item.NormalDiscount__c_Input == atItem.NormalDiscount__c_Input && //非对象品折扣录入 item.GuaranteeDiscount__c_Input == atItem.GuaranteeDiscount__c_Input) { //对象品折扣录入 TempItemTOName = atItem; return; } }) this.jzDataProduct.forEach(ite => { if (ite.PromotionId == TempItemTOName.Id && ite.NormalDiscount__c_Input == TempItemTOName.NormalDiscount__c_Input && ite.GuaranteeDiscount__c_Input == TempItemTOName.GuaranteeDiscount__c_Input) { falg = false; } }); } else { arrTempTOName.forEach(atItem => { if (item.Category__c == atItem.Category__c && item.Discount__c_Input == atItem.NormalDiscount__c_Input) { TempItemTOName = atItem; return; } }) this.jzDataProduct.forEach(ite => { if (ite.Category__c == TempItemTOName.Category__c && ite.Discount__c_Input == TempItemTOName.NormalDiscount__c_Input) { falg = false; } }); } if (TempItemTOName != undefined && falg) { this.SelectedFnDataDiscount.push(TempItemTOName); this.delectTableDiscountTemp(); } } this.ContractPriceCompute(); }) } //删除产品明细和待选产品 item是选中的产品明细对象 TypeName是选中的产品明细对对应的方案类型 DeleteIsChangelogic(item, TypeName, num, list) { //item 选中的数据对象 TypeName 方案类型 var jzdatas = []; var flg = true; this.jzDataProduct.forEach(proItem => { //proItem产品明细 if (TypeName == "价格政策") { var PromotionHeadRecordId = item.recordTypeName__c; if (PromotionHeadRecordId == "Promotion") { if (!item.if_Fix__c) { if (proItem.Id == item.Id && item.PromotionId == proItem.PromotionId) {} else { jzdatas.push(proItem); } } else { flg = false; this.Alert("促销方案内产品型号,数量固定,不可删除明细", true, true); } } else if (PromotionHeadRecordId == "NormalProduct") { flg = false; this.Alert("该产品为一般产品,不可删除明细", true, true); } else { jzdatas.push(proItem); } } else if (TypeName == "折扣政策") { var PromotionHeadRecordId = item.recordTypeName__c; if (PromotionHeadRecordId == "Authorizer") { if (proItem.Id == item.Id && item.PromotionId == proItem.PromotionId && item.NormalDiscount__c_Input == proItem.NormalDiscount__c_Input && item.GuaranteeDiscount__c_Input == proItem.GuaranteeDiscount__c_Input) {} else { jzdatas.push(proItem); } } else { if (proItem.Id == item.Id && item.Category__c == proItem.Category__c && item.Discount__c_Input == proItem.Discount__c_Input) {} else { jzdatas.push(proItem); } } } }); if (flg) { // this.jzDataProduct = [...[], ...jzdatas];//20230214 this.jzDataProduct = [].concat(jzdatas);//20230214 if (TypeName == "价格政策") { //删除价格计算 this.delectComputeData(item); } //合同价格汇总 this.ContractPriceCompute(); var fg = true; var arr = this.jzDataDefault; arr.forEach(jddf => { //jddf待选产品 if (jddf.Id == item.Id) { jddf.Quantity = jddf.Quantity + item.Quantity fg = false; } }); if (fg) { this.jzDataDefaultCopy.forEach(itm => { //itm报价行项目主数据 if (itm.Id == item.Id) { itm.Quantity = item.Quantity arr.push(itm); fg = false; } }); } // this.jzDataDefault = [...[], ...arr];//20230214 this.jzDataDefault = [].concat(arr);//20230214 } } // ==================通知显示 ====================== @track Tongzhishow = false; @track ErrorTongzhishow = false; ShowErrorContent = '折扣类只能选择一个'; // 新提示 Tongzhishow = false; //提示显示的标识 SaveShowText = "操作成功"; //提示框的文本 TongzhiIcon = 'standard:account' //提示框的图标 IsLeftStyle = "" //提示框的样式 BgColorStyle = "" //弹框提示 content 内容 error 是否是错误提示框 left 是否居左 Alert(content, error = false, left = false) { this.SaveShowText = content; this.Tongzhishow = true; if (error) { this.TongzhiIcon = "standard:account"; this.BgColorStyle = "background-color:#f88568"; } else { this.TongzhiIcon = "standard:account"; this.BgColorStyle = "background-color:#69e669"; } if (left) { this.IsLeftStyle = "left: 40%" } else { this.IsLeftStyle = "" } } //关闭提示框 CloseAlert() { if (this.Tongzhishow == true) { this.Tongzhishow = false; } if (this.SaveShowText != "") { this.SaveShowText = ""; } } // END // ===================== 弹出框组件 ===================================== @track show = false showModal() { this.show = true } cancel() { this.show = false } @track pagingShow; constructor() { super(); this.pagingShow = false; } @track initSearchForm = initSearchForm2 @track initDataTable = initDataTable2; @track jzData = []; @track tableIsLoding = true; // 点击搜索触发 searchData(event) { let searchParams = event.detail.searchParams || {}; let temp = this.template; this.template.querySelector('[data-parent-id="parent-div-id"]').refreshDataTable({ searchParams: searchParams }); } //页面切换触发 pagingClick(event) { let page = event.detail.page || {}; this.template.querySelector('c-jz-data-table').refreshDataTable({ page: page }); } // 后台交互,获取列表数据 getTableData(event) { let listQuery = event; if (event.fag == undefined) { listQuery = event.detail.listQuery; } GetPromotionPromotionSearch(listQuery).then(result => { //促销方案查询结果 //CCCC var responseObj = JSON.parse(result); responseObj.records.forEach(item => { var SeachData = { SearchId: item.Id }; GetSearchProductById(SeachData).then(result => { //方案关联的产品 // var sumListPrice = 0; // var sumNoDiscount = 0; result.forEach(itemss => { //itemss方案关联的产品 var fl = true; if (this.jzDataDefaultCopyQuantityList.length == 0) { this.jzDataDefaultCopyQuantityList.push({ Asset_Model_No__c: itemss.Asset_Model_No__c, Quantity__c__c: itemss.Quantity__c, Id_H: item.PromotionNo__c }); } else { this.jzDataDefaultCopyQuantityList.forEach(jdcql => { //保存方案关联产品的数量 if (itemss.Asset_Model_No__c == jdcql.Asset_Model_No__c && jdcql.Id_H == item.PromotionNo__c) { fl = false; } }); if (fl) { this.jzDataDefaultCopyQuantityList.push({ Asset_Model_No__c: itemss.Asset_Model_No__c, Quantity__c__c: itemss.Quantity__c, Id_H: item.PromotionNo__c }); } } }); var iflag = true; var newarrjdf = []; this.jzDataFixedPrice.forEach(jdf => { //jdf价格政策 if (jdf.Id == item.Id) { iflag = false; newarrjdf.push(jdf); } else { newarrjdf.push(jdf); } }); // this.jzDataFixedPrice = [...[], ...newarrjdf];//20230214 this.jzDataFixedPrice = [].concat(newarrjdf);//20230214 }); }); // this.jzData = [...[], ...responseObj.records];//20230214 this.jzData = [].concat(responseObj.records);//20230214 // this.index=this.jzData.length; this.tableIsLoding = false; }) } // 促销方案选中 SelectedFn(event) { let arr = event.detail.rows; if (arr.length > 1) { this.Alert("价格政策只可选择一个方案", true, true); } else { this.cancel(); this.ifqianpi = true; this.GetSearchProductByIdFn(arr[0].Id, arr[0], "价格政策", [], arr); } } // ================== END 弹出框 ============================== // ===================== 待选着产品 ============================= @track jzDataDefault = []; //数据 待选择产品数据据 jzDataDefaultNotChange = []; jzDataDefaultCopy = []; @track tableIsLodingDefault = true; @track initSearchFormDefalt = initSearchFormDefalt2 @track initDataTableDefault = initDataTableDefault2; getRowActions(event) { let a = event; } //查询价格政策方案关联产品明细 //算出的合计 sumTotal = []; getschemedetails() { this.jzDataFixedPrice.forEach(jdfp => { //价格政策集合列表 var SeachData = { SearchId: jdfp.Id }; GetSearchProductById(SeachData).then(result => { var tempObject = { ...{}, ...jdfp } jdfp = this.countListAndNod(tempObject, result); this.sumTotal.push(jdfp); }); }); } //比对报价行项目改变后试算界面的变化 //‘试算合成待选数据’是为了与现在报价行项目进行比对,用试算产品表数据合并出的上一次进行试算的报价行项目 //试算之前已将报价行项目相同的产品进行了合并 //1.‘报价行项目’条数少于‘试算合成待选数据’条数时将之前的试算清空,使用新的报价行项目 //2.当‘报价行项目’条数大于或等于‘试算合成待选数据’条数将两组数据进行比对 // 2-1)当‘报价行项目’条数等于‘试算合成待选数据’条数时先对比两组数据(根据产品Id进行匹配) // (2-1-1)当数据匹配成功后判断其数量字段,当‘报价行项目’数量小于‘试算合成待选数据’数量时将之前的试算清空,使用新的报价行项目 // (2-1-2)等于则删除‘试算合成待选数据’中匹配成功的数据 // (2-1-3)大于则用‘报价行项目’数量减去‘试算合成待选数据’数量并将这条数据存入待选报价行项目集合 // 2-2)当比对结束后如果‘试算合成待选数据’中有数据没有被匹配则将之前的试算清空,使用新的报价行项目 // 2-3)当‘报价行项目’条数大于‘试算合成待选数据’条数,且‘试算合成待选数据’都已匹配则将‘报价行项目’中未被匹配的数据全部存入待选报价行项目集合 index = 3; comparisonUniqueKey() { //xxx this.index--; if (this.index == 0) { if (this.flagall) { if (this.jzDataDefaultCopy.length < this.lastQuotation.length) { //1、条数小于 // this.jzDataDefault = [...[], ...this.jzDataDefaultCopy];//20230214 this.jzDataDefault = [].concat(this.jzDataDefaultCopy);//20230214 this.jzDataProduct = []; this.jzDataFixedPrice = []; this.jzDataDiscount = []; return; } else { //2、 // var lastQuotation = [...[], ...this.lastQuotation];//20230214 var lastQuotation = [].concat(this.lastQuotation);//20230214 // var DefaultCopy = [...[], ...this.jzDataDefaultCopy];//20230214 var DefaultCopy = [].concat(this.jzDataDefaultCopy);//20230214 var Default = []; for (var j = 0; j < DefaultCopy.length; j++) { var arrList = []; var fag = true if (lastQuotation.length != 0) { for (var i = 0; i < lastQuotation.length; i++) { if (DefaultCopy[j].Id == lastQuotation[i].Id) { if (DefaultCopy[j].Quantity < lastQuotation[i].Quantity) { //2-1-1 数量小于 clear // this.jzDataDefault = [...[], ...this.jzDataDefaultCopy];//20230214 this.jzDataDefault = [].concat(this.jzDataDefaultCopy);//20230214 this.jzDataProduct = []; this.jzDataFixedPrice = []; this.jzDataDiscount = []; return; } else if (DefaultCopy[j].Quantity == lastQuotation[i].Quantity) { //2-1-2 fag = false; } else { //2-1-3 数量大于 塞到待选产品 DefaultCopy[j].Quantity = DefaultCopy[j].Quantity - lastQuotation[i].Quantity; Default.push(DefaultCopy[j]); fag = false; } } else { arrList.push(lastQuotation[i]); } } lastQuotation = arrList; if (fag) { Default.push(DefaultCopy[j]); } } else { //2-3 条数大于 将数据塞到待选产品 Default.push(DefaultCopy[j]); } } if (lastQuotation.length != 0) { //2-2 合成数据有剩余 // this.jzDataDefault = [...[], ...this.jzDataDefaultCopy];//20230214 this.jzDataDefault = [].concat(this.jzDataDefaultCopy);//20230214 this.jzDataProduct = []; this.jzDataFixedPrice = []; this.jzDataDiscount = []; return; } // this.jzDataDefault = [...[], ...Default];//20230214 this.jzDataDefault = [].concat(Default);//20230214 } } } } // 后台交互,获取待选择产品列表数据 UniqueKey = new Map(); getTableDataDefault(event) { let data = []; //todu10 GetPromotionDefalut({ IdParam: this.ParamIdStr }).then(result => { this.jzDataDefaultNotChange = []; this.jzDataDefaultCopy = []; var i = 1; result.forEach(rItem => { rItem.ListPrice = rItem.ListPrice__c; rItem.HangHao = i++; // if (!this.flagall) { rItem.Id = rItem.Product2Id; //报价行唯一key // } let tempS = { ...{}, ...rItem }; this.jzDataDefaultNotChange.push(tempS); this.jzDataDefaultCopy.push(tempS); }); this.getschemedetails(); if (this.flagall) { var newList = []; this.OnLoadProduct.forEach(items => { //items未选择产品 var DataTemp = {}; result.forEach(reItgem => { if (reItgem.Id == items.Id) { DataTemp = reItgem; return; } reItgem.ListPrice = reItgem.ListPrice__c; }) if (DataTemp != undefined && DataTemp != {}) { DataTemp = { ...DataTemp, ...items }; } newList.push(DataTemp); }) this.jzDataDefault = newList; this.tableIsLodingDefault = false; this.comparisonUniqueKey(); return; } else { result.forEach(rItems => { rItems.ListPrice = rItems.ListPrice__c; }); this.jzDataDefault = result; this.tableIsLodingDefault = false; var event = { page: 1, pageLimit: 10, search: "", sortOrder: "asc", sortPlus: undefined, fag: true }; this.getTableDataFix(event); } }) } SelectedFnDefault(rows) { let arr = rows; } // ===================== END待选着产品 ============================= // ===================== 使用价格政策 ============================= @track jzDataFixedPrice = []; //价格政策数据存储1 集合 @track tableIsLodingFixedPrice = true; Lianxi = true; @track initSearchFormFixedPrice = initSearchFormFixedPrice2 @track initDataTableFixedPrice = initDataTableFixedPrice2 // 后台交互,获取列表数据 getTableDataFixedPrice(event) { this.tableIsLodingFixedPrice = false; var indexTemp = []; } //对比价格政策赋值 comparativeAssignment() { this.jzDataFixedPrice.forEach(jdfp => { //价格政策集合 this.sumTotal.forEach(stl => { //初始化时价格政策集合 if (jdfp.Id == stl.Id) { if (stl.sumListPrice != undefined && stl.sumNoDiscount != undefined) { jdfp.sumListPrice = stl.sumListPrice; jdfp.sumNoDiscount = stl.sumNoDiscount; } } }); }); } //计算价格政策的最大次数 ComputeMaximumTimes(priceArr) { // var num=0; var Pricepolicy = { ...{}, ...priceArr }; var b = this.jzDataDefaultCopyQuantityList; //查出的每个方案的明细的数量 var selectproducts = this.jzDataDefault; //待选产品 Pricepolicy.maxCounts = ComputationalLogic(Pricepolicy, b, selectproducts); return Pricepolicy; } //保存价格政策编辑列 handleSaveFixedPrice(event) { this.comparativeAssignment(); // 更改次数 把对应的id 的 num值也需要改变,这个集合是记录所有匹配上的 政策的 关系的,改变了对应关系 也需要维护一下这个集合 var a = this.CompareFullData; var CompareFullDataedit = []; var HeTongTotal = 0; var data = event.detail.rows; let newData = []; let editnewDate = []; var boolean = 1; for (var i = 0; i < this.jzDataFixedPrice.length; i++) { var editData = {}; var flag = false; for (var j = 0; j < data.length; j++) { var id = data[j].DelectId.replace("row-", ""); if (this.jzDataFixedPrice[i].DelectId == id) { // editData=data[j]; editData = { Counts: '', HeTongTotal: '' }; //对象折扣 editData.Counts = data[j].Counts; //赋值 非对象折扣 editData.HeTongTotal = data[j].HeTongTotal; // editData.id=id; flag = true; } } if (flag) { var newItem = { ...this.jzDataFixedPrice[i], ...{} }; //价格政策数据 //计算最大次数 newItem = this.ComputeMaximumTimes(newItem); if (editData.Counts != undefined) { var ifNec = true; if (newItem.recordTypeName__c == "NormalProduct") { if (newItem.ifNecessary__c) { ifNec = false; } } newItem.maxCounts = Number(newItem.maxCounts); if (newItem.maxCounts >= editData.Counts && ifNec) { if (editData.Counts == 0) { boolean = 4; } else { if (newItem.if_Contain_Nod__c) { HeTongTotal = newItem.Price_CNY__c * editData.Counts; } else { HeTongTotal = newItem.Price_CNY__c * editData.Counts + newItem.sumNoDiscount * editData.Counts; } newItem.Counts = editData.Counts; // newItem.HeTongTotal = HeTongTotal; if (newItem.recordTypeName__c == "Promotion") { newItem.HeTongTotal = HeTongTotal; } newItem.determine = '改过'; a.forEach(editnum => { if (editnum.Id == newItem.Id) { editnum.num = newItem.Counts; CompareFullDataedit.push(editnum); } else { CompareFullDataedit.push(editnum); } }); // this.CompareFullData = [...[], ...CompareFullDataedit];//20230214 this.CompareFullData = [].concat(CompareFullDataedit);//20230214 // } } } else { if (ifNec) { boolean = 3; } else { boolean = 5; } } } if (editData.HeTongTotal != undefined) { if (newItem.if_Contain_Nod__c) { HeTongTotal = newItem.Price_CNY__c * newItem.Counts; } else { HeTongTotal = newItem.Price_CNY__c * newItem.Counts + newItem.sumNoDiscount * newItem.Counts; } if (editData.HeTongTotal < HeTongTotal) { boolean = 6; } else { newItem.HeTongTotal = editData.HeTongTotal; newItem.determine = '改过'; } } newData.push(newItem); editnewDate.push(newItem); } else { newData.push({ ...{}, ...this.jzDataFixedPrice[i] }); } } //haha // var newArrs = [...[], ...editnewDate];//20230214 var newArrs = [].concat(editnewDate);//20230214 if (boolean == 1) { this.jzDataFixedPrice = newData; newArrs.forEach(item => { this.ComputeData(item.Id, '价格政策'); this.Alert("数据修改成功", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); }); // this.jzDataProduct = [...this.newArrsTemp3, ...this.newArrsTemp4];//20230213 this.jzDataProduct = this.newArrsTemp3.concat(this.newArrsTemp4);//20230213 //合同价格汇总 this.ContractPriceCompute(); } else if (boolean == 3) { this.Alert("修改错误,次数已经超过最大值,不可增加", true, true); } else if (boolean == 4) { this.Alert("修改错误,次数不可以为0", true, true); } else if (boolean == 5) { this.Alert("该方案为强制匹配,次数不可修改!", true, true); } else if (boolean == 6) { var str1 = String(HeTongTotal); var str = "修改错误,合同价格不得小于"; var str3 = str + str1; this.Alert(str3, true, true); } //刷新 this.jzshows3 = false; this.IsLoading3 = true; setTimeout(() => { this.IsLoading3 = false; this.jzshows3 = true; }, 800); } newArrsTemp3 = []; newArrsTemp4 = []; UpdateJZData(arrs) { //arrs 选中的数据集合 if (this.jzDataFixedPrice == null || this.jzDataFixedPrice.length <= 0) { this.jzDataFixedPrice = arrs; } else { // this.jzDataFixedPrice = [...this.jzDataFixedPrice, ...arrs];//20230213 this.jzDataFixedPrice = this.jzDataFixedPrice.concat(arrs);//20230213 }; } //价格政策选中 @track SelectedFnDataFixedPrice = []; SelectedFnFixedPrice(event) { let arr = event.detail.rows; this.SelectedFnDataFixedPrice = arr; } //删除价格政策 //todu8 deleteFixedPrice() { let ids = []; var fag = true; var select = []; for (var j = 0; j < this.SelectedFnDataFixedPrice.length; j++) { fag = true; var PromotionHeadRecordId = this.SelectedFnDataFixedPrice[j].recordTypeName__c; if (PromotionHeadRecordId == "NormalProduct") { if (this.SelectedFnDataFixedPrice[j].ifNecessary__c) { fag = false; this.Alert("一般产品为强制匹配,不可删除", true, true); } else { select.push(this.SelectedFnDataFixedPrice[j]); } } else { select.push(this.SelectedFnDataFixedPrice[j]); } if (fag) { var a = this.CompareFullData; var compareFu = []; ids.push(this.SelectedFnDataFixedPrice[j].Id); a.forEach(deletId => { if (this.SelectedFnDataFixedPrice[j].Id != deletId.Id) { compareFu.push(deletId); } }); // this.CompareFullData = [...[], ...compareFu];//20230214 this.CompareFullData = [].concat(compareFu);//20230214 } } // this.SelectedFnDataFixedPrice = [...[], ...select];//20230214 this.SelectedFnDataFixedPrice = [].concat(select);//20230214 if (fag) { //删除所选方案匹配的产品 this.DeleteChangesFn(ids, "价格政策"); //调用删除价格政策 this.deleteFixedPriceTemp(); //合同价格汇总 this.ContractPriceCompute(); } } jzshows3 = true; //加载 //删除价格政策 deleteFixedPriceTemp() { let newarr = []; for (var j = 0; j < this.SelectedFnDataFixedPrice.length; j++) { for (var i = 0; i < this.jzDataFixedPrice.length; i++) { var a = this.CompareFullData; var compareFu = []; a.forEach(deletId => { if (this.SelectedFnDataFixedPrice[j].Id != deletId.Id) { compareFu.push(deletId); } }); // this.CompareFullData = [...[], ...compareFu];//20230214 this.CompareFullData = [].concat(compareFu);//20230214 if (this.SelectedFnDataFixedPrice[j].Id == this.jzDataFixedPrice[i].Id) { this.jzDataFixedPrice.splice(i, 1); // 将使后面的元素依次前移,数组长度减1 i--; } } } for (var i = 0; i < this.jzDataFixedPrice.length; i++) { newarr.push(this.jzDataFixedPrice[i]); } this.jzDataFixedPrice = newarr; this.SelectedFnDataFixedPrice = []; } // ===================== END使用价格政策 ============================= // =========================固定价格 弹出框 ========================= @track ShowFix; showModalFix() { this.ShowFix = true } cancelFix() { this.ShowFix = false } @track initSearchFormFix = initSearchFormFix2; @track initDataTableFix = initDataTableFix2; @track jzDataFix = []; @track tableIsLodingFix = true; // 点击搜索触发 searchDataFix(event) { let searchParams = event.detail.searchParams || {}; this.template.querySelector('[data-parent-id="parent-div-idFix"]').refreshDataTable({ searchParams: searchParams }); } //页面切换触发 pagingClickFix(event) { let page = event.detail.page || {}; this.template.querySelector('[data-parent-id="parent-div-idFix"]').refreshDataTable({ page: page }); } jzDataDefaultCopyQuantityList = []; // 后台交互,获取一般产品列表数据 ifqianpi = true; getTableDataFix(event) { let listQuery = event; if (event.fag) { this.ifqianpi = false; } else { listQuery = event.detail.listQuery; } listQuery.pageLimit = 200; GetNormalProductSearch(listQuery).then(result => { //BBBB var tempArr = result.split("--"); var responseObj = JSON.parse(tempArr[0]); var responseObjAll = JSON.parse(tempArr[1]); //排序 var newArrs = new Array; responseObjAll.forEach(item => { newArrs.push(item); }) newArrs.sort((a, b) => { return a.OrderNo__c - b.OrderNo__c; }) newArrs.forEach(item => { //排序后的一般产品主数据 var SeachData = { SearchId: item.Id }; GetSearchProductById(SeachData).then(results => { results.forEach(itemss => { //方案关联的产品 var fl = true; if (this.jzDataDefaultCopyQuantityList.length == 0) { this.jzDataDefaultCopyQuantityList.push({ Asset_Model_No__c: itemss.Asset_Model_No__c, Quantity__c__c: itemss.Quantity__c, Id_H: item.PromotionNo__c }); } else { this.jzDataDefaultCopyQuantityList.forEach(jdcql => { if (itemss.Asset_Model_No__c == jdcql.Asset_Model_No__c && jdcql.Id_H == item.PromotionNo__c) { fl = false; } }); if (fl) { this.jzDataDefaultCopyQuantityList.push({ Asset_Model_No__c: itemss.Asset_Model_No__c, Quantity__c__c: itemss.Quantity__c, Id_H: item.PromotionNo__c }); } } // } // }); }); var iflag = true; var newarrjdf = []; this.jzDataFixedPrice.forEach(jdf => { //价格政策 if (jdf.Id == item.Id) { iflag = false; // jdf.sumListPrice = sumListPrice; // jdf.sumNoDiscount = sumNoDiscount; newarrjdf.push(jdf); } else { newarrjdf.push(jdf); } }); // this.jzDataFixedPrice = [...[], ...newarrjdf];//20230214 this.jzDataFixedPrice = [].concat(newarrjdf);//20230214 if (event.fag && iflag) { var newArr = []; newArr.push(item); this.ifqianpi = false; this.GetSearchProductByIdFn(item.Id, item, "价格政策", [], newArr, false); } }); }); var respons = []; responseObj.records.forEach(rrds => { //查出的前十条 responseObjAll.forEach(rsja => { //查出的所有一般产品数据 if (rrds.Id == rsja.Id) { respons.push(rsja); } }) }) // this.jzDataFix = [...[], ...respons];//20230214 this.jzDataFix = [].concat(respons);//20230214 this.tableIsLodingFix = false; }) } // 价格政策选中 SelectedFnFix(event) { let arr = event.detail.rows; this.ifqianpi = true; if (arr.length > 1) { this.TZshow(false); this.TZErrorshow(true); } else { //获取数据 this.GetSearchProductByIdFn(arr[0].Id, arr[0], "价格政策", [], arr); this.cancelFix(); } } // ============================END ======================= // ===================== 使用折扣政策 ============================= @track jzDataDiscount = []; //折扣政策数据2 集合 @track tableIsLodingDiscount = true; @track initSearchFormDiscount = initSearchFormDiscount2; @track initDataTableDiscount = initDataTableDiscount2; // 后台交互,获取列表数据 getTableDataDiscount(event) { this.tableIsLodingDiscount = false; } //将产品与方案匹配 UpdateDiscountData(arrs) { //选中的数据 if (this.jzDataDiscount == null || this.jzDataDiscount.length <= 0) { this.jzDataDiscount = arrs; } else { // this.jzDataDiscount = [...this.jzDataDiscount, ...arrs];//20230213 this.jzDataDiscount = this.jzDataDiscount.concat(arrs);//20230213 } } //折扣政策选中 @track SelectedFnDataDiscount = [] SelectedFnDiscount(event) { let arr = event.detail.rows; this.SelectedFnDataDiscount = arr; } //删除折扣政策 //todu9 delectTableDiscount() { let ids = []; for (var j = 0; j < this.SelectedFnDataDiscount.length; j++) { ids.push(this.SelectedFnDataDiscount[j].Id); } //删除方案对应的产品明细 // this.DeleteChangesFn(ids, "折扣政策"); this.DeleteSchemeMatching(this.SelectedFnDataDiscount, "折扣政策"); //删除折扣政策 this.delectTableDiscountTemp(); //合同价格汇总 this.ContractPriceCompute(); } //折扣政策删除方案对应产品规则 DeleteSchemeMatching(ids, TypeName) { var CompareFullDataTemp = []; ids.forEach(id => { //删除 规则数量 this.CompareFullData.forEach(cItem => { if (cItem.Id == id.Id && cItem.ListName == TypeName) { console.warn("CompareFullData 删除"); } else { CompareFullDataTemp.push(cItem); } }) //删除 已选产品 var CurrentTemp = {}; if (TypeName == "价格政策") { CurrentTemp = this.jzDataFixedPrice.filter(fItem => { if (fItem.Id == id.Id) { return true; } return false; })[0]; } if (TypeName == "折扣政策") { CurrentTemp = this.jzDataDiscount.filter(fItem => { var PromotionHeadRecordId = id.recordTypeName__c; if (PromotionHeadRecordId == "Authorizer") { if (fItem.Id == id.Id && //方案Id fItem.NormalDiscount__c_Input == id.NormalDiscount__c_Input && //非对象品折扣录入 fItem.GuaranteeDiscount__c_Input == id.GuaranteeDiscount__c_Input) { //对象品折扣录入 return true; } } else { if (fItem.NormalDiscount__c_Input == id.NormalDiscount__c_Input && fItem.Category__c == id.Category__c) { //折扣政策分类 return true; } } return false; })[0]; } //匹配需要删除产品 var ProductNumsTemp = []; var NewjzDataProduct = [];; if (TypeName == "价格政策") { this.jzDataProduct.forEach(proItem => { if (proItem.PromotionNo__c == CurrentTemp.PromotionNo__c) { ProductNumsTemp.push({ Id: proItem.Id, num: proItem.Quantity }) } else { NewjzDataProduct.push(proItem); } }); } else if (TypeName == "折扣政策") { this.jzDataProduct.forEach(proItem => { var PromotionHeadRecordId = id.recordTypeName__c; if (PromotionHeadRecordId == "Authorizer") { if (CurrentTemp.Id == proItem.PromotionId && //方案Id CurrentTemp.NormalDiscount__c_Input == proItem.NormalDiscount__c_Input && //非对象品折扣录入 CurrentTemp.GuaranteeDiscount__c_Input == proItem.GuaranteeDiscount__c_Input) { //对象品折扣录入 ProductNumsTemp.push({ Id: proItem.Id, num: proItem.Quantity }) } else { NewjzDataProduct.push(proItem); } } else { if (CurrentTemp.NormalDiscount__c_Input == proItem.NormalDiscount__c_Input && CurrentTemp.Category__c == proItem.Category__c) { //折扣政策分类 ProductNumsTemp.push({ Id: proItem.Id, num: proItem.Quantity }) } else { NewjzDataProduct.push(proItem); } } }); } // 执行删除 this.jzDataProduct = NewjzDataProduct; //合同价格汇总 this.ContractPriceCompute(); // 添加数量 var newjzDataDefaults = []; var AddnumsTemp = []; this.jzDataDefault.forEach(defItem => { var defItemTemp = { ...{}, ...defItem }; ProductNumsTemp.forEach(pTempItem => { if (pTempItem.Id == defItem.Id) { defItemTemp.Quantity += pTempItem.num; AddnumsTemp.push(pTempItem.Id); } }); newjzDataDefaults.push(defItemTemp); }) this.jzDataDefault = newjzDataDefaults; //添加整条数据 var PFTempArr = ProductNumsTemp.filter(pTempItem => { var flag = true; AddnumsTemp.filter(addItem => { if (addItem == pTempItem.Id) { flag = false; } }) return flag; }) this.jzDataDefaultNotChange.forEach(noChangeItem => { PFTempArr.forEach(pftItem => { if (pftItem.Id == noChangeItem.Id) { let newChangeItem = { ...{}, ...noChangeItem }; newChangeItem.Quantity = pftItem.num; this.jzDataDefault.push(newChangeItem); } }) }) }); this.CompareFullData = CompareFullDataTemp; } //ttt jzshows2 = true; jzshows3 = true; //加载 //删除折扣政策 delectTableDiscountTemp() { let newarr = []; for (var j = 0; j < this.SelectedFnDataDiscount.length; j++) { for (var i = 0; i < this.jzDataDiscount.length; i++) { var PromotionHeadRecordId = this.SelectedFnDataDiscount[j].recordTypeName__c; if (PromotionHeadRecordId == "Authorizer") { if (this.SelectedFnDataDiscount[j].Id == this.jzDataDiscount[i].Id && this.SelectedFnDataDiscount[j].NormalDiscount__c_Input == this.jzDataDiscount[i].NormalDiscount__c_Input && this.SelectedFnDataDiscount[j].GuaranteeDiscount__c_Input == this.jzDataDiscount[i].GuaranteeDiscount__c_Input) { this.jzDataDiscount.splice(i, 1); // 将使后面的元素依次前移,数组长度减1 i--; } } else { if (this.SelectedFnDataDiscount[j].Category__c == this.jzDataDiscount[i].Category__c && this.SelectedFnDataDiscount[j].NormalDiscount__c_Input == this.jzDataDiscount[i].NormalDiscount__c_Input) { this.jzDataDiscount.splice(i, 1); // 将使后面的元素依次前移,数组长度减1 i--; } } } } for (var i = 0; i < this.jzDataDiscount.length; i++) { newarr.push(this.jzDataDiscount[i]); } this.jzDataDiscount = newarr; this.SelectedFnDataDiscount = []; } //save 方法,保存折扣政策编辑列 handleSaveDiscount(event) { var boolean = 0; var boolean2 = false; var boolean3 = false; var data = event.detail.rows; let newData = []; let newData2 = []; var newMap3 = new Map(); let newData3 = []; var key=0; let editnewDate = []; var GuaranteeDiscount__cZuiXiao =0; var NormalDiscount__cZuiXiao =0; for (var i = 0; i < this.jzDataDiscount.length; i++) { var editData = {}; var flag = false; for (var j = 0; j < data.length; j++) { var id = data[j].DelectId.replace("row-", ""); if (this.jzDataDiscount[i].DelectId == id) { // editData=data[j]; editData = { GuaranteeDiscount__c_Input: '', NormalDiscount__c_Input: '', HeTongPrice: '', GuaranteeDiscount_H_Money__c: '', NormalDiscount_H_Money__c: '' }; //对象折扣 editData.GuaranteeDiscount__c_Input = data[j].GuaranteeDiscount__c_Input; //赋值 非对象折扣 editData.NormalDiscount__c_Input = data[j].NormalDiscount__c_Input; //一般折扣合同价格 editData.HeTongPrice = data[j].HeTongPrice; //对象品合同金额 editData.GuaranteeDiscount_H_Money__c = data[j].GuaranteeDiscount_H_Money__c; //非对象品合同金额 editData.NormalDiscount_H_Money__c = data[j].NormalDiscount_H_Money__c; // editData.id=id; flag = true; } } if (flag) { var newItem = { ...this.jzDataDiscount[i], ...{} }; if (editData.GuaranteeDiscount__c_Input != undefined) { if(newItem.JxsType == "特约折扣"){ var GuaranteeDiscount__c_Input = parseFloat(editData.GuaranteeDiscount__c_Input); editData.GuaranteeDiscount__c_Input=GuaranteeDiscount__c_Input+'%'; var GuaranteeDiscount__c = parseFloat(newItem.GuaranteeDiscount__c); if (GuaranteeDiscount__c_Input < GuaranteeDiscount__c) { GuaranteeDiscount__cZuiXiao=GuaranteeDiscount__c; boolean = 1; break; } else { this.jzDataProduct.forEach(jdpt => { if (newItem.Id == jdpt.PromotionId && newItem.GuaranteeDiscount__c_Input == jdpt.GuaranteeDiscount__c_Input && newItem.NormalDiscount__c_Input == jdpt.NormalDiscount__c_Input) { jdpt.GuaranteeDiscount__c_Input = editData.GuaranteeDiscount__c_Input; } }); newItem.GuaranteeDiscount__c_Input = editData.GuaranteeDiscount__c_Input; newItem.iftrue = "改过"; } }else{ boolean = 3; break; } } if (editData.NormalDiscount__c_Input != undefined) { if(editData.NormalDiscount__c_Input!=''&&editData.NormalDiscount__c_Input>=0){ var NormalDiscount__c_Input = parseFloat(editData.NormalDiscount__c_Input); editData.NormalDiscount__c_Input = NormalDiscount__c_Input+'%'; var NormalDiscount__c = parseFloat(newItem.NormalDiscount__c); if (NormalDiscount__c_Input < NormalDiscount__c) { NormalDiscount__cZuiXiao=NormalDiscount__c; boolean = 2; break; } else { this.jzDataProduct.forEach(jdpt => { if (newItem.Id == jdpt.PromotionId && newItem.GuaranteeDiscount__c_Input == jdpt.GuaranteeDiscount__c_Input && newItem.NormalDiscount__c_Input == jdpt.NormalDiscount__c_Input) { jdpt.NormalDiscount__c_Input = editData.NormalDiscount__c_Input; } }); newItem.NormalDiscount__c_Input = editData.NormalDiscount__c_Input; newItem.iftrue = "改过"; } }else{ boolean = 5 break; } } newItem.GuaranteeDiscount_H_Money_yuan=newItem.GuaranteeDiscount_H_Money__c; if (editData.GuaranteeDiscount_H_Money__c != undefined) { if(newItem.JxsType == "特约折扣"){ if(editData.GuaranteeDiscount_H_Money__c==""){ editData.GuaranteeDiscount_H_Money__c=0; } newItem.GuaranteeDiscount_H_Money__c = editData.GuaranteeDiscount_H_Money__c; newMap3.set(key,newItem); boolean = 4; boolean2 = true ; }else{ boolean = 3; break; } } newItem.NormalDiscount_H_Money_yuan=newItem.NormalDiscount_H_Money__c; if (editData.NormalDiscount_H_Money__c != undefined) { if(editData.NormalDiscount_H_Money__c==""){ editData.NormalDiscount_H_Money__c=0; } newItem.NormalDiscount_H_Money__c = editData.NormalDiscount_H_Money__c; if(newItem.JxsType == "一般折扣"){ newData2.push(newItem); boolean = 4; boolean3 = true; }else{ newMap3.set(key,newItem); boolean = 4; boolean2 = true; } } if (editData.NormalDiscount_H_Money__c != undefined||editData.GuaranteeDiscount_H_Money__c != undefined) { if(newItem.JxsType == "一般折扣"){ newItem.HeTongPrice = parseFloat(newItem.NormalDiscount_H_Money__c) }else{ newItem.HeTongPrice = parseFloat(newItem.NormalDiscount_H_Money__c)+parseFloat(newItem.GuaranteeDiscount_H_Money__c); } } key++; newData.push(newItem); editnewDate.push(newItem); } else { newData.push({ ...{}, ...this.jzDataDiscount[i] }); } } for (let [k, v] of newMap3) { newData3.push(v); } //haha2 debugger if (boolean == 0) { this.jzDataDiscount = newData; // var newArrs = [...[], ...editnewDate];//20230214 var newArrs = [].concat(editnewDate);//20230214 newArrs.forEach(item => { // this.ComputeData(item.Id, '折扣政策'); //合并折扣政策重复方案 this.ConsolidatedDiscountPolicy(this.jzDataDiscount); this.ComputeDiscount(item.Id, item.NormalDiscount__c_Input, item.GuaranteeDiscount__c_Input, item.Category__c, item.JxsType); }); // this.jzDataProduct = [...this.newArrsTemp2, ...this.newArrsTemp];//20230213 this.jzDataProduct = this.newArrsTemp2.concat(this.newArrsTemp);//20230213 //合同价格汇总 this.ContractPriceCompute(); this.Alert("数据修改成功", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); } else if (boolean == 1) { this.Alert("修改错误,对象品折扣不得小于对象品最低折扣:"+GuaranteeDiscount__cZuiXiao+"%", true, true); } else if (boolean == 2) { this.Alert("修改错误,非对象品折扣不得小于非对象品最低折扣:"+NormalDiscount__cZuiXiao+"%", true, true); } else if (boolean == 3) { this.Alert("修改错误,一般折扣没有对象品折扣", true, true); } else if (boolean == 5) { this.Alert("非对象品折扣不可以为空或小于0", true, true); } else if (boolean == 4) { this.jzDataDiscount = newData; var ffgg=0; console.warn('newData'+newData); console.warn('this.jzDataDiscount'+this.jzDataDiscount); if(boolean3){ newData2.forEach(HeTo => { //根据合同价格计算一般折扣 HeTo = this.ComouteProductDiscount(HeTo.Id,HeTo.Category__c,HeTo.GuaranteeDiscount__c_Input, HeTo.NormalDiscount__c_Input, HeTo.GuaranteeDiscount_H_Money__c,HeTo.NormalDiscount_H_Money__c, HeTo); if(HeTo==1||HeTo==2||HeTo==12||HeTo==3){ ffgg=HeTo; return ; } console.warn('HeTo'+HeTo); //合并折扣政策重复方案 // let jzDataDiscountx = [...[], ...this.jzDataDiscount];//20230214 let jzDataDiscountx = [].concat(this.jzDataDiscount);//20230214 console.warn('jzDataDiscountx'+jzDataDiscountx); console.warn('this.jzDataDiscountxxx'+this.jzDataDiscount); this.ConsolidatedDiscountPolicy(jzDataDiscountx); //一般折扣更改过合同价格计算 this.updateCommonlyDiscountLogic(HeTo.Id,HeTo.JxsType,HeTo.GuaranteeDiscount__c_Input,HeTo.NormalDiscount__c_Input,HeTo.Category__c,this.jzDataDiscount); }); } if(boolean2&&ffgg==0){ newData3.forEach(TeYue=>{ //根据合同价格计算特约折扣 GuaranteeDiscount__cZuiXiao=parseFloat(TeYue.GuaranteeDiscount__c); NormalDiscount__cZuiXiao=parseFloat(TeYue.NormalDiscount__c); TeYue=this.ComouteProductDiscount(TeYue.Id,TeYue.Category__c,TeYue.GuaranteeDiscount__c_Input, TeYue.NormalDiscount__c_Input, TeYue.GuaranteeDiscount_H_Money__c,TeYue.NormalDiscount_H_Money__c, TeYue); if(TeYue==1||TeYue==2||TeYue==12||TeYue==3){ ffgg=TeYue; return ; }else{ //合并折扣政策重复方案 this.ConsolidatedDiscountPolicy(this.jzDataDiscount); //一般折扣更改过合同价格计算 this.updateCommonlyDiscountLogic(TeYue.Id,TeYue.JxsType,TeYue.GuaranteeDiscount__c_Input,TeYue.NormalDiscount__c_Input,TeYue.Category__c,this.jzDataDiscount); } }); } if(ffgg==1||ffgg==2||ffgg==12||ffgg==3){ this.Alert(InverseCalculationTiShi(ffgg,GuaranteeDiscount__cZuiXiao,NormalDiscount__cZuiXiao), true, true); }else{ this.Alert("数据修改成功", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); } } //刷新 this.jzshows2 = false; this.IsLoading2 = true; setTimeout(() => { this.jzshows2 = true; this.IsLoading2 = false; }, 800) } newArrsTemp = []; newArrsTemp2 = []; // ===================== END使用价格政策 ============================= // =========================特约折扣 弹出框 ========================= @track ShowSpecial; //打开特约折扣弹出框 showModalSpecial() { this.QuoteData.forEach(qtd => { if (!qtd.Opportunity.IsAuthorized__c) { this.Alert("该询价不是特约经销商授权", true, true); } else { this.ShowSpecial = true; } }); } cancelSpecial() { this.ShowSpecial = false this.ShowSpecialIsError = false; this.SelectedFnDataSpecial = []; this.SelectedOtherDataArr = []; } //特约错误提示 errorTiShi(str){ this.ShowSpecialIsError = true; this.ShowSpecial = true; this.ShowSpecialError = str; } @track TyName = [] ShowSpecialError = "只能选择一条折扣数据!"; //特约折扣点击确定后执行 SavesSpecial() { this.ShowSpecialIsError = false; this.ShowSpecial = false; var ItempTempData = { ...{}, ...this.SelectedFnDataSpecial[0] }; if (this.SelectedOtherDataArr.length == 0 && this.SelectedFnDataSpecial.length != 0) { this.errorTiShi("请选择特约折扣产品!"); } else if (this.SelectedFnDataSpecial.length == 0 && this.SelectedOtherDataArr.length != 0) { this.errorTiShi("请选择特约折扣方案!"); } else if (this.SelectedFnDataSpecial.length == 0 && this.SelectedOtherDataArr.length == 0) { this.errorTiShi("请选择特约折扣方案和产品!"); } else { ItempTempData.itemss = this.SelectedOtherDataArr; ItempTempData.IsTempItems = true; //tt // ItempTempData.NormalDiscount__c = parseFloat(ItempTempData.NormalDiscount__c); // ItempTempData.GuaranteeDiscount__c = parseFloat(ItempTempData.GuaranteeDiscount__c); ItempTempData.NormalDiscount__c_Input = ItempTempData.NormalDiscount__c; ItempTempData.GuaranteeDiscount__c_Input = ItempTempData.GuaranteeDiscount__c; //tt this.SelectedFnDataSpecial[0] = ItempTempData; //将产品与方案匹配 this.UpdateDiscountData(this.SelectedFnDataSpecial); //特约折扣匹配规则 this.SpecialSavesChange("特约折扣", ItempTempData, this.SelectedFnDataSpecial[0].Id, this.SelectedFnDataSpecial[0].CompareId); this.Alert("特约折扣选择完成", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); //合并折扣政策重复方案 this.ConsolidatedDiscountPolicy(this.jzDataDiscount); //折扣政策价格计算 // this.ComputeData(ItempTempData.Id, '折扣政策'); this.ComputeDiscount(ItempTempData.Id, ItempTempData.NormalDiscount__c, ItempTempData.GuaranteeDiscount__c, ItempTempData.Category__c, ItempTempData.JxsType); this.SelectedFnDataSpecial = []; this.SelectedOtherDataArr = []; } } //合并折扣政策重复方案 ConsolidatedDiscountPolicy(SchemeSet) { console.warn('SchemeSet'+SchemeSet); var arr = []; arr = ConsolidatedDiscountPolicyLogic(SchemeSet, arr); //合并折扣政策重复方案逻辑 console.warn('arr'+arr); // this.jzDataDiscount = [...[], ...arr];//20230214 this.jzDataDiscount = [].concat(arr);//20230214 console.warn('this.jzDataDiscount2'+this.jzDataDiscount); // this.ConsolidationProgramProducts(arr); this.ConsolidatedDiscountDetails(arr); //合并折扣政策产品明细 } //合并折扣政策产品明细 ConsolidatedDiscountDetails(arrSchemes) { // var jzdataList = [...[], ...this.jzDataProduct];//20230214 var jzdataList = [].concat(this.jzDataProduct);//20230214 console.warn('jzdataList'+jzdataList); this.jzDataProduct = ConsolidatedDiscountDetailsLogic(arrSchemes, jzdataList); //合并折扣政策产品明细逻辑 } @track initSearchFormSpecial = initSearchFormSpecial2; @track initDataTableSpecial = initDataTableSpecial2; @track jzDataSpecial = []; @track tableIsLodingSpecial = true; // 后台交互,获取特约折扣方案列表数据 getTableDataSpecial(event) { let listQuery = event.detail.listQuery; var Agency1__c = this.QuoteData[0].Agency1__c; listQuery.pageLimit = 40; listQuery.Agency1c = Agency1__c; GetAuthorizerSearch(listQuery).then(result => { var responseObj = JSON.parse(result); this.jzDataSpecial = responseObj.records; this.jzDataSpecial.forEach(element => { element.JxsType = "特约折扣"; //tt element.NormalDiscount__c = element.NormalDiscount__c+"%"; // element.NormalDiscount__c=Number(element.NormalDiscount__c.toFixed(2)); element.GuaranteeDiscount__c = element.GuaranteeDiscount__c+'%'; // element.GuaranteeDiscount__c=Number(element.GuaranteeDiscount__c.toFixed(2)); //tt }); GetAgencyRName().then(gar => { //获取经销商姓名 var a = JSON.parse(gar); a.forEach(ga => { if (ga.Agency__r != undefined) { var arr = []; this.jzDataSpecial.forEach(jzdsc => { //特约折扣方案数据 if (ga.Agency__c == jzdsc.Agency__c) { jzdsc.Agency__Name = ga.Agency__r.Name; arr.push(jzdsc); } else { arr.push(jzdsc); } }); // this.jzDataSpecial = [...[], ...arr];//20230214 this.jzDataSpecial = [].concat(arr);//20230214 } }); }) this.tableIsLodingSpecial = false; }) } // 选中特约折扣方案数据 @track SelectedFnDataSpecial = []; ShowSpecialIsError = false; SelectedFnSpecial(event) { let arr = event.detail.rows; if (event.detail.rows.length > 1) { this.ShowSpecialIsError = true; } else { this.ShowSpecialIsError = false; } var TempArr = []; TempArr.push(arr[0]) var tempObject = { ...{}, ...TempArr[0] } tempObject.CompareId = GetUUID(); this.SelectedFnDataSpecial = [tempObject]; } //特约折扣数量拆分 IsLoading5 = false; jzshows5 = true; IsLoadingFlag1 = true; SaveSpecialDiscount(event) { var data = event.detail.rows; let newData = []; let editnewDate = []; var boolean = 1; for (var i = 0; i < this.jzDataOtherData.length; i++) { var editData = {}; var flag = false; for (var j = 0; j < data.length; j++) { var id = data[j].Id; if (this.jzDataOtherData[i].Id == id) { // editData=data[j]; editData = { SplitQuantity: '' }; //拆分次数 editData.SplitQuantity = data[j].SplitQuantity; // editData.id=id; flag = true; } } if (flag) { var newItem = { ...this.jzDataOtherData[i], ...{} }; if (editData.SplitQuantity != undefined) { newItem.SplitQuantity = Number(editData.SplitQuantity); } newData.push(newItem); editnewDate.push(newItem); } else { newData.push({ ...{}, ...this.jzDataOtherData[i] }); } } //haha4 // var newArrs = [...[], ...editnewDate];//20230214 var newArrs = [].concat(editnewDate);//20230214 newArrs.forEach(item => { if (item.Quantity < item.SplitQuantity) { boolean = 2; } else if (item.SplitQuantity == 0 || item.SplitQuantity == '') { boolean = 3; } }); if (boolean == 1) { this.jzDataOtherData = newData; this.ShowSpecialIsError = false; } else if (boolean == 2) { this.errorTiShi("修改错误,使用数量不得大于数量"); } else if (boolean == 3) { this.errorTiShi("修改错误,使用数量不得为0或为空"); } //刷新 this.jzshows5 = false; this.IsLoading5 = true; this.IsLoadingFlag1 = false; setTimeout(() => { this.SelectedOtherDataArr = []; this.IsLoading5 = false; this.jzshows5 = true; }, 1000); setTimeout(() => { this.IsLoadingFlag1 = true; }, 2000); } // OtherData @track initSearchFormOtherData = initSearchFormOtherData2; @track initDataTableOtherData = initDataTableOtherData2; @track jzDataOtherData = []; @track tableIsLodingOtherData = true; // 后台交互,获取特约折扣产品列表数据 getTableDataOtherData(event) { if (!this.IsLoadingFlag1) { return }; this.jzDataOtherData = this.jzDataDefault; var jzDataOtherDataTemp = []; this.jzDataOtherData.forEach(jzdod => { var ItemsTemp = { ...{}, ...jzdod }; ItemsTemp.SplitQuantity = ItemsTemp.Quantity; jzDataOtherDataTemp.push(ItemsTemp); }) this.jzDataOtherData = jzDataOtherDataTemp; this.tableIsLodingOtherData = false; } // 特约折扣产品选中 @track SelectedOtherDataArr = []; SelectedFnOtherData(event) { let arr = event.detail.rows; this.SelectedOtherDataArr = arr; } // ============================END ======================= // =========================一般价格 弹出框 ========================= @track ShowCommonly; showModalCommonly() { this.ShowCommonly = true } //保存使用数量 @track IsLoading4 = false; jzshows4 = true; IsLoadingFlag = true; //一般折扣匹配规则 SaveGeneralDiscount(event) { var data = event.detail.rows; let newData = []; let editnewDate = []; var boolean = 1; for (var i = 0; i < this.jzDataCommonly.length; i++) { var editData = {}; var flag = false; for (var j = 0; j < data.length; j++) { var id = data[j].Id; if (this.jzDataCommonly[i].Id == id) { // editData=data[j]; editData = { SplitQuantity: '' }; //拆分次数 editData.SplitQuantity = data[j].SplitQuantity; // editData.id=id; flag = true; } } if (flag) { var newItem = { ...this.jzDataCommonly[i], ...{} }; if (editData.SplitQuantity != undefined) { newItem.SplitQuantity = Number(editData.SplitQuantity); } newData.push(newItem); editnewDate.push(newItem); } else { newData.push({ ...{}, ...this.jzDataCommonly[i] }); } } //haha3 // var newArrs = [...[], ...editnewDate];//20230214 var newArrs = [].concat(editnewDate);//20230214 newArrs.forEach(item => { if (item.Quantity < item.SplitQuantity) { boolean = 2; } else if (item.SplitQuantity == 0 || item.SplitQuantity == '') { boolean = 3; } }); if (boolean == 1) { this.jzDataCommonly = newData; this.ShowCommonlyIsError = false; } else if (boolean == 2) { this.ShowCommonlyIsError = true; this.ShowCommonlyError = "修改错误,使用数量不得大于数量"; } else if (boolean == 3) { this.ShowCommonlyIsError = true; this.ShowCommonlyError = "修改错误,使用数量不得为0或为空"; } //刷新 this.jzshows4 = false; this.IsLoading4 = true; this.IsLoadingFlag = false; setTimeout(() => { this.SelectedFnCommonlyData = []; this.IsLoading4 = false; this.jzshows4 = true; }, 1000); setTimeout(() => { this.IsLoadingFlag = true; }, 2000); } //关闭一般折扣弹出框触发 cancelCommonly() { this.ShowCommonly = false; this.ShowCommonlyIsError = false; this.SelectedFnCommonlyData = []; this.SaveLb = ''; this.SaveZk = ''; } @track initSearchFormCommonly = initSearchFormCommonly2; @track initDataTableCommonly = initDataTableCommonly2; @track jzDataCommonly = []; @track tableIsLodingCommonly = true; // 后台交互,获取一般折扣列表数据 getTableDataCommonly(event) { if (!this.IsLoadingFlag) { return }; this.jzDataCommonly = this.jzDataDefault; var jzDataCommonlyTemp = []; this.jzDataCommonly.forEach(items => { var ItemsTemp = { ...{}, ...items }; ItemsTemp.JxsType = "一般折扣"; ItemsTemp.SplitQuantity = ItemsTemp.Quantity; jzDataCommonlyTemp.push(ItemsTemp); }) this.jzDataCommonly = jzDataCommonlyTemp; this.tableIsLodingCommonly = false; } SelectedFnCommonlyData = []; // 选中一般折扣产品 SelectedFnCommonly(event) { let arr = event.detail.rows; var newArr = []; arr.forEach(item => { var TempObject = { ...{}, ...item }; TempObject.JxsType = "一般折扣"; newArr.push(TempObject); }) this.SelectedFnCommonlyData = newArr; } SaveLb = ''; SaveZk = ''; //获取一般折扣弹出框产品类别 handleChangeLb(event) { this.SaveLb = event.target.value; } //获取一般折扣弹出框使用折扣 handleChangeZk(event) { if (event.target.value != '') { event.target.value = parseFloat(event.target.value) + "%"; } this.SaveZk = event.target.value; } //一般错误提示 errorTiShiYi(str){ this.ShowCommonlyIsError = true; this.ShowCommonlyError = str; } //点击一般折扣弹出框确定按钮触发 PromotionNoTemp = 1001; ShowCommonlyError = "请选择一般产品!"; ShowCommonlyIsError = false; cancelSaveCommonly() { //处理数据 var arr = this.SelectedFnCommonlyData; this.ShowCommonlyIsError = false; if (this.SelectedFnCommonlyData.length != 0) { var ItempTempData = {}; ItempTempData.Id = GetUUID(); ItempTempData.CompareId = GetUUID(); ItempTempData.Name = '一般折扣'; ItempTempData.JxsType = "一般折扣"; ItempTempData.itemss = arr; if (this.SaveLb == '' || this.SaveZk == '') { if (this.SaveLb == '' && this.SaveZk != '') { this.errorTiShiYi("请选择产品类别!"); } else if (this.SaveZk == '' && this.SaveLb != '') { this.errorTiShiYi("请输入使用折扣!"); } else if (this.SaveZk == '' && this.SaveLb == '') { this.errorTiShiYi("请输入使用折扣和产品类别!"); } } else { ItempTempData.Category__c = this.SaveLb; ItempTempData.NormalDiscount__c_Input = this.SaveZk; ItempTempData.if_Contain_Nod__c = false; var TempList = []; TempList.push(ItempTempData); //将产品与方案匹配 this.UpdateDiscountData(TempList); //折扣政策匹配规则 this.SpecialSavesChange("一般折扣", ItempTempData, ItempTempData.Id, ItempTempData.CompareId); //关闭一般折扣弹出框触发 this.cancelCommonly(); this.Alert("一般折扣选择完成", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); this.ConsolidatedDiscountPolicy(this.jzDataDiscount); //计算折扣政策价格 // this.ComputeData(ItempTempData.Id, '折扣政策'); this.ComputeDiscount(ItempTempData.Id, ItempTempData.NormalDiscount__c_Input, ItempTempData.GuaranteeDiscount__c, ItempTempData.Category__c, ItempTempData.JxsType); } } else { this.errorTiShiYi("请选择一般产品!"); } } // ============================END ======================= // ===================== 产品明细 ============================= @track jzDataProduct = []; @track tableIsLodingProduct = true; @track initDataTableProduct = initDataTableProduct2; // 后台交互,获取列表数据 getTableDataProduct(event) { this.tableIsLodingProduct = false; } @track SelectedFnProductData = []; //选中产品明细 SelectedFnProduct(event) { let arr = event.detail.rows; this.SelectedFnProductData = arr; } //todu5 jzshows = true; //加载 IsLoading = false; OnLoading(flag) { this.IsLoading = flag; } //删除产品明细 delectTableProduct() { this.DeleteIsChangesFnSingle(this.SelectedFnProductData); } ifTips=true; ifFTip=true; //保存所有报价试算界面数据 saveAllDataProductFn() { var newTemp = []; this.jzDataFixedPrice.forEach(item => { //价格政策 var itemTemp = { ...{}, ...item }; // itemTemp.分类名称(根据 两个折扣数据分类 1) 价格政策 2)折扣政策) itemTemp.typess = "价格政策 "; newTemp.push(itemTemp); }); var newTemp2 = []; this.jzDataDiscount.forEach(item => { //折扣政策 var itemTemp = { ...{}, ...item }; // itemTemp.分类名称(根据 两个折扣数据分类 1) 价格政策 2)折扣政策) itemTemp.typess = "折扣政策"; newTemp2.push(itemTemp); }); // var data = [...newTemp, ...newTemp2];//20230213 var data = newTemp.concat(newTemp2);//20230213 var ParamIdStr = this.ParamIdStr; var Trade__c = this.QuoteData[0].Opportunity.Trade__c; var NewData = ConsolidationScheme(data, ParamIdStr, Trade__c); var NewData1 = MergeProducts(this.jzDataProduct, this.jzDataDefault, data, ParamIdStr); var jsondatasss = JSON.stringify(NewData); var jsondatassss = JSON.stringify(NewData1); var Sales_Root__c = this.QuoteData[0].Opportunity.Sales_Root__c; var QuoteId = this.QuoteData[0].Id; var OpportunityId = this.QuoteData[0].OpportunityId; if (this.jzDataDefault.length == 0) { var ifnull = true; var ifnunum=1; newTemp.forEach(ntp => { //价格政策 if (ntp.HeTongTotal == undefined || ntp.HeTongTotal == 0) { ifnull = false; } }); this.jzDataProduct.forEach(jzdp=>{ if(jzdp.AgencyUnitPrice__c<0){ ifnunum=2; return; } }); debugger; if (ifnull&&ifnunum==1) { this.IsLoading=true; saveAllDataProduct({ JsonStr: jsondatasss, ParamIdStr: this.ParamIdStr, JsonStr2: jsondatassss, QuoteId: QuoteId, SalesRootc: Sales_Root__c, ContractPrice: this.ContractPrice, OpportunityId: OpportunityId, DealerFinalPriceFc: this.QuoteData[0].Dealer_Final_Price_F__c, Agent1Agent2Pricec: this.QuoteData[0].Agent1_Agent2_Price__c }).then(result => { if(this.ifTips){ this.IsLoading=false; this.Alert("数据已保存", false, true); setTimeout(() => { this.CloseAlert(); }, 2000); } // SWAG-C9X7S3 20211224 ssm start else { this.jumpNewQuoteEntry(); } // SWAG-C9X7S3 20211224 ssm end }); } else { if(ifnunum==2){ this.ifFTip=false; this.Alert("产品明细中金额有负数,不可保存", true, true); }else{ this.ifFTip=false; this.Alert("一般产品的合同价格为空,不可保存", true, true); } } } else { this.ifFTip=false; this.Alert("产品未选完,不可保存", true, true); } } // ===================== 产品明细 ============================= //成功提示 SaveShowText = '促销方案选择完成'; //折扣政策合同价格汇总 HeTongPriceCompute() { var HeTongPriceList = []; var jzdateList=this.jzDataDiscount;//折扣政策 var jzDataProductList=this.jzDataProduct;//产品明细 HeTongPriceList=HeTongPriceComputeLogic(jzdateList,jzDataProductList); if (HeTongPriceList.length > 0) { this.jzDataDiscount = HeTongPriceList; } } //合同价格汇总 ContractPrice = 0; ContractPriceCompute() { this.HeTongPriceCompute(); this.ContractPrice = 0; var sum = this.ContractPrice; var jzDataProductList = this.jzDataProduct//产品明细 var jzDataDiscountList = this.jzDataDiscount//折扣政策 var jzDataFixedPriceList = this.jzDataFixedPrice//价格政策 sum = parseFloat(sum); sum=ContractPriceComputeLogic(sum,jzDataProductList,jzDataDiscountList,jzDataFixedPriceList); this.ContractPrice = sum; } //更改一般折扣合同价格计算合同总价 GeneralDiscountContractSummary(){ this.ContractPrice = 0; var sum = this.ContractPrice; sum = parseFloat(sum); var jzDataDiscountList = this.jzDataDiscount;//折扣政策 var jzDataFixedPriceList = this.jzDataFixedPrice;//价格政策 sum=GeneralDiscountContractSummaryLogic(sum,jzDataDiscountList,jzDataFixedPriceList); this.ContractPrice = sum; } //删除时需要用的唯一id的添加 updateIdStr(str) { //方案的识别字符串 // TODU var newArr = []; var indexNum = 0; var jzdpdc = []; if (str == "1") { // jzdpdc = [...[], ...this.jzDataProduct]; //促销产品//20230214 jzdpdc = [].concat(this.jzDataProduct);//20230214 } else if (str == "2") { // jzdpdc = [...[], ...this.jzDataDiscount]; //折扣政策//20230214 jzdpdc = [].concat(this.jzDataDiscount);//20230214 } else if (str == "3") { // jzdpdc = [...[], ...this.jzDataFixedPrice]; //价格政策//20230214 jzdpdc = [].concat(this.jzDataFixedPrice);//20230214 } jzdpdc.forEach(item => { indexNum++; var temp = { ...item }; temp.DelectId = indexNum; newArr.push(temp); }) if (str == "1") { // this.jzDataProduct = [...[], ...newArr]; //促销产品//20230214 this.jzDataProduct = [].concat(newArr);//20230214 } else if (str == "2") { // this.jzDataDiscount = [...[], ...newArr]; //折扣政策//20230214 this.jzDataDiscount = [].concat(newArr);//20230214 } else if (str == "3") { // this.jzDataFixedPrice = [...[], ...newArr]; //价格政策//20230214 this.jzDataFixedPrice = [].concat(newArr);//20230214 } //TODU } //返回不保存 jumpNewQuoteEntry() { var DeveloperName = this.QuoteData[0].Opportunity.RecordType.DeveloperName; //路径跳转 PathJump(DeveloperName,this.ParamIdStr); } //返回并保存 jumpNewQuoteEntryAndSave(){ this.ifTips=false; this.saveAllDataProductFn(); // SWAG-C9X7S3 20211224 ssm start // if(this.ifFTip){ // this.jumpNewQuoteEntry(); // } // SWAG-C9X7S3 20211224 ssm end } //复制 copyJzDataTableProduct(){ var QuoteId = this.QuoteData[0].Id; if (QuoteId == null || QuoteId == '') { alert(this.label.Please_Save_Quote); return null; } var records; var x; var targetString = '产品型号\t产品名称\t数量\t保修类型\t方案代码\t促销方案名称/产品系列\t主报价\t多年保价格小计\t折扣\t合同单价\t合同总价'; try { SelectAllDataDiscount({ ParamIdStr: this.ParamIdStr }).then(reslut=>{ copyLogic(this.label.Check_Your_Clipboard,records,x,targetString,reslut); }); } catch (e) { alert(e.faultcode + ',' + e.faultstring); } } }