const initSearchFormProduct = [{
|
label: "产品型号",
|
type: "text",
|
name: "Asset_Model_No__c",
|
isInput: true
|
},
|
{
|
label: "产品名称",
|
type: "text",
|
name: "Name__c",
|
isInput: true
|
}
|
]
|
export var arrTempsss = [];
|
export var arrProductTempsss = [];
|
export var NewDefaultDatass = [];
|
export var AddProductDatass = [];
|
export var jzDataFixedPriceTemps = [];
|
export var jzDataDiscountTemps = [];
|
export var DeftCopyQtyLists = [];
|
|
export function GetName() {
|
// debugger;
|
// var divs = this.template.querySelectorAll('div');
|
|
|
// var outLine=[];
|
// divs.forEach(item=>{
|
// debugger
|
// });
|
}
|
//=======更新促销方案次数数据逻辑
|
export function updatesNumsLogic(jzDataFixedPriceTemp,jzDataDiscountTemp,CompareFullData) {
|
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
|
};
|
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
|
};
|
element = elementTemp;
|
}
|
return element;
|
});
|
}
|
}
|
})
|
jzDataFixedPriceTemps = jzDataFixedPriceTemp;
|
jzDataDiscountTemps = jzDataDiscountTemp;
|
}
|
//反算折扣时修改折扣政策逻辑
|
export function ReverseCalculationModifyDiscountLogic(arrTemp1,arrProductTemp,Id,Category__c,GuaranteeDiscount__c_Input, NormalDiscount__c_Input,GuaranteeDiscount_H_Money__c, NormalDiscount_H_Money__c, item){
|
//price和
|
var sumListCount = 0;
|
//nod和
|
var sumNodCount = 0;
|
//特约折扣nod和list合
|
var sumListAndNod = 0;
|
//含多年保产品list
|
var ObjectProducList=[];
|
//不含多年保产品list
|
var NotObjectProducList=[];
|
//折扣
|
var NormalDisN = 0;
|
var NormalDisG = 0;
|
var distinguish = 0;
|
var distinguish2 = 0;
|
arrProductTemp.forEach(itemss => {
|
if(itemss.recordTypeName__c=="Authorizer"){
|
if (itemss.PromotionId==Id&&
|
itemss.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
itemss.GuaranteeDiscount__c_Input == GuaranteeDiscount__c_Input) {
|
if(itemss.warrantyType__c=="市场多年保修"){
|
sumListAndNod +=itemss.Quantity *(itemss.ListPrice+itemss.ServicePrice__c);
|
ObjectProducList.push(itemss);
|
}else if(itemss.warrantyType__c!="市场多年保修"){
|
sumListCount += itemss.Quantity * itemss.ListPrice;
|
sumNodCount += itemss.Quantity * itemss.ServicePrice__c;
|
NotObjectProducList.push(itemss);
|
}
|
}
|
}else{
|
if (itemss.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
itemss.Category__c == Category__c) {
|
sumListCount += itemss.Quantity * itemss.ListPrice;
|
sumNodCount += itemss.Quantity * itemss.ServicePrice__c;
|
}
|
}
|
});
|
if (sumListCount != 0||sumListAndNod!=0) {
|
if(item.JxsType=='一般折扣'||NotObjectProducList.length!=0){
|
NormalDisN = ((NormalDiscount_H_Money__c - sumNodCount) / sumListCount * 100).toFixed(2);
|
if(item.JxsType!='一般折扣'){
|
if(item.NormalDiscount__c!=undefined&&item.NormalDiscount__c!=''){
|
var NormalDiscount__cc=parseFloat(item.NormalDiscount__c);
|
if(NormalDisN<NormalDiscount__cc){
|
distinguish=1;
|
}
|
}
|
}else if(NormalDisN<0){
|
distinguish=3;
|
}
|
}
|
debugger
|
if(ObjectProducList.length!=0){
|
NormalDisG =(GuaranteeDiscount_H_Money__c/sumListAndNod*100).toFixed(2);
|
if(item.GuaranteeDiscount__c!=undefined&&item.GuaranteeDiscount__c!=''){
|
var GuaranteeDiscount__cc=parseFloat(item.GuaranteeDiscount__c);
|
if(NormalDisG<GuaranteeDiscount__cc){
|
distinguish2 = 2;
|
}
|
}
|
}
|
arrTemp1.forEach(arrte => {
|
if (item.JxsType=="一般折扣") {
|
if(arrte.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
arrte.Category__c == Category__c){
|
if(distinguish==1||distinguish==3){
|
arrte.NormalDiscount_H_Money__c = arrte.NormalDiscount_H_Money_yuan;
|
item.NormalDiscount_H_Money__c = item.NormalDiscount_H_Money_yuan;
|
}else{
|
arrte.NormalDiscount__c_Input = NormalDisN+'%';
|
item.NormalDiscount__c_Input = NormalDisN+'%';
|
}
|
}
|
}else if(item.JxsType=="特约折扣"){
|
if(arrte.Id==Id&&
|
arrte.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
arrte.GuaranteeDiscount__c_Input == GuaranteeDiscount__c_Input){
|
|
if(distinguish2==2||distinguish==1||distinguish==3){
|
arrte.NormalDiscount_H_Money__c = arrte.NormalDiscount_H_Money_yuan;
|
item.NormalDiscount_H_Money__c = item.NormalDiscount_H_Money_yuan;
|
arrte.GuaranteeDiscount_H_Money__c = arrte.GuaranteeDiscount_H_Money_yuan;
|
item.GuaranteeDiscount_H_Money__c = item.GuaranteeDiscount_H_Money_yuan;
|
}else{
|
if(NormalDisN!=0){
|
arrte.NormalDiscount__c_Input = NormalDisN+'%';
|
item.NormalDiscount__c_Input = NormalDisN+'%';
|
}
|
if(NormalDisG!=0){
|
arrte.GuaranteeDiscount__c_Input = NormalDisG+'%';
|
item.GuaranteeDiscount__c_Input = NormalDisG+'%';
|
}
|
}
|
}
|
}
|
});
|
if(distinguish!=1&&distinguish2!=2&&distinguish!=3){
|
arrProductTemp.forEach(arrpt => {
|
if(arrpt.recordTypeName__c=="Authorizer"){
|
if(arrpt.PromotionId==Id&&
|
arrpt.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
arrpt.GuaranteeDiscount__c_Input == GuaranteeDiscount__c_Input){
|
if(NormalDisN!=0){
|
arrpt.NormalDiscount__c_Input = NormalDisN+'%';
|
}
|
if(NormalDisG!=0){
|
arrpt.GuaranteeDiscount__c_Input = NormalDisG+'%';
|
}
|
}
|
}else{
|
if (arrpt.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
arrpt.Category__c == Category__c) {
|
arrpt.NormalDiscount__c_Input = NormalDisN+'%';
|
}
|
}
|
});
|
}
|
arrTempsss =arrTemp1;
|
arrProductTempsss = arrProductTemp;
|
}
|
debugger
|
if(distinguish==1&&distinguish2!=2){
|
return 1;
|
}else if(distinguish!=1&&distinguish2==2){
|
return 2;
|
}else if(distinguish==1&&distinguish2==2){
|
return 12;
|
}else if(distinguish==3){
|
return 3;
|
}else{
|
return item;
|
}
|
}
|
//反算折扣提示信息
|
export function InverseCalculationTiShi(ffgg,GuaranteeDiscount__cZuiXiao,NormalDiscount__cZuiXiao){
|
if(ffgg==1){
|
return "修改错误,非对象品折扣不得小于非对象品最低折扣:"+NormalDiscount__cZuiXiao+"%";
|
}else if(ffgg==2){
|
return "修改错误,对象品折扣不得小于对象品最低折扣:"+GuaranteeDiscount__cZuiXiao+"%";
|
}else if(ffgg==12){
|
return "修改错误,对象品折扣不得小于对象品最低折扣:"+GuaranteeDiscount__cZuiXiao+"%"+",且非对象品折扣不得小于非对象品最低折扣:"+NormalDiscount__cZuiXiao+"%";
|
}else if(ffgg==3){
|
return "修改错误,非对象品折扣不得小于0";
|
}else{
|
return "数据修改成功";
|
}
|
}
|
//合同价格汇总逻辑
|
export function ContractPriceComputeLogic(sum,jzDataProductList,jzDataDiscountList,jzDataFixedPriceList){
|
var DataDiscount = []; //折扣政策产品明细
|
jzDataProductList.forEach(jdpd => {
|
jzDataDiscountList.forEach(jddp => {
|
var PromotionHeadRecordId = jddp.recordTypeName__c;
|
if (PromotionHeadRecordId == "Authorizer") {
|
if (jdpd.PromotionId == jddp.Id && //方案Id
|
jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
|
jddp.GuaranteeDiscount__c_Input == jdpd.GuaranteeDiscount__c_Input) { //对象品折扣录入
|
DataDiscount.push(jdpd);
|
}
|
} else {
|
if (jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
|
jddp.Category__c == jdpd.Category__c) { //折扣政策分类
|
DataDiscount.push(jdpd);
|
}
|
}
|
});
|
});
|
DataDiscount.forEach(jjc => {
|
jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
|
sum = sum + jjc.AgencySubtotal__c;
|
});
|
jzDataFixedPriceList.forEach(jzdfp => {
|
var HeTongTotals = parseFloat(jzdfp.HeTongTotal)
|
if (jzdfp.HeTongTotal == undefined || jzdfp.HeTongTotal == "") {
|
HeTongTotals = 0;
|
}
|
sum = sum + HeTongTotals;
|
});
|
sum = Math.round(sum * 100) / 100;
|
return sum;
|
}
|
//计算过后特约折扣的合同价格
|
export function SpecialPriceComputeReverse(DataDiscount,fag){
|
var sum=0;
|
var sum1=0
|
DataDiscount.forEach(jjc => {
|
if(jjc.warrantyType__c=="市场多年保修"){
|
jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
|
sum = sum + jjc.AgencySubtotal__c;
|
sum=parseFloat(sum.toFixed(2));
|
}
|
if(jjc.warrantyType__c!="市场多年保修"){
|
jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
|
sum1 = sum1 + jjc.AgencySubtotal__c;
|
sum1=parseFloat(sum1.toFixed(2));
|
}
|
});
|
if(fag){
|
return sum;
|
}else{
|
return sum1;
|
}
|
}
|
//更改一般折扣合同价格计算合同总价逻辑
|
export function GeneralDiscountContractSummaryLogic(sum,jzDataDiscountList,jzDataFixedPriceList){
|
jzDataDiscountList.forEach(jddp => {
|
var HeTongPrice = parseFloat(jddp.HeTongPrice)
|
if (jddp.HeTongPrice == undefined || jddp.HeTongPrice == "") {
|
HeTongPrice = 0;
|
}
|
sum =sum + HeTongPrice;
|
});
|
jzDataFixedPriceList.forEach(jzdfp =>{
|
var HeTongTotals = parseFloat(jzdfp.HeTongTotal)
|
if (jzdfp.HeTongTotal == undefined || jzdfp.HeTongTotal == "") {
|
HeTongTotals = 0;
|
}
|
sum =sum + HeTongTotals;
|
});
|
sum = Math.round(sum * 100) / 100;
|
return sum;
|
}
|
//折扣政策匹配规则部分逻辑
|
export function SpecialSavesChangePartLogic(jzDataDefaultList,SaveName, SelectedData, IdStr, CompareId,DefalutQuantity,newDicountData,jzDataDiscountList){
|
var NewDefaultData = [];
|
var AddProductData = [];
|
jzDataDefaultList.forEach(defaultItem => { //待选产品
|
var defaultItemTemp = {
|
...{},
|
...defaultItem
|
};
|
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;
|
if (SaveName == "一般折扣") {
|
SelectedListDataTemp.NormalDiscount__c_Input = SelectedData.NormalDiscount__c_Input;
|
} else {
|
SelectedListDataTemp.NormalDiscount__c_Input = SelectedData.NormalDiscount__c;
|
}
|
SelectedListDataTemp.GuaranteeDiscount__c_Input = SelectedData.GuaranteeDiscount__c;
|
SelectedListDataTemp.Category__c = SelectedData.Category__c;
|
SelectedListDataTemp.CompareId = CompareId;
|
SelectedListDataTemp.Quantity = SelectedListDataTemp.SplitQuantity;
|
if (defaultItemTemp.Quantity != SelectedListDataTemp.Quantity) {
|
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);
|
}
|
})
|
NewDefaultDatass=NewDefaultData;
|
AddProductDatass=AddProductData;
|
//添加数量
|
jzDataDiscountList.forEach(disItem => { //折扣政策
|
var newTemp = {
|
...{},
|
...disItem
|
};
|
if (newTemp.Id == IdStr) {
|
newTemp.Counts = DefalutQuantity;
|
}
|
newDicountData.push(newTemp);
|
})
|
return newDicountData;
|
}
|
//折扣政策合同价格汇总逻辑
|
export function HeTongPriceComputeLogic(jzdateList,jzDataProductList){
|
var HeTongPriceList = [];
|
jzdateList.forEach(jddp => {
|
var sum = 0;
|
var sumNor = 0;
|
var sumGua = 0;
|
var PromotionHeadRecordId = jddp.recordTypeName__c;
|
jzDataProductList.forEach(jdpd => {
|
if (PromotionHeadRecordId == "Authorizer") {
|
if (jddp.Id == jdpd.PromotionId && //方案Id
|
jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
|
jddp.GuaranteeDiscount__c_Input == jdpd.GuaranteeDiscount__c_Input) { //对象品折扣录入
|
if(jdpd.warrantyType__c=="市场多年保修"){
|
sumGua = sumGua +jdpd.AgencySubtotal__c;
|
}else if(jdpd.warrantyType__c!="市场多年保修"){
|
sumNor = sumNor +jdpd.AgencySubtotal__c;
|
}
|
sum = sum + jdpd.AgencySubtotal__c;
|
}
|
} else {
|
if (jddp.NormalDiscount__c_Input == jdpd.NormalDiscount__c_Input && //非对象品折扣录入
|
jddp.Category__c == jdpd.Category__c) { //折扣政策分类
|
sum = sum + jdpd.AgencySubtotal__c;
|
}
|
}
|
});
|
sum = Math.round(sum * 100) / 100;
|
sumGua = Math.round(sumGua * 100) / 100;
|
sumNor = Math.round(sumNor * 100) / 100;
|
jddp.HeTongPrice = sum;
|
if(PromotionHeadRecordId == "Authorizer"){
|
jddp.GuaranteeDiscount_H_Money__c = sumGua;
|
jddp.NormalDiscount_H_Money__c = sumNor;
|
}else{
|
jddp.NormalDiscount_H_Money__c = sum;
|
}
|
HeTongPriceList.push(jddp);
|
});
|
return HeTongPriceList;
|
}
|
//价格策合并明细逻辑
|
export function PriceConsolidation(arrSchemes,jzdataList){
|
arrSchemes.forEach(arrsch=>{
|
var Setmap=new Map();
|
var arrList=[];
|
jzdataList.forEach(jdpd=>{
|
if(arrsch.Id==jdpd.PromotionId){
|
var object={};
|
if(Setmap.has(jdpd.Id)){
|
object={...{},...Setmap.get(jdpd.Id)};
|
object.Quantity=object.Quantity+jdpd.Quantity;
|
Setmap.set(jdpd.Id,object);
|
}else{
|
Setmap.set(jdpd.Id,jdpd);
|
}
|
}else{
|
arrList.push(jdpd);
|
}
|
});
|
for (let [k, v] of Setmap) {
|
arrList.push(v);
|
}
|
// jzdataList=[...[],...arrList];//20230214
|
jzdataList = [].concat(arrList);//20230214
|
});
|
return jzdataList;
|
}
|
//合并折扣政策重复方案逻辑
|
export function ConsolidatedDiscountPolicyLogic(SchemeSet,arr){
|
var Setmap=new Map();
|
var arr2=SchemeSet;
|
arr2.forEach(arrs=>{
|
var object={};
|
var PromotionHeadRecordId = arrs.recordTypeName__c;
|
if(PromotionHeadRecordId == "Authorizer"){
|
var key=arrs.Id+"_"+arrs.NormalDiscount__c_Input+"_"+arrs.GuaranteeDiscount__c_Input;//方案Id/非对象品折扣录入/对象品折扣录入
|
if(Setmap.has(key)){
|
object={...{},...Setmap.get(key)};
|
object.determine='';
|
arrs.HeTongPrice=Number(arrs.HeTongPrice);
|
object.HeTongPrice=Number(object.HeTongPrice);
|
object.HeTongPrice +=arrs.HeTongPrice;
|
arrs.GuaranteeDiscount_H_Money__c=Number(arrs.GuaranteeDiscount_H_Money__c);
|
object.GuaranteeDiscount_H_Money__c=Number(object.GuaranteeDiscount_H_Money__c);
|
object.GuaranteeDiscount_H_Money__c +=arrs.GuaranteeDiscount_H_Money__c;
|
arrs.NormalDiscount_H_Money__c=Number(arrs.NormalDiscount_H_Money__c);
|
object.NormalDiscount_H_Money__c=Number(object.NormalDiscount_H_Money__c);
|
object.NormalDiscount_H_Money__c +=arrs.NormalDiscount_H_Money__c;
|
Setmap.set(key,object);
|
}else{
|
Setmap.set(key,arrs);
|
}
|
}else{
|
var key=arrs.NormalDiscount__c_Input+"_"+arrs.Category__c;//非对象品折扣录入、折扣政策分类
|
if(Setmap.has(key)){
|
object={...{},...Setmap.get(key)};
|
object.determine='';
|
arrs.HeTongPrice=Number(arrs.NormalDiscount_H_Money__c);
|
object.HeTongPrice=Number(object.HeTongPrice);
|
object.HeTongPrice +=arrs.HeTongPrice;
|
arrs.NormalDiscount_H_Money__c=Number(arrs.NormalDiscount_H_Money__c);
|
object.NormalDiscount_H_Money__c=Number(object.NormalDiscount_H_Money__c);
|
object.NormalDiscount_H_Money__c +=arrs.NormalDiscount_H_Money__c;
|
|
Setmap.set(key,object);
|
}else{
|
Setmap.set(key,arrs);
|
}
|
}
|
});
|
for (let [k, v] of Setmap) {
|
arr.push(v);
|
}
|
return arr;
|
}
|
//合并折扣政策产品明细逻辑
|
export function ConsolidatedDiscountDetailsLogic(arrSchemes,jzdataList){
|
arrSchemes.forEach(arrsch=>{
|
var Setmap=new Map();
|
var arrList=[];
|
jzdataList.forEach(jdpd=>{
|
var PromotionHeadRecordId = arrsch.recordTypeName__c;
|
if(PromotionHeadRecordId == "Authorizer"){
|
if(arrsch.Id==jdpd.PromotionId&&//方案Id
|
arrsch.NormalDiscount__c_Input==jdpd.NormalDiscount__c_Input&&//非对象品折扣录入
|
arrsch.GuaranteeDiscount__c_Input==jdpd.GuaranteeDiscount__c_Input){//对象品折扣录入
|
var object={};
|
if(Setmap.has(jdpd.Id)){
|
object={...{},...Setmap.get(jdpd.Id)};
|
object.Quantity=object.Quantity+jdpd.Quantity;
|
Setmap.set(jdpd.Id,object);
|
}else{
|
Setmap.set(jdpd.Id,jdpd);
|
}
|
}else{
|
arrList.push(jdpd);
|
}
|
}else{
|
if(arrsch.NormalDiscount__c_Input==jdpd.NormalDiscount__c_Input&&//非对象品折扣录入
|
arrsch.Category__c==jdpd.Category__c){//折扣政策分类
|
var object={};
|
if(Setmap.has(jdpd.Id)){
|
object={...{},...Setmap.get(jdpd.Id)};
|
object.Quantity=object.Quantity+jdpd.Quantity;
|
Setmap.set(jdpd.Id,object);
|
}else{
|
Setmap.set(jdpd.Id,jdpd);
|
}
|
}else{
|
arrList.push(jdpd);
|
}
|
}
|
});
|
for (let [k, v] of Setmap) {
|
arrList.push(v);
|
}
|
// jzdataList=[...[],...arrList];//20230214
|
jzdataList = [].concat(arrList);//20230214
|
});
|
return jzdataList;
|
}
|
//合并上一次的报价行的逻辑
|
export function addOfferLogic(TrialLine){
|
var Offermap=new Map();
|
var arr=[];
|
var arr2=TrialLine;
|
arr2.forEach(arrs=>{
|
var object={};
|
if(Offermap.has(arrs.Id)){
|
object={...{},...Offermap.get(arrs.Id)};
|
object.Quantity=object.Quantity+arrs.Quantity;
|
Offermap.set(arrs.Id,object);
|
}else{
|
Offermap.set(arrs.Id,arrs);
|
}
|
});
|
for (let [k, v] of Offermap) {
|
arr.push(v);
|
}
|
return arr;
|
}
|
// ==============生成UUID
|
export function 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;
|
}
|
//一般产品部分逻辑
|
export function partGeneralDiscountLogical(itemsss,item){
|
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;
|
return itemsss;
|
}
|
//促销方案部分逻辑
|
export function partPromotionSchemeLogical(itemsss,item,multiYearWarranty__c){
|
debugger
|
if(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;
|
}
|
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;
|
return itemsss;
|
}
|
//一般折扣计算逻辑
|
export function commonlyDiscountLogic(itemss,item){
|
var Discount__c_Input = parseFloat(item.NormalDiscount__c_Input)*0.01;
|
debugger
|
itemss.AgencyUnitPrice__c = itemss.ListPrice * (Discount__c_Input) + itemss.ServicePrice__c;
|
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 = itemss.ServicePrice__c * itemss.Quantity;
|
itemss.Discount__c_Input = item.NormalDiscount__c_Input;
|
itemss.Category__c=item.Category__c;
|
return itemss
|
}
|
//特约折扣计算逻辑
|
export function contributingDiscountLogic(itemss,Discount__c_Input,item){
|
if (itemss.warrantyType__c=="市场多年保修") {
|
itemss.AgencyUnitPrice__c = (itemss.ListPrice + itemss.ServicePrice__c) * (Discount__c_Input*0.01);
|
} else {
|
itemss.AgencyUnitPrice__c = itemss.ListPrice * (Discount__c_Input*0.01) + itemss.ServicePrice__c;
|
}
|
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 = itemss.ServicePrice__c * itemss.Quantity;
|
debugger
|
itemss.Discount__c_Input = Discount__c_Input+"%";
|
// itemss.Discount__c_Input = Discount__c_Input;
|
itemss.GuaranteeDiscount__c_Input=item.GuaranteeDiscount__c_Input;
|
itemss.NormalDiscount__c_Input=item.NormalDiscount__c_Input;
|
itemss.recordTypeName__c = item.recordTypeName__c;
|
return itemss
|
}
|
//计算价格政策的最大次数逻辑
|
export function ComputationalLogic(Pricepolicy,b,selectproducts){
|
var num=0;
|
var flag=true;
|
for(var j=0;j<b.length;j++){
|
if(b[j].Id_H==Pricepolicy.PromotionNo__c){
|
var fg=true;
|
for(var i=0;i<selectproducts.length;i++){
|
if(b[j].Asset_Model_No__c==selectproducts[i].Product2.MDM_Model_No__c){
|
var frequency = parseInt(selectproducts[i].Quantity/b[j].Quantity__c__c);
|
if(frequency<1){
|
fg=true;
|
break;
|
}else{
|
if(flag){
|
num=frequency;
|
flag=false;
|
}else{
|
if(num>frequency){
|
num=frequency;
|
}
|
}
|
}
|
fg=false;
|
}
|
}
|
if(fg){
|
num=0;
|
break;
|
}
|
}
|
}
|
var Counts = Number(Pricepolicy.Counts);
|
return Counts+num;
|
}
|
//替换listprice单价逻辑
|
export function ReplacementUnitPriceLogic(arr,ifTrade){
|
arr.forEach(jdpct => { //产品明细
|
if (ifTrade == "内貿") {
|
jdpct.ListPrice = jdpct.Product2.Intra_Trade_List_RMB__c;
|
if (jdpct.multiYearWarranty__c) {
|
jdpct.ServicePrice__c = jdpct.Product2.Intra_Trade_Service_RMB__c;
|
} else {
|
jdpct.ServicePrice__c = 0;
|
}
|
} else if (ifTrade == "外貿") {
|
jdpct.ListPrice = jdpct.Product2.Foreign_Trade_List_US__c;
|
if (jdpct.multiYearWarranty__c) {
|
jdpct.ServicePrice__c = jdpct.Product2.NoDiscount_Foreign__c;
|
} else {
|
jdpct.ServicePrice__c = 0;
|
}
|
}
|
});
|
return arr
|
}
|
//合并方案
|
export function ConsolidationScheme(data,ParamIdStr,Trade__c){
|
var NewData = [];
|
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;
|
//tt
|
if (itms.JxsType == "特约折扣") {
|
Temp.GuaranteeDiscountcInput = parseFloat(itms.GuaranteeDiscount__c_Input);
|
Temp.GuaranteeDiscountc = parseFloat(itms.GuaranteeDiscount__c);
|
Temp.NormalDiscountc = parseFloat(itms.NormalDiscount__c);
|
Temp.NormalDiscountcInput = parseFloat(itms.NormalDiscount__c_Input);
|
}
|
}else{
|
//tt
|
Temp.NormalDiscountcInput = parseFloat(itms.NormalDiscount__c_Input);
|
}
|
if (PromotionHeadRecordId == 'Promotion') {
|
Temp.Categoryc = '促销方案';
|
}
|
//一般产品
|
else if (PromotionHeadRecordId == 'NormalProduct') {
|
Temp.Categoryc = '一般产品';
|
}
|
//特约固定
|
else if (PromotionHeadRecordId == 'Authorizer') {
|
Temp.Categoryc = '经销商固定折扣';
|
} else {
|
Temp.Categoryc = itms.Category__c;
|
}
|
Temp.PromotionNocEqual = itms.PromotionNo__cEqual;
|
Temp.typess = itms.typess;
|
Temp.PromotionNoc = itms.PromotionNo__c;
|
Temp.Name = itms.Name;
|
Temp.ParamIdStr = ParamIdStr;
|
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 = Trade__c;
|
Temp.maxCounts = itms.maxCounts;
|
Temp.CompareId = itms.CompareId;
|
Temp.sumNoDiscountTotal = itms.sumNoDiscountTotal;
|
Temp.GuaranteeDiscountHMoneyc = itms.GuaranteeDiscount_H_Money__c;
|
Temp.NormalDiscountHMoneyc = itms.NormalDiscount_H_Money__c;
|
//...c/compent
|
NewData.push(Temp);
|
});
|
return NewData;
|
}
|
//待选产品数据变化字段赋值
|
export function ProductAssignmentSelect(item){
|
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.QuoteTrialKey__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;
|
return item;
|
}
|
//已选产品数据变化字段赋值
|
export function ProductSelected(item){
|
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.QuoteTrialKey__c;
|
item.Product2Id = item.Product2__c;
|
item.Product2 = item.Product2__r;
|
if (item.Name == "一般折扣") {
|
item.PromotionId = item.PromotionSales__c;
|
// item.GuaranteeDiscount__c_Input = item.GuaranteeDiscountcInput__c;
|
// item.Discount__c_Input = item.DiscountRate__c;
|
item.Discount__c_Input = item.DiscountRate__c+'%';
|
// item.NormalDiscount__c_Input = item.NormalDiscountcInput__c
|
item.NormalDiscount__c_Input = item.NormalDiscountcInput__c+'%';
|
} else {
|
item.PromotionId = item.Promotion_id__c;
|
if(item.TypeName__c != "价格政策"){
|
// item.GuaranteeDiscount__c_Input = item.GuaranteeDiscountcInput__c;
|
item.GuaranteeDiscount__c_Input = item.GuaranteeDiscountcInput__c+'%';
|
// item.Discount__c_Input = item.DiscountRate__c;
|
item.Discount__c_Input = item.DiscountRate__c+'%';
|
// item.NormalDiscount__c_Input = item.NormalDiscountcInput__c;
|
item.NormalDiscount__c_Input = item.NormalDiscountcInput__c+'%';
|
// item.GuaranteeDiscount__c_Input=Number(item.GuaranteeDiscount__c_Input.toFixed(2));
|
}
|
}
|
item.warrantyType__c=item.GuranteeType__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=Number(item.Discount__c_Input.toFixed(2));
|
// item.NormalDiscount__c_Input = item.NormalDiscountcInput__c;
|
// item.NormalDiscount__c_Input=Number(item.NormalDiscount__c_Input.toFixed(2));
|
return item;
|
}
|
//折扣方案数据变化字段赋值
|
export function UnselectedScheme(items){
|
items.JxsType = items.JxsType__c;
|
// items.NormalDiscount__c_Input = items.NormalDiscount_c_Input__c;
|
items.NormalDiscount__c_Input=items.NormalDiscount_c_Input__c+'%';
|
// items.NormalDiscount__c_Input=Number(items.NormalDiscount__c_Input.toFixed(2));
|
items.TypeName = items.TypeName__c;
|
if (items.JxsType__c != "一般折扣") {
|
items.Id = items.PromotionHead__c;
|
// items.NormalDiscount__c = items.NormalDiscountc__c;
|
items.NormalDiscount__c=items.NormalDiscountc__c+'%';
|
// items.NormalDiscount__c=Number(items.NormalDiscount__c.toFixed(2));
|
// items.GuaranteeDiscount__c = items.GuaranteeDiscount__c;
|
items.GuaranteeDiscount__c=items.GuaranteeDiscount__c+'%';
|
// items.GuaranteeDiscount__c=Number(items.GuaranteeDiscount__c.toFixed(2));
|
// items.GuaranteeDiscount__c_Input = items.GuaranteeDiscount_c_Input__c;
|
items.GuaranteeDiscount__c_Input=items.GuaranteeDiscount_c_Input__c+'%';
|
// items.GuaranteeDiscount__c_Input=Number(items.GuaranteeDiscount__c_Input.toFixed(2));
|
|
}
|
// else{
|
// items.NormalDiscount__c = items.NormalDiscountc__c;
|
// items.NormalDiscount__c=items.NormalDiscountc__c+'%';
|
// items.NormalDiscount__c=Number(items.NormalDiscount__c.toFixed(2));
|
// items.GuaranteeDiscount__c = items.GuaranteeDiscount__c;
|
// items.GuaranteeDiscount__c=Number(items.GuaranteeDiscount__c.toFixed(2));
|
// items.GuaranteeDiscount__c_Input = items.GuaranteeDiscount_c_Input__c;
|
// items.GuaranteeDiscount__c_Input=Number(items.GuaranteeDiscount__c_Input.toFixed(2));
|
// }
|
items.ParamIdStr = items.Quote__c;
|
items.sumNoDiscountTotal = items.sumNoDiscountTotal__c;
|
items.maxCounts = items.maxCounts__c;
|
items.CompareId = items.CompareId__c;
|
return items;
|
}
|
//循环判断空
|
export function IfCopyProperties(x){
|
debugger
|
if(x.Asset_Model_No__c==undefined){
|
x.Asset_Model_No__c='';
|
}
|
if(x.Name_c__c==undefined){
|
x.Name_c__c='';
|
}
|
if(x.Quantity__c==undefined){
|
x.Quantity__c='';
|
}
|
if(x.GuranteeType__c==undefined){
|
x.GuranteeType__c='';
|
}
|
if(x.PromotionNo__c==undefined){
|
x.PromotionNo__c='';
|
}
|
if(x.Name__c==undefined){
|
x.Name__c='';
|
}
|
if(x.ListPrice__c==undefined){
|
x.ListPrice__c='';
|
}
|
if(x.NoDiscountTotal__c==undefined){
|
x.NoDiscountTotal__c='';
|
}
|
if(x.DiscountRate__c==undefined){
|
x.DiscountRate__c='';
|
}
|
if(x.AgencyUnitPrice__c==undefined){
|
x.AgencyUnitPrice__c='';
|
}
|
if(x.AgencySubtotal__c==undefined){
|
x.AgencySubtotal__c='';
|
}
|
return x;
|
}
|
//价格方案数据变化字段赋值
|
export function SelectedScheme(items){
|
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;
|
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.sumNoDiscountTotal = items.sumNoDiscountTotal__c;
|
items.maxCounts = items.maxCounts__c;
|
return items;
|
}
|
|
//合并产品
|
export function MergeProducts(arr3,arr4,data,ParamIdStr){
|
var NewData1 = [];
|
var newTemp3 = [];
|
arr3.forEach(itmsss => { //产品明细
|
var itemTemp = {
|
...{},
|
...itmsss
|
};
|
// itemTemp.分类名称(根据 产品状态 1) 0未匹配 2)1以匹配)
|
itemTemp.ismatch = '1';
|
newTemp3.push(itemTemp);
|
});
|
var newTemp4 = [];
|
arr4.forEach(itmsss => { //待选产品
|
var itemTemp = {
|
...{},
|
...itmsss
|
};
|
// itemTemp.分类名称(根据 产品状态 1) 0未匹配 2)1以匹配)
|
itemTemp.ismatch = '0';
|
newTemp4.push(itemTemp);
|
});
|
// var data2 = [...newTemp3, ...newTemp4];//20230213
|
var data2 = newTemp3.concat(newTemp4);//20230213
|
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 =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.DiscountcInput = parseFloat(itmss.Discount__c_Input);
|
if(itmss.Name=="一般折扣"){
|
Temp1.NormalDiscountcInput = parseFloat(itmss.NormalDiscount__c_Input);
|
}else{
|
Temp1.GuaranteeDiscountcInput = parseFloat(itmss.GuaranteeDiscount__c_Input);
|
Temp1.NormalDiscountcInput = parseFloat(itmss.NormalDiscount__c_Input);
|
}
|
}
|
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.multiYearWarrantyc = itmss.multiYearWarranty__c;
|
Temp1.Categoryc = itmss.Category__c;
|
|
NewData1.push(Temp1);
|
});
|
return NewData1;
|
}
|
// //方案需要更新的字段
|
export function 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;
|
}
|
export function getQueryVariable(variable) { //id字符串
|
var query = window.location.search.substring(1);
|
var vars = query.split("&");
|
for (var i = 0; i < vars.length; i++) {
|
var pair = vars[i].split("=");
|
if (pair[0] == variable) {
|
return pair[1];
|
}
|
}
|
return (false);
|
}
|
//跳转路径
|
export function PathJump(DeveloperName,ParamIdStr){
|
if(DeveloperName=='Opportunity'){
|
// 测试非完整路径是不是可以正确跳转
|
window.open('/apex/NewQuoteEntry?id=' + ParamIdStr, '_self');
|
}else if(DeveloperName=='SI_Oppor'){
|
// 测试非完整路径是不是可以正确跳转
|
window.open('/apex/SI_NewQuoteEntry?id=' + ParamIdStr, '_self');
|
}
|
}
|
//计算过后一般折扣的合同价格
|
export function ContractPriceComputeReverse(DataDiscount){
|
var sum=0;
|
DataDiscount.forEach(jjc => {
|
jjc.AgencySubtotal__c = parseFloat(jjc.AgencySubtotal__c)
|
sum = sum + jjc.AgencySubtotal__c;
|
});
|
sum=sum.toFixed(2);
|
return sum;
|
}
|
//复制逻辑
|
export function copyLogic(Check_Your_Clipboard,records,x,targetString,reslut){
|
records=reslut;
|
for (var i = 0; i < records.length; i++) {
|
x = records[i];
|
//判断空
|
x=IfCopyProperties(x);
|
targetString += '\r\n' + x. Asset_Model_No__c + '\t' + x.Name_c__c + '\t' + x.Quantity__c + '\t' + x.GuranteeType__c + '\t' + x.PromotionNo__c +'\t' + x.Name__c + '\t' + x.ListPrice__c + '\t' + x.NoDiscountTotal__c + '\t' + x.DiscountRate__c +
|
'\t' + x.AgencyUnitPrice__c + '\t' + x.AgencySubtotal__c ;
|
console.warn(x.PromotionNo__c);
|
}
|
try {
|
console.warn(targetString);
|
var tag = document.createElement('textarea');
|
tag.setAttribute('id', 'cp_hgz_textarea');
|
var strlenght=targetString.replace(/[\u0000-\u007f]/g,"a").replace(/[\u0080-\u07ff]/g,"aa").replace(/[\u0800-\uffff]/g,"aaa").length;
|
tag.maxLength=strlenght+666;
|
tag.value = targetString;
|
document.getElementsByTagName('body')[0].appendChild(tag);
|
document.getElementById('cp_hgz_textarea').select();
|
document.execCommand('copy');
|
document.getElementById('cp_hgz_textarea').remove();
|
alert(Check_Your_Clipboard);
|
} catch (error) {
|
alert(error);
|
}
|
}
|
//一般折扣更改过合同价格计算逻辑
|
export function updateCDLogic(Id,JxsType,GuaranteeDiscount__c_Input,NormalDiscount__c_Input,Category__c,jzDataDiscount,arrProductTemp){
|
console.warn('JxsType'+JxsType);
|
console.warn('jzDataDiscount'+jzDataDiscount);
|
var newArrsTempplus1=[];
|
var newArrsTempplus2=[];
|
var jzDataProductlast=[];
|
jzDataDiscount.forEach(item=>{
|
if(JxsType=="特约折扣"){
|
if(item.JxsType=="特约折扣"){
|
if (Id == item.Id) {
|
if (NormalDiscount__c_Input == item.NormalDiscount__c_Input && //非对象品折扣录入
|
GuaranteeDiscount__c_Input == item.GuaranteeDiscount__c_Input) { //对象品折扣录入
|
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);
|
} else {
|
Discount__c_Input = item.NormalDiscount__c_Input;
|
Discount__c_Input = parseFloat(Discount__c_Input);
|
}
|
debugger
|
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); //特约折扣计算逻辑
|
newArrsTempplus1.push(itemss);
|
} else if (itemss.PromotionId != item.Id ||
|
itemss.GuaranteeDiscount__c_Input != item.GuaranteeDiscount__c_Input ||
|
itemss.NormalDiscount__c_Input != item.NormalDiscount__c_Input) {
|
newArrsTempplus2.push(itemss);
|
}
|
});
|
var newArrsplusG=[];
|
var newArrsplusN=[];
|
newArrsTempplus1.forEach(ntp=>{
|
if(ntp.warrantyType__c=="市场多年保修"){
|
newArrsplusG.push(ntp);
|
}else if(ntp.warrantyType__c!="市场多年保修"){
|
newArrsplusN.push(ntp);
|
}
|
});
|
if(newArrsplusG.length!=0){
|
var yibanSumG = SpecialPriceComputeReverse(newArrsTempplus1,true);
|
var chazhiG=(Number(item.GuaranteeDiscount_H_Money__c)*100-Number(yibanSumG)*100)/100;
|
var dangechazhiG=Math.round((chazhiG/newArrsplusG[0].Quantity) * 100) / 100;
|
newArrsplusG[0].AgencySubtotal__c =newArrsplusG[0].AgencySubtotal__c+chazhiG;
|
newArrsplusG[0].AgencyUnitPrice__c =newArrsplusG[0].AgencyUnitPrice__c+dangechazhiG;
|
}
|
if(newArrsplusN.length!=0){
|
var yibanSumN = SpecialPriceComputeReverse(newArrsTempplus1,false);
|
var chazhiN=(Number(item.NormalDiscount_H_Money__c)*100-Number(yibanSumN)*100)/100;
|
var dangechazhiN=Math.round((chazhiN/newArrsplusN[0].Quantity) * 100) / 100;
|
newArrsplusN[0].AgencySubtotal__c =newArrsplusN[0].AgencySubtotal__c+chazhiN;
|
newArrsplusN[0].AgencyUnitPrice__c =newArrsplusN[0].AgencyUnitPrice__c+dangechazhiN;
|
}
|
// newArrsTempplus1=[...newArrsplusG,...newArrsplusN];//20230213
|
newArrsTempplus1=newArrsplusG.concat(newArrsplusN);//20230213
|
// jzDataProductlast = [...newArrsTempplus1,...newArrsTempplus2];//20230213
|
jzDataProductlast = newArrsTempplus1.concat(newArrsTempplus2);//20230213
|
}
|
}
|
}
|
}else if(JxsType=="一般折扣"){
|
console.warn('item.JxsType'+item.JxsType);
|
if(item.JxsType=="一般折扣"){
|
console.warn('NormalDiscount__c_Input'+NormalDiscount__c_Input);
|
console.warn('NormalDiscount__c_Input'+NormalDiscount__c_Input);
|
if (NormalDiscount__c_Input == item.NormalDiscount__c_Input &&
|
Category__c == item.Category__c){
|
arrProductTemp.forEach(itemss => { //itemss产品明细
|
if (itemss.NormalDiscount__c_Input == NormalDiscount__c_Input &&
|
itemss.Category__c == Category__c) {
|
itemss = commonlyDiscountLogic(itemss, item); //一般折扣计算逻辑
|
newArrsTempplus1.push(itemss);
|
} else if (itemss.Category__c != Category__c ||
|
itemss.NormalDiscount__c_Input != NormalDiscount__c_Input) {
|
newArrsTempplus2.push(itemss);
|
}
|
});
|
var yibanSum = ContractPriceComputeReverse(newArrsTempplus1);//计算过后一般折扣的合同价格
|
var chazhi=(Number(item.NormalDiscount_H_Money__c)*100-Number(yibanSum)*100)/100;
|
var dangechazhi=Math.round((chazhi/newArrsTempplus1[0].Quantity) * 100) / 100;
|
newArrsTempplus1[0].AgencySubtotal__c =newArrsTempplus1[0].AgencySubtotal__c+chazhi;
|
newArrsTempplus1[0].AgencyUnitPrice__c =newArrsTempplus1[0].AgencyUnitPrice__c+dangechazhi;
|
// jzDataProductlast = [...newArrsTempplus1,...newArrsTempplus2];//20230213
|
jzDataProductlast =newArrsTempplus1.concat(newArrsTempplus2);//20230213
|
console.warn('newArrsTempplus2'+newArrsTempplus2);
|
console.warn('jzDataProductlast'+jzDataProductlast);
|
}
|
}
|
}
|
});
|
return jzDataProductlast;
|
}
|
|
export function countListAndNodLogic(ifTrade,copydate,item,result,DeftCopyQtyList){
|
var ListPrices = 0;
|
var Nodiscounts = 0;
|
result.forEach(itemss => { //方案主数据关联的产品
|
copydate.forEach(jddc => { //报价行项目主数据
|
if (itemss.Asset_Model_No__c == jddc.Product2.MDM_Model_No__c) {
|
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 (DeftCopyQtyList.length == 0) {
|
DeftCopyQtyList.push({
|
Asset_Model_No__c: itemss.Asset_Model_No__c,
|
Quantity__c__c: itemss.Quantity__c,
|
Id_H: item.PromotionNo__c
|
});
|
} else {
|
DeftCopyQtyList.forEach(jdcql => { //保存方案关联产品数量
|
if (itemss.Asset_Model_No__c == jdcql.Asset_Model_No__c && jdcql.Id_H == item.PromotionNo__c) {
|
fl = false;
|
}
|
});
|
if (fl) {
|
DeftCopyQtyList.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;
|
DeftCopyQtyLists=DeftCopyQtyList;
|
return item;
|
}
|
export const initDataTableProduct2 = {
|
columns: [{
|
label: '产品型号',
|
fieldName: 'Asset_Model_No__c',
|
sortable: true,
|
typeAttributes: {
|
|
},
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '产品名称',
|
fieldName: 'Name__c',
|
sortable: true,
|
initialWidth: 205
|
},
|
{
|
label: '数量',
|
fieldName: 'Quantity',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 88
|
},
|
{
|
label: '保修类型',
|
fieldName: 'warrantyType__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '方案代码',
|
fieldName: 'PromotionNo__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '促销方案名称/产品系列',
|
fieldName: 'Name',
|
sortable: true,
|
initialWidth: 124
|
},
|
{
|
label: '主报价',
|
fieldName: 'ListPrice',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '多年保价格小计',
|
fieldName: 'NoDiscountTotal__c',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '折扣',
|
fieldName: 'Discount__c_Input',
|
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'
|
}
|
},
|
|
|
],
|
sortInterfaces: false,
|
searchColumns:initSearchFormProduct
|
}
|
|
export const initSearchForm2 = [{
|
label: "方案代码",
|
type: "text",
|
name: "PromotionNo__cEqual",
|
isInput: true
|
},
|
{
|
label: "名称",
|
type: "text",
|
name: "NameLike",
|
isInput: true
|
}
|
]
|
|
export const initDataTable2 = {
|
columns: [{
|
label: '方案代码',
|
fieldName: 'PromotionNo__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '名称',
|
fieldName: 'Name',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 300
|
},
|
{
|
label: '描述',
|
fieldName: 'Description__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 300
|
},
|
{
|
label: '促销价格',
|
fieldName: 'Price_CNY__c',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 200
|
},
|
{
|
label: '是否包含多年保修价格',
|
fieldName: 'if_Contain_Nod__c',
|
sortable: true,
|
type: 'boolean',
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 200
|
},
|
{
|
label: '是否固定数量',
|
type: 'boolean',
|
fieldName: 'if_Fix__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 200
|
},
|
],
|
sortInterfaces: false,
|
searchColumns: initSearchForm2
|
}
|
export const initSearchFormFix2 = [{
|
label: "方案代码",
|
type: "text",
|
name: "PromotionNo__cEqual",
|
isInput: true
|
},
|
{
|
label: "名称",
|
type: "text",
|
name: "NameLike",
|
isInput: true
|
}
|
]
|
export const initDataTableFix2 = {
|
columns: [{
|
label: '方案代码',
|
fieldName: 'PromotionNo__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '名称',
|
fieldName: 'Name',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 351
|
},
|
{
|
label: '描述',
|
fieldName: 'Description__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 327
|
},
|
{
|
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: initSearchFormFix2
|
}
|
export const initSearchFormDefalt2 = [{
|
label: "产品型号",
|
type: "text",
|
name: "Asset_Model_No__c",
|
isInput: true
|
},
|
{
|
label: "产品名称",
|
type: "text",
|
name: "Name__c",
|
isInput: true
|
}
|
]
|
export const initDataTableDefault2 = {
|
columns: [{
|
label: '产品型号',
|
fieldName: 'Asset_Model_No__c',
|
sortable: true
|
},
|
{
|
label: '产品名称',
|
fieldName: 'Name__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 251
|
},
|
{
|
label: '数量',
|
fieldName: 'Quantity',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '保修类型',
|
fieldName: 'warrantyType__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '主报价',
|
fieldName: 'ListPrice',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '多年保价格小计',
|
fieldName: 'NoDiscountTotal__c',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
|
],
|
sortInterfaces: false,
|
searchColumns: initSearchFormDefalt2
|
}
|
export const initSearchFormFixedPrice2 = [{
|
label: "产品型号",
|
type: "text",
|
name: "Asset_Model_No__c",
|
isInput: true
|
},
|
{
|
label: "产品名称",
|
type: "text",
|
name: "Name__c",
|
isInput: true
|
}
|
]
|
export const initDataTableFixedPrice2 = {
|
columns: [{
|
label: '方案代码',
|
fieldName: 'PromotionNo__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '促销方案名称/产品系列',
|
fieldName: 'Name',
|
sortable: true,
|
initialWidth: 196
|
},
|
{
|
label: '方案描述',
|
fieldName: 'Description__c',
|
sortable: true,
|
initialWidth: 105
|
},
|
{
|
label: '分类',
|
fieldName: 'Category__c',
|
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'
|
}
|
},
|
{
|
label: '促销单价',
|
fieldName: 'Price_CNY__c',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '次数',
|
fieldName: 'Counts',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
editable: false
|
},
|
{
|
label: '多年保价格合计',
|
fieldName: 'sumNoDiscountTotal',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '促销总价',
|
fieldName: 'Total',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '合同价格',
|
fieldName: 'HeTongTotal',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
editable: false,
|
initialWidth: 100
|
},
|
|
],
|
sortInterfaces: [],
|
searchColumns: initSearchFormFixedPrice2
|
}
|
export const initSearchFormDiscount2 = []
|
export const initDataTableDiscount2 = {
|
columns: [{
|
label: '经销商分类',
|
fieldName: 'JxsType',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '分类',
|
fieldName: 'Category__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
// {
|
// label: '对象品折扣',
|
// fieldName: 'GuaranteeDiscount__c',
|
// sortable: true,
|
// cellAttributes: {
|
// alignment: 'center'
|
// }
|
// },
|
// {
|
// label: '非对象品折扣',
|
// fieldName: 'NormalDiscount__c',
|
// sortable: true,
|
// cellAttributes: {
|
// alignment: 'center'
|
// }
|
// },
|
{
|
label: '对象品折扣',
|
fieldName: 'GuaranteeDiscount__c_Input',
|
editable: false,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
},
|
{
|
label: '对象品合同金额',
|
fieldName: 'GuaranteeDiscount_H_Money__c',
|
type: 'number',
|
editable: false,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
typeAttributes: {
|
minimumFractionDigits: '2',
|
maximumFractionDigits: '2'
|
}
|
},
|
{
|
label: '非对象品折扣',
|
fieldName: 'NormalDiscount__c_Input',
|
editable: false,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
},
|
{
|
label: '非对象品合同金额',
|
fieldName: 'NormalDiscount_H_Money__c',
|
type: 'number',
|
editable: false,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
typeAttributes: {
|
minimumFractionDigits: '2',
|
maximumFractionDigits: '2'
|
}
|
},
|
{
|
label: '合同价格',
|
fieldName: 'HeTongPrice',
|
type: 'number',
|
editable: false,
|
cellAttributes: {
|
class: {},
|
alignment: 'center'
|
},
|
typeAttributes: {
|
minimumFractionDigits: '2',
|
maximumFractionDigits: '2'
|
}
|
}
|
],
|
sortInterfaces: [],
|
searchColumns: initSearchFormDiscount2
|
}
|
export const initSearchFormSpecial2 = []
|
export const initDataTableSpecial2 = {
|
columns: [{
|
label: '编码',
|
fieldName: 'PromotionNo__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '协议产品',
|
fieldName: 'Department__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '对象品折扣',
|
fieldName: 'GuaranteeDiscount__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '非对象品折扣',
|
fieldName: 'NormalDiscount__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '协议编码',
|
fieldName: 'Contract__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '经销商',
|
fieldName: 'Agency__Name',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
],
|
sortInterfaces: false,
|
searchColumns: initSearchFormSpecial2
|
}
|
export const initSearchFormOtherData2 = []
|
export const initDataTableOtherData2 = {
|
columns: [{
|
label: '产品型号',
|
fieldName: 'Asset_Model_No__c',
|
sortable: true,
|
typeAttributes: {
|
},
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '产品名称',
|
fieldName: 'Name__c',
|
sortable: true,
|
|
initialWidth: 268
|
},
|
{
|
label: '数量',
|
fieldName: 'Quantity',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '使用数量',
|
fieldName: 'SplitQuantity',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center',
|
class: {}
|
},
|
editable: false
|
},
|
{
|
label: '保修类型',
|
fieldName: 'warrantyType__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '主报价',
|
fieldName: 'ListPrice',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '多年保价格小计',
|
fieldName: 'NoDiscountTotal__c',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
],
|
sortInterfaces: false,
|
searchColumns: initSearchFormOtherData2
|
}
|
export const initSearchFormCommonly2 = [{
|
label: "方案代码",
|
type: "text",
|
name: "PromotionNo__cEqual",
|
isInput: true
|
},
|
{
|
label: "名称",
|
type: "text",
|
name: "NameLike",
|
isInput: true
|
}
|
]
|
export const initDataTableCommonly2 = {
|
columns: [{
|
label: '产品型号',
|
fieldName: 'Asset_Model_No__c',
|
sortable: true,
|
typeAttributes: {
|
},
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '产品名称',
|
fieldName: 'Name__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
},
|
initialWidth: 268
|
},
|
{
|
label: '数量',
|
fieldName: 'Quantity',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '使用数量',
|
fieldName: 'SplitQuantity',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center',
|
class: {}
|
},
|
editable: false
|
},
|
{
|
label: '保修类型',
|
fieldName: 'warrantyType__c',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '主报价',
|
fieldName: 'ListPrice',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
{
|
label: '多年保价格小计',
|
fieldName: 'NoDiscountTotal__c',
|
type: 'number',
|
sortable: true,
|
cellAttributes: {
|
alignment: 'center'
|
}
|
},
|
|
],
|
sortInterfaces: false,
|
searchColumns: initSearchFormCommonly2
|
}
|