import { LightningElement,track } from 'lwc'; import GetPromotionDefalut from '@salesforce/apex/PromotioService.GetPromotionDefalut'; import GetPromotionPromotionSearch from '@salesforce/apex/PromotioService.GetPromotionPromotionSearch'; import GetNormalProductSearch from '@salesforce/apex/PromotioService.GetNormalProductSearch'; import GetAuthorizerSearch from '@salesforce/apex/PromotioService.GetAuthorizerSearch'; import GetSearchProductById from '@salesforce/apex/PromotioService.GetSearchProductById'; import saveAllDataProduct from '@salesforce/apex/PromotioService.saveAllDataProduct'; import GetParamToId from '@salesforce/apex/PromotioService.GetParamToId'; import SelectAllDataProduct from '@salesforce/apex/PromotioService.selectAllDataProduct'; import SelectAllDataDiscount from '@salesforce/apex/PromotioService.selectAllDataDiscount'; import deleteAllDiscounttable from '@salesforce/apex/PromotioService.deleteAllDiscounttable'; import deleteAlltable from '@salesforce/apex/PromotioService.deleteAlltable'; import GetQuoteData from '@salesforce/apex/PromotioService.GetQuoteData'; import GetAgencyRName from '@salesforce/apex/PromotioService.GetAgencyRName'; import selectUpdateFiexedpriceData from '@salesforce/apex/PromotioService.selectUpdateFiexedpriceData'; import selectUpdateQuoteLineItemData from '@salesforce/apex/PromotioService.selectUpdateQuoteLineItemData'; export default class Test02 extends LightningElement { //全局加载 IsLoading = false; //加载的标识 //加载提示框 OnLoading(flag){ this.IsLoading = flag; } deleteAllDiscounttable(){ deleteAllDiscounttable().then(result=>{ console.warn(result); }) } deleteAlltable(){ deleteAlltable().then(result=>{ console.warn(result); }) } // ===============通用的方法 ==================== //获取Id ParamIdStr = ''; getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i{ if (result) { console.warn("ID OK"); } }) this.ScreenWidth = "height:"+(window.screen.availHeight-50)+"px;overflow:scroll;"; //加载数据 this.OnLoading(true); setTimeout(()=>{ this.ItmeOutFn(); },2000); this.OnLoadSavesDatas(); this.OnLoadQuoteData(this.ParamIdStr); //todu11 var event={page: 1,pageLimit: 10,search: "",sortOrder: "asc",sortPlus: undefined,fag: true}; setTimeout(()=>{ this.getTableDataFix(event); },2000); } ItmeOutFn() { this.OnLoading(false); if(this.Complate) { // this.SaveShowText = "保存数据发生改变,已加载最新数据!"; // this.TZshow(true); this.Alert("保存数据发生改变,已加载最新数据!",false,true); } } QuoteData=[]; //加载报价数据 OnLoadQuoteData(idStr) { GetQuoteData({QuoteID:idStr}).then(result=>{ var responseObj = JSON.parse(result); debugger this.QuoteData = responseObj; }) } // errorPromptBox(str){ // this.TZErrorshow(true); // this.ShowErrorContent=str; // setTimeout(()=>{ // this.ErrorTongzhiClick(); // this.ShowErrorContent = "折扣类只能选着一个"; // },3000) // } OnLoadProduct = []; //未选择产品 OnLoadSaveProduct = []; //已选择产品 OnLoadDiscount = []; //折扣政策 OnLoadFixDiscount = []; //价格政策 flagall=false; //加载保存的数据 OnLoadSavesDatas(){ //获取产品数据 SelectAllDataDiscount({ParamIdStr:this.ParamIdStr}).then(result=>{ result.forEach(item=>{ if (item.ismatch__c == "0") { item.Quantity = item.Quantity__c; item.Name=item.Name__c; item.Name__c=item.Name_c__c; item.ListPrice=item.ListPrice__c; item.Id=item.QuiteLineitem__c; item.PromotionId=item.Promotion_id__c; item.TypeName=item.TypeName__c; item.RecordTypeId=item.RecordTypeId__c; item.ParamIdStr=item.QuantityId__c; item.Product2Id=item.Product2__c; item.QuiteLineitem__c = item.QuiteLineitem__c; this.OnLoadProduct.push(item); }else if (item.ismatch__c == "1") { item.Quantity = item.Quantity__c; item.Name=item.Name__c; item.Name__c=item.Name_c__c; item.ListPrice=item.ListPrice__c; item.Id=item.QuiteLineitem__c; item.Product2Id=item.Product2__c; item.Product2=item.Product2__r; if(item.Name=="一般折扣"){ item.PromotionId=item.PromotionSales__c; }else{ item.PromotionId=item.Promotion_id__c; } item.TypeName=item.TypeName__c; item.RecordTypeId=item.RecordTypeId__c; item.ParamIdStr=item.QuantityId__c; item.QuiteLineitem__c = item.QuiteLineitem__c; item.CompareId=item.CompareId__c; item.Discount__c_Input=item.DiscountRate__c; this.OnLoadSaveProduct.push(item); } }) 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.JxsType=items.JxsType__c; items.NormalDiscount__c=items.NormalDiscountc__c; items.GuaranteeDiscount__c_Input=items.GuaranteeDiscount_c_Input__c; items.NormalDiscount__c_Input=items.NormalDiscount_c_Input__c; items.TypeName=items.TypeName__c; if(items.JxsType__c!="一般折扣"){ items.Id=items.PromotionHead__c; } items.ParamIdStr=items.Quote__c; items.maxCounts=items.maxCounts__c; items.CompareId=items.CompareId__c; this.OnLoadDiscount.push(items); }else if (items.typess__c == "价格政策") { items.Counts=items.itemCounts__c; items.Total=items.Price_total__c; items.HeTongTotal=items.contractPrice__c; items.TypeName=items.TypeName__c; items.Id=items.PromotionHead__c; items.ParamIdStr=items.Quote__c; debugger if(items.trade__c=="内貿"){ items.sumListPrice=items.ListPriceTotal__c; items.sumNoDiscount=items.NodiscountTotal__c; }else if(items.trade__c=="外貿"){ items.sumListPrice=items.ListPriceTotalUSD__c; items.sumNoDiscount=items.NodiscountTotalUSD__c; } items.maxCounts=items.maxCounts__c; this.OnLoadFixDiscount.push(items); } }) 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"); } }) } 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 = this.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"); }) }    ChangeFiexedData(key){         var keyArr = ['Status__c','ifNecessary__c','OrderNo__c','Price_CNY__c','Price_USD__c'];         var flag = false;         keyArr.forEach(item=>{             if (item == key) {                 flag = true;             }         })         return flag;     } //产品需要更新的字段   ChangeProductData(key){         var keyArr = [''];         var flag = false;         keyArr.forEach(item=>{             if (item == key) {                 flag = true;             }         })         return flag;     } //从数据库更新已保存的数据 产品 UpdateBy 2021 06 29 UpdateSaveDataQuoteLineItemSelectByID(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; //TODU 这里的逻辑需要重新计算 this.updateIdStr("1"); //合同价格汇总 this.ContractPriceCompute(); }) } } // ==============UUID GetUUID() { var s = []; var hexDigits = "0123456789abcdef"; for (var i = 0; i < 36; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); } s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010 s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01 s[8] = s[13] = s[18] = s[23] = "-"; var uuid = s.join(""); return uuid; } // ==== 特约与一般折扣添加 价格= jzDataFixedPrice 折扣=jzDataDiscount 已选择的= jzDataProduct SpecialSavesChange(SaveName,SelectedData,IdStr,CompareId){ var NewDefaultData = []; var AddProductData = []; var DefalutQuantity = 0; this.jzDataDefault.forEach(defaultItem=>{ var defaultItemTemp = {...{},...defaultItem}; debugger var SelectedList = SelectedData.itemss.filter(items=>{ if (items.Id == defaultItem.Id) { return true; }else { return false; } }) if (SelectedList!=undefined && SelectedList.length > 0) { var SelectedListDataTemp = {...{},...SelectedList[0]}; SelectedListDataTemp.PromotionNo__c = SelectedData.PromotionNo__c; SelectedListDataTemp.Name = SelectedData.Name; SelectedListDataTemp.TypeName = "折扣政策"; SelectedListDataTemp.PromotionId = IdStr; SelectedListDataTemp.CompareId = CompareId; // if(SaveName=="一般折扣"){ SelectedListDataTemp.Quantity = SelectedListDataTemp.SplitQuantity; // } // SelectedListDataTemp if (defaultItemTemp.Quantity != SelectedListDataTemp.Quantity) { debugger defaultItemTemp.Quantity = defaultItemTemp.Quantity - SelectedListDataTemp.Quantity; DefalutQuantity += defaultItemTemp.Quantity ; NewDefaultData.push(defaultItemTemp); AddProductData.push(SelectedListDataTemp); }else{ DefalutQuantity += SelectedListDataTemp.Quantity ; AddProductData.push(SelectedListDataTemp); return } }else{ NewDefaultData.push(defaultItemTemp); } }) this.jzDataDefault = NewDefaultData; // SelectedData.Counts = DefalutQuantity; this.jzDataProduct = [...this.jzDataProduct,...AddProductData]; //合同价格汇总 this.ContractPriceCompute(); //添加数量 var newDicountData = []; this.jzDataDiscount.forEach(disItem=>{ var newTemp = {...{},...disItem}; if (newTemp.Id == IdStr) { newTemp.Counts = DefalutQuantity; } newDicountData.push(newTemp); }) this.jzDataDiscount = newDicountData; } GetSearchProductByIdFn(idStr,jzDataProductParam,TypeName,jzDataDefaultToTemps,arrData,isShow = true) { //dddd var SeachData = {SearchId:idStr}; console.warn("GetSearchProductById Start"); GetSearchProductById(SeachData).then(result => { console.warn("GetSearchProductById END"); var tempObject = {...{},...jzDataProductParam} jzDataProductParam=this.countListAndNod(tempObject,result); //返回数据比较规则 this.CompareData(result,idStr,jzDataProductParam,TypeName,jzDataDefaultToTemps,arrData,isShow); }) } //计算listPrice的和以及nod和 countListAndNod(item,result){ var ifTrade=this.QuoteData[0].Opportunity.Trade__c; var ListPrices=0; var Nodiscounts=0; result.forEach(itemss=>{ this.jzDataDefaultCopy.forEach(jddc=>{ if(itemss.Asset_Model_No__c==jddc.Asset_Model_No__c){ debugger if(ifTrade=="内貿"){ ListPrices +=itemss.Quantity__c*jddc.Product2.Intra_Trade_List_RMB__c; Nodiscounts +=itemss.Quantity__c*jddc.Product2.Intra_Trade_Service_RMB__c; }else if(ifTrade=="外貿"){ ListPrices +=itemss.Quantity__c*jddc.Product2.Foreign_Trade_List_US__c; Nodiscounts +=itemss.Quantity__c*jddc.Product2.NoDiscount_Foreign__c; } 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}); } } } }); }); item.sumListPrice=ListPrices; item.sumNoDiscount=Nodiscounts; var arr={...{},...item}; return arr; } CompareData(list,idStr,jzDataProductParam,TypeName,jzDataDefaultToTemps,arrData,isShow){ var isChange = false; var TempsJzData = [] TempsJzData = [...[],...this.jzDataDefault]; var TempsJzDataToCompare = [] TempsJzData.forEach(item=>{ list.forEach(element => { if (element.Asset_Model_No__c == item.Asset_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{ 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]; // console.warn(TempsJzDataToCompare); //End if(TempsJzDataToCompare.length == list.length){ TempsJzDataToCompare.forEach(TempsItems => { this.ComparePushData(TempsItems.item.Quantity,TempsItems.element.Quantity__c,TempsItems.element.Asset_Model_No__c,idStr,jzDataProductParam,TypeName); }); //判断是否显示 提示框 debugger if(isShow) { if(this.ifqianpi){ // this.TZshow(true); // setTimeout(()=>{ // this.TongzhiClick(); // },2000) // this.TZErrorshow(false); this.Alert("促销方案选择完成",false,true); } } }else{ if(isShow) { if(this.ifqianpi){ // this.errorPromptBox('促销方案不满足,请从新选择'); this.Alert("促销方案不满足,请从新选择",true,true); } } return; } if (isChange) { this.ChangeNumZeroTrueChanges(); } var temps = this.CompareFullData; //添加 this.UpdateJZData(arrData); //更新次数 this.updatesNums(); //保存最大次数 this.savecount(idStr); //计算价格 this.ComputeData(idStr,'价格政策'); } savecount(idStr){ 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单价 //111 ReplacementUnitPrice(){ var ifTrade=this.QuoteData[0].Opportunity.Trade__c; var arr=[...[],...this.jzDataProduct]; arr.forEach(jdpct=>{ if(ifTrade=="内貿"){ jdpct.ListPrice=jdpct.Product2.Intra_Trade_List_RMB__c; jdpct.ServicePrice__c=jdpct.Product2.Intra_Trade_Service_RMB__c; }else if(ifTrade=="外貿"){ jdpct.ListPrice=jdpct.Product2.Foreign_Trade_List_US__c; jdpct.ServicePrice__c=jdpct.Product2.NoDiscount_Foreign__c; } }); this.jzDataProduct=[...[],...arr]; } //计算价格 ComputeData(id,category){ this.ReplacementUnitPrice(); //数据 this.updateIdStr("3"); var arrTemp = this.jzDataFixedPrice; // id 政策的价格 this.updateIdStr("1"); var arrProductTemp = this.jzDataProduct; // PromotionId 产品的价格 // var QuoteData = this.QuoteData[0]; // 报价 this.updateIdStr("2"); var arrTemp1 =this.jzDataDiscount;//折扣政策 var arrTemp2 =this.jzDataDefault;//待选产品 if(category=='价格政策'){ //todu1 arrTemp.forEach(item=>{ if(id==item.Id){ item.Total=item.Counts*item.Price_CNY__c; //计算促销总价 if(item.Price_CNY__c!=undefined&&item.HeTongTotal==undefined){ if(item.if_Contain_Nod__c){ item.HeTongTotal=item.Total; }else{ item.HeTongTotal=item.Total+item.sumNoDiscount*item.Counts; } } //计算选择促销政策是的经销商单价和小计 var PromotionHeadRecordId = item.recordTypeName__c; ; // console.warn(PromotionHeadRecordId); if(PromotionHeadRecordId=="Promotion"){//促销方案 // if(item.if_Contain_Nod__c){ this.newArrsTemp3=[]; this.newArrsTemp4=[]; var newArrsTemp5=[]; var newArrsTemp6=[]; debugger arrProductTemp.forEach(itemsss=>{ if(itemsss.PromotionId==item.Id){ if(item.determine=='改过'){ var flag=true; // var a = this.jzDataDefaultQuantityList ; var b = this.jzDataDefaultCopyQuantityList ; arrTemp2.forEach(datedefault=>{ debugger var quantity=0; if(datedefault.Id==itemsss.Id){ b.forEach(iem=>{ if(iem.Asset_Model_No__c==datedefault.Asset_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=>{ var quantity=0; if(add.Id==itemsss.Id){ b.forEach(iems=>{ if(iems.Asset_Model_No__c==add.Asset_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; } }); } } debugger itemsss.AgencyUnitPrice__c=((item.HeTongTotal/item.Counts)-item.sumNoDiscount)*(itemsss.ListPrice/item.sumListPrice)+itemsss.ServicePrice__c; itemsss.AgencySubtotal__c=itemsss.AgencyUnitPrice__c*itemsss.Quantity; itemsss.AgencySubtotal__c=Math.round(itemsss.AgencySubtotal__c * 100) / 100; itemsss.AgencyUnitPrice__c=Math.round(itemsss.AgencyUnitPrice__c * 100) / 100; itemsss.NoDiscountTotal__c=itemsss.ServicePrice__c*itemsss.Quantity; itemsss.UseCount__c=item.Counts; itemsss.if_Fix__c=item.if_Fix__c; itemsss.if_Contain_Nod__c=item.if_Contain_Nod__c; itemsss.recordTypeName__c=item.recordTypeName__c; 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]; this.jzDataDefault=newArrsTemp5; } this.jzDataProduct=arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); // }else{ // debugger // this.newArrsTemp3=[]; // this.newArrsTemp4=[]; // var newArrsTemp5=[]; // var newArrsTemp6=[]; // arrProductTemp.forEach(itemsss=>{ // if(itemsss.PromotionId==item.Id){ // if(item.determine=='改过'){ // var flag=true; // // var a = this.jzDataDefaultQuantityList ; // var b = this.jzDataDefaultCopyQuantityList ; // arrTemp2.forEach(datedefault=>{ // var quantity=0; // if(datedefault.Id==itemsss.Id){ // b.forEach(iem=>{ // if(iem.Asset_Model_No__c==datedefault.Asset_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=>{ // var quantity=0; // if(add.Id==itemsss.Id){ // b.forEach(iems=>{ // if(iems.Asset_Model_No__c==add.Asset_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; // } // }); // } // } // debugger // itemsss.AgencyUnitPrice__c=(item.HeTongTotal/item.Counts)*(itemsss.ListPrice/item.sumListPrice)+itemsss.ServicePrice__c; // itemsss.AgencySubtotal__c=itemsss.AgencyUnitPrice__c*itemsss.Quantity; // itemsss.AgencySubtotal__c=Math.round(itemsss.AgencySubtotal__c * 100) / 100; // itemsss.AgencyUnitPrice__c=Math.round(itemsss.AgencyUnitPrice__c * 100) / 100; // itemsss.NoDiscountTotal__c=itemsss.ServicePrice__c*itemsss.Quantity; // itemsss.UseCount__c=item.Counts; // itemsss.if_Fix__c=item.if_Fix__c; // itemsss.if_Contain_Nod__c=item.if_Contain_Nod__c; // itemsss.recordTypeName__c=item.recordTypeName__c; // 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]; // this.jzDataDefault=newArrsTemp5; // } // this.jzDataProduct=arrProductTemp; // //合同价格汇总 // this.ContractPriceCompute(); // } }else if(PromotionHeadRecordId=="NormalProduct"){//一般产品 //todu3 this.newArrsTemp3=[]; this.newArrsTemp4=[]; var newArrsTemp5=[]; var newArrsTemp6=[]; arrProductTemp.forEach(itemsss=>{ var flag=true; if(itemsss.PromotionId==item.Id){ if(item.determine=='改过'){ var b = this.jzDataDefaultCopyQuantityList ; arrTemp2.forEach(datedefault=>{ var quantity=0; if(datedefault.Id==itemsss.Id){ b.forEach(iem=>{ if(iem.Asset_Model_No__c==datedefault.Asset_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=>{ var quantity=0; if(add.Id==itemsss.Id){ b.forEach(iems=>{ if(iems.Asset_Model_No__c==add.Asset_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); } }); } }); } } 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.AgencySubtotal__c=itemsss.AgencyUnitPrice__c*itemsss.Quantity; itemsss.AgencySubtotal__c=Math.round(itemsss.AgencySubtotal__c * 100) / 100; itemsss.AgencyUnitPrice__c=Math.round(itemsss.AgencyUnitPrice__c * 100) / 100; itemsss.NoDiscountTotal__c=itemsss.ServicePrice__c*itemsss.Quantity; itemsss.UseCount__c=item.Counts; itemsss.ifNecessary__c=item.ifNecessary__c; itemsss.recordTypeName__c=item.recordTypeName__c; 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]; this.jzDataDefault=newArrsTemp5; } this.jzDataProduct=arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); } } }); this.jzDataFixedPrice=[...[],...arrTemp]; }else if(category=='折扣政策'){ //todu2 arrTemp1.forEach(item=>{ if(id==item.Id){ if(item.JxsType=='特约折扣'){ if(item.iftrue!="改过"){ item.GuaranteeDiscount__c_Input=item.GuaranteeDiscount__c; item.NormalDiscount__c_Input=item.NormalDiscount__c; } this.newArrsTemp=[]; this.newArrsTemp2=[]; arrProductTemp.forEach(itemss=>{ var Discount__c_Input=0; if(itemss.multiYearWarranty__c){ Discount__c_Input=item.GuaranteeDiscount__c_Input; }else{ Discount__c_Input=item.NormalDiscount__c_Input; } if(itemss.PromotionId==item.Id){ itemss.AgencyUnitPrice__c=(itemss.ListPrice+itemss.ServicePrice__c)*(Discount__c_Input*0.01); itemss.AgencySubtotal__c=itemss.AgencyUnitPrice__c*itemss.Quantity; itemss.AgencySubtotal__c=Math.round(itemss.AgencySubtotal__c * 100) / 100; itemss.AgencyUnitPrice__c=Math.round(itemss.AgencyUnitPrice__c * 100) / 100; // itemss.NoDiscountTotal__c=999.99; itemss.NoDiscountTotal__c=itemss.ServicePrice__c*itemss.Quantity; itemss.Discount__c_Input=Discount__c_Input; this.newArrsTemp.push(itemss); // console.warn(this.newArrsTemp) }else if(itemss.PromotionId!=item.Id){ this.newArrsTemp2.push(itemss); } }); this.jzDataProduct=arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); }else if(item.JxsType=='一般折扣'){ this.newArrsTemp=[]; this.newArrsTemp2=[]; arrProductTemp.forEach(itemss=>{ if(itemss.PromotionId==item.Id){ itemss.AgencyUnitPrice__c=itemss.ListPrice*(item.NormalDiscount__c_Input*0.01); itemss.AgencySubtotal__c=itemss.AgencyUnitPrice__c*itemss.Quantity; itemss.AgencySubtotal__c=Math.round(itemss.AgencySubtotal__c * 100) / 100; itemss.AgencyUnitPrice__c=Math.round(itemss.AgencyUnitPrice__c * 100) / 100; // itemss.NoDiscountTotal__c=999.99; itemss.NoDiscountTotal__c=itemss.ServicePrice__c*itemss.Quantity; itemss.Discount__c_Input=item.NormalDiscount__c_Input; this.newArrsTemp.push(itemss); // console.warn(this.newArrsTemp) }else if(itemss.PromotionId!=item.Id){ this.newArrsTemp2.push(itemss); } }); this.jzDataProduct=arrProductTemp; //合同价格汇总 this.ContractPriceCompute(); } } }); this.jzDataDiscount=[...[],...arrTemp1]; } } //todu //删除价格的listprice和 ComputeListPrice(PromotionId){ var sum=0; this.jzDataProduct.forEach(jzdp=>{ if(jzdp.PromotionId==PromotionId){ sum=sum+jzdp.ListPrice*jzdp.Quantity; } }); return sum; } //删除价格计算 delectComputeData(item){ var sum=this.ComputeListPrice(item.PromotionId); var jzProductarry=[...[],...this.jzDataProduct]; jzProductarry.forEach(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]; } ComparePushData(length,Quantity,Asset_Model_No__c,Id,jzDataProductParam,TypeName){ //修改 促销方案产品 let num = parseInt(length/Quantity); let addArr = []; var newss = [...[],...this.jzDataDefault]; var newDataDefault =newss.map(item=>{ if(item == undefined){ console.warn("undefined!!"); } if(item.Asset_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]; //合同价格汇总 this.ContractPriceCompute(); this.jzDataDefault = newDataDefault; //判断是否有 full的值 this.ChangeNumZeroTrue(); //追加次数 this.AddNums(TypeName,Asset_Model_No__c,num,Id); } // ======================== 追加次数 //用于填充次数 CompareFullData=[ ] 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; FilterList[0].num = addNums; } } // =======更新促销方案次数数据 updatesNums(){ var jzDataFixedPriceTemp = [...[],...this.jzDataFixedPrice]; var jzDataDiscountTemp = [...[],...this.jzDataDiscount]; this.CompareFullData.forEach(item=>{ if (item.ListName == "价格政策") { var filterTemp = jzDataFixedPriceTemp.filter(fItem=>{ if (fItem.Id == item.Id) { return true; }else{ return false; } }) if (filterTemp!=undefined || filterTemp.length > 0) { var fileterTempObject = {...{},...filterTemp[0]}; fileterTempObject.Counts =item.num; jzDataFixedPriceTemp = jzDataFixedPriceTemp.map(element => { if (element.Id == fileterTempObject.Id) { element = fileterTempObject; }else{ let elementTemp = {...{},...element}; // elementTemp.Counts = 0 element = elementTemp; } return element; }); } } if (item.ListName == "折扣政策") { var filterTemp = jzDataDiscountTemp.filter(fItem=>{ if (fItem.Id == item.Id) { return true; }else{ return false; } }) if (filterTemp!=undefined || filterTemp.length > 0) { var fileterTempObject = {...{},...filterTemp[0]}; fileterTempObject.Counts =item.num; jzDataDiscountTemp = jzDataDiscountTemp.map(element => { if (element.Id == fileterTempObject.Id) { element = fileterTempObject; }else{ let elementTemp = {...{},...element}; // elementTemp.Counts = 0 element = elementTemp; } return element; }); } } }) this.jzDataFixedPrice = jzDataFixedPriceTemp; ; this.jzDataDiscount = jzDataDiscountTemp; } // ====================== 判断是否为0 ChangeNumZeroTrueData=[] ChangeNumZeroTrue(){ this.ChangeNumZeroTrueData = [...[],...this.jzDataDefault]; 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) { 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; } //todu4 // ============= 删除已选择的产品 DeleteIsChangesFn(list) { var listTemps = []; list.forEach(listItem=>{ var flag = true; listTemps.forEach(TempItem=>{ if (TempItem.PromotionId == listItem.PromotionId) { flag = false; return; } }) if (flag) { listTemps.push(listItem); } }) listTemps.forEach(item=>{ var ids = []; ids.push(item.PromotionId); this.DeleteChangesFn(ids,item.TypeName); if (item.TypeName =="价格政策") { //SelectedFnDataFixedPrice jzDataCommonly jzDataSpecial var arrTemp = [...[],...this.jzDataFixedPrice]; var TempItem = {}; arrTemp.forEach(atItem=>{ if (atItem.Id == item.PromotionId) { TempItem = atItem; return; } }) if (TempItem != undefined) { this.SelectedFnDataFixedPrice.push(TempItem); this.deleteFixedPriceTemp(); } }else if(item.TypeName =="折扣政策"){ var arrTempTOName = [...[],...this.jzDataDiscount]; var TempItemTOName = {}; arrTempTOName.forEach(atItem=>{ if (atItem.Id == item.PromotionId) { TempItemTOName = atItem; return; } }) if (TempItemTOName != undefined) { this.SelectedFnDataDiscount.push(TempItemTOName); this.delectTableDiscountTemp(); } } }) } //todu6 //================删除已选产品2========== DeleteIsChangesFnSingle(list) { // let num = 0; list.forEach(item=>{ num++; // var ids = []; var falg=true; if (item.TypeName =="价格政策") { this.DeleteIsChangelogic(item,item.TypeName,num,list); var arrTemp = [...[],...this.jzDataFixedPrice];//价格政策 var TempItem = {}; arrTemp.forEach(atItem=>{ if (atItem.Id == item.PromotionId) { TempItem = atItem; return; } }) this.jzDataProduct.forEach(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];//折扣政策 var TempItemTOName = {}; arrTempTOName.forEach(atItem=>{ if (atItem.Id == item.PromotionId) { TempItemTOName = atItem; return; } // } }) this.jzDataProduct.forEach(ite=>{ if(ite.PromotionId==TempItemTOName.Id){ falg=false; } }); if (TempItemTOName != undefined&&falg) { this.SelectedFnDataDiscount.push(TempItemTOName); this.delectTableDiscountTemp(); } } this.ContractPriceCompute(); }) } DeleteIsChangelogic(item,TypeName,num,list){ var jzdatas=[]; var flg=true; this.jzDataProduct.forEach(proItem => { //.slice(0,15) if(TypeName=="价格政策"){ var PromotionHeadRecordId=proItem.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.errorPromptBox('促销方案内产品型号,数量固定,不可删除') this.Alert("促销方案内产品型号,数量固定,不可删除",true,true); } }else if(PromotionHeadRecordId=="NormalProduct"){ if(!item.ifNecessary__c){ if(proItem.Id==item.Id&&item.PromotionId==proItem.PromotionId){ }else{ jzdatas.push(proItem); } }else{ flg=false; // this.errorPromptBox('一般产品为强制匹配,不可删除') this.Alert("一般产品为强制匹配,不可删除",true,true); } }else{ jzdatas.push(proItem); } }else if(TypeName=="折扣政策"){ if(proItem.Id==item.Id&&item.PromotionId==proItem.PromotionId){ }else{ jzdatas.push(proItem); } // } } }); if(flg){ this.jzDataProduct=[...[],...jzdatas]; this.delectComputeData(item) this.ContractPriceCompute(); //合同价格汇总 var fg=true; var arr=this.jzDataDefault; arr.forEach(jddf=>{ if(jddf.Id==item.Id){ jddf.Quantity=jddf.Quantity+item.Quantity fg=false; } }); if(fg){ this.jzDataDefaultCopy.forEach(itm=>{ debugger if(itm.Id==item.Id){ itm.Quantity=item.Quantity arr.push(itm); fg=false; } }); } this.jzDataDefault=[...[],...arr]; } } // ==================通知显示 ====================== @track Tongzhishow = false; @track ErrorTongzhishow = false; ShowErrorContent = '折扣类只能选着一个'; TZshow(init){ this.Tongzhishow = init; } TZErrorshow(init){ this.ErrorTongzhishow = init; } TongzhiClick(event) { this.Tongzhishow = false; } ErrorTongzhiClick(event) { this.ErrorTongzhishow = false; } // 新提示 Tongzhishow=false; //提示显示的标识 SaveShowText="操作成功";//提示框的文本 TongzhiIcon = 'standard:account' //提示框的图标 IsLeftStyle = "" //提示框的样式 BgColorStyle = "" //弹框提示 content 内容 error 是否是错误提示框 left 是否居左 Alert(content,error = false,left = false){ this.SaveShowText = content; this.Tongzhishow = true; // setTimeout(()=>{ // this.Tongzhishow = false; // this.SaveShowText = ""; // },3000) if (error) { this.TongzhiIcon = "standard:first_non_empty"; this.BgColorStyle = "background-color:#f88568"; }else{ this.TongzhiIcon = "standard:account"; this.BgColorStyle = "background-color:#69e669"; } if (left) { this.IsLeftStyle = "left: 0.25rem" }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 = [ { label: "方案代码", type: "text", name: "PromotionNo__cEqual", isInput: true }, { label: "名称", type: "text", name: "Description__cLike", isInput: true } ] @track initDataTable = { columns: [ {label: '方案代码', fieldName: 'PromotionNo__c', sortable: true}, {label: '名称', fieldName: 'Name', sortable: true}, {label: '描述', fieldName: 'Description__c', sortable: true}, {label: '促销价格', fieldName: 'Price_CNY__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '是否包含多年保修价格', fieldName: 'if_Contain_Nod__c', sortable: true,type: 'boolean'}, {label: '是否固定数量', type: 'boolean', fieldName: 'if_Fix__c',sortable: true}, ], sortInterfaces: false, searchColumns: this.initSearchForm } @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=>{ this.jzDataDefaultCopy.forEach(jddc=>{ if(itemss.Asset_Model_No__c==jddc.Asset_Model_No__c){ // jddc.Quantity__c__c=itemss.Quantity__c; sumListPrice +=itemss.Quantity__c*jddc.ListPrice; sumNoDiscount +=itemss.Quantity__c*jddc.ServicePrice__c; 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}); } } } }); }); item.sumListPrice=sumListPrice; item.sumNoDiscount=sumNoDiscount; // item.Quantity__c=Quantity__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]; }); }); this.jzData = [...[],...responseObj.records]; this.tableIsLoding = false; }) } // 选中 SelectedFn(event){ let arr= event.detail.rows; if(arr.length > 1) { this.TZshow(false); this.TZErrorshow(true); }else{ this.cancel(); var sumNoDiscount=0; var sumListPrice=0; this.ifqianpi=true; this.GetSearchProductByIdFn(arr[0].Id,arr[0],"价格政策",[],arr); // this.UpdateJZData(arr); } } // ================== END 弹出框 ============================== // ===================== 待选着产品 ============================= @track jzDataDefault = []; //数据 待选择产品数据据 jzDataDefaultNotChange = []; jzDataDefaultCopy = []; @track tableIsLodingDefault = true; @track initSearchFormDefalt = [ { label: "产品型号", type: "text", name: "Asset_Model_No__c", isInput: true }, { label: "产品名称", type: "text", name: "Name__c", isInput: true } ] @track initDataTableDefault = { columns: [ {label: '产品型号', fieldName: 'Asset_Model_No__c', sortable: true,typeAttributes: { rowActions: this.getRowActions }}, {label: '产品名称', fieldName: 'Name__c', sortable: true}, {label: '数量', fieldName: 'Quantity', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '保修类型', fieldName: 'warrantyType__c', sortable: true}, {label: 'ListPrice', fieldName: 'ListPrice', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: 'NoDiscount小计', fieldName: 'NoDiscountTotal__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, ], sortInterfaces: false, searchColumns: this.initSearchFormDefalt } getRowActions(event) { let a = event; } // 后台交互,获取列表数据 getTableDataDefault(event){ let data = []; //todu10 GetPromotionDefalut({IdParam:this.ParamIdStr}).then(result => { this.jzDataDefaultNotChange = []; this.jzDataDefaultCopy=[]; result.forEach(rItem => { rItem.ListPrice=rItem.ListPrice__c; let tempS = {...{},...rItem}; this.jzDataDefaultNotChange .push(tempS); this.jzDataDefaultCopy .push(tempS); }); if (this.flagall) { var newList = []; this.OnLoadProduct.forEach(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; return; }else{ result.forEach(rItems => { rItems.ListPrice=rItems.ListPrice__c; // rItems.Id = this.GetUUID(); }); 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; @track initSearchFormFixedPrice = [ { label: "产品型号", type: "text", name: "Asset_Model_No__c", isInput: true }, { label: "产品名称", type: "text", name: "Name__c", isInput: true } ] @track initDataTableFixedPrice = { columns: [ {label: '方案代码', fieldName: 'PromotionNo__c', sortable: true}, {label: '促销方案名称/产品系列', fieldName: 'Name', sortable: true}, {label: '方案描述', fieldName: 'Description__c', sortable: true,}, {label: '分类', fieldName: 'Category__c', sortable: true}, {label: '是否包含多年保修价格', fieldName: 'if_Contain_Nod__c', type: 'boolean', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '是否固定数量', fieldName: 'if_Fix__c', type: 'boolean', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '促销单价', fieldName: 'Price_CNY__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '次数', fieldName: 'Counts', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }, editable : 'true' }, {label: '促销总价', fieldName: 'Total', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '合同价格', fieldName: 'HeTongTotal', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }, editable : 'true' }, ], sortInterfaces: [], searchColumns: this.initSearchFormDefalt } // 后台交互,获取列表数据 getTableDataFixedPrice(event){ this.tableIsLodingFixedPrice = false; var indexTemp = []; } handleSaveFixedPrice(event){ // 更改次数 把对应的id 的 num值也需要改变,这个集合是记录所有匹配上的 政策的 关系的,改变了对应关系 也需要维护一下这个集合 var a = this.CompareFullData ; var CompareFullDataedit =[]; // console.warn(this.CompareFullData); var HeTongTotal=0; // var data = event.detail.rows; let newData = []; let editnewDate=[]; var boolean = 1; debugger for(var i=0 ;i=editData.Counts&&ifNec){ if(editData.Counts==0){ boolean=4; }else{ HeTongTotal=newItem.Price_CNY__c*editData.Counts+newItem.sumNoDiscount*editData.Counts; if(newItem.HeTongTotal{ if(editnum.Id==newItem.Id){ editnum.num=newItem.Counts; CompareFullDataedit.push(editnum); }else{ CompareFullDataedit.push(editnum); } }); this.CompareFullData=[...[],...CompareFullDataedit]; } } }else{ if(ifNec){ boolean=3; }else{ boolean=5; } } } if (editData.HeTongTotal != undefined ) { debugger HeTongTotal=newItem.Price_CNY__c*newItem.Counts+newItem.sumNoDiscount*newItem.Counts;; if(editData.HeTongTotal{ // debugger // HeTongTotal=item.Price_CNY__c*item.Counts+item.sumNoDiscount*item.Counts; // if(item.HeTongTotal{ this.ComputeData(item.Id,'价格政策'); // this.TZshow(true); // this.SaveShowText='数据修改成功'; // setTimeout(()=>{ // this.TongzhiClick(); // this.SaveShowText = "促销方案选着完成"; // },2000) this.Alert("数据修改成功",false,true); }); this.jzDataProduct = [...this.newArrsTemp3,...this.newArrsTemp4]; //合同价格汇总 this.ContractPriceCompute(); } // else if(boolean==2){ // // this.errorPromptBox('修改错误,合同价格不得小于促销总价') // this.Alert("修改错误,合同价格不得小于最小值!",true,true); // } else if(boolean==3){ // this.errorPromptBox('修改错误,次数已经超过最大值,不可在增加') this.Alert("修改错误,次数已经超过最大值,不可增加",true,true); }else if(boolean==4){ // this.errorPromptBox('修改错误,次数不可以为0') this.Alert("修改错误,次数不可以为0",true,true); }else if(boolean==5){ // this.errorPromptBox('该方案为强制匹配,次数不可修改!') this.Alert("该方案为强制匹配,次数不可修改!",true,true); }else if(boolean==6){ // this.errorPromptBox('该方案为强制匹配,次数不可修改!') var str1= String(HeTongTotal); var str="修改错误,合同价格不得小于"; // var str2=str+HeTongTotal; var str3=str+str1; this.Alert(str3,true,true); } //刷新 this.jzshows3 = false; this.IsLoading3 = true; setTimeout(()=>{ this.IsLoading3 = false; this.jzshows3 = true; },1000); } newArrsTemp3=[]; newArrsTemp4=[]; UpdateJZData(arrs){ if ( this.jzDataFixedPrice == null ||this.jzDataFixedPrice.length <= 0) { this.jzDataFixedPrice = arrs; }else{ this.jzDataFixedPrice = [...this.jzDataFixedPrice,...arrs]; } ; } //选中 @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.errorPromptBox('一般产品为强制匹配,不可删除') 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]; } } this.SelectedFnDataFixedPrice=[...[],...select]; if(fag){ this.DeleteChangesFn(ids,"价格政策"); this.deleteFixedPriceTemp(); } } jzshows3 = true;    //加载 deleteFixedPriceTemp(){ // this.jzshows3 = false; // this.OnLoading3(true); 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]; 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 = [ { label: "方案代码", type: "text", name: "PromotionNo__cEqual", isInput: true }, { label: "名称", type: "text", name: "Description__cLike", isInput: true } ] @track initDataTableFix = { columns: [ {label: '方案代码', fieldName: 'PromotionNo__c', sortable: true}, {label: '名称', fieldName: 'Name', sortable: true}, {label: '描述', fieldName: 'Description__c', sortable: true}, {label: '促销价格', fieldName: 'Price_CNY__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '是否包含多年保修价格', fieldName: 'if_Contain_Nod__c', type: 'boolean', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '是否固定数量', fieldName: 'if_Fix__c',type:'boolean', sortable: true, cellAttributes: { alignment: 'center' }} ], sortInterfaces: false, searchColumns: this.initSearchFormFix } @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}); } // jzDataDefaultQuantityList = []; jzDataDefaultCopyQuantityList = []; // 后台交互,获取列表数据 ifqianpi=true; getTableDataFix(event){ let listQuery =event; // var ff=true; if(event.fag){ this.ifqianpi=false; }else{ listQuery = event.detail.listQuery; } debugger listQuery.pageLimit=200; GetNormalProductSearch(listQuery).then(result => { console.warn("GetNormalProductSearch"); //BBBB var tempArr = result.split("--"); var responseObj = JSON.parse(tempArr[0]); var responseObjAll = JSON.parse(tempArr[1]); //排序 var newArrs = new Array; responseObjAll.forEach(item=>{ // if (item.ifNecessary__c) { 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 => { console.warn("GetSearchProductById 2"); var sumListPrice=0; var sumNoDiscount=0; results.forEach(itemss=>{ this.jzDataDefaultCopy.forEach(jddc=>{ if(itemss.Asset_Model_No__c==jddc.Asset_Model_No__c){ // jddc.Quantity__c__c=itemss.Quantity__c; // console.warn(itemss.Quantity__c); sumListPrice +=itemss.Quantity__c*jddc.ListPrice; sumNoDiscount +=itemss.Quantity__c*jddc.ServicePrice__c; //123123123123 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}); } } } }); }); // console.warn(results); debugger item.sumListPrice=sumListPrice; item.sumNoDiscount=sumNoDiscount; // item.Quantity__c=Quantity__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]; if(event.fag&&iflag){//&&ff // if(item.ifNecessary__c){ var newArr = []; newArr.push(item); this.ifqianpi=false; console.warn("GetSearchProductByIdFn 3"); 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]; 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 = [ ] @track initDataTableDiscount = { columns: [ {label: '经销商分类', fieldName: 'JxsType', sortable: true}, {label: '分类', fieldName: 'Category__c', sortable: true}, {label: '对象品折扣', fieldName: 'GuaranteeDiscount__c', sortable: true}, {label: '非对象品折扣', fieldName: 'NormalDiscount__c', sortable: true,}, {label: '对象品折扣(录入)', fieldName: 'GuaranteeDiscount__c_Input', editable : 'true'}, {label: '非对象品折扣(录入)', fieldName: 'NormalDiscount__c_Input', editable : 'true' } ], sortInterfaces: [], searchColumns: this.initSearchFormDiscount } // 后台交互,获取列表数据 getTableDataDiscount(event){ this.tableIsLodingDiscount = false; } UpdateDiscountData(arrs){ if ( this.jzDataDiscount == null ||this.jzDataDiscount.length <= 0) { this.jzDataDiscount = arrs; }else{ this.jzDataDiscount = [...this.jzDataDiscount,...arrs]; } } //选中 @track SelectedFnDataDiscount=[] SelectedFnDiscount(event){ // this.SelectedFnDataDiscount=[]; 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.delectTableDiscountTemp(); } //ttt jzshows2 = true; jzshows3 = true;    //加载 //     IsLoading2 = false; //     OnLoading2(flag){ //             this.IsLoading2 = flag; //     } delectTableDiscountTemp() { // // this.jzshows2 = false; // this.OnLoading2(true); let newarr = []; for (var j = 0; j < this.SelectedFnDataDiscount.length; j++) { for (var i = 0; i < this.jzDataDiscount.length; i++) { if(this.SelectedFnDataDiscount[j].Id==this.jzDataDiscount[i].Id){ 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 方法 // saveDis=''; handleSaveDiscount(event) { var aa = event; var boolean=0; var data = event.detail.rows; let newData = []; let editnewDate=[]; for(var i=0 ;i{ this.ComputeData(item.Id,'折扣政策'); }); this.jzDataProduct = [...this.newArrsTemp2,...this.newArrsTemp]; //合同价格汇总 this.ContractPriceCompute(); // this.TZshow(true); // this.SaveShowText='数据修改成功'; // setTimeout(()=>{ // this.TongzhiClick(); // this.SaveShowText = "促销方案选着完成"; // },2000) this.Alert("数据修改成功",false,true); }else if(boolean==1){ this.Alert("修改错误,对象品折扣(录入)不得小于对象品折扣",true,true); // this.errorPromptBox('修改错误,对象品折扣(录入)不得小于对象品折扣') }else if(boolean==2){ this.Alert("修改错误,非对象品折扣(录入)不得小于非对象品折扣",true,true); // this.errorPromptBox('修改错误,非对象品折扣(录入)不得小于非对象品折扣') } //刷新 this.jzshows2=false; this.IsLoading2=true; setTimeout(()=>{ this.jzshows2=true; this.IsLoading2=false; },1000) } newArrsTemp=[]; newArrsTemp2=[]; // ===================== END使用价格政策 ============================= // =========================特约折扣 弹出框 ========================= @track ShowSpecial; showModalSpecial() { this.QuoteData.forEach(qtd=>{ if(!qtd.Opportunity.IsAuthorized__c){ this.Alert("该询价不是特约经销商授权",true,true); // this.errorPromptBox('该询价不是特约经销商授权') }else{ this.ShowSpecial = true; } }); } cancelSpecial() { this.ShowSpecial = false this.ShowSpecialIsError= false; this.SelectedFnDataSpecial=[]; this.SelectedOtherDataArr=[]; } @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.ShowSpecialIsError= true; this.ShowSpecial = true; this.ShowSpecialError="请选择促销产品!"; }else if(this.SelectedFnDataSpecial.length==0&&this.SelectedOtherDataArr.length!=0){ this.ShowSpecialIsError= true; this.ShowSpecial = true; this.ShowSpecialError="请选择促销方案!"; }else if(this.SelectedFnDataSpecial.length==0&&this.SelectedOtherDataArr.length==0){ this.ShowSpecialIsError= true; this.ShowSpecial = true; this.ShowSpecialError="请选择促销方案和产品!"; }else{ ItempTempData.itemss = this.SelectedOtherDataArr; ItempTempData.IsTempItems = true; this.SelectedFnDataSpecial[0] = ItempTempData; this.UpdateDiscountData(this.SelectedFnDataSpecial); this.SpecialSavesChange("特约折扣",ItempTempData,this.SelectedFnDataSpecial[0].Id,this.SelectedFnDataSpecial[0].CompareId); // this.TZshow(true); // this.SaveShowText='特约折扣选择完成'; // setTimeout(()=>{ // this.TongzhiClick(); // this.SaveShowText = "促销方案选着完成"; // },2000) // this.TZErrorshow(false); this.Alert("特约折扣选择完成",false,true); this.ComputeData(ItempTempData.Id,'折扣政策'); this.SelectedFnDataSpecial=[]; this.SelectedOtherDataArr=[]; } } // ----设置已选着的 ChangetSelecetedProductItems(items,Specials){ var ItemsTemp = []; items.forEach(element => { let elementTemp = {...{},...element}; elementTemp.PromotionNo__c =Specials.PromotionNo__c; elementTemp.Name =Specials.Name; ItemsTemp.push(element); }); this.jzDataProduct = [...this.jzDataProduct,...ItemsTemp] //合同价格汇总 this.ContractPriceCompute(); if(this.SelectedFnDataSpecial.length != 1) { // this.TZshow(false); // this.TZErrorshow(true); this.Alert("特约折扣选择完成",true,true); return; }else{ // this.TZshow(true); // this.SaveShowText='特约折扣选择完成'; // setTimeout(()=>{ // this.TongzhiClick(); // this.SaveShowText = "促销方案选着完成"; // },2000) // this.TZErrorshow(false); this.Alert("特约折扣选择完成",false,true); } } @track initSearchFormSpecial = [ ] @track initDataTableSpecial = { columns: [ {label: '编码', fieldName: 'PromotionNo__c', sortable: true}, {label: '协议区域', fieldName: 'xxx', sortable: true}, {label: '对象品折扣', fieldName: 'GuaranteeDiscount__c', sortable: true}, {label: '非对象品折扣', fieldName: 'NormalDiscount__c', sortable: true}, {label: '协议编码', fieldName: 'Contract__c',sortable: true}, {label: '经销商', fieldName: 'Agency__Name',sortable: true}, ], sortInterfaces: false, searchColumns: this.initSearchFormSpecial } @track jzDataSpecial = []; @track tableIsLodingSpecial = true; // 后台交互,获取列表数据 getTableDataSpecial(event){ let listQuery = event.detail.listQuery; var Agency1__c = this.QuoteData[0].Agency1__c; listQuery.Agency1c=Agency1__c; GetAuthorizerSearch(listQuery).then(result => { var responseObj = JSON.parse(result); this.jzDataSpecial = responseObj.records; this.jzDataSpecial.forEach(element => { element.JxsType = "特约折扣"; }); 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]; } }); // console.warn(a); }) 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 = this.GetUUID(); this.SelectedFnDataSpecial = [tempObject]; } //特约折扣数量拆分 IsLoading5 = false; jzshows5 = true; IsLoadingFlag1 = true; SaveSpecialDiscount(event){ debugger var data = event.detail.rows; let newData = []; let editnewDate=[]; var boolean = 1; for(var i=0 ;i{ if(item.Quantity{ this.SelectedOtherDataArr=[]; this.IsLoading5 = false; this.jzshows5 = true; },1000); setTimeout(()=>{ this.IsLoadingFlag1 = true; },2000); } // OtherData @track initSearchFormOtherData = [ ] @track initDataTableOtherData = { columns: [ {label: '产品型号', fieldName: 'Asset_Model_No__c', sortable: true,typeAttributes: { rowActions: this.getRowActions }}, {label: '产品名称', fieldName: 'Name__c', sortable: true}, {label: '数量', fieldName: 'Quantity', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '拆分数量', fieldName: 'SplitQuantity', type: 'number', sortable: true, cellAttributes: { alignment: 'center' },editable : 'true'}, {label: '保修类型', fieldName: 'warrantyType__c', sortable: true}, {label: 'ListPrice', fieldName: 'ListPrice', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: 'NoDiscount小计', fieldName: 'NoDiscountTotal__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, ], sortInterfaces: false, searchColumns: this.initSearchFormOtherData } @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 } //保存拆分数量 IsLoading4 = false; jzshows4 = true; IsLoadingFlag = true; SaveGeneralDiscount(event){ // 更改次数 把对应的id 的 num值也需要改变,这个集合是记录所有匹配上的 政策的 关系的,改变了对应关系 也需要维护一下这个集合 // var a = this.CompareFullData ; // var CompareFullDataedit =[]; // console.warn(this.CompareFullData); // debugger var data = event.detail.rows; let newData = []; let editnewDate=[]; var boolean = 1; for(var i=0 ;i{ if(item.Quantity{ this.SelectedFnCommonlyData=[]; this.IsLoading4 = false; this.jzshows4 = true; },1000); setTimeout(()=>{ this.IsLoadingFlag = true; },2000); } cancelCommonly() { this.ShowCommonly = false; this.ShowCommonlyIsError=false; this.SelectedFnCommonlyData=[]; } @track initSearchFormCommonly= [ { label: "方案代码", type: "text", name: "PromotionNo__cEqual", isInput: true }, { label: "名称", type: "text", name: "Description__cLike", isInput: true } ] @track initDataTableCommonly= { columns: [ {label: '产品型号1', fieldName: 'Asset_Model_No__c', sortable: true,typeAttributes: { rowActions: this.getRowActions }}, {label: '产品名称', fieldName: 'Name__c', sortable: true}, {label: '数量', fieldName: 'Quantity', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '拆分数量', fieldName: 'SplitQuantity', type: 'number', sortable: true, cellAttributes: { alignment: 'center' },editable : 'true'}, {label: '保修类型', fieldName: 'warrantyType__c', sortable: true}, {label: 'ListPrice', fieldName: 'ListPrice', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: 'NoDiscount小计', fieldName: 'NoDiscountTotal__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, ], sortInterfaces: false, searchColumns : this.initSearchFormCommonly } @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){ this.SaveZk = event.target.value; } PromotionNoTemp = 1001; ShowCommonlyError="请选择一般产品!"; ShowCommonlyIsError=false; cancelSaveCommonly(){ //处理数据 var arr= this.SelectedFnCommonlyData; this.ShowCommonlyIsError=false; if(this.SelectedFnCommonlyData.length!=0){ var ItempTempData = {}; ItempTempData.Id = this.GetUUID(); ItempTempData.CompareId = this.GetUUID(); ItempTempData.Name = '一般折扣'; ItempTempData.JxsType = "一般折扣"; ItempTempData.itemss =arr; if(this.SaveLb==''||this.SaveZk==''){ if(this.SaveLb==''&&this.SaveZk!=''){ this.ShowCommonlyIsError=true; this.ShowCommonlyError="请选择产品类别!"; }else if(this.SaveZk==''&&this.SaveLb!=''){ this.ShowCommonlyIsError=true; this.ShowCommonlyError="请输入使用折扣!"; }else if(this.SaveZk==''&&this.SaveLb==''){ this.ShowCommonlyIsError=true; this.ShowCommonlyError="请输入使用折扣和产品类别!"; } }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.TZshow(true); // this.SaveShowText='一般折扣选择完成'; // setTimeout(()=>{ // this.TongzhiClick(); // this.SaveShowText = "促销方案选着完成"; // },2000) // this.TZErrorshow(false); this.Alert("一般折扣选择完成",false,true); this.ComputeData(ItempTempData.Id,'折扣政策'); } }else{ this.ShowCommonlyIsError=true; } } // ============================END ======================= // ===================== 促销方案产品 ============================= @track jzDataProduct = []; @track tableIsLodingProduct = true; @track initSearchFormProduct = [ { label: "产品型号", type: "text", name: "Asset_Model_No__c", isInput: true }, { label: "产品名称", type: "text", name: "Name__c", isInput: true } ] @track initDataTableProduct = { columns: [ {label: '产品型号', fieldName: 'Asset_Model_No__c', sortable: true,typeAttributes: { rowActions: this.getRowActions }}, {label: '产品名称', fieldName: 'Name__c', sortable: true}, {label: '数量', fieldName: 'Quantity', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '保修类型', fieldName: 'warrantyType__c', sortable: true}, {label: '方案代码', fieldName: 'PromotionNo__c', sortable: true}, {label: '促销方案名称/产品系列', fieldName: 'Name', sortable: true}, {label: 'ListPrice', fieldName: 'ListPrice', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '经销商单价', fieldName: 'AgencyUnitPrice__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' },typeAttributes: {minimumFractionDigits: '2',maximumFractionDigits: '2'}}, {label: '经销商小计', fieldName: 'AgencySubtotal__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' },typeAttributes: {minimumFractionDigits: '2',maximumFractionDigits: '2'}}, {label: 'NoDiscount小计', fieldName: 'NoDiscountTotal__c', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, {label: '折扣', fieldName: 'Discount__c_Input', type: 'number', sortable: true, cellAttributes: { alignment: 'center' }}, ], sortInterfaces: false, searchColumns: this.initSearchFormProduct } // 后台交互,获取列表数据 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); } 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]; var NewData = []; var NewData1 = []; data.forEach(itms => { let Temp = {}; Temp.itemCounts = itms.Counts+""; Temp.Id = itms.Id; Temp.JxsType=itms.JxsType; //促销方案 if(itms.JxsType!="一般折扣"){ var PromotionHeadRecordId = itms.recordTypeName__c; } if(PromotionHeadRecordId=='Promotion'){ Temp.Categoryc = '促销方案'; } //一般产品 else if(PromotionHeadRecordId=='NormalProduct'){ Temp.Categoryc = '一般产品'; } //特约固定 else if(PromotionHeadRecordId=='Authorizer'){ Temp.Categoryc = '经销商固定折扣'; }else{ Temp.Categoryc = itms.Category__c; } Temp.GuaranteeDiscountcInput=itms.GuaranteeDiscount__c_Input; Temp.NormalDiscountcInput=itms.NormalDiscount__c_Input; Temp.PromotionNocEqual=itms.PromotionNo__cEqual; Temp.typess=itms.typess; Temp.PromotionNoc=itms.PromotionNo__c; Temp.Name =itms.Name; Temp.ParamIdStr=this.ParamIdStr; Temp.GuaranteeDiscountc=itms.GuaranteeDiscount__c; Temp.NormalDiscountc=itms.NormalDiscount__c; Temp.Descriptionc=itms.Description__c; Temp.ifContainNodc=itms.if_Contain_Nod__c; Temp.ifFixc=itms.if_Fix__c; Temp.PriceCNYc=itms.Price_CNY__c; Temp.Total=itms.Total; Temp.ListPriceTotalc=itms.sumListPrice; Temp.sumNod=itms.sumNoDiscount; // Temp.sumNodUSD=itms.sumNodUSD; Temp.HeTongTotal=itms.HeTongTotal; Temp.ifNecessaryc=itms.ifNecessary__c; Temp.Trade=this.QuoteData[0].Opportunity.Trade__c; Temp.maxCounts=itms.maxCounts; Temp.CompareId=itms.CompareId; //...c/compent NewData.push(Temp); }); var newTemp3 =[]; this.jzDataProduct.forEach(itmsss=>{ var itemTemp = {...{},...itmsss}; // itemTemp.分类名称(根据 产品状态 1) 0未匹配 2)1以匹配) itemTemp.ismatch='1'; newTemp3.push(itemTemp); }); var newTemp4 =[]; this.jzDataDefault.forEach(itmsss=>{ var itemTemp = {...{},...itmsss}; // itemTemp.分类名称(根据 产品状态 1) 0未匹配 2)1以匹配) itemTemp.ismatch='0'; newTemp4.push(itemTemp); }); var data2=[...newTemp3,...newTemp4]; data2.forEach(itmss=>{ let Temp1 = {}; Temp1.Id = itmss.Id; Temp1.AssetModelNoc = itmss.Asset_Model_No__c; Temp1.Namec = itmss.Name__c; Temp1.Quantity = itmss.Quantity; Temp1.GuranteeTypec = itmss.warrantyType__c; Temp1.PromotionNoc = itmss.PromotionNo__c; Temp1.Name = itmss.Name; Temp1.ListPrice = itmss.ListPrice; Temp1.AgencyUnitPricec = itmss.AgencyUnitPrice__c; Temp1.AgencySubtotalc = itmss.AgencySubtotal__c; Temp1.NoDiscountTotalc = itmss.NoDiscountTotal__c; Temp1.ParamIdStr = this.ParamIdStr; Temp1.TypeName = itmss.TypeName; Temp1.UseCountc=itmss.UseCount__c; if(itmss.TypeName=="价格政策"){ data.forEach(itemsss => { if(itemsss.PromotionNo__c == itemsss.PromotionNo__c) { Temp1.fanan_id = itemsss.Id; } }); }else if(itmss.TypeName=="折扣政策"){ data.forEach(itemss => { if(itemss.PromotionNo__c == itemss.PromotionNo__c) { Temp1.fanan_id = itemss.Id; } }); } // Temp1.UUID=this.GetUUID(); Temp1.ismatch=itmss.ismatch; Temp1.PromotionId=itmss.PromotionId; Temp1.Product2c=itmss.Product2Id; Temp1.ServicePricec=itmss.ServicePrice__c; Temp1.ifFixc=itmss.if_Fix__c; Temp1.ifNecessaryc=itmss.ifNecessary__c; Temp1.CompareId=itmss.CompareId; Temp1.DiscountcInput=itmss.Discount__c_Input; NewData1.push(Temp1); }); 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; newTemp.forEach(ntp=>{ if(ntp.HeTongTotal==undefined||ntp.HeTongTotal==0){ ifnull=false; } }); if(ifnull){ saveAllDataProduct({JsonStr:jsondatasss,ParamIdStr:this.ParamIdStr,JsonStr2:jsondatassss,QuoteId:QuoteId,SalesRootc:Sales_Root__c,ContractPrice:this.ContractPrice,OpportunityId:OpportunityId}).then(result => { var resultObject = JSON.parse(result); // console.warn(resultObject); // x++; // if(x==1){ // this.TZshow(true); // this.SaveShowText='数据已保存'; // setTimeout(()=>{ // this.TongzhiClick(); // this.SaveShowText = "促销方案选着完成"; // },2000) this.Alert("数据已保存",false,true); // } }); }else{ // this.TZErrorshow(true); // this.ShowErrorContent='一般产品的合同价格为空,不可保存'; // setTimeout(()=>{ // this.ErrorTongzhiClick(); // this.ShowErrorContent = "折扣类只能选着一个"; // },3000) this.Alert("一般产品的合同价格为空,不可保存",true,true); } }else{ // this.TZErrorshow(true); // this.ShowErrorContent='产品未选完,不可保存'; // setTimeout(()=>{ // this.ErrorTongzhiClick(); // this.ShowErrorContent = "折扣类只能选着一个"; // },3000) this.Alert("产品未选完,不可保存",true,true); } } // ===================== 促销方案产品 ============================= //成功提示 SaveShowText='促销方案选择完成'; //合同价格汇总 ContractPrice=0; ContractPriceCompute(){ this.ContractPrice=0; var sum=this.ContractPrice; sum=parseFloat(sum); this.jzDataProduct.forEach(jdpd=>{ jdpd.AgencySubtotal__c=parseFloat(jdpd.AgencySubtotal__c) sum=sum+jdpd.AgencySubtotal__c; }); sum=Math.round(sum * 100) / 100; this.ContractPrice=sum; } //删除时需要用的唯一id的添加 updateIdStr(str){ // TODU var newArr = []; var indexNum = 0; var jzdpdc=[]; if(str=="1"){ jzdpdc=[...[],...this.jzDataProduct];//促销产品 }else if(str=="2"){ jzdpdc=[...[],...this.jzDataDiscount];//折扣政策 }else if(str=="3"){ jzdpdc=[...[],...this.jzDataFixedPrice];//价格政策 } jzdpdc.forEach(item=>{ indexNum++; var temp = {...item}; temp.DelectId = indexNum ; newArr.push(temp); }) if(str=="1"){ this.jzDataProduct =[...[],...newArr] ;//促销产品 }else if(str=="2"){ this.jzDataDiscount = [...[],...newArr] ;//折扣政策 }else if(str=="3"){ this.jzDataFixedPrice =[...[],...newArr] ;//价格政策 } //TODU } }