export var bflag; export var oppInfosave; export var quoLineItemsave; export var DataStatus; export var newQuoteFlagex; export var MultiYearWarrantyTotalPriceExport; export var newQuoteFlagExp; export var productStatusUpdatedExp; export var quoExp; export var selection_hpExp; export var options_hpflgExp; export var fagExp; export var ListPriceTotalExp; export var unitPriceTotalExp; export var errorflg; export var StrExp; export var IsQuoteTrialExp; export var alertExp = ''; export var alfExp = 0; export var nafgExp = {}; export var flg = false; export var tStringe = 'No.\t编码\t状态\t名称\tListPrice\t数量\t规格\t医院单价\t医院小计\t赠送\t经销商单价\t经销商小计'; tStringe += '\t多年保修\t保修\tNoDiscount小计'; tStringe += '\t保修期\t通货'; var addproductList = []; var trade; //选择报价产品配置列 export var initDataTableToBeproductConfig = { columns: [ { label: '产品型号', fieldName: 'Asset_Model', editable: false, cellAttributes: { class: {}, alignment: 'left' }, hideDefaultActions: true, initialWidth: 150 }, { label: 'NMPA状态', fieldName: 'SFDA_Status__c', type: 'text', cellAttributes: { class:{ fieldName:'SFDAStatuclass' }, alignment: 'left' }, hideDefaultActions: true, initialWidth: 150 }, { label: '供应商名称', fieldName: 'VenderName', hideDefaultActions: true, initialWidth: 150 }, { label: '主报价价格', fieldName: 'ListPrice_Page', type: 'number', typeAttributes: { minimumFractionDigits: '2', maximumFractionDigits: '2' }, cellAttributes: { class:{ fieldName:'ListPricePageclass' }, alignment: 'right' }, hideDefaultActions: true, initialWidth: 150 }, { label: '数量', fieldName: 'Quantity__c', type: 'number', editable: false, cellAttributes: { class: {}, alignment: 'right' }, hideDefaultActions: true, initialWidth: 150 }, { label: '规格', fieldName: 'Specifications', type: 'number', cellAttributes: { alignment: 'right' }, hideDefaultActions: true, initialWidth: 150 }, { label: '医院单价', fieldName: 'UnitPrice_Page__c', // editable: true, cellAttributes: { class: {}, alignment: 'right', }, type: 'number', typeAttributes: { minimumFractionDigits: '2', maximumFractionDigits: '2' }, hideDefaultActions: true, initialWidth: 150 }, { label: '医院小计', fieldName: 'Subtotal__c', cellAttributes: { alignment: 'right' }, type: 'number', typeAttributes: { minimumFractionDigits: '2', maximumFractionDigits: '2' }, hideDefaultActions: true, initialWidth: 150 }, { label: '多年保修', fieldName: 'multiYearWarranty__c', type: 'boolean', cellAttributes: { alignment: 'center' }, hideDefaultActions: true, initialWidth: 150 }, { label: '保修', fieldName: 'warrantyType__c', type: 'text', hideDefaultActions: true, initialWidth: 150 }, { label: '保修年限', fieldName: 'GuaranteePeriod__c', cellAttributes: { alignment: 'center' }, hideDefaultActions: true, initialWidth: 150 }, { label: '预计消耗至', fieldName: 'Estimated_ConsumptionDueDate', type: 'date', typeAttributes:{ // weekday: "long", year: "numeric", month: "long", day: "2-digit" }, cellAttributes: { class:{ fieldName:'EstimatedConsumptionDueDateclass' }, alignment: 'center' }, hideDefaultActions: true, initialWidth: 150 }, { label: '库存状态', fieldName: 'StorageStatus', type: 'text', cellAttributes: { alignment: 'center' }, hideDefaultActions: true, initialWidth: 150 }, { label: '产品名称', fieldName: 'Name', type: 'url', typeAttributes: { label: { fieldName: 'Name__c' }, tooltip: { fieldName: 'website' }, target: '_blank' }, cellAttributes: { class:{ fieldName:'Nameclass' }, }, hideDefaultActions: true, initialWidth: 300 }, ], sortInterfaces: false, searchColumns: [] }; //产品配套配置列 export var initDataSetProductTablefig = { columns: [ { label: '产品配套名', fieldName: 'Name', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, // initialWidth: 150 }, { label: '产品配套编码', fieldName: 'Product_Set_CD__c', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, // initialWidth: 150 }, { label: '数量', fieldName: 'Quantity__c', type: 'number', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, // initialWidth: 150 }, { label: '补足信息', fieldName: 'Quote_Select_Info__c', type: 'text', cellAttributes: { class: {}, alignment: 'left' }, hideDefaultActions: true, // initialWidth: 150 }, { label: '有効', fieldName: 'Valid_Status__c', type: 'boolean', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, // initialWidth: 150 }, ], sortInterfaces: false, searchColumns: [] }; //新增产品产品配置列 export var initDataProductTablefig = { columns: [{ label: '产品型号', fieldName: 'Asset_Model_No__c', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 110 }, { label: '产品编码', fieldName: 'OT_CODE_no_link__c', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 120 }, { label: '产品名称', fieldName: 'Name', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 270 }, { label: '适用科室', fieldName: 'suitDepartment__c', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 100 }, { label: '代替产品', fieldName: 'Alternative_Products__c', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 100 }, { label: 'NMPA状态', fieldName: 'SFDA_Status__c', type: 'text', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 115 }, { label: 'ListPrice(内贸)', fieldName: 'Intra_Trade_List_RMB__c', type: 'number', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 130 }, { label: 'ListPrice(外贸)', fieldName: 'Foreign_Trade_List_US__c', type: 'number', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 130 }, { label: '规格', fieldName: 'Packing_list_manual__c', type: 'number', cellAttributes: { alignment: 'left' }, hideDefaultActions: true, initialWidth: 60 }, ], sortInterfaces: false, searchColumns:[] }; export function localParseInt( input) { input += ""; input = input.split(" "); if (input.length > 1) { input = input[1]; } else { input = input[0]; } input = input.replace(/,/g, ""); input = input.replace(/ /g, ""); if ( input == '' || isNaN( input)) { input = 0; } input = parseInt(input); if (isNaN( input)) input = 0.00; return input; } export function number_format_common (number, decimals, dec_point, thousands_sep) { number = (number + '').replace(/[^0-9+\-Ee.]/g, ''); var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, s = '', toFixedFix = function (n, prec) { var k = Math.pow(10, prec); return '' + Math.round(n * k) / k; }; // Fix for IE parseFloat(0.55).toFixed(0) = 0; s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.'); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || '').length < prec) { s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0'); } return ( s.join(dec)); } export function toNum( input) { return number_format_common( input, 2, ".", ""); } export function toNumComma( input) { return number_format_common( input, 2, ".", ","); } export function toNumComma_One_digit(input) { return number_format_common( input, 1, ".", ","); } export function localParseFloat( input) { input += ""; input = input.split(" "); if (input.length > 1) { input = input[1]; } else { input = input[0]; } input = input.replace(/,/g, ""); input = input.replace(/ /g, ""); if ( input == '' || isNaN( input)) { input = 0.00; } input = parseFloat(input); if (isNaN( input)) input = 0.00; return input; } //复制按钮change export function NewQcopyLogic(Check_Your_Clipboard,records,x,targetString,reslut,displayCost,CurrencyIsoCode){ records=reslut; alfExp = false; alertExp = ''; for (var i = 0; i < records.length; i++) { x = records[i]; //判断空 // x=IfCopyProperties(x); targetString += '\r\n' + (i + 1) + '\t' + '=MID(( "_" & "' + x.ProductCode__c + '"),2,LEN("' + '_' + x.ProductCode__c + '")-1)' + '\t' + x.SFDA_Status__c + '\t' + x.Name__c + '\t' + toNumComma(x.ListPrice__c) + '\t' + x.Quantity + '\t' + (x.Qty_Unit__c == null ? '' : x.Qty_Unit__c) + '\t' + toNumComma(x.UnitPrice__c) + '\t' + toNumComma(x.UnitPrice__c * x.Quantity) + '\t' + x.Present__c + '\t' + toNumComma_One_digit(x.AgencyUnitPrice__c) + '\t' + toNumComma_One_digit(x.AgencySubtotal__c); if (!x.warrantyType__c) { x.warrantyType__c = ''; } targetString += '\t' + x.multiYearWarranty__c + '\t' + x.warrantyType__c + '\t' + toNumComma(x.NoDiscountTotal__c); targetString += '\t' + x.GuaranteePeriod__c; ; if (displayCost) { targetString += '\t' + toNumComma(x.Cost__c) + '\t' + CurrencyIsoCode; } } 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(); alfExp = true; alertExp = Check_Your_Clipboard; } catch (error) { alfExp = false; alertExp = error; } } export function productCompareLogic(jzDataToBeproduct,id2Product,t,b){ debugger bflag = b; jzDataToBeproduct.forEach(jzdtbt=>{ var a = jzdtbt.pageObject.Id__c; if (a != '') { var newProductGuranteePrice = 0; var newProductServicePrice = 0; var newMaintenance_Price_Year = 0; if (t == '外貿') { var recordTypeRecord = id2Product[a]; var y1 = recordTypeRecord.Name; var y2 = recordTypeRecord.Foreign_Trade_List_US__c; var y3 = recordTypeRecord.Foreign_Trade_Cost_US__c; newProductGuranteePrice = recordTypeRecord.Intra_Trade_Foreign_RMB__c; newProductServicePrice = recordTypeRecord.NoDiscount_Foreign__c; newMaintenance_Price_Year = recordTypeRecord.Repair_Contract_USD__c; } else { var recordTypeRecord = id2Product[a]; var y1 = recordTypeRecord.Name; var y2 = recordTypeRecord.Intra_Trade_List_RMB__c; var y3 = recordTypeRecord.Intra_Trade_Cost_RMB__c; newProductGuranteePrice = recordTypeRecord.Intra_Trade_Gurantee_RMB__c; newProductServicePrice = recordTypeRecord.Intra_Trade_Service_RMB__c; newMaintenance_Price_Year = recordTypeRecord.Maintenance_Price_Year__c; } // 保修类型 var newGuranteeType = recordTypeRecord.GuranteeType__c; if (!newGuranteeType) { var newGuranteeType = ''; } var newProductEntend_gurantee_period_all = recordTypeRecord.Entend_gurantee_period_all__c; var oldGuranteeType = jzdtbt.pageObject.GuranteeType__c; var oldProductEntend_gurantee_period_all = jzdtbt.pageObject.ProductEntend_gurantee_period_all__c; var oldProductGuranteePrice = jzdtbt.ProductGuranteePrice; var oldProductServicePrice = jzdtbt.pageObject.productServicePrice__c; var oldMaintenance_Price_Year = jzdtbt.Maintenance_Price_Year; oldProductServicePrice = localParseFloat(oldProductServicePrice); newProductServicePrice = localParseFloat(newProductServicePrice); oldProductGuranteePrice = localParseFloat(oldProductGuranteePrice); newProductGuranteePrice = localParseFloat(newProductGuranteePrice); newProductEntend_gurantee_period_all = localParseFloat(newProductEntend_gurantee_period_all); oldMaintenance_Price_Year = localParseFloat(oldMaintenance_Price_Year); newMaintenance_Price_Year = localParseFloat(newMaintenance_Price_Year); var y4 = recordTypeRecord.SFDA_Status__c; var s1 = recordTypeRecord.StorageStatus__c; var x1 = jzdtbt.pageObject.Name__c; var x2 = jzdtbt.ListPrice_Page; var x3 = jzdtbt.Cost_c; var x4 = jzdtbt.pageObject.SFDA_Status__c; //連続半角スペース対応 y1 = y1 + ''; // y1 = y1.replace(/\s+/g, " "); x2 = localParseFloat(x2); x3 = localParseFloat(x3); y2 = localParseFloat(y2); y3 = localParseFloat(y3); if ((x1 === y1) && (x2 === y2) && (x3 === y3) && (x4 === y4) && (oldGuranteeType === newGuranteeType) && (oldProductEntend_gurantee_period_all === newProductEntend_gurantee_period_all) && (oldProductGuranteePrice === newProductGuranteePrice) && (oldProductServicePrice === newProductServicePrice) && (oldMaintenance_Price_Year === newMaintenance_Price_Year) ) {} else { console.warn('x1 === y1'+(x1 === y1)); console.warn('x2 === y2'+(x2 === y2)); console.warn('x3 === y3'+(x3 === y3)); console.warn('x4 === y4'+(x4 === y4)); console.warn('oldGuranteeType === newGuranteeType'+(oldGuranteeType === newGuranteeType)); console.warn('oldProductEntend_gurantee_period_all === newProductEntend_gurantee_period_all'+(oldProductEntend_gurantee_period_all === newProductEntend_gurantee_period_all)); console.warn('oldProductGuranteePrice === newProductGuranteePrice'+(oldProductGuranteePrice === newProductGuranteePrice)); console.warn('oldProductServicePrice === newProductServicePrice'+(oldProductServicePrice === newProductServicePrice)); console.warn('oldMaintenance_Price_Year === newMaintenance_Price_Year'+(oldMaintenance_Price_Year === newMaintenance_Price_Year)); bflag = false; } jzdtbt.latestInfo.GuranteeType = newGuranteeType; jzdtbt.latestInfo.ProductEntend_gurantee_period_all = newProductEntend_gurantee_period_all; jzdtbt.latestInfo.Intra_Trade_Gurantee = localParseFloat(recordTypeRecord.Intra_Trade_Gurantee_RMB__c); jzdtbt.latestInfo.Intra_Trade_Service = localParseFloat(recordTypeRecord.Intra_Trade_Service_RMB__c); jzdtbt.latestInfo.Maintenance_Price_Year = localParseFloat(recordTypeRecord.Maintenance_Price_Year__c); jzdtbt.latestInfo.ProductName = recordTypeRecord.Name; jzdtbt.latestInfo.ListPrice = y2; jzdtbt.latestInfo.Cost = y3; jzdtbt.latestInfo.SFDA_Status = y4; } }); return jzDataToBeproduct; } export function TimeToString(newDate){ var value=newDate.toLocaleDateString(); var value2=value.split('/'); if(value2[1].length == 1){ value2[1]='0'+value2[1]; } if(value2[2].length == 1){ value2[2]='0'+value2[2]; } value=value2[0]+'-'+value2[1]+'-'+value2[2]; return value; } export function saveEvoluationLogic(quoin,oppInfoIn,quoLineItemIn){ debugger var quo ={...{},...quoin}; quo.Dealer_Final_Price_Page__c = quoin.Dealer_Final_Price_Page__c!=undefined&&quoin.Dealer_Final_Price_Page__c!=='' ?localParseFloat(quoin.Dealer_Final_Price_Page__c):null; quo.OCM_Agent1_Price_Page__c = quoin.OCM_Agent1_Price_Page__c!=undefined &&quoin.OCM_Agent1_Price_Page__c!==''? localParseFloat(quoin.OCM_Agent1_Price_Page__c):null; quo.MultiYearWarrantyTotalPrice__c = quoin.MultiYearWarrantyTotalPrice__c!=undefined? localParseFloat(quoin.MultiYearWarrantyTotalPrice__c):null; quo.Estimation_List_Price__c = quoin.Estimation_List_Price__c!=undefined? localParseFloat(quoin.Estimation_List_Price__c):null; quo.QuoteTotal_Page__c = quoin.QuoteTotal_Page__c !=undefined?localParseFloat(quoin.QuoteTotal_Page__c):null; quo.Agency1_Profit__c = quoin.Agency1_Profit__c !=undefined?localParseFloat(quoin.Agency1_Profit__c):null; quo.Agency1_Profit_Rate__c = quoin.Agency1_Profit_Rate__c!=undefined? localParseFloat(quoin.Agency1_Profit_Rate__c):null; quo.Agent1_Agent2_Price_Page__c = quoin.Agent1_Agent2_Price_Page__c!=undefined &&quoin.Agent1_Agent2_Price_Page__c!=='' ?localParseFloat(quoin.Agent1_Agent2_Price_Page__c):null; quo.Agency2_Profit__c = quoin.Agency2_Profit__c !=undefined?localParseFloat(quoin.Agency2_Profit__c):null; quo.Agency2_Profit_Rate__c = quoin.Agency2_Profit_Rate__c!=undefined? localParseFloat(quoin.Agency2_Profit_Rate__c):null; quo.Quote_Adjust_Amount_Page__c = quoin.Quote_Adjust_Amount_Page__c !=undefined&&quoin.Quote_Adjust_Amount_Page__c!==''?localParseFloat(quoin.Quote_Adjust_Amount_Page__c):null; console.warn(quoin.Quote_Adjust_Amount_Page__c); console.warn(quoin.Quote_Adjust_Amount_Page__c !=undefined && quoin.Quote_Adjust_Amount_Page__c!==''); console.warn(quoin.Quote_Adjust_Amount_Page__c !=undefined); console.warn(quoin.Quote_Adjust_Amount_Page__c!='0'); quo.Quote_Adjust_Calculate__c = quoin.Quote_Adjust_Calculate__c !=undefined&&quoin.Quote_Adjust_Calculate__c!==''?localParseFloat(quoin.Quote_Adjust_Calculate__c):null; quo.Stocking_Price__c = quoin.Stocking_Price__c!=undefined? localParseFloat(quoin.Stocking_Price__c):null; quo.Discount_Amount__c = quoin.Discount_Amount__c !=undefined?localParseFloat(quoin.Discount_Amount__c):null; quo.AgencyDiscount__c = quoin.AgencyDiscount__c !=undefined?localParseFloat(quoin.AgencyDiscount__c):null; quo.Discount_Amount_Calculate__c = quoin.Discount_Amount_Calculate__c !=undefined?localParseFloat(quoin.Discount_Amount_Calculate__c):null; debugger quo.PriceRefreshDate__c =quoin.PriceRefreshDate__c? TimeToString(new Date(quoin.PriceRefreshDate__c)):null; quo.CreatedDate =quoin.CreatedDate? TimeToString(new Date(quoin.CreatedDate)):null; quo.Quote_Expiration_Date__c =quoin.Quote_Expiration_Date__c? TimeToString(new Date(quoin.Quote_Expiration_Date__c)):null; quo.Agency1__c =quoin.Agency1__c? quoin.Agency1__c:null; quo.Agency2__c =quoin.Agency2__c? quoin.Agency2__c:null; //预测金额修改 fy quo.OCM_Sales_Forecast__c = quoin.OCM_Sales_Forecast__c!=undefined? localParseFloat(quoin.OCM_Sales_Forecast__c):null; //预测金额修改 fy var oppInfo ={...{},...oppInfoIn}; oppInfo.Wholesale_Price__c =oppInfoIn.Wholesale_Price__c!=undefined? localParseFloat(oppInfoIn.Wholesale_Price__c):null; oppInfosave = oppInfo; var quoitemList = [...[],...quoLineItemIn]; quoitemList.forEach(quoitem=>{ debugger quoitem.pageObject.Quantity__c = quoitem.Quantity__c; quoitem.pageObject.UnitPrice_Page__c = localParseFloat(quoitem.UnitPrice_Page__c); quoitem.pageObject.AgencySubtotal__c = localParseFloat(quoitem.AgencySubtotal__c); quoitem.pageObject.AgencyUnitPrice__c = localParseFloat(quoitem.AgencyUnitPrice__c); quoitem.pageObject.ListPrice_Page = localParseFloat(quoitem.ListPrice_Page); quoitem.UnitPrice_Page__c = localParseFloat(quoitem.UnitPrice_Page__c); quoitem.AgencySubtotal__c = localParseFloat(quoitem.AgencySubtotal__c); quoitem.AgencyUnitPrice__c = localParseFloat(quoitem.AgencyUnitPrice__c); quoitem.ListPrice_Page = localParseFloat(quoitem.ListPrice_Page); quoitem.pageObject.multiYearWarranty__c = quoitem.multiYearWarranty__c; quoitem.pageObject.GuaranteePeriod__c = quoitem.GuaranteePeriod__c; quoitem.pageObject.warrantyType__c = quoitem.warrantyType__c; quoitem.pageObject.NoDiscountTotal__c = localParseFloat(quoitem.NoDiscountTotal__c); quoitem.NoDiscountTotal__c = localParseFloat(quoitem.NoDiscountTotal__c); // quoitem.pageObject.SFDA_Status__c = quoitem.SFDA_Status__c; quoitem.pageObject.Name__c = quoitem.Name__c; quoitem.pageObject.Subtotal__c = localParseFloat(quoitem.Subtotal__c); quoitem.Subtotal__c = localParseFloat(quoitem.Subtotal__c); quoitem.Cost_Subtotal_c = localParseFloat(quoitem.Cost_Subtotal_c); }); quoLineItemsave = quoitemList; return quo; } export function jzProductsearchLogic(result){ debugger var jzProductData =[...[],...result]; jzProductData.forEach(izpd=>{ izpd.Asset_Model_No__c = izpd.Product2.Asset_Model_No__c; izpd.OT_CODE_no_link__c = izpd.Product2.OT_CODE_no_link__c; izpd.Name = izpd.Product2.Name; izpd.suitDepartment__c = izpd.Product2.suitDepartment__c; izpd.Alternative_Products__c = izpd.Product2.Alternative_Products__c; izpd.SFDA_Status__c = izpd.Product2.SFDA_Status__c; izpd.SFDA_Status__c = SFDAtranslate(izpd.SFDA_Status__c); izpd.Intra_Trade_List_RMB__c = izpd.Product2.Intra_Trade_List_RMB__c; izpd.Foreign_Trade_List_US__c = izpd.Product2.Foreign_Trade_List_US__c; izpd.Packing_list_manual__c = izpd.Product2.Packing_list_manual__c; }); return jzProductData; } export function additionaljzProductLogic(selectvlue,Listvalue,tradec,IsQuoteTrial){ IsQuoteTrialExp = IsQuoteTrial; debugger var LineNoList = []; Listvalue.forEach(lsv=>{ lsv.lineNo = localParseInt(lsv.lineNo); if(lsv.lineNo){ LineNoList.push(lsv.lineNo); } }); var maxLineNo = FindMaximumMalue(LineNoList); maxLineNo += 1; // var newvalueList = []; selectvlue.forEach(selectv=>{ debugger alertExp = ''; // var newvalue = {...{},...selectv}; // var Intra_Trade_Gurantee_RMB = selectv.Product2.Intra_Trade_Gurantee_RMB__c; // var GuranteeType = selectv.Product2.GuranteeType__c; //是否登录报价 if(selectv.Product2.Estimation_Entry_Possibility__c=='×' ){ var Estimation_Entry_Possibility = true; }else{ var Estimation_Entry_Possibility = false; } //内贸成本 if(selectv.Product2.Intra_Trade_Cost_RMB__c > 0 ){ var CostFlag= false; }else{ var CostFlag = true; } //内外贸 trade = tradec; //内贸报价金额 var Intra_Trade_List_RMB__c = selectv.Product2.Intra_Trade_List_RMB__c; //外贸报价金额 var Foreign_Trade_List_US__c = selectv.Product2.Foreign_Trade_List_US__c; //外贸成本 var Foreign_Trade_Cost_US__c = selectv.Product2.Foreign_Trade_Cost_US__c; //外贸多年保 取产品主数据上的金额以及报价 精琢技术 wql start // var Intra_Trade_Gurantee_USD = selectv.Product2.Intra_Trade_Foreign_RMB__c; // var Intra_Trade_Service_USD = selectv.Product2.NoDiscount_Foreign__c; // var Maintenance_Price_Year_USD = selectv.Product2.Repair_Contract_USD__c; if(trade == "CNY") { if(Estimation_Entry_Possibility){ alertExp = '产品未登录报价时不可报价!'; }else if(CostFlag){ alertExp = '产品的成本为空时不可报价!'; }else if(!Intra_Trade_List_RMB__c||Intra_Trade_List_RMB__c<0){ alertExp = '产品的报价金额为空时不可报价!'; }else{ SetProductId(maxLineNo, selectv); } //外贸 }else if(trade == "USD"){ if(Estimation_Entry_Possibility){ alertExp = '产品未登录报价时不可报价!'; } else if(!Foreign_Trade_List_US__c||Foreign_Trade_List_US__c<0 ){ alertExp = '产品的报价金额为空时不可报价!'; }else if(!Foreign_Trade_Cost_US__c||Foreign_Trade_Cost_US__c<0){ alertExp = '产品的成本为空时不可报价!'; }else{ SetProductId(maxLineNo, selectv); } } maxLineNo++; }); Listvalue = Listvalue.concat(addproductList); addproductList = [] return Listvalue; } export function FindMaximumMalue(value){ if(value.length!=0){ var max = getMaximin(value,"max"); }else{ var max = 0; } return max; } function getMaximin(arr,maximin) { if(maximin=="max") { return Math.max.apply(Math,arr); } else if(maximin=="min") { return Math.min.apply(Math, arr); } } function SetProductId(lineno,selectv){ var Product2 = {}; var PricebookEntry = {Product2:Product2}; var latestInfo = {}; var pageObject = {}; var addobj = {PricebookEntry:PricebookEntry, latestInfo:latestInfo, pageObject:pageObject}; var Asset_Model_No__c = selectv.Product2.Asset_Model_No__c; var Product2Id = selectv.Product2Id; var SFDA_Status__c = selectv.Product2.SFDA_Status__c var SFDA_Status = selectv.Product2.SFDA_Status__c; var Estimated_ConsumptionDueDate__c = selectv.Product2.Estimated_ConsumptionDueDate__c; var name = selectv.Product2.Name; var Intra_Trade_List_RMB__c = selectv.Product2.Intra_Trade_List_RMB__c; var Foreign_Trade_List_US__c = selectv.Product2.Foreign_Trade_List_US__c; var NameCode = selectv.Product2.ProductCode; var Sales_Possibility = selectv.Product2.Sales_Possibility__c; var Intra_Trade_Cost_RMB__c = selectv.Product2.Intra_Trade_Cost_RMB__c; var Foreign_Trade_Cost_US__c = selectv.Product2.Foreign_Trade_Cost_US__c; var Packing_list_manual__c = selectv.Product2.Packing_list_manual__c; var Bsscategory = selectv.Product2.BSSCategory__c; var PricebookEntryId = selectv.Id; var StorageStatus__c = selectv.Product2.StorageStatus__c; var Intra_Trade_Gurantee_USD = selectv.Product2.Intra_Trade_Foreign_RMB__c; var Intra_Trade_Service_USD = selectv.Product2.NoDiscount_Foreign__c; var Maintenance_Price_Year_USD = selectv.Product2.Repair_Contract_USD__c; addobj.PricebookEntry.Product2.StorageStatus__c = StorageStatus__c; addobj.StorageStatus = StorageStatus__c; addobj.lineNo = parseInt(lineno); addobj.Asset_Model = Asset_Model_No__c; addobj.SFDA_Status__c = SFDA_Status__c; addobj.SFDA_Status__c = SFDAtranslate(addobj.SFDA_Status__c); addobj.Estimated_ConsumptionDueDate = Estimated_ConsumptionDueDate__c; addobj.Estimated_ConsumptionDueDate1 = Estimated_ConsumptionDueDate__c; addobj.pageObject.SFDA_Status__c = SFDA_Status; addobj.latestInfo.Specifications = Packing_list_manual__c; addobj.Specifications = Packing_list_manual__c; addobj.Name = '/'+Product2Id; addobj.Name__c = name; addobj.pageObject.Name__c = name; var ListPrice = 0; var Cost_c = 0; // var Extend_new_product_gurantee = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Extend_new_product_gurantee__c")).val(); // var Extend_new_product_gurantee_MD = j$(escapeVfId("Page:mainForm:idSearchSetProduct:idRezultVisitor:"+ i +":Extend_new_product_gurantee_MD__c")).val(); var GuranteeType = selectv.Product2.GuranteeType__c; var Entend_gurantee_period_all = selectv.Product2.Entend_gurantee_period_all__c; var Intra_Trade_Gurantee_RMB = selectv.Product2.Intra_Trade_Gurantee_RMB__c; var Intra_Trade_Service_RMB = selectv.Product2.Intra_Trade_Service_RMB__c; var Maintenance_Price_Year = selectv.Product2.Maintenance_Price_Year__c; if(selectv.Product2.VenderName__c==null||selectv.Product2.VenderName__c==null){ var VenderName =' 无 '; }else{ var VenderName = selectv.Product2.VenderName__c; } var CanNotCancelledGurantee = selectv.Product2.CanNotCancelledGurantee__c; var Is_DangerousChemicals = selectv.Product2.Is_DangerousChemicals__c; var ProductGuranteePrice = 0; var ProductServicePrice = 0; var productMaintenance_Price_Year = 0; if(trade == "CNY") { ProductGuranteePrice = Intra_Trade_Gurantee_RMB; ProductServicePrice = Intra_Trade_Service_RMB; productMaintenance_Price_Year = Maintenance_Price_Year; ListPrice = Intra_Trade_List_RMB__c; Cost_c = Intra_Trade_Cost_RMB__c; } else if(trade == "USD"){ ProductGuranteePrice = Intra_Trade_Gurantee_USD; ProductServicePrice = Intra_Trade_Service_USD; productMaintenance_Price_Year = Maintenance_Price_Year_USD; ListPrice = Foreign_Trade_List_US__c; Cost_c = Foreign_Trade_Cost_US__c; } Cost_c = toNum(Cost_c); // ListPrice = toNum(ListPrice); // addobj.ListPrice_Page = toNumComma(ListPrice); addobj.ListPrice_Page = ListPrice; addobj.pageObject.ListPrice_Page = ListPrice; addobj.Quantity__c = 1; // addobj.UnitPrice_Page__c = toNumComma(ListPrice); addobj.UnitPrice_Page__c = ListPrice; // addobj.Subtotal__c = toNumComma(ListPrice); addobj.Subtotal__c = ListPrice; addobj.pageObject.Subtotal__c = ListPrice; addobj.latestInfo.ProductCode = NameCode; addobj.latestInfo.ProductName = name; addobj = MarkRedFLG(addobj,Estimated_ConsumptionDueDate__c); addobj.latestInfo.SFDA_Status = SFDA_Status__c; addobj.latestInfo.Sales_Possibility = Sales_Possibility; addobj.latestInfo.ListPrice = ListPrice; addobj.latestInfo.Cost = Cost_c; addobj.Cost_c = Cost_c; addobj.Cost_Subtotal_c = Cost_c; addobj.pageObject.BSS_Category__c = Bsscategory; addobj.pageObject.Id__c = Product2Id; addobj.pageObject.PricebookEntryId = PricebookEntryId; addobj.pageObject.ProductEntend_gurantee_period_all__c = Entend_gurantee_period_all; addobj.Maintenance_Price_Year = productMaintenance_Price_Year; addobj.latestInfo.Maintenance_Price_Year = productMaintenance_Price_Year; addobj.pageObject.GuranteeType__c = GuranteeType; addobj.VenderName = VenderName; addobj.CanNotCancelledGurantee = CanNotCancelledGurantee; addobj.Is_DangerousChemicals = Is_DangerousChemicals; addobj.ProductGuranteePrice = ProductGuranteePrice; addobj.pageObject.productServicePrice__c = ProductServicePrice; //chenjingwu DB202308355043 2023.8.25 start addobj.Category5 = selectv.Product2.Category5__c; //chenjingwu DB202308355043 2023.8.25 end addproductList.push(addobj); // if(VenderName != 'OSH'&&VenderName != ''){ // window.opener.j$(escapeVfId('Page:mainForm:block:lists:'+lineno+':UnitPrice')).attr('disabled','disabled'); // } IsQuoteTrialExp = false; } function MarkRedFLG(addobj,Estimated_ConsumptionDueDate__c){ var date1 = new Date(); var seperator = "/"; var year = date1.getFullYear(); var month = date1.getMonth() + 1; var day = date1.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (day >= 0 && day <= 9) { day = "0" + day; } var currentdate = year + seperator + month + seperator + day; //预计消耗到期日 - 当前日 相差天数(difDate) var ndate = new Date(currentdate); var nowDate = ndate.getTime(); var edate = new Date(Estimated_ConsumptionDueDate__c); var endDate = edate.getTime(); var difDate = (endDate - nowDate)/((1000 * 60 * 60 * 24)); //判断 if(difDate < 90){ addobj.EstimatedConsumptionDueDateclass = 'slds-text-color_error slds-text-title_caps'; } return addobj; } export function MarkRed(quoitemList) { quoitemList.forEach(item=>{ var a = item.Asset_Model; var b = item.Estimated_ConsumptionDueDate; if (a != '') { var date1 = new Date(); var seperator = "/"; var year = date1.getFullYear(); var month = date1.getMonth() + 1; var day = date1.getDate(); if (month >= 1 && month <= 9) { month = "0" + month; } if (day >= 0 && day <= 9) { day = "0" + day; } var currentdate = year + seperator + month + seperator + day; //预计消耗到期日 - 当前日 相差天数(difDate) var ndate = new Date(currentdate); var nowDate = ndate.getTime(); var edate = new Date(b); var endDate = edate.getTime(); var difDate = (endDate - nowDate) / ((1000 * 60 * 60 * 24)); //判断 if (difDate < 90) { item.EstimatedConsumptionDueDateclass = 'slds-text-color_error slds-text-title_caps'; }else{ item.EstimatedConsumptionDueDateclass = ''; } } }); return quoitemList; } export function filterNameoptionList(){ var optionList = [{label:'--无--',value: ''}, {label:'消化科',value: '消化科'}, {label:'呼吸科',value: '呼吸科'}, {label:'普外科',value: '普外科'}, {label:'泌尿科',value: '泌尿科'}, {label:'妇科',value: '妇科'}, {label:'耳鼻喉科',value: '耳鼻喉科'}, {label:'能量',value: '能量'}, {label:'SI',value: 'SI'}, {label:'外科通用',value: '外科通用'}]; return optionList; } export function SelectDone(activities){ debugger var setPFString = ''; activities.forEach(arc=>{ if(!setPFString){ setPFString = arc.Id; }else{ setPFString = setPFString+','+arc.Id; } }); DataStatus = 'Fin'; return setPFString; } //初始化产品赋值 export function InitializeProductAssignment(quoteLineItem){ debugger console.warn(JSON.stringify(quoteLineItem)); quoteLineItem.forEach(quotltiem=>{ quotltiem.Quantity__c = quotltiem.pageObject.Quantity__c; quotltiem.UnitPrice_Page__c = quotltiem.pageObject.UnitPrice_Page__c; // quotltiem.UnitPrice_Page__c = toNumComma(quotltiem.UnitPrice_Page__c); quotltiem.AgencySubtotal__c = quotltiem.pageObject.AgencySubtotal__c; quotltiem.AgencyUnitPrice__c = quotltiem.pageObject.AgencyUnitPrice__c; // quotltiem.ListPrice_Page = toNumComma(quotltiem.ListPrice_Page); quotltiem.multiYearWarranty__c = quotltiem.pageObject.multiYearWarranty__c; quotltiem.GuaranteePeriod__c = quotltiem.pageObject.GuaranteePeriod__c; quotltiem.warrantyType__c = quotltiem.pageObject.warrantyType__c; quotltiem.NoDiscountTotal__c = quotltiem.pageObject.NoDiscountTotal__c; quotltiem.SFDA_Status__c = quotltiem.pageObject.SFDA_Status__c; quotltiem.SFDA_Status__c = SFDAtranslate(quotltiem.SFDA_Status__c); quotltiem.Name__c = quotltiem.pageObject.Name__c; quotltiem.Subtotal__c = quotltiem.pageObject.Subtotal__c; // quotltiem.Subtotal__c = toNumComma(quotltiem.Subtotal__c); quotltiem.Name = '/'+quotltiem.pageObject.Id__c; if((!(!quotltiem.pageObject.Product_Sales_Possibility__c || quotltiem.pageObject.Product_Sales_Possibility__c == '○') && !quotltiem.changed_sfda)){ quotltiem.SFDAStatuclass = 'slds-text-color_error slds-text-title_caps'; } if(quotltiem.haveno_Register){ quotltiem.SFDAStatuclass = 'slds-text-color_error slds-text-title_caps'; } if(quotltiem.changed_list){ quotltiem.ListPricePageclass = 'slds-text-color_error slds-text-title_caps'; } if(quotltiem.changed_name == true || quotltiem.wrong_Register == true){ quotltiem.Nameclass = 'slds-text-color_red'; } //产品Id }); const inputAlignright = document.createElement('style'); inputAlignright .innerText = `.slds-text-color_red a{ color:#ba0517;!important; }`; document.body.appendChild(inputAlignright); quoteLineItem = MarkRed(quoteLineItem); return quoteLineItem; } export function actState(reslut,list){ var reslutList = JSON.parse(reslut); var reMap = new Map(); reslutList.forEach(itm=>{ var val = { haveno_Register:itm.haveno_Register, wrong_Register:itm.wrong_Register }; reMap.set(itm.pageObject.Id__c,val); }); list.forEach(ac=>{ if(reMap.has(ac.pageObject.Id__c)){ var vlu = reMap.get(ac.pageObject.Id__c); ac.haveno_Register = vlu.haveno_Register; ac.wrong_Register = vlu.wrong_Register; } if((!(!ac.pageObject.Product_Sales_Possibility__c || ac.pageObject.Product_Sales_Possibility__c == '○') && !ac.changed_sfda)){ ac.SFDAStatuclass = 'slds-text-color_error slds-text-title_caps'; } if(ac.haveno_Register){ ac.SFDAStatuclass = 'slds-text-color_error slds-text-title_caps'; } if(ac.changed_list){ ac.ListPricePageclass = 'slds-text-color_error slds-text-title_caps'; } if(ac.changed_name == true || ac.wrong_Register == true){ ac.Nameclass = 'slds-text-color_red'; } }); const inputAlignright = document.createElement('style'); inputAlignright .innerText = `.slds-text-color_red a{ color:#ba0517;!important; }`; document.body.appendChild(inputAlignright); return list; } export function PriceStatusUpdateLogic(jzDataToBeproduct,newQuoteFlag){ newQuoteFlagex = newQuoteFlag; jzDataToBeproduct.forEach(jzdtbt=>{ debugger if ((jzdtbt.Asset_Model != null) && (jzdtbt.Asset_Model != '')&& (jzdtbt.Asset_Model.length>0)) { // 只要更新,就生成新报价编码 jzdtbt.ListPrice_Page = localParseFloat(jzdtbt.ListPrice_Page); if (jzdtbt.pageObject.SFDA_Status__c != jzdtbt.latestInfo.SFDA_Status || jzdtbt.pageObject.Name__c != jzdtbt.latestInfo.ProductName || jzdtbt.ListPrice_Page != jzdtbt.latestInfo.ListPrice || jzdtbt.pageObject.Cost__c != jzdtbt.latestInfo.Cost || jzdtbt.Cost_c != jzdtbt.latestInfo.Cost //计提金额 || jzdtbt.ProductGuranteePrice != jzdtbt.latestInfo.Intra_Trade_Gurantee || jzdtbt.pageObject.productServicePrice__c != jzdtbt.latestInfo.Intra_Trade_Service // 维修合同报价 || jzdtbt.Maintenance_Price_Year != jzdtbt.latestInfo.Maintenance_Price_Year ) { newQuoteFlagex = true; } if (jzdtbt.pageObject.Name__c != jzdtbt.latestInfo.ProductName) { jzdtbt.changed_name = true; } if (jzdtbt.pageObject.SFDA_Status__c != jzdtbt.latestInfo.SFDA_Status) { jzdtbt.changed_sfda = true; } if (jzdtbt.ListPrice_Page != jzdtbt.latestInfo.ListPrice) { jzdtbt.changed_list = true; } if (jzdtbt.pageObject.Cost__c != jzdtbt.latestInfo.Cost) { jzdtbt.changed_cost = true; } // TODO katsu SFDAステータスの確認などいらないですか(最新商品XXXの項目も) jzdtbt.pageObject.SFDA_Status__c = jzdtbt.latestInfo.SFDA_Status; jzdtbt.SFDA_Status__c = jzdtbt.pageObject.SFDA_Status__c; jzdtbt.pageObject.Name__c = jzdtbt.latestInfo.ProductName; jzdtbt.Name__c = jzdtbt.pageObject.Name__c; jzdtbt.ListPrice_Page = jzdtbt.latestInfo.ListPrice; jzdtbt.pageObject.Cost__c = jzdtbt.latestInfo.Cost; jzdtbt.Cost_c = jzdtbt.latestInfo.Cost; jzdtbt.pageObject.ProductGuranteePrice__c = jzdtbt.latestInfo.Intra_Trade_Gurantee; jzdtbt.pageObject.GuranteeType__c = jzdtbt.latestInfo.GuranteeType; // 计提金额 jzdtbt.pageObject.productServicePrice__c = jzdtbt.latestInfo.Intra_Trade_Service; // 多年保修年限 jzdtbt.pageObject.ProductEntend_gurantee_period_all__c = jzdtbt.latestInfo.ProductEntend_gurantee_period_all; // 维修合同报价 jzdtbt.Maintenance_Price_Year = jzdtbt.latestInfo.Maintenance_Price_Year; // jzdtbt.ListPrice_Page = toNumComma(jzdtbt.ListPrice_Page); jzdtbt.ListPrice_Page = jzdtbt.ListPrice_Page; } }); return jzDataToBeproduct; } export function calGuranteeAllFieldsLogic(jzDataToBeproduct,quo){ debugger var AllGurantee_Period = quo.Gurantee_Period__c; var contractmultiYearWarranty = true; if (quo.multiYearWarranty__c != null) { contractmultiYearWarranty = quo.multiYearWarranty__c; } var MultiYearWarrantyTotalPrice__c = 0.00; jzDataToBeproduct.forEach(jzdtbt=>{ var GuranteeType =jzdtbt.pageObject.GuranteeType__c; // 保修类型 var warrantyType = ''; // 产品保修期 var ProductEntend_gurantee_period = jzdtbt.pageObject.ProductEntend_gurantee_period_all__c; // 产品计提金额 var ProductGuranteePrice__c = jzdtbt.ProductGuranteePrice; // 产品 service Price var ServicePrice = jzdtbt.pageObject.productServicePrice__c; // 保修 var multiYearWarranty = false; // 是否取消保修 var If_Cancel_Guarantee = false; //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql start var CanNotCancelledGurantee = jzdtbt.CanNotCancelledGurantee; //产品主数据增加“不可取消多年保” 2020/08/28 精琢技术 wql end // 老 no discount price var oldServicePrice =jzdtbt.pageObject.ServicePrice__c; jzdtbt.pageObject.ServicePrice__c = 0; jzdtbt.warrantyType__c = ''; var NoDiscountTotal = 0; if (GuranteeType == '服务') { multiYearWarranty = true; jzdtbt.warrantyType__c = '服务多年保修'; warrantyType = '服务多年保修'; } else if (GuranteeType == '市场' && contractmultiYearWarranty == false) { multiYearWarranty = true; jzdtbt.pageObject.ServicePrice__c = ServicePrice; jzdtbt.warrantyType__c = '市场多年保修'; warrantyType = '市场多年保修'; var Quantity =jzdtbt.Quantity__c; MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c + localParseFloat(ServicePrice) * localParseFloat(Quantity); NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity); } else if (GuranteeType == '市场' && contractmultiYearWarranty && CanNotCancelledGurantee) { multiYearWarranty = true; jzdtbt.pageObject.ServicePrice__c = ServicePrice; jzdtbt.warrantyType__c = '市场多年保修'; warrantyType = '市场多年保修'; // 数量 var Quantity = jzdtbt.Quantity__c; MultiYearWarrantyTotalPrice__c = MultiYearWarrantyTotalPrice__c + localParseFloat(ServicePrice) * localParseFloat(Quantity); NoDiscountTotal = localParseFloat(ServicePrice) * localParseFloat(Quantity); } else if (GuranteeType == '市场') { If_Cancel_Guarantee = true; } // if (jzdtbt.NoDiscountTotal__c != null) { jzdtbt.NoDiscountTotal__c = toNumComma(NoDiscountTotal); // } // 更新后的 no discount price var newServicePrice = jzdtbt.pageObject.ServicePrice__c; newServicePrice = localParseFloat(newServicePrice); oldServicePrice = localParseFloat(oldServicePrice); if (newServicePrice != oldServicePrice) { var unitPrice = jzdtbt.UnitPrice_Page__c; unitPrice = localParseFloat(unitPrice); // jzdtbt.UnitPrice_Page__c = toNum(unitPrice + newServicePrice - oldServicePrice); jzdtbt.UnitPrice_Page__c = unitPrice + newServicePrice - oldServicePrice; } jzdtbt.pageObject.If_Cancel_Guarantee__c = If_Cancel_Guarantee; // 设置保修 // if (jzdtbt.multiYearWarranty__c != null) { jzdtbt.multiYearWarranty__c = multiYearWarranty; // } var GuranteePrice = 0; // 计提年限 var provistonPeriod = 0; // 根据产品信息设置保修年限 和计提金额 if (GuranteeType == '服务') { jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; jzdtbt.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; GuranteePrice = ProductGuranteePrice__c; jzdtbt.GuranteePrice = GuranteePrice; provistonPeriod = ProductEntend_gurantee_period; } else if (GuranteeType == '市场') { if (contractmultiYearWarranty == false) { if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) { jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; jzdtbt.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; } else { jzdtbt.pageObject.GuaranteePeriod__c = AllGurantee_Period; jzdtbt.GuaranteePeriod__c = AllGurantee_Period; } provistonPeriod = ProductEntend_gurantee_period; GuranteePrice = ProductGuranteePrice__c; jzdtbt.GuranteePrice = GuranteePrice; }else if (contractmultiYearWarranty && CanNotCancelledGurantee) { if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) { jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; jzdtbt.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; } else { jzdtbt.pageObject.GuaranteePeriod__c = AllGurantee_Period; jzdtbt.GuaranteePeriod__c = AllGurantee_Period; } provistonPeriod = ProductEntend_gurantee_period; GuranteePrice = ProductGuranteePrice__c; jzdtbt.GuranteePrice = GuranteePrice; } else { jzdtbt.pageObject.GuaranteePeriod__c = 1; jzdtbt.GuaranteePeriod__c = 1; jzdtbt.GuranteePrice = GuranteePrice; } } else { jzdtbt.pageObject.GuaranteePeriod__c = AllGurantee_Period; jzdtbt.GuaranteePeriod__c = AllGurantee_Period; jzdtbt.GuranteePrice = GuranteePrice; } jzdtbt.pageObject.provistonPeriod__c = provistonPeriod | 0; }); MultiYearWarrantyTotalPriceExport = MultiYearWarrantyTotalPrice__c; return jzDataToBeproduct; } export function initQuoteLineItemcheck(quoteLineItem,productStatusUpdated){ debugger newQuoteFlagExp = false; productStatusUpdatedExp = productStatusUpdated; quoteLineItem.forEach(a=>{ if(!a.Maintenance_Price_Year){ a.Maintenance_Price_Year = 0; } if(!a.latestInfo.Maintenance_Price_Year){ a.latestInfo.Maintenance_Price_Year = 0; } if(!a.pageObject.GuranteeType__c){ a.pageObject.GuranteeType__c = ''; } if(!a.latestInfo.GuranteeType){ a.latestInfo.GuranteeType = ''; } if (a.Asset_Model) { if(a.pageObject.SFDA_Status__c != a.latestInfo.SFDA_Status ||a.pageObject.Name__c != a.latestInfo.ProductName ||a.ListPrice_Page != a.latestInfo.ListPrice ||a.pageObject.Cost__c != a.latestInfo.Cost ||a.Cost_c != a.latestInfo.Cost ||a.ProductGuranteePrice != a.latestInfo.Intra_Trade_Gurantee ||a.pageObject.productServicePrice__c != a.latestInfo.Intra_Trade_Service ||a.Maintenance_Price_Year != a.latestInfo.Maintenance_Price_Year ||a.pageObject.GuranteeType__c != a.latestInfo.GuranteeType ||a.pageObject.ProductEntend_gurantee_period_all__c != a.latestInfo.ProductEntend_gurantee_period_all ||a.pageObject.PricebookEntry.Product2.CanNotCancelledGurantee__c != a.latestInfo.CanNotCancelledGurantee ) { newQuoteFlagExp = true; productStatusUpdatedExp = true; } if (a.pageObject.Name__c != a.latestInfo.ProductName) { a.changed_name = true; productStatusUpdatedExp = true; } if (a.pageObject.SFDA_Status__c != a.latestInfo.SFDA_Status) { a.changed_sfda = true; productStatusUpdatedExp = true; } if (a.ListPrice_Page != a.latestInfo.ListPrice) { a.changed_list = true; productStatusUpdatedExp = true; } if (a.pageObject.Cost__c != a.latestInfo.Cost) { a.changed_cost = true; productStatusUpdatedExp = true; } a.pageObject.SFDA_Status__c = a.latestInfo.SFDA_Status; a.pageObject.Name__c = a.latestInfo.ProductName; a.ListPrice_Page = a.latestInfo.ListPrice; a.pageObject.Cost__c = a.latestInfo.Cost; a.Cost_c = a.latestInfo.Cost; a.ProductGuranteePrice = a.latestInfo.Intra_Trade_Gurantee; a.pageObject.productServicePrice__c = a.latestInfo.Intra_Trade_Service; a.Maintenance_Price_Year = a.latestInfo.Maintenance_Price_Year; a.pageObject.ProductEntend_gurantee_period_all__c= a.latestInfo.ProductEntend_gurantee_period_all; a.pageObject.GuranteeType__c = a.latestInfo.GuranteeType; } }); return quoteLineItem; } //加天数 export function addDay(dayNumber, date) { var ms = dayNumber * (1000 * 60 * 60 * 24) var newDate = new Date(date.getTime() + ms); return newDate; } //计算两个日期之间的天数 export function dateDaysBetween(dateStrBegin, dateStrEnd) { if (!dateStrBegin || !dateStrEnd) return 0; var s1 = dateStrBegin.getTime(), s2 = dateStrEnd.getTime(); var total = (s2 - s1) / 1000; var day = parseInt(total / (24 * 60 * 60)); return day; } /* 计算经销商单价和经销商小计 */ // quoteAgencyTotalPriceAction1 // CHAN-B4YAB8 2018/9/28 计算经销商单价和小计 start // 如果是OCSM直销,则更改医院合同价格时会计算经销商单价和小计 // 如果是 经销商销售,则更改 第一经销商总价是会计算经销商单价和小计 export function quoteAgencyTotalPriceActionLogic(jzDataToBeproduct,quo,oppInfo,QuoteDecision_Button,hidden_MultiYearWarrantyTotalPrice){ debugger var s,l; var SalesAmount1 = quo.OCM_Agent1_Price_Page__c; var Estimation_List_Price = 0; var thirdPartyEstimation_List_Price = 0; jzDataToBeproduct.forEach(jzdtbt=>{ // 供应商名称 var VenderName = jzdtbt.VenderName; s = jzdtbt.Quantity__c; s = localParseInt(s); l = jzdtbt.ListPrice_Page; l = localParseInt(l); var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } if (VenderName == '' || VenderName == 'OSH') { Estimation_List_Price = Estimation_List_Price + s * l; } else { thirdPartyEstimation_List_Price = thirdPartyEstimation_List_Price + s * l; } }); // 医院的合同金额 var Dealer_Final_Price = quo.Dealer_Final_Price_Page__c; // 销售渠道 var Sales_Root = oppInfo.Sales_Root__c; var TotalPrice = 0; var StardardPrice = 0; var totalAgencyPrice = 0; var AgencySubtotal = 0; var LastAgencySubtotal = 0; var j = 0; var i = -1; var lastQuantity = 0; Sales_Root = Sales_Root + ''; Sales_Root = Sales_Root.replace(/\s+/g, ""); if (Sales_Root == '经销商') { TotalPrice = SalesAmount1; } else { TotalPrice = Dealer_Final_Price; } TotalPrice = localParseFloat(TotalPrice); var oldTotalPrice = TotalPrice; totalAgencyPrice = TotalPrice; //no discount price 合计 var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice; noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal); TotalPrice = TotalPrice - noDiscountPriceTotal; jzDataToBeproduct.forEach(jzdtbt=>{ s = jzdtbt.Quantity__c; s = localParseInt(s); l = jzdtbt.ListPrice_Page; l = localParseInt(l); if ((s == 0) || (l == 0)) { //処理なし } else if (oldTotalPrice == 0) { jzdtbt.pageObject.AgencySubtotal__c = 0; jzdtbt.AgencySubtotal__c = toNumComma_One_digit(0); jzdtbt.AgencyUnitPrice__c = toNumComma_One_digit(0); } else { StardardPrice = s * l; StardardPrice = localParseFloat(StardardPrice); // 供应商名称 var VenderName = jzdtbt.VenderName; //行项目 no discount price: var noDiscountPrice = jzdtbt.pageObject.ServicePrice__c; noDiscountPrice = localParseFloat(noDiscountPrice); var Agency_UnitPrice = (l).toFixed(1); var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } if (VenderName == '' || VenderName == 'OSH') { var Agency_UnitPrice = (StardardPrice * (TotalPrice - thirdPartyEstimation_List_Price) / (Estimation_List_Price * s) + noDiscountPrice ).toFixed(1); } AgencySubtotal = Agency_UnitPrice * s; jzdtbt.pageObject.AgencySubtotal__c = AgencySubtotal; jzdtbt.AgencySubtotal__c = toNumComma_One_digit(AgencySubtotal); jzdtbt.AgencyUnitPrice__c = toNumComma_One_digit(Agency_UnitPrice); totalAgencyPrice = totalAgencyPrice - toNum(AgencySubtotal); i++; j=i; lastQuantity = s; LastAgencySubtotal = AgencySubtotal; } }); if (oldTotalPrice != 0){ LastAgencySubtotal = LastAgencySubtotal + totalAgencyPrice; if(jzDataToBeproduct.length>0){ jzDataToBeproduct[j].pageObject.AgencySubtotal__c = toNum(LastAgencySubtotal); jzDataToBeproduct[j].AgencySubtotal__c = toNumComma_One_digit(LastAgencySubtotal); jzDataToBeproduct[j].AgencyUnitPrice__c = toNumComma_One_digit(LastAgencySubtotal / lastQuantity); } } return jzDataToBeproduct; } //根据行项目上产品的信息 更新多年保修行项目所有字段, 并且更新No Discount Price合计 export function calPriceAllLogic(jzDataToBeproduct){ var x, y, z, c; jzDataToBeproduct.forEach(jzdtbt=>{ x = jzdtbt.Quantity__c; x = localParseInt(x); if (x > 0) { y = jzdtbt.UnitPrice_Page__c; c = jzdtbt.Cost_c; y = localParseFloat(y); c = localParseFloat(c); z = x * y; // jzdtbt.Subtotal__c = toNumComma(z); jzdtbt.Subtotal__c = z; jzdtbt.pageObject.Subtotal__c = toNum(z); z = x * c; jzdtbt.Cost_Subtotal_c = toNum(z); } }); return jzDataToBeproduct; } export function QuoteAdjustLogic(jzDataToBeproduct,quo,hidden_MultiYearWarrantyTotalPrice,QuoteDecision_Button){ debugger var x = quo.QuoteTotal_Page__c; x = localParseFloat(x); var y = quo.hidden_Estimation_List; y = localParseFloat(y); var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice; noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal); var thirdPartyEstimation_List_Price = 0; var price = 0; var Quantity = 0; jzDataToBeproduct.forEach(jzdtbt=>{ var VenderName = jzdtbt.VenderName; var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } if (VenderName != '' && VenderName != 'OSH') { price = jzdtbt.ListPrice_Page; price = localParseFloat(price); Quantity = jzdtbt.Quantity__c; Quantity = localParseInt(Quantity); thirdPartyEstimation_List_Price = thirdPartyEstimation_List_Price + price * Quantity; } }); thirdPartyEstimation_List_Price = localParseFloat(thirdPartyEstimation_List_Price); quo.Quote_Adjust_Amount_Page__c = toNumComma(x - noDiscountPriceTotal - y); if (y - thirdPartyEstimation_List_Price == 0) { quo.Quote_Adjust_Calculate__c = toNumComma(0); } else { quo.Quote_Adjust_Calculate__c = toNumComma((x - noDiscountPriceTotal - y) / (y - thirdPartyEstimation_List_Price) * 100); } quoExp = quo; return jzDataToBeproduct; } export function AgencyDiscountCalculation1Logic(quo,jzDataToBeproduct,QuoteDecision_Button,hidden_MultiYearWarrantyTotalPrice){ var y = quo.OCM_Agent1_Price_Page__c; if (y != '' && y.length != 0) { var Estimation_List_Price = quo.Estimation_List_Price__c; y = y + ''; y = y.replace(/ /g, ""); if (Estimation_List_Price.length != 0) { y = localParseFloat(y); Estimation_List_Price = localParseFloat(Estimation_List_Price); // 第三方产品标准定价总额 var thirdPartyEstimation_List_Price = 0; var price = 0; var Quantity = 0; jzDataToBeproduct.forEach(jzdtbt=>{ var VenderName = jzdtbt.VenderName; var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } if (VenderName != '' && VenderName != 'OSH') { price = jzdtbt.ListPrice_Page; price = localParseFloat(price); Quantity = jzdtbt.Quantity__c; Quantity = localParseInt(Quantity); thirdPartyEstimation_List_Price = thirdPartyEstimation_List_Price + price * Quantity; } }); thirdPartyEstimation_List_Price = localParseFloat(thirdPartyEstimation_List_Price); if (Estimation_List_Price - thirdPartyEstimation_List_Price == 0) { quo.AgencyDiscount__c = toNumComma(0); // j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(0)); } else { //no discount price 合计 var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice; noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal); var t = (y - noDiscountPriceTotal - thirdPartyEstimation_List_Price) / (Estimation_List_Price - thirdPartyEstimation_List_Price) * 100; quo.AgencyDiscount__c = toNumComma(t); // j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(t)); } } else { quo.AgencyDiscount__c = toNumComma(0); // j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(0)); } } else { quo.AgencyDiscount__c = toNumComma(0); // j$(escapeVfId('Page:mainForm:block:AgencyDiscount')).val(toNumComma(0)); } quoExp = quo; return jzDataToBeproduct; } //检查报价行的NMPA状态 export function checkNMPA(jzDataToBeproduct) { var cnt = 0; var nmpa; jzDataToBeproduct.forEach(jzdtbt=>{ nmpa = jzdtbt.SFDA_Status__c; if (nmpa == '停止') { cnt = cnt + 1; return; } }); if (cnt > 0) { return true; } else { return false; } } export function AlertAuthorize(oppInfo) { var Authorized_DB_No = oppInfo.Authorized_DB_No__c; var If_Need_Authorize = oppInfo.If_Need_Authorize__c; if (If_Need_Authorize) { if (Authorized_DB_No == null || Authorized_DB_No == '') { return false; } else { return true; } } else { return true; } } export function AlertForCFDA(jzDataToBeproduct) { var SFDA_Status__c, cnt; cnt = 0; jzDataToBeproduct.forEach(jzdtbt=>{ SFDA_Status__c = jzdtbt.SFDA_Status__c; if (SFDA_Status__c == '失效-重新申请中' || SFDA_Status__c == '失効(再申請中)') { cnt = cnt + 1; } }); if (cnt > 0) { return true; } else { return false; } } export function CheckForCost(jzDataToBeproduct) { var Cost, cnt, name; cnt = 0; jzDataToBeproduct.forEach(jzdtbt=>{ Cost = jzdtbt.Cost_c; name = jzdtbt.pageObject.Name__c; if (name && Cost <= 0) { cnt = cnt + 1; } }); if (cnt > 0) { return true; } else { return false; } } //检查是否有标准定价为0的情况 export function CheckForListPrice(jzDataToBeproduct) { var ListPrice, name; var cnt = 0; jzDataToBeproduct.forEach(jzdtbt=>{ ListPrice = jzdtbt.ListPrice_Page; ListPrice = localParseFloat(ListPrice); name = jzdtbt.pageObject.Name__c; if (name && ListPrice <= 0) { cnt = cnt + 1; } }); if (cnt > 0) { return true; } else { return false; } } export function SubtotalupdateLogic(jzDataToBeproduct){ debugger console.warn('Unit6'); var x, y, z; z = 0; jzDataToBeproduct.forEach(jzdtbt=>{ x = jzdtbt.Quantity__c; x = localParseInt(x); y = jzdtbt.UnitPrice_Page__c; y = localParseFloat(y); z = x * y; if (jzdtbt.UnitPrice_Page__c != "") { // jzdtbt.Subtotal__c = toNumComma(z); jzdtbt.Subtotal__c = z; jzdtbt.pageObject.Subtotal__c = toNum(z); } }); return jzDataToBeproduct; } export function quoteTotalPriceActionLogic(quo,jzDataToBeproduct,hidden_MultiYearWarrantyTotalPrice,QuoteDecision_Button){ var s = 0; var x = 0; var l = 0; // 非第三方产品标准定价总额 var y = 0; var yy = 0; // 非第三方产品报价总额 var z = quo.QuoteTotal_Page__c; // 产品报价总额 var zz = 0; z = localParseFloat(z); //no discount price 合计 var noDiscountPriceTotal = hidden_MultiYearWarrantyTotalPrice; noDiscountPriceTotal = localParseFloat(noDiscountPriceTotal); jzDataToBeproduct.forEach(jzdtbt=>{ s = jzdtbt.Quantity__c; s = localParseInt(s); l = jzdtbt.ListPrice_Page; l = localParseInt(l); x = s * l; // 供应商名称 var VenderName = jzdtbt.VenderName; var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } // OSH 计算标准定价总额 if (VenderName == 'OSH' || VenderName == '') { y = y + x; // 非OSH 将产品报价总额 减去 第三方产品 } else { z = z - x; } }); jzDataToBeproduct.forEach(jzdtbt=>{ //行项目 no discount price: var noDiscountPrice = jzdtbt.pageObject.ServicePrice__c; noDiscountPrice = localParseFloat(noDiscountPrice); // 供应商名称 var VenderName = jzdtbt.VenderName; s = jzdtbt.Quantity__c; s = localParseInt(s); l = jzdtbt.ListPrice_Page; l = localParseInt(l); // 行项目 标准定价小计 x = s * l; x = localParseFloat(x); if ((s == 0) || (x == 0)) { //不处理 } else { var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } if (VenderName == 'OSH' || VenderName == '') { yy = localParseFloat(x * (z - noDiscountPriceTotal) / y); jzdtbt.pageObject.Subtotal__c = toNum(yy + s * noDiscountPrice); // jzdtbt.Subtotal__c = toNumComma(yy + s * noDiscountPrice); jzdtbt.Subtotal__c = yy + s * noDiscountPrice; // jzdtbt.UnitPrice_Page__c = toNumComma(yy / s + noDiscountPrice); jzdtbt.UnitPrice_Page__c = yy / s + noDiscountPrice; } else { yy = localParseFloat(x); } zz = zz + yy; } }); quo.QuoteTotal_Page__c = toNumComma(zz + noDiscountPriceTotal); quoExp = quo; return jzDataToBeproduct; } //删除产品明细和待选产品 item是选中的产品明细对象 TypeName是选中的产品明细对对应的方案类型 export function UnitPriceUpdateLogic(quo,jzDataToBeproduct,QuoteDecision_Button){ debugger var num; num = quo.Quote_Adjust_Calculate__c; num = localParseFloat(num); quo.Quote_Adjust_Calculate__c = toNumComma(num); num = (100 + num) / 100; var price = 0; jzDataToBeproduct.forEach(jzdtbt=>{ var VenderName = jzdtbt.VenderName; price = jzdtbt.ListPrice_Page; price = localParseFloat(price); var noDiscountPrice = jzdtbt.pageObject.ServicePrice__c; noDiscountPrice = localParseFloat(noDiscountPrice); var backbutton = QuoteDecision_Button; if (backbutton == '') { VenderName = ''; } if (price != '' && VenderName == 'OSH') { // jzdtbt.UnitPrice_Page__c = toNumComma(price * num + noDiscountPrice); jzdtbt.UnitPrice_Page__c = price * num + noDiscountPrice; } else if (price != '' && VenderName == '') { // jzdtbt.UnitPrice_Page__c = toNumComma(price * num + noDiscountPrice); jzdtbt.UnitPrice_Page__c = price * num + noDiscountPrice; } }); quoExp = quo; return jzDataToBeproduct; } export function calGuranteePeriodLogic(jzDataToBeproduct,AllGurantee_Period){ jzDataToBeproduct.forEach(jzdtbt=>{ // 保修 var multiYearWarranty = true; if (jzdtbt.multiYearWarranty__c) { multiYearWarranty = jzdtbt.multiYearWarranty__c; } // 保修类型 var warrantyType = jzdtbt.warrantyType__c; // 产品保修类型 var GuranteeType = jzdtbt.pageObject.GuranteeType__c; // 产品保修期 var ProductEntend_gurantee_period = jzdtbt.pageObject.ProductEntend_gurantee_period_all__c; // 计提年限 var provistonPeriod = 0; // 根据产品信息设置保修年限 if (GuranteeType == '服务') { jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; jzdtbt.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; provistonPeriod = ProductEntend_gurantee_period; } else if (GuranteeType == '市场') { if (multiYearWarranty == true) { if (localParseFloat(ProductEntend_gurantee_period) >= localParseFloat(AllGurantee_Period)) { jzdtbt.pageObject.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; jzdtbt.GuaranteePeriod__c = ProductEntend_gurantee_period | 0; } else { jzdtbt.pageObject.GuaranteePeriod__c = AllGurantee_Period; jzdtbt.GuaranteePeriod__c = AllGurantee_Period; } provistonPeriod = ProductEntend_gurantee_period; } else { jzdtbt.pageObject.GuaranteePeriod__c = 1; jzdtbt.GuaranteePeriod__c = 1; } } else { jzdtbt.pageObject.GuaranteePeriod__c = AllGurantee_Period; jzdtbt.GuaranteePeriod__c = AllGurantee_Period; } jzdtbt.pageObject.provistonPeriod__c = provistonPeriod | 0; }); return jzDataToBeproduct; } export function PrintCustomerNameoptionsvlue(options_hp,selection_hp,quo,options_hpflg,accs){ if (JSON.stringify(accs) != "{}") { if (accs[0].Name) { var options_hpvalue = {}; options_hpvalue.label = accs[0].Name; options_hpvalue.value = accs[0].Name; options_hp.push(options_hpvalue); } if (accs[0].Site) { var options_hpvalue = {}; options_hpvalue.label = accs[0].Site; options_hpvalue.value = accs[0].Site; options_hp.push(options_hpvalue); } if (accs[0].Alias_Name2__c) { var options_hpvalue = {}; options_hpvalue.label = accs[0].Alias_Name2__c; options_hpvalue.value = accs[0].Alias_Name2__c; options_hp.push(options_hpvalue); } debugger if (!quo.Print_HP_Name__c || (quo.Print_HP_Name__c !== accs[0].Name && quo.Print_HP_Name__c !== accs[0].Site && quo.Print_HP_Name__c !== accs[0].Alias_Name2__c) ) { selection_hp = accs[0].Name; } else { selection_hp = quo.Print_HP_Name__c; } options_hpflg = false; } selection_hpExp = selection_hp; options_hpflgExp = options_hpflg; console.warn('selection_hp'+selection_hp); return options_hp } export function initquoassignment(quote,quoc,it){ var quo = quoc var rtn = quo.Cancel_Decide__c; quo.rtn = !rtn ? it : !rtn; var CreatedDateTime = new Date(quote.CreatedDate); var PriceRefreshDate = new Date(quote.PriceRefreshDate__c); quo.PriceRefreshPeriod = dateDaysBetween(!PriceRefreshDate ? CreatedDateTime : PriceRefreshDate,new Date()); quo.QuoteName__c = quote.Name; quo.QuoteTotal_Page__c = toNumComma(quote.TotalPrice__c); quo.Dealer_Final_Price_Page__c = toNumComma(quote.Dealer_Final_Price__c); quo.Quote_Adjust_Amount_Page__c = toNumComma(quote.Quote_Adjust_Amount__c); if(quo.OCM_Agent1_Price__c){ quo.OCM_Agent1_Price_Page__c = toNumComma(quote.OCM_Agent1_Price__c); }else{ quo.OCM_Agent1_Price_Page__c = ''; } quo.MultiYearWarrantyTotalPrice__c = toNumComma(quo.MultiYearWarrantyTotalPrice__c); quo.Agency1_Profit__c = toNumComma(quo.Agency1_Profit__c); quo.Agency2_Profit__c = toNumComma(quo.Agency2_Profit__c); //预测金额修改 fy quo.OCM_Sales_Forecast__c = toNumComma(quo.OCM_Sales_Forecast__c); //预测金额修改 fy if(!quote.QuotationChange__c){ quo.QuotationChange__c = ''; } if(!quote.Installation_location__c){ quo.Installation_location__c = ''; } if(quote.Agent1_Agent2_Price__c){ quo.Agent1_Agent2_Price_Page__c = toNumComma(quote.Agent1_Agent2_Price__c); }else{ quo.Agent1_Agent2_Price_Page__c = ''; } quo.hidden_Estimation_List = quote.Estimation_List_Price__c; return quo; } export function initquoassignmentcopy(quote,quoc,it){ debugger var quo = quoc let Name = quote.Name; var QX = Name.indexOf('已取消:'); if (QX >= 0) { quo.Name = quo.Name.substring(QX + 4); } quo.QuoteName__c = quo.Name; quo.IsQuoteTrial__c = false; quo.Cancel_Decide__c = false; quo.PriceRefreshDate__c = new Date(); quo.Quote_Date__c = null; quo.Quote_Print_Date__c = null; quo.QuoteTotal_Page__c = toNumComma(quote.TotalPrice__c); if(quo.OCM_Agent1_Price__c){ quo.OCM_Agent1_Price_Page__c = toNumComma(quote.OCM_Agent1_Price__c); }else{ quo.OCM_Agent1_Price_Page__c = ''; } quo.Agency1_Profit__c = toNumComma(quo.Agency1_Profit__c); quo.Agency2_Profit__c = toNumComma(quo.Agency2_Profit__c); if(quote.Agent1_Agent2_Price__c){ quo.Agent1_Agent2_Price_Page__c = toNumComma(quote.Agent1_Agent2_Price__c); }else{ quo.Agent1_Agent2_Price_Page__c = ''; } quo.Dealer_Final_Price_Page__c = toNumComma(quote.Dealer_Final_Price__c); //预测金额修改 fy quo.OCM_Sales_Forecast__c = toNumComma(quo.OCM_Sales_Forecast__c); //预测金额修改 fy quo.Quote_Adjust_Calculate__c = ''; quo.Quote_Adjust_Amount_Page__c = ''; quo.hidden_Estimation_List = quote.Estimation_List_Price__c; quo.PriceRefreshPeriod = null; if(!quote.QuotationChange__c){ quo.QuotationChange__c = ''; } if(!quote.Installation_location__c){ quo.Installation_location__c = ''; } var rtn = quo.Cancel_Decide__c; quo.rtn = !rtn ? it : !rtn; return quo; } export function salesProfit1Logic(quo,Salesprofit1value){ var x = quo.Dealer_Final_Price_Page__c; var y = quo.OCM_Agent1_Price_Page__c; debugger y = y + ''; y = y.replace(/ /g, ""); if (y.length == 0) { var z = quo.Agent1_Agent2_Price_Page__c; z = z + ''; z = z.replace(/ /g, ""); if (z.length == 0) { quo.OCM_Agent1_Price_Page__c = ''; Salesprofit1value = ''; quo.Agency1_Profit__c = ''; } else { quo.OCM_Agent1_Price_Page__c = toNumComma(0); Salesprofit1value = toNum(0); quo.Agency1_Profit__c = toNumComma(0); } } else { quo.OCM_Agent1_Price_Page__c = toNumComma(y); x = localParseFloat(x); y = localParseFloat(y); var t = quo.Agent1_Agent2_Price_Page__c; if (t.length == 0) { Salesprofit1value = toNum(x - y); quo.Agency1_Profit__c = toNumComma(x - y); } else { t = localParseFloat(t); Salesprofit1value = toNum(t - y); quo.Agency1_Profit__c = toNumComma(t - y); } } quoExp = quo; return Salesprofit1value; } export function salesCalculation1Logic(quo,Salesprofit1value,SalesCalculation1value){ var w = quo.OCM_Agent1_Price_Page__c; w = w + ''; w = w.replace(/ /g, ''); var x = Salesprofit1value; var y = quo.Dealer_Final_Price_Page__c; var z = quo.Agent1_Agent2_Price_Page__c; z = z + ''; z = z.replace(/ /g, ''); if (w.length == 0) { SalesCalculation1value = ''; quo.Agency1_Profit_Rate__c = ''; } else { x = localParseFloat(x); var t = 0; if (z.length == 0) { y = localParseFloat(y); if (y != 0) { t = x / y * 100; } else { t = 0; } } else { z = localParseFloat(z); if (z != 0) { t = x / z * 100; } else { t = 0; } } SalesCalculation1value = toNum(t); quo.Agency1_Profit_Rate__c = toNumComma(t); } quoExp = quo; return SalesCalculation1value; } export function salesProfit2Logic(quo,Salesprofit2value){ var x = quo.Dealer_Final_Price_Page__c; var y = quo.Agent1_Agent2_Price_Page__c; y = y + ''; y = y.replace(/ /g, ""); if (y.length == 0) { quo.Agent1_Agent2_Price_Page__c = ''; Salesprofit2value =''; quo.Agency2_Profit__c = ''; } else { x = localParseFloat(x); y = localParseFloat(y); quo.Agent1_Agent2_Price_Page__c = toNumComma(y); Salesprofit2value = toNum(x - y); quo.Agency2_Profit__c = toNumComma(x - y); } quoExp = quo; return Salesprofit2value; } /* 计算第二经销商栏最右边的百分比 2次販売店利益率_元 = 第二经销商利润除以医院的合同金额 */ export function salesCalculation2Logic(quo,Salesprofit2value,SalesCalculation2value){ var w = quo.Agent1_Agent2_Price_Page__c; w = w + ''; w = w.replace(/ /g, ''); var x = Salesprofit2value; var y = quo.Dealer_Final_Price_Page__c; if (w.length == 0) { SalesCalculation2value = ''; quo.Agency2_Profit_Rate__c = ''; } else { x = localParseFloat(x); y = localParseFloat(y); if ((y == 0)) { SalesCalculation2value = toNum(0); quo.Agency2_Profit_Rate__c = toNumComma(0); } else { var z = x / y * 100; SalesCalculation2value = toNum(z); quo.Agency2_Profit_Rate__c = toNumComma(z); } } quoExp = quo; return SalesCalculation2value; } export function additionabuttonLoc(SelectedNewsetProduct,quo,oppInfo,jzDataToBeproduct){ var Str = SelectDone(SelectedNewsetProduct); var quoc = saveEvoluationLogic(quo,oppInfo,jzDataToBeproduct); var oppInfoc = oppInfosave; var quoLineItemc = quoLineItemsave; var quoLineItemCan = JSON.stringify(quoLineItemc); var oppInfoCan = JSON.stringify(oppInfoc); var quoCan = JSON.stringify(quoc); StrExp = Str; return {setProduct_text:Str, activitiesCan:quoLineItemCan, oppInfoc:oppInfoCan, quoc:quoCan}; } export function onsaveToBeproductLoc(data,jzDataToBeproduct){ var dataMap = new Map(); var fag = false; data.forEach(item=>{ var key = Number(item.lineNo); var value = {Quantity__c:'',UnitPrice_Page__c:''} if(item.Quantity__c != undefined){ value.Quantity__c = item.Quantity__c; fag = true; } if(item.UnitPrice_Page__c != undefined){ value.UnitPrice_Page__c = item.UnitPrice_Page__c; } dataMap.set(key,value); }); jzDataToBeproduct.forEach(jzdtbt=>{ var x, y, z, c; if(dataMap.has(jzdtbt.lineNo)){ var datavaue = dataMap.get(jzdtbt.lineNo); if(datavaue.Quantity__c){ jzdtbt.Quantity__c = localParseInt(datavaue.Quantity__c); } if(datavaue.UnitPrice_Page__c){ // jzdtbt.UnitPrice_Page__c = toNumComma(datavaue.UnitPrice_Page__c); jzdtbt.UnitPrice_Page__c = datavaue.UnitPrice_Page__c; } x = localParseInt(jzdtbt.Quantity__c); y = localParseFloat(jzdtbt.UnitPrice_Page__c); c = localParseFloat(jzdtbt.Cost_c); z = x * y; // jzdtbt.Subtotal__c = toNumComma(z) jzdtbt.Subtotal__c = z // jzdtbt.pageObject.Subtotal__c = toNumComma(z) jzdtbt.pageObject.Subtotal__c = z z = x * y; jzdtbt.Cost_Subtotal_c = toNum(z); } }); fagExp = fag; return jzDataToBeproduct; } export function PrintButtonLoc(quo,oppInfo,jzDataToBeproduct,CheckItem,WinOrDecideAlert, productStatusUpdated,enableSales,oppId,quoId,newQuoteFlag,changedAfterPrint,quoteGurantee_Period, quotemultiYearWarranty,selection_hp,SkipQuotefilg,QuoteDecision){ debugger var quoc = saveEvoluationLogic(quo,oppInfo,jzDataToBeproduct); var oppInfoc = oppInfosave; var quoLineItemc = quoLineItemsave; var quoLineItemCan = JSON.stringify(quoLineItemc); var CheckItemCan = JSON.stringify(CheckItem); var oppInfoCan = JSON.stringify(oppInfoc); var quoCan = JSON.stringify(quoc); var data ={activitiesCan:quoLineItemCan, CheckItemCan:CheckItemCan, WinOrDecideAlertc:WinOrDecideAlert, productStatusUpdatedc:productStatusUpdated, oppInfoc:oppInfoCan, quoc:quoCan, enableSalesc:enableSales, oppIdc:oppId, quoIdc:quoId, newQuoteFlagc:newQuoteFlag, changedAfterPrintc:changedAfterPrint, quoteGurantee_Periodc:quoteGurantee_Period, quotemultiYearWarrantyc:quotemultiYearWarranty, selection_hpc:selection_hp, SkipQuotefilgc:SkipQuotefilg, QuoteDecisionc:QuoteDecision }; return data; } export function saverebackloc(resaut,quoId,nafg){ alertExp = '' var Setmap = new Map() var key = Object.keys(resaut) key.forEach(item=>{ Setmap.set(item,resaut[item]); }); if(Setmap.has('errormessage')){ errorflg = true; alertExp = Setmap.get('errormessage'); }else{ if(Setmap.has('quoId')){ quoId = Setmap.get('quoId'); } if(Setmap.has('quoId')){ window.open('/lightning/n/lexNewQuoteEntry#Id=' + Setmap.get('quoId'), '_self'); // window.location.href ='/lightning/n/lexNewQuoteEntry#Id='+Setmap.get('quoId'); flg = true; } errorflg = false; } nafgExp = resultFlag(nafg,Setmap) return quoId; } // 优惠折扣 = 优惠价格 / (报价总额 - No discount price 合计); export function DisCalculationfunctionLoc(quo){ var x = quo.Discount_Amount__c; x = localParseFloat(x); var y = quo.QuoteTotal_Page__c; y = localParseFloat(y); if ((y == 0)) { quo.Discount_Amount_Calculate__c = ''; } else { var z = 0; z = x / y * 100; z = z.toFixed(2); quo.Discount_Amount_Calculate__c = toNum(z); } return quo; } // 根据医院小计计算报价总额 export function quoteTotalPriceLoc(jzDataToBeproduct,quo,quoId,oppInfo,Saleslet){ debugger var x = 0; var y = 0; jzDataToBeproduct.forEach(jzdtbt=>{ x = jzdtbt.pageObject.Subtotal__c; x = localParseFloat(x); y = y + localParseFloat(x); }); quo.QuoteTotal_Page__c = toNumComma(y); var z = quo.Estimation_List_Price__c; var id = quoId; if(!id){ var IsQuoteTrial =quo.IsQuoteTrial__c; if(!IsQuoteTrial){ var mp =quo.MultiYearWarrantyTotalPrice__c; mp = localParseFloat(mp); var num = quo.Quote_Adjust_Calculate__c; num = localParseFloat(num); quo.Quote_Adjust_Calculate__c = toNumComma(num); num = (100 + num) / 100; z=localParseFloat(z); var rh = oppInfo.rate_hospital; var ra = oppInfo.rate_agency1; quo.Dealer_Final_Price_Page__c = toNumComma(z*rh); quo.OCM_Agent1_Price_Page__c = Saleslet ? toNumComma(z*num*ra+mp) : ''; } } quoExp = quo; return jzDataToBeproduct; } //计算隐藏 listPirce 汇总 和 UnitPrice(医院单价) 汇总 export function calUnitPriceTotalLoc(jzDataToBeproduct){ var ListPriceTotal = 0.0, listPrice = 0.0; var unitPriceTotal = 0.0, unitPrice = 0.0; jzDataToBeproduct.forEach(jzdtbt=>{ listPrice = jzdtbt.ListPrice_Page; unitPrice = jzdtbt.UnitPrice_Page__c; ListPriceTotal += localParseFloat(listPrice); unitPriceTotal += localParseFloat(unitPrice); }); ListPriceTotalExp = ListPriceTotal; unitPriceTotalExp = unitPriceTotal; jzDataToBeproduct =[].concat(jzDataToBeproduct); return jzDataToBeproduct; } //判断进销商1 和 2 清空 利润百分比显示 export function pageArrangeLoc(quo){ if (!quo.OCM_Agent1_Price_Page__c) { quo.Agency1_Profit__c = ''; quo.Agency1_Profit_Rate__c = ''; quo.OCM_Agent1_Price_Page__c = ''; } if (!quo.Agent1_Agent2_Price_Page__c) { quo.Agency2_Profit__c = ''; quo.Agency2_Profit_Rate__c = ''; quo.Agent1_Agent2_Price_Page__c = ''; } return quo; } export function openQuotePage(b, b2, b3) { var quoid = b3; if (b2) { } else { if (b) { //openPopup('/apex/contractdetailpdf?id=quoid'); window.open('/apex/contractdetailpdf?id=' + quoid, 'Contract'); } else { //openPopup('/apex/quotepdf?id=quoid'); window.open('/apex/quotepdf?id=' + quoid, 'Quote'); } } } export function quoteinit(quo){ if (!quo.Gurantee_Period__c) { quo.Gurantee_Period__c = '1'; } if (quo.Quote_Expiration_Date__c == null) { quo.Quote_Expiration_Date__c = addDay(30,new Date()); } quo.Offer_Amount__c = true; quo.TOTAL__c = true; quo.Preferential_Gurantee_Period__c = true; return quo; } /* 如果询价是经销商贩卖,OCM预测额销售 = 第一经销商 如果询价是OCM直销,OCM预测额销售 = 医院的合同金额 */ export function setOCMAmountc(enableSales,quo,oppInfo){ var s, t; s = enableSales; if (s) { t = quo.OCM_Agent1_Price_Page__c; } else { t = quo.Dealer_Final_Price_Page__c; } t = localParseFloat(t); oppInfo.hidden_Wholesale_Price = toNum(t); oppInfo.Wholesale_Price__c = toNumComma(t); //预测金额修改 fy quo.OCM_Sales_Forecast__c = toNumComma(t); quoExp = quo; //预测金额修改 fy return oppInfo; } // 优惠价格 = 报价总额 - 医院的合同金额 // 然后调用 DisCalculation export function DisAmountfunctionc(quo){ var x = quo.QuoteTotal_Page__c; x = localParseFloat(x); var y = quo.Dealer_Final_Price_Page__c; y = localParseFloat(y); quo.Discount_Amount__c = toNum(x - y); return quo; } export function SFDAtranslate(key){ var value = ''; if(key == '準備中'){ value = '准备中'; }else if(key == '新製品申請中'){ value = '新产品注册中'; }else if(key == '有効'){ value = '有效'; }else if(key == '失効(期限内生産済在庫対応)'){ value = '失效或停止(注册证有效期内生产的库存品对应)'; }else if(key == '失効(再申請中)'){ value = '失效-重新申请中'; }else if(key == '失効(申請無)'){ value = '失效-不再注册'; }else if(key == '有効(再申請中)'){ value = '有效-重新申请中'; }else{ value = key; } return value; } export function decisionlol(jzDataToBeproduct,oppInfo,QuotationCalculationFag){ var ff = false; alertExp = ''; var Shut = AlertForCFDA(jzDataToBeproduct); var ifAuth = AlertAuthorize(oppInfo); var arr = []; var Venderflag = false; jzDataToBeproduct.forEach(jzdtbt=>{ var VenderName = jzdtbt.VenderName; var prdouctName = jzdtbt.pageObject.Name__c; if (prdouctName) { arr.push(VenderName); } }); for (var i = 0; i < arr.length; i++) { if (arr[0] != arr[i]) { Venderflag = true; } } var listPrice = CheckForListPrice(jzDataToBeproduct); var cost = CheckForCost(jzDataToBeproduct); if (Shut == true) { ff = true; alertExp = '提示:包含重新申请CFDA的产品,不可Decide。'; } else if (ifAuth == false) { ff = true; alertExp = '提示:该询价未授权,不可Decide'; } else if (Venderflag == true) { ff = true; alertExp = '提示:请按照不同供应商拆单,不允许decide。'; }else if (listPrice == true || cost == true) { ff = true; alertExp = '产品定价/成本为0,请联系产品本部。'; }else if(QuotationCalculationFag){ ff = true; alertExp = '产品配置发生变化,请再次进行报价计算'; } return ff; } export function saveQuotel(quo,oppInfo,jzDataToBeproduct,CheckItem,WinOrDecideAlert,productStatusUpdated,enableSales, oppId,quoId,newQuoteFlag,changedAfterPrint,quoteGurantee_Period,quotemultiYearWarranty,selection_hp,SkipQuotefilg,quoteflg){ var quoc = saveEvoluationLogic(quo,oppInfo,jzDataToBeproduct); debugger var oppInfoc = oppInfosave; var quoLineItemc = quoLineItemsave; var quoLineItemCan = JSON.stringify(quoLineItemc); var CheckItemCan = JSON.stringify(CheckItem); var oppInfoCan = JSON.stringify(oppInfoc); var quoCan = JSON.stringify(quoc); var SaveQuotecan = {activitiesCan:quoLineItemCan, CheckItemCan:CheckItemCan, WinOrDecideAlertc:WinOrDecideAlert, productStatusUpdatedc:productStatusUpdated, oppInfoc:oppInfoCan, quoc:quoCan, enableSalesc:enableSales, oppIdc:oppId, quoIdc:quoId, newQuoteFlagc:newQuoteFlag, changedAfterPrintc:changedAfterPrint, quoteGurantee_Periodc:quoteGurantee_Period, quotemultiYearWarrantyc:quotemultiYearWarranty, selection_hpc:selection_hp, SkipQuotefilgc:SkipQuotefilg, quoteflg:quoteflg } return SaveQuotecan; } export function resultFlag(nafg,Setmap){ debugger if(!Setmap){ nafg.dfpp = false; nafg.qname = false; nafg.qacc = false; nafg.qaapc = false; nafg.Agency1 = false; nafg.nAgency1 = false; nafg.oapp = false; nafg.noapp = false; nafg.Agency2 = false; nafg.nAgency2 = false; nafg.aapp = false; nafg.naapp = false; }else{ if(Setmap.has('dfpp')){ nafg.dfpp = true; }else{ nafg.dfpp = false; } if(Setmap.has('qname')){ nafg.qname = true; }else{ nafg.qname = false; } if(Setmap.has('qacc')){ nafg.qacc = true; }else{ nafg.qacc = false; } if(Setmap.has('qaapc')){ nafg.qaapc = true; }else{ nafg.qaapc = false; } if(Setmap.has('Agency1')){ nafg.Agency1 = true; }else{ nafg.Agency1 = false; } if(Setmap.has('nAgency1')){ nafg.nAgency1 = true; }else{ nafg.nAgency1 = false; } if(Setmap.has('oapp')){ nafg.oapp = true; }else{ nafg.oapp = false; } if(Setmap.has('noapp')){ nafg.noapp = true; }else{ nafg.noapp = false; } if(Setmap.has('Agency2')){ nafg.Agency2 = true; }else{ nafg.Agency2 = false; } if(Setmap.has('nAgency2')){ nafg.nAgency2 = true; }else{ nafg.nAgency2 = false; } if(Setmap.has('aapp')){ nafg.aapp = true; }else{ nafg.aapp = false; } if(Setmap.has('naapp')){ nafg.naapp = true; }else{ nafg.naapp = false; } } return nafg; } // 计算产品标准定价总额 export function EstimationL(jzDataToBeproduct,quo){ var x, y, z; x = 0; y = 0; z = 0; jzDataToBeproduct.forEach(jzdtbt=>{ x = jzdtbt.ListPrice_Page; y = jzdtbt.Quantity__c; x = localParseFloat(x); y = localParseFloat(y); z = z + (x * y); }); jzDataToBeproduct =[].concat(jzDataToBeproduct); quo.hidden_Estimation_List = toNum(z); quo.Estimation_List_Price__c = toNumComma(z); quoExp = quo; return jzDataToBeproduct; } export function checkch(jzDataToBeproduct){ var activities = []; jzDataToBeproduct.forEach(jzdtbt=>{ var lineId = jzdtbt.pageObject.PricebookEntryId; if (lineId) { var item = new Object(); item.PricebookEntryId = jzdtbt.pageObject.PricebookEntryId; item.SFDA_Status__c = jzdtbt.pageObject.SFDA_Status__c; item.UnitPrice__c = localParseFloat(jzdtbt.UnitPrice_Page__c); item.ListPrice__c = localParseFloat(jzdtbt.ListPrice_Page); item.Quantity = localParseInt(jzdtbt.Quantity__c); item.Is_DangerousChemicals = jzdtbt.Is_DangerousChemicals; item.Is_CanNotCancelFlag = jzdtbt.CanNotCancelledGurantee; activities.push(item); } }); return activities; }