import { LightningElement,wire,track,api} from 'lwc';
|
import LightningConfirm from 'lightning/confirm';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { CurrentPageReference } from "lightning/navigation";
|
import estimateUtility from 'c/lexSelectEstimateUtility';
|
|
import init from "@salesforce/apex/lexSelectAssetEstimateVMController.init";
|
import save from "@salesforce/apex/lexSelectAssetEstimateVMController.save";
|
import refreshProductData from "@salesforce/apex/lexSelectAssetEstimateVMController.refreshProductData";
|
import saveAndCancel from "@salesforce/apex/lexSelectAssetEstimateVMController.saveAndCancel";
|
import addNewRows from "@salesforce/apex/lexSelectAssetEstimateVMController.addNewRows";
|
import searchBtn from "@salesforce/apex/lexSelectAssetEstimateVMController.searchBtn";
|
import exchangeAsset from "@salesforce/apex/lexSelectAssetEstimateVMController.exchangeAsset";
|
import approvalProcess from "@salesforce/apex/lexSelectAssetEstimateVMController.approvalProcess";
|
import ComputeLTYRepair from "@salesforce/apex/lexSelectAssetEstimateVMController.ComputeLTYRepair";
|
import ShowLTYRepair from "@salesforce/apex/lexSelectAssetEstimateVMController.ShowLTYRepair";
|
import toApprovalProcess from "@salesforce/apex/lexSelectAssetEstimateVMController.toApprovalProcess";
|
import decide from "@salesforce/apex/lexSelectAssetEstimateVMController.decide";
|
import decideCancle from "@salesforce/apex/lexSelectAssetEstimateVMController.decideCancle";
|
import undecide from "@salesforce/apex/lexSelectAssetEstimateVMController.undecide";
|
import print from "@salesforce/apex/lexSelectAssetEstimateVMController.print";
|
import sendEmail from "@salesforce/apex/lexSelectAssetEstimateVMController.sendEmail";
|
//import excelImport from "@salesforce/apex/lexSelectAssetEstimateVMController.excelImport";
|
//import readExcel from "@salesforce/apex/lexSelectAssetEstimateVMController.readExcel";
|
import accSendEmailFW from "@salesforce/apex/lexSelectAssetEstimateVMController.accSendEmailFW";// WYL 贸易合规2期 add
|
|
import getApprovalBtnNewDisabled from "@salesforce/apex/lexSelectAssetEstimateVMController.getApprovalBtnNewDisabled";
|
// import ToConsumptionRate from "@salesforce/apex/ConsumptionRateWebService2.ToConsumptionRate";
|
import interceptsend from "@salesforce/apex/lexSelectAssetEstimateVMController.interceptsend";
|
|
//前端需要补充方法
|
import getMCAEIsCreateable from "@salesforce/apex/lexSelectAssetEstimateVMController.getMCAEIsCreateable";
|
import saveBeforeCheckPriceChangeAsset from "@salesforce/apex/lexSelectAssetEstimateVMController.saveBeforeCheckPriceChangeAsset";
|
import saveBeforeCheckPriceChangeProduct2 from "@salesforce/apex/lexSelectAssetEstimateVMController.saveBeforeCheckPriceChangeProduct2";
|
import onChDealerUpdate from "@salesforce/apex/lexSelectAssetEstimateVMController.onChDealerUpdate";
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
import lexSendNfm103 from '@salesforce/resourceUrl/lexSendNfm103';
|
|
//completion=? page里跳转回原编辑页面 id=传回参数
|
export default class lexSelectAssetEstimateVM extends NavigationMixin(LightningElement){
|
activeSections = ['A', 'B','C','D','E'];
|
// @track activeSections = ['A'];
|
IsLoading = true;
|
objName = 'Maintenance_Contract_Estimate__c';
|
recordId;
|
params;
|
goTo;
|
IsParams;
|
// openQuoteExcelImportWindow=null;
|
//三方协议 勾选是否显示
|
EnablePrintContract;
|
//请提交待审批 文字提示
|
IS_Clone_After_Decide;
|
@track
|
estimate = {};
|
contract = {};
|
|
@track estimateTemp = {Request_quotation_Amount__c : 0,AgencyHos_Price__c : 0};
|
@track estimateAgencyHosPrice = {AgencyHos_Price__c : 0};
|
//存放初始化所有数据
|
allData = {};
|
checkedAssetRelatedMaintenanceContractAssetEstimate = 'Maintenance_Contract_Asset_Estimate__c';
|
//页面数据显示 recId -- rec.Id(原通过后端的get方法取值)
|
checkedAssetData = [];
|
IsCheckAllcheckedAsset = false;
|
//选中保有设备 数据统计 //allData.productCount3 可替换
|
productCount3 = 0;
|
checkedAssetDataSize = true;
|
//修理总额--仅页面显示
|
assetRepairSumNum;
|
//未选中保有设备 弹框显示与否
|
IsShowUnCheckedAsset;
|
unCheckedAssetData = [];
|
IsCheckAllUncheckedAsset = false;
|
unCheckedAssetDataLength;
|
//分页处理--是否可以直接在前端处理
|
currentPage = 1;
|
pageDataLimit = 20;
|
pageCount;
|
//未选中保有设备 下方文字
|
unCheckedAssetDataShow1 ;
|
unCheckedAssetDataShow2 ;
|
//当前页数据
|
unCheckedAssetNowData = [];
|
//保有设备 搜索条件 -> allData里
|
text1 = 'S:AssetMark__c'; // 对象
|
cond1 = 'equals'; // 条件
|
val1;
|
//前端判断按钮是否可以点击
|
SaveBtnDisabled;
|
//consumptionbtnDisabled;
|
ApprovalBtnDisabled;
|
//后台返回结果
|
ApprovalBtnNewDisabled;
|
PageDisabled;
|
hasSendEmail;
|
//allData.productCount 可替换
|
productCount;
|
//报价提交对象 变更按钮 Disabled DecideBtnDisabled
|
DecideBtnDisabled =true;
|
UnDecideBtnDisabled = true;
|
//提交RC评估 btn
|
SendEmailBtnDisabled;
|
//补充初始化数据
|
approvalDate = '';
|
refreshAssetBtn;
|
// lwc 刷新按钮禁用
|
refreshAssetBtnLWC;
|
IsTop;
|
IsPre;
|
IsNext;
|
IsEnd;
|
lineAddBtn;
|
IsChangePageLimit;
|
printFlag = true;
|
//相关字段改动导致禁用或不显示
|
IsContractstartdateDisabled;
|
IsDealerDisabled;
|
AgreeRenewTenDisabled;
|
IsRequestQuotationAmountDisabled;
|
isAgreeRenew;
|
IsLimitPriceAmountDisabled;
|
IsContractEstiStartDateDisabled;
|
//页面数据刷新
|
IsRefresh = true;
|
EstimateTargetIsDealer;
|
EstimatePricerange;
|
ContractPriceType;
|
//excel导入
|
//showQuoteExcelImport=false;
|
//svgRichText='富文本';
|
// WYL 贸易合规 合同id
|
mcid;
|
//获取Id
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.fragment;
|
if (urlValue) {
|
this.otherParams = urlValue;
|
let str = `${urlValue}`;
|
this.params = str.split('=');
|
|
this.recordId = str.split('=')[1];
|
this.IsParams = this.params[0] == 'id';
|
this.goTo = true;
|
}else{
|
estimateUtility.toast.showToast(this, 'error', '请从合同和报价页面进入');
|
setTimeout(function() {
|
window.open('/lightning/page/home','_self');
|
}, 3000);
|
this.goTo = false;
|
}
|
}
|
}
|
//页面初始化
|
connectedCallback() {
|
Promise.all([
|
loadStyle(this, lwcCSS),
|
loadStyle(this, lexSendNfm103)
|
]);
|
if (this.goTo) {
|
init({
|
recordId: this.recordId,
|
param: this.params[0],
|
}).then(result => {
|
result = JSON.parse(result);
|
console.log('estimate===',JSON.stringify(result.estimate));
|
this.mcid = result.estimate.Maintenance_Contract__c; //贸易合规二期
|
if (result != null) {
|
|
this.allData = result;
|
|
this.handleInitSimpleData(result);
|
this.allData.checkedAssets = this.refreshAsset(result.checkedAssets.length,result.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
this.calonLoad();
|
this.allDataInfo();
|
}
|
}).catch(error => {
|
console.log('错误==='+error);
|
estimateUtility.toast.showToast(this, 'error', '无法显示维修合同报价');
|
}).finally(() => {
|
const sections = this.template.querySelectorAll('lightning-accordion-section');
|
sections.forEach(section => {
|
if(section.id.includes('myAccordionSection')) {
|
section.active = true;
|
}
|
});
|
this.IsLoading = false;
|
});
|
}
|
|
}
|
|
handleCheckedAssetColumnsAndData(checkedAssets){
|
console.log('handleCheckedAssetColumnsAndData');
|
this.IsRefresh = false;
|
let checkedAssetsData = [];
|
let index = 0;
|
let assetsCount = 0;
|
let refreshAssetBtnLWCDisabled = true;
|
checkedAssets.forEach(function(ar) {
|
let objData = {};
|
|
objData['lineNo'] = ar.lineNo;
|
objData['rec_checkBox_c'] = ar.rec_checkBox_c;
|
objData['IsManual'] = ar.isManual;
|
|
objData['CheckRows'] =ar.CheckRows;
|
|
objData['Repair_Price_Auto'] =ar.Repair_Price_Auto;
|
//共有字段
|
if (ar.mcae != null) {
|
objData['EquipmentGuaranteeFlgTxt__c'] = ar.mcae.EquipmentGuaranteeFlgTxt__c;
|
objData['Check_Object__c'] = ar.mcae.Check_Object__c;
|
objData['IsNew__c'] = ar.mcae.IsNew__c;
|
var adl = '';
|
var adu = '';
|
if (ar.mcae.Adjustment_Lower_price__c !=''&& ar.mcae.Adjustment_Lower_price__c != null) {
|
if (typeof ar.mcae.Adjustment_Lower_price__c === 'number') {
|
adl = ar.mcae.Adjustment_Lower_price__c;
|
}else{
|
adl = parseFloat(ar.mcae.Adjustment_Lower_price__c);
|
}
|
}
|
if ( ar.mcae.Adjustment_Upper_price__c !='' && ar.mcae.Adjustment_Upper_price__c != null) {
|
if (typeof ar.mcae.Adjustment_Upper_price__c === 'number') {
|
adu = ar.mcae.Adjustment_Upper_price__c;
|
}else{
|
adu = parseFloat(ar.mcae.Adjustment_Upper_price__c);
|
}
|
}
|
if (adu!='' ) {
|
objData['Adjustment_Upper_price__c'] = new Intl.NumberFormat('en-US', {
|
style: 'decimal',
|
// currency: 'USD',
|
minimumFractionDigits: 2
|
}).format(adu);
|
}
|
if (adl!='' ) {
|
objData['Adjustment_Lower_price__c'] = new Intl.NumberFormat('en-US', {
|
style: 'decimal',
|
// currency: 'USD',
|
minimumFractionDigits: 2
|
}).format(adl);
|
}
|
|
objData['Repair_Price__c'] = ar.mcae.Repair_Price__c;
|
objData['Comment__c'] = ar.mcae.Comment__c;
|
objData['commentTitle'] = ar.mcae.Comment__c ? ar.mcae.Comment__c : '';
|
objData['Third_Party_Return__c'] = ar.mcae.Third_Party_Return__c;
|
}
|
if (ar.rec != null) {
|
objData['IsCurrentContract'] = ar.rec.CurrentContract_F__c != null;
|
objData['recId'] = ar.rec.Id;
|
|
objData['CurrentContract_F__c'] = ar.rec.CurrentContract_F__c;
|
}
|
if (ar.isManual == true && ar.mcae != null) {
|
objData['Name'] = ar.mcae.Product_Manual__c;
|
|
if (ar.mcae.Product_Manual__c) {
|
assetsCount += 1;
|
}
|
}else if ( ar.isManual == false) {
|
assetsCount += 1;
|
if (ar.rec != null) {
|
objData['Name'] = ar.rec.Name;
|
refreshAssetBtnLWCDisabled = false;
|
objData['CurrentContract_End_Date__c'] = ar.rec.CurrentContract_End_Date__c;
|
objData['Asset_situation__c'] = ar.rec.Asset_situation__c;
|
objData['SerialNumber'] = ar.rec.SerialNumber;
|
objData['InstallDate'] = ar.rec.InstallDate;
|
objData['Department_Name__c'] = ar.rec.Department_Name__c;
|
if (ar.rec.CurrentContract_F__r != null) {
|
if (ar.rec.CurrentContract_F_asset__r != null) {
|
objData['IS_VMContract_Asset__c'] = ar.rec.CurrentContract_F_asset__r.IS_VMContract_Asset__c;
|
}
|
objData['Maintenance_Contract_No_F__c'] = ar.rec.CurrentContract_F__r.Maintenance_Contract_No_F__c;
|
objData['Contract_End_Date__c'] = ar.rec.CurrentContract_F__r.Contract_End_Date__c;
|
}
|
}
|
if (ar.mcae != null) {
|
objData['Asset_Consumption_rate__c'] = ar.mcae.Asset_Consumption_rate__c;
|
}
|
}
|
//补充字段可否编辑
|
objData['IsAssertDisabled'] = ar.IsAssertDisabled;
|
objData['IsRepairPriceDisabled'] = ar.IsRepairPriceDisabled;
|
objData['ISCommentDisabled'] = ar.ISCommentDisabled;
|
objData['IsThirdPartyReturnDisabled'] = ar.IsThirdPartyReturnDisabled;
|
objData['ShowAssetSituation'] = ar.ShowAssetSituation;
|
checkedAssetsData.push(objData);
|
|
});
|
this.checkedAssetData = checkedAssetsData;
|
console.log('this.checkedAssetData=='+this.checkedAssetData);
|
//已选择保有设备
|
//this.productCount3 统计
|
this.productCount3 = assetsCount;
|
this.allData.productCount3 = this.productCount3;
|
this.refreshAssetBtnLWC = this.refreshAssetBtnLWC || refreshAssetBtnLWCDisabled;
|
this.IsRefresh = true;
|
}
|
|
|
handleunCheckedAssetColumnsAndData(unCheckedAssets){
|
console.log('handleunCheckedAssetColumnsAndData');
|
this.IsRefresh = false;
|
|
let uncheckedAssetsData = [];
|
let refreshAssetBtnDisabled = true;
|
unCheckedAssets.forEach(function(ar) {
|
let objData = {};
|
//共有字段
|
objData['rec_checkBox_c'] = ar.rec_checkBox_c;
|
if (ar.mcae != null) {
|
}
|
if (ar.rec != null) {
|
objData['Id'] = ar.rec.Id;
|
|
objData['uncheckedDisable'] = ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty_Service__c == '否';
|
if (!objData['uncheckedDisable']) {
|
refreshAssetBtnDisabled = false;
|
}
|
objData['EquipmentGuaranteeFlg__c'] = ar.rec.EquipmentGuaranteeFlg__c;
|
|
objData['name'] = ar.rec.Name;
|
objData['Asset_situation__c'] = ar.rec.Asset_situation__c;
|
|
objData['SerialNumber'] = ar.rec.SerialNumber;
|
objData['InstallDate'] = ar.rec.InstallDate;
|
objData['Department_Name__c'] = ar.rec.Department_Name__c;
|
objData['IF_Warranty_Service__c'] = ar.rec.IF_Warranty_Service__c;
|
objData['AssetMark__c'] = ar.rec.AssetMark__c;
|
objData['EquipmentGuaranteeFlg__c'] = ar.rec.EquipmentGuaranteeFlg__c;
|
objData['Reson_Can_not_Warranty__c'] = ar.rec.Reson_Can_not_Warranty__c;
|
objData['Accumulation_Repair_Amount__c'] = ar.rec.Accumulation_Repair_Amount__c;
|
objData['CurrentContract_End_Date__c'] = ar.rec.CurrentContract_End_Date__c;
|
}
|
uncheckedAssetsData.push(objData);
|
});
|
this.unCheckedAssetData = uncheckedAssetsData;
|
console.log('this.unCheckedAssetData',this.unCheckedAssetData);
|
this.getUnCheckedAssetNowData();
|
|
this.refreshAssetBtn = this.refreshAssetBtn || refreshAssetBtnDisabled;
|
|
this.IsRefresh = true;
|
}
|
|
handleInitSimpleData(result) {
|
console.log('handleInitSimpleData');
|
|
this.IsRefresh = false;
|
|
|
this.estimate = result.estimate;
|
this.handleEstimateTargetIsHospitalTrue();
|
|
if (this.estimate.Is_RecognitionModel__c == null || !this.estimate.Is_RecognitionModel__c) {
|
this.estimate.Is_RecognitionModel__c = false;
|
}
|
if (this.estimate.Print_RepairPrice__c == null || !this.estimate.Print_RepairPrice__c) {
|
this.estimate.Print_RepairPrice__c = false;
|
}
|
if (this.estimate.Print_SumPrice__c == null || !this.estimate.Print_SumPrice__c) {
|
this.estimate.Print_SumPrice__c = false;
|
}
|
if (this.estimate.Print_Contract__c == null || !this.estimate.Print_Contract__c) {
|
this.estimate.Print_Contract__c = false;
|
}
|
if (this.estimate.Print_Tripartite__c == null || !this.estimate.Print_Tripartite__c) {
|
this.estimate.Print_Tripartite__c = false;
|
}
|
if (this.estimate.Print_Agent__c == null || !this.estimate.Print_Agent__c) {
|
this.estimate.Print_Agent__c = false;
|
}
|
this.contract = result.contract;
|
|
this.pageDataLimit = result.selRecordOption;
|
this.currentPage = result.currPage;
|
this.pageCount = result.totalPage;
|
this.IsChangePageLimit = result.totalRecords<10;
|
this.hasSendEmail = result.hasSendEmail;
|
this.productCount = result.checkedAssets.length;
|
this.val1 = result.val1;
|
this.productCount3 = result.productCount3;
|
this.IS_Clone_After_Decide = result.IS_Clone_After_Decide;
|
|
this.allData.text1 = this.text1 ; // 对象
|
this.allData.cond1 = this.cond1 ;
|
// if (this.contract.Status__c =='引合中' || this.estimate.Process_Status__c && this.estimate.Process_Status__c != '草案中') {
|
// this.consumptionbtnDisabled = true;
|
// }else{
|
// this.consumptionbtnDisabled = false;
|
// }
|
if (this.contract.Decided_Estimation__c || this.estimate.Process_Status__c && this.estimate.Process_Status__c != '草案中') {
|
this.SaveBtnDisabled = true;
|
this.ApprovalBtnDisabled = true;
|
this.PageDisabled = true;
|
this.SendEmailBtnDisabled = true;
|
}else{
|
this.SaveBtnDisabled = false;
|
this.ApprovalBtnDisabled = false;
|
this.SendEmailBtnDisabled = false;
|
this.PageDisabled = false;
|
if(this.hasSendEmail == true){
|
this.SendEmailBtnDisabled = true;
|
}
|
}
|
if(this.contract.Decided_Estimation__c || this.estimate.Process_Status__c != '批准'
|
|| (this.estimate.Change_Dealer_Approval__c && this.estimate.Change_Dealer_Approval__c != '批准'
|
&& this.estimate.Change_Dealer_Approval__c != '未批准')){
|
|
this.DecideBtnDisabled = true;
|
|
}else{
|
this.DecideBtnDisabled = false;
|
}
|
if (this.contract.Decided_Estimation__c) {
|
this.EnablePrintContract = this.estimate.Estimation_Decision__c;
|
if (this.estimate.Estimation_Decision__c) {
|
this.UnDecideBtnDisabled = false;
|
}
|
}else{
|
this.UnDecideBtnDisabled = true;
|
this.EnablePrintContract = false;
|
}
|
getMCAEIsCreateable({
|
}).then(result => {
|
console.log('getMCAEIsCreateable result',result);
|
this.lineAddBtn = this.PageDisabled || !result;
|
}).catch(error => {
|
}).finally(() => {
|
});
|
if (this.contract.Decided_Estimation__c || this.estimate.Process_Status__c && this.estimate.Process_Status__c != '草案中') {
|
// TODO 特別資格があれば 申請可能にする
|
this.ApprovalBtnNewDisabled = true;
|
}else{
|
getApprovalBtnNewDisabled({
|
}).then(result => {
|
this.ApprovalBtnNewDisabled = result;
|
console.log('getApprovalBtnNewDisabled this.ApprovalBtnNewDisabled',this.ApprovalBtnNewDisabled);
|
}).catch(error => {
|
}).finally(() => {
|
});
|
}
|
// 报价规则改善 20230713 start
|
if (result.isAgreeRenewTen == true) {
|
this.AgreeRenewTenDisabled = false;
|
}else{
|
this.AgreeRenewTenDisabled = true;
|
}
|
this.refreshAssetBtn = this.SaveBtnDisabled;
|
console.log('this.refreshAssetBtn ',this.refreshAssetBtn);
|
this.refreshAssetBtnLWC = this.refreshAssetBtn;
|
this.recordId = this.allData.targetEstimateId;
|
this.IsRefresh = true;
|
}
|
pageBtnDiasbled(){
|
console.log('pageBtnDiasbled');
|
this.IsTop = this.pageCount == 0 || this.currentPage == 1;
|
this.IsPre = this.pageCount == 0 || this.currentPage == 1;
|
this.IsNext = this.pageCount == 0 || this.currentPage == this.pageCount;
|
this.IsEnd = this.pageCount == 0 || this.currentPage == this.pageCount;
|
}
|
//页面按钮禁用初始化
|
async calonLoad() {
|
console.log('calonLoad');
|
|
// refreshAsset 再次 空白期会被修改,实际显示值可能会与第一次计算不一致
|
this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
|
var RequestquotationAmount = this.estimate.Request_quotation_Amount__c;
|
var AssetRepairSumPrice = this.estimate.Asset_Repair_Sum_Price__c;
|
var Limit_Price_Amount = (this.localParseFloat(AssetRepairSumPrice)+this.localParseFloat(RequestquotationAmount))*1.3;
|
Limit_Price_Amount = Math.round(Limit_Price_Amount);
|
var Limit_Price_AmountOne = this.estimate.Limit_Price_Amount__c;
|
var Limit_PriceHidden = this.allData.OldLimitPrice;
|
if (Limit_PriceHidden*1==0) {
|
this.estimate.Limit_Price_Amount__c = Limit_Price_Amount;
|
}
|
var Limit_PriceHidden2 = this.allData.isLimitPrice;
|
if (Limit_PriceHidden2 == false) {
|
this.estimate.Limit_Price_Amount__c = '';
|
}
|
var Price111 = this.estimate.Limit_Price_Amount__c;
|
await this.pageSetDisabled();
|
var createdDate = new Date(this.estimate.CreatedDate);
|
// 报价中设备的机身编码为空时的新品合同有效期延长 20200710 gzw
|
var aLLManual = 'true';
|
var cntWithKara = this.productCount;
|
for (var i = 0; i < cntWithKara; i++) {
|
var isManual = this.allData.checkedAssets[i].isManual;
|
if (isManual != true) {
|
aLLManual = 'false';
|
break;
|
}
|
}
|
var nowDate = new Date();
|
if (aLLManual == 'false') {
|
createdDate = createdDate.setMonth(createdDate.getMonth() + 3);
|
// FIX liang JSの時間って addMonthsないですか? そかも 1/1 なら、 4/1もだめですよ。
|
if (createdDate < Date.parse(nowDate)) {
|
this.SaveBtnDisabled = true;
|
this.ApprovalBtnDisabled = true;
|
this.SendEmailBtnDisabled = true;
|
if (await estimateUtility.toast.handleConfirmClick("已超过创建日3个月,是否更新报价?")) {
|
window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateVM#copyid="+this.allData.targetEstimateId;
|
location.reload();
|
return true;
|
} else {
|
if (!this.DecideBtnDisabled) {
|
// decide可能の場合、別途decideのチェックが必要、
|
// チェック後再度画面refreshされるため、decide可能の場合、decideボタンが使えるようになります。
|
this.changeContractStartdate(this.estimate.Contract_Start_Date__c);
|
}
|
return false;
|
}
|
}
|
}else{
|
createdDate = createdDate.setMonth(createdDate.getMonth() + 6);
|
// FIX liang JSの時間って addMonthsないですか? そかも 1/1 なら、 4/1もだめですよ。
|
if (createdDate < Date.parse(nowDate)) {
|
this.SaveBtnDisabled = true;
|
this.ApprovalBtnDisabled = true;
|
this.SendEmailBtnDisabled = true;
|
if (await estimateUtility.toast.handleConfirmClick("已超过创建日6个月,是否更新报价?")) {
|
window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateVM#copyid="+this.allData.targetEstimateId;
|
location.reload();
|
return true;
|
} else {
|
if (!this.DecideBtnDisabled) {
|
// decide可能の場合、別途decideのチェックが必要、
|
// チェック後再度画面refreshされるため、decide可能の場合、decideボタンが使えるようになります。
|
this.changeContractStartdate(this.estimate.Contract_Start_Date__c);
|
}
|
return false;
|
}
|
}
|
}
|
if (!this.DecideBtnDisabled) {
|
this.allData.OldMaintenancePrice = this.estimate.Maintenance_Price__c;
|
}
|
}
|
|
pageSetDisabled(){
|
console.log('pageSetDisabled');
|
|
var hasSendEmail = this.allData.hasSendEmail;
|
if(hasSendEmail == true){
|
this.SendEmailBtnDisabled = true;
|
}
|
|
var isDisabled = this.PageDisabled;
|
if (isDisabled) {
|
|
|
this.IsContractEstiStartDateDisabled = true;
|
|
var rowCnt = this.productCount;
|
for (var i = 0; i < rowCnt; i++) {
|
|
var isManual = this.allData.checkedAssets[i].isManual;
|
if (isManual == true) {
|
this.allData.checkedAssets[i].IsAssertDisabled = true;
|
}
|
this.allData.checkedAssets[i].CheckRows = true;
|
this.allData.checkedAssets[i].IsRepairPriceDisabled = true;
|
this.allData.checkedAssets[i].ISCommentDisabled = true;
|
this.allData.checkedAssets[i].IsThirdPartyReturnDisabled = true;
|
}
|
this.IsRequestQuotationAmountDisabled = true;
|
this.IsContractstartdateDisabled = true;
|
var target = this.estimate.Estimate_Target__c;
|
if (target != '医院') {
|
this.IsDealerDisabled = true;
|
}
|
}
|
if (!this.DecideBtnDisabled) {
|
this.IsContractstartdateDisabled = false;
|
// 2023/09/06 报价规则改善空白期 start +-
|
var renewTenOFF = this.estimate.renewTen_OFF__c;
|
var startime1 = new Date(this.allData.Past_Contract_end_day);
|
var startime2 = new Date(this.estimate.Contract_Esti_Start_Date__c);
|
var result = (startime2-startime1)/(3600*24*1000);
|
var VMProductCountAll = this.allData.VMProductCountAll;
|
var ProductCountAll = this.allData.ProductCountAll;
|
console.log('VMProductCountAll',VMProductCountAll);
|
console.log('ProductCountAll',ProductCountAll);
|
// 不能 添加有值判定
|
if (VMProductCountAll ==ProductCountAll) {
|
result = 0;
|
}
|
console.log('result',result);
|
|
if (renewTenOFF) {
|
if (result==0) {
|
}else{
|
this.IsContractstartdateDisabled = true;
|
}
|
}
|
// 报价规则改善空白期 end
|
}
|
//补充页面数据处理
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
}
|
//
|
async changeContractStartdate(val) {
|
var oldDateStr = this.estimate.Contract_Start_Date__c;
|
console.log('changeContractStartdate oldDateStr',oldDateStr);
|
console.log('changeContractStartdate Date',new Date(this.estimate.Contract_Start_Date__c));
|
var oldDate = new Date();
|
if (oldDateStr != null && oldDateStr != '') {
|
oldDate = new Date(oldDateStr);
|
}
|
if (!this.DecideBtnDisabled) {
|
var monthStr = '00' + (oldDate.getMonth()+1);
|
monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
|
var dayStr = '00' + oldDate.getDate();
|
dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
|
var oldDateVal = oldDate.getFullYear() + '/' + monthStr + '/' + dayStr;
|
this.allData.OldContractStartDate = oldDateVal;
|
if (await this.saveBeforeCheckPriceChange()) {
|
}
|
this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
} else {
|
var cntWithKara = this.productCount;
|
var haveLine = 'false';
|
for (var i = 0; i < cntWithKara; i++) {
|
var isManual = this.allData.checkedAssets[i].isManual;
|
if (isManual) {
|
//Assert_lkid id未找到
|
} else {
|
haveLine = 'true';
|
}
|
}
|
if (haveLine == 'false') {
|
return false;
|
}
|
var contractStartDate = new Date(val);
|
var strCreatedDate = this.estimate.CreatedDate;
|
var createDate = new Date();
|
if (strCreatedDate != '') {
|
createDate = new Date(strCreatedDate);
|
}
|
createDate = new Date(createDate.toDateString());
|
var threeMA = new Date(createDate.setMonth(createDate.getMonth() + 3));
|
var isnewMA = new Date(createDate.setMonth(createDate.getMonth() - 3 - this.allData.isNewAddMonth));
|
this.estimate.Contract_Start_Date__c = val;
|
this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
}
|
}
|
//分页Limit
|
get pageDataLimitOptions() {
|
return [
|
{ label: '10', value: '10' },
|
{ label: '20', value: '20' },
|
{ label: '50', value: '50' },
|
{ label: '100', value: '100' },
|
{ label: '200', value: '200' },
|
];
|
}
|
handlePageLimitChange(event) {
|
this.IsLoading = true;
|
// this.allDataInfo();
|
this.pageDataLimit = event.detail.value;
|
this.allData.selRecordOption = event.detail.value;
|
this.allData.selctRecordNum = this.allData.selRecordOption *1;
|
|
this.currentPage = 1;
|
this.allData.currPage = 1;
|
// this.getUnCheckedAssetNowData();
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
|
this.IsLoading = false;
|
}
|
//首页
|
toTop(event) {
|
this.IsLoading = true;
|
|
// 前端 处理
|
this.currentPage = 1;
|
this.allData.currPage = 1;
|
// this.getUnCheckedAssetNowData();
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
this.IsLoading = false;
|
}
|
//上一页
|
toPre(event) {
|
this.IsLoading = true;
|
// currentPage 后台未对currentPage值判断,补充--页面禁用
|
if (this.currentPage <= 1) {
|
this.IsLoading = false;
|
return;
|
} else {
|
this.currentPage--;
|
}
|
|
this.allData.currPage = this.currentPage;
|
// this.getUnCheckedAssetNowData();
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
this.IsLoading = false;
|
}
|
//下一页
|
toNext(event) {
|
this.IsLoading = true;
|
if (this.currentPage >= this.pageCount) {
|
this.IsLoading = false;
|
return;
|
} else {
|
this.currentPage++;
|
}
|
|
this.allData.currPage = this.currentPage;
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
this.IsLoading = false;
|
}
|
//尾页
|
toEnd(event) {
|
this.IsLoading = true;
|
|
this.currentPage = this.pageCount;
|
this.allData.currPage = this.currentPage;
|
// this.getUnCheckedAssetNowData();
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
this.IsLoading = false;
|
}
|
//分页后台数据返回后处理
|
handlePageBtnReturn(result){
|
result = JSON.parse(result);
|
this.allData = result;
|
//页面相关数据初始化
|
this.handleInitSimpleData(result);
|
//unCheckedAssets 处理
|
this.handleunCheckedAssetColumnsAndData(result.unCheckedAssets);
|
this.IsLoading = false;
|
}
|
|
//保有设备 搜索条件
|
get textOpts() {
|
return [
|
{ label: '主机/耗材', value: 'S:AssetMark__c' },
|
{ label: '保有设备名', value: 'S:Name' },
|
{ label: '机身编码', value: 'S:SerialNumber' },
|
{ label: '最近一期维修合同', value: 'S:CurrentContract__r.Management_Code__c' },
|
{ label: '装机地点', value: 'S:Installation_Site__c' },
|
{ label: '科室', value: 'S:Department_Name__c' },
|
];
|
}
|
get equalOpts() {
|
return [
|
{ label: '等于', value: 'equals' },
|
{ label: '包含', value: 'contains' },
|
{ label: '不等于', value: 'notequals' },
|
];
|
}
|
//获取当前未选择的保有设备--util
|
getUnCheckedAssetNowData(){
|
if(this.unCheckedAssetData && this.unCheckedAssetData.length > 0){
|
this.unCheckedAssetNowData = this.unCheckedAssetData.slice((this.currentPage-1)*this.allData.selRecordOption,this.currentPage*this.allData.selRecordOption);
|
// this.unCheckedAssetNowData = this.unCheckedAssetData;
|
}else{
|
this.unCheckedAssetNowData = [];
|
}
|
|
this.unCheckedAssetDataLength = this.unCheckedAssetData.length;
|
this.pageCount = Math.ceil(this.unCheckedAssetData.length / this.allData.selRecordOption);
|
this.allData.currPage = this.currentPage;
|
// 下方文字 所在位置
|
this.unCheckedAssetDataShow1 = (this.currentPage-1)*this.pageDataLimit;
|
// 数据下标 -1(最后一条数据位置)
|
this.unCheckedAssetDataShow2 = this.currentPage*this.pageDataLimit >= this.allData.totalRecords ? this.allData.totalRecords : this.currentPage*this.pageDataLimit - 1;
|
this.pageBtnDiasbled();
|
}
|
handleTableUncheckedRecCheckBox(event) {
|
let index = event.currentTarget.dataset.id;
|
console.log('handleTableUncheckedRecCheckBox index',index);
|
this.allData.unCheckedAssets.forEach(function(ar) {
|
if (ar.rec.Id == index) {
|
ar.rec_checkBox_c = event.detail.checked;
|
console.log('ar.rec_checkBox_c',ar.rec_checkBox_c);
|
}
|
});
|
}
|
|
//报价提交对象 变更 --util
|
controlDisabled(event) {
|
window.open("/apex/ChangeDealerApproval?eid=" + this.recordId,'ChangeDealerApproval','height=300,width=700,toolbar=no,menubar=no,left=20%,top=30%,scrollbars=yes,resizable=no,location=no,status=no');
|
}
|
//服务合同 内容修改 todo 通过传入参数,制定字段值
|
changeDepartment(event) {
|
this.estimate.Department__c = event.detail.value;
|
}
|
//合同开始预订日
|
changeEstiStartdate(event) {
|
this.IsRefresh = false;
|
let val = event.detail.value;
|
this.estimate.Contract_Esti_Start_Date__c = event.detail.value;
|
// 2023/09/01 合同结束预订日 显示同步
|
// 报价规则改善 20230310 start val 2022-12-12
|
var startday = estimateUtility.handleInfo.addMonths(val,6);
|
var startday1 = estimateUtility.handleInfo.addMonths(val,12);
|
// del startdateaddsix1-3 seamlessRenew 会重新赋值,这里给值无意义 - page好像有改动逻辑?简单看了下逻辑,依旧会重新赋值
|
this.allData.startdateaddsix1 = startday;
|
this.allData.startdateaddsix2 = startday;
|
this.allData.startdateaddsix3 = startday1;
|
this.allData.startdateaddsix4 = val;
|
console.log('this.allData.startdateaddsix1 ',this.allData.startdateaddsix1 );
|
console.log('this.allData.startdateaddsix2 ',this.allData.startdateaddsix2 );
|
console.log('this.allData.startdateaddsix3 ',this.allData.startdateaddsix3 );
|
console.log('this.allData.startdateaddsix4 ',this.allData.startdateaddsix4 );
|
var rowCnt = this.productCount;
|
this.allDataInfo();
|
let returnData = estimateUtility.handleInfo.seamlessRenew(this,rowCnt,this.allData,this.allData.checkedAssets,this.PageDisabled,this.IsContractEstiStartDateDisabled);
|
this.allData = returnData.allData;
|
this.allData.checkedAssets = returnData.checkedAssets;
|
this.handleInitSimpleData(this.allData);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
// 2023/09/18 seamlessRenew 可能修改 IsContractEstiStartDateDisabled 值,handleInitSimpleData中未处理该禁用
|
this.IsContractEstiStartDateDisabled = returnData.IsContractEstiStartDateDisabled;
|
// 报价规则改善 20230310 end
|
if (!this.SaveBtnDisabled) {
|
this.estimate.Contract_Start_Date__c =val;
|
this.changeContractStartdate(val);
|
}
|
this.makeRealPrice(1);
|
this.IsRefresh = true;
|
}
|
// == checkContractRange
|
handleChangeContractRange(event) {
|
let errorMsg = '';
|
//页面 required
|
if (isNaN(parseInt(event.target.value))) {
|
errorMsg = '必须输入合同月数!';
|
}else if (event.target.value <= 0) {
|
errorMsg = '合同月数必须大于0';
|
}else if (event.target.value > 60) {
|
errorMsg = '合同期最长只能选择60个月!';
|
}
|
if (errorMsg != '') {
|
estimateUtility.toast.showToast(this, 'error', errorMsg);
|
//页面值同步刷新
|
event.target.value = null;
|
}
|
this.estimate.Contract_Range__c = event.target.value;
|
// 2023/09/01 合同结束预订日 显示同步
|
// this.handleChangeContractEstiEndDate(this.estimate.Contract_Esti_Start_Date__c);
|
console.log('this.estimate.Contract_Range__c',this.estimate.Contract_Range__c);
|
//页面数据刷新 --checkAssetData reresh
|
this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
}
|
//合同结束预订日 - 有计算逻辑,填写无意义 -> 同步 初步计算
|
handleChangeContractEstiEndDate(val) {
|
console.log('handleChangeContractEstiEndDate');
|
if (this.estimate.Contract_Esti_Start_Date__c && this.estimate.Contract_Range__c) {
|
let datearr = val.split("-");//基础日期
|
let months = this.estimate.Contract_Range__c *1;//增加月数 *1 转Number
|
let year = parseInt(datearr[0]);
|
let month = parseInt(datearr[1][0] == 0 ? datearr[1][1] : datearr[1]) - 1;
|
let day = parseInt(datearr[2][0] == 0 ? datearr[2][1] : datearr[2]);
|
year += Math.floor((month + months) / 12); //计算年
|
month = Math.floor((month + months) % 12) + 1; //计算月
|
let d_max = new Date(year + "/" + (month + 1) + "/0").getDate(); //获取计算后的月的最大天数
|
if (day > d_max) {
|
day = d_max;
|
}
|
|
let date = year + "-" + (month < 10 ? ("0" + month) : month) + "-" + (day < 10 ? ("0" + day) : day);
|
this.estimate.Contract_Esti_End_Date__c = date;
|
|
}
|
console.log('this.estimate.Contract_Esti_End_Date__c',this.estimate.Contract_Esti_End_Date__c);
|
}
|
//报价提交对象
|
handleChangeEstimateTarget(event) {
|
this.estimate.Estimate_Target__c = event.detail.value;
|
//resetDealer 处理页面隐藏
|
this.handleEstimateTargetIsHospitalTrue();
|
}
|
handleEstimateTargetIsHospitalTrue(){
|
this.EstimateTargetIsDealer = this.estimate.Estimate_Target__c == '经销商';
|
}
|
//==onChDealerUpdateJs 报价提交对象 为经销商 才能触发该事件
|
handleChangeDealer(event) {
|
this.estimate.Dealer__c = event.detail.value[0] ? event.detail.value[0] : '';
|
onChDealerUpdate({
|
estimateStr: JSON.stringify(this.estimate),
|
checkDealerId : this.estimate.Dealer__c
|
}).then(result => {
|
if (result != null) {
|
this.estimate = JSON.parse(result);
|
}
|
}).catch(error => {
|
}).finally(() => {
|
if (this.estimate.Is_RecognitionModel__c) {
|
estimateUtility.toast.showToast(this, 'warning', '请注意,当前经销商为先款对象。');
|
}
|
});
|
|
}
|
//申请报价金额
|
checkDiscount(event) {
|
console.log('checkDiscount');
|
console.log('event.detail.value;',event.currentTarget.value);
|
// this.IsRefresh = false;
|
let val = event.currentTarget.value;
|
this.estimateTemp = {Request_quotation_Amount__c : Math.round(val)};
|
if (!val) {
|
val = '';
|
this.estimate.Request_quotation_Amount__c = "";
|
this.estimate.Service_discount_Rate__c = 0.00;
|
this.IsRefresh = true;
|
return;
|
}
|
// 非数字,并不会触发,页面会有提示
|
if (isNaN(parseInt(val))) {
|
estimateUtility.toast.showToast(this, 'error', '请输入数值');
|
val = 0.00;
|
this.estimate.Request_quotation_Amount__c = 0.00;
|
this.IsRefresh = true;
|
return;
|
}
|
this.allDataInfo();
|
let returnData = estimateUtility.handleInfo.checkDiscount(this,val,this.allData,this.IsContractEstiStartDateDisabled,this.IsContractstartdateDisabled,this.IsRequestQuotationAmountDisabled,this.refreshAssetBtn,this.AgreeRenewTenDisabled);
|
|
this.allData = returnData.allData;
|
this.handleInitSimpleData(this.allData);
|
this.IsContractEstiStartDateDisabled = returnData.IsContractEstiStartDateDisabled;
|
this.IsContractstartdateDisabled = returnData.IsContractstartdateDisabled;
|
this.IsRequestQuotationAmountDisabled = returnData.IsRequestQuotationAmountDisabled;
|
this.refreshAssetBtn = returnData.refreshAssetBtn;
|
this.isAgreeRenew = returnData.isAgreeRenew;
|
this.refreshAssetBtnLWC = this.refreshAssetBtn;
|
console.log('Until checkDiscount after',returnData.AgreeRenewTenDisabled);
|
this.AgreeRenewTenDisabled = returnData.AgreeRenewTenDisabled;
|
this.makeRealPrice(1);
|
|
//上限金额清空
|
this.estimate.Limit_Price_Amount__c = '';
|
// this.estimate.Request_quotation_Amount__c = Math.round(val);
|
// event.detail.value = this.estimate.Request_quotation_Amount__c;
|
console.log('this.estimate.Request_quotation_Amount__c final',this.estimate.Request_quotation_Amount__c);
|
this.estimate.Request_quotation_Amount__c = 0;
|
console.log('this.estimate.Request_quotation_Amount__c 0',this.estimate.Request_quotation_Amount__c);
|
|
this.event1 = setTimeout(() => {
|
if (this.isAgreeRenew) {
|
this.estimate.Request_quotation_Amount__c = Math.round(val*0.9);
|
}else{
|
this.estimate.Request_quotation_Amount__c = Math.round(val);
|
}
|
this.estimate.Limit_Price_Amount__c = (this.localParseFloat(this.estimate.Asset_Repair_Sum_Price__c)+this.localParseFloat(this.estimate.Request_quotation_Amount__c))*1.3; //zzm 20240117 上限金额bug
|
console.log('setTimeout',this.estimate.Request_quotation_Amount__c);
|
}, 1);
|
console.log('this.estimate.Request_quotation_Amount__c 01',this.estimate.Request_quotation_Amount__c);
|
|
this.estimate = JSON.parse(JSON.stringify(this.estimate));
|
console.log('this.estimate.Request_quotation_Amount__c 02',this.estimate.Request_quotation_Amount__c);
|
|
// this.IsRefresh = true;
|
}
|
|
get quotationAmount(){
|
return this.estimateTemp.Request_quotation_Amount__c;
|
}
|
// 上限金额
|
handleLimitPriceAmount(event) {
|
console.log('handleLimitPriceAmount',event.currentTarget.value);
|
// this.estimate.Limit_Price_Amount__c = event.detail.value;
|
let num = event.currentTarget.value;
|
this.estimate.Limit_Price_Amount__c = 0;
|
this.event1 = setTimeout(() => {
|
// this.estimate.AgencyHos_Price__c = num.toFixed(2);
|
this.estimate.Limit_Price_Amount__c = Math.round(num);
|
|
console.log('this.estimate.Limit_Price_Amount__c event1',this.estimate.Limit_Price_Amount__c);
|
}, 1);
|
|
this.estimate = JSON.parse(JSON.stringify(this.estimate));
|
console.log('this.estimate.AgencyHos_Price__c',this.estimate.Limit_Price_Amount__c);
|
|
}
|
/*
|
* @param t 1: 金額により割引
|
*/
|
makeRealPrice(t) {
|
|
// 実際金額合計
|
// 申请报价金额
|
var sum1 = this.localParseFloat(this.estimate.Request_quotation_Amount__c);
|
// 修理总额
|
var sum2 = this.estimate.Asset_Repair_Sum_Price__c ? this.estimate.Asset_Repair_Sum_Price__c : null ;
|
//*1 避免NaN
|
var sum1 = this.localParseFloat(sum1*1);
|
// 上限
|
var upPrice = this.estimate.GuidePrice_Up__c;
|
upPrice = this.localParseFloat(upPrice*1);
|
// 下限
|
var downPrice = this.estimate.GuidePrice_Down__c;
|
downPrice = this.localParseFloat(downPrice*1);
|
|
// 相对标准价格范围的折扣率 计算
|
// 1)标准价格范围内时,结果为0;
|
// 2)比标准价格低时,结果是1-希望价格/标准价的最低价格
|
// 3)比标准价格高时,结果是1-希望价格/标准价的最高价格
|
var disMP = 0.00;
|
var disP = this.estimate.Service_discount_Rate__c;
|
|
if(sum1 < downPrice){
|
disMP = ((1 - sum1/downPrice) * 100)*1;
|
}else if(sum1 >= downPrice && sum1 <= upPrice){
|
disMP = 0.00;
|
}else if(sum1 > upPrice){
|
disMP = 1*((1 - sum1/upPrice) * 100);
|
}
|
//出现精度浮动
|
|
if (disMP != disP) {
|
disMP = '' + disMP.toFixed(2) + '%';
|
// 20% -parseFloat = 20
|
this.estimate.Service_discount_Rate__c = parseFloat(disMP);
|
}
|
// 修理総額を計上
|
let sum = sum1 + this.localParseFloat(sum2*1);
|
this.estimate.Maintenance_Price__c = sum*1;
|
}
|
//最终价格决定形式
|
handleFinalPriceDecideWay(event) {
|
this.estimate.finalPriceDecideWay__c = event.detail.value;
|
}
|
//是否销售附带
|
handleSalesIncidental(event) {
|
this.estimate.Sales_incidental__c = event.detail.checked;
|
}
|
//主要谈判次数
|
handleMainTalksTime(event) {
|
this.estimate.mainTalksTime__c = event.detail.value;
|
}
|
//谈判的开始时间
|
handleTalksStartDate(event) {
|
this.estimate.talksStartDate__c = event.detail.value;
|
}
|
//经销商和医院的价格 classic 保存两位小数,四舍五入 页面显示依旧是多位,但实际值已经变化(classic效果)
|
handleAgencyHosPrice(event) {
|
let num = event.currentTarget.value * 1;
|
// event
|
this.estimate.AgencyHos_Price__c = num.toFixed(2);
|
console.log('this.handleAgencyHosPrice.AgencyHos_Price__c',this.estimate.AgencyHos_Price__c);
|
}
|
//价格申请理由
|
handleDiscountReason(event) {
|
this.estimate.Discount_reason__c = event.detail.value;
|
}
|
//消费率改善方案
|
handleImproveConsumptionRateIdea(event) {
|
this.estimate.Improve_ConsumptionRate_Idea__c = event.detail.value;
|
}
|
//打印报价 复选框选择 单选
|
handleSimply(event){
|
let param = event.currentTarget.dataset.param;
|
this.estimate[param] = event.detail.checked;
|
this.printFlag = false;
|
let paramsList = ["Print_ListPrice__c","Print_Simplify__c","Print_RepairPrice__c","Print_SumPrice__c"];
|
for (var i = 0; i < paramsList.length; i++) {
|
if (param != paramsList[i]) {
|
this.estimate[paramsList[i]] = false;
|
}
|
}
|
this.printFlag = true;
|
}
|
//三方协议
|
handlePrintContract(event) {
|
let param = event.currentTarget.dataset.param;
|
this.estimate[param] = event.detail.checked;
|
}
|
//合同开始日
|
handleContractStartDate(event) {
|
this.estimate.Contract_Start_Date__c = event.detail.value;
|
//changeContractStartdate
|
this.changeContractStartdate(this.estimate.Contract_Start_Date__c);
|
}
|
//无缝续签折扣
|
handleRenewTenOFF(event) {
|
this.estimate.renewTen_OFF__c = event.detail.checked;
|
console.log('this.estimate.renewTen_OFF__c',this.estimate.renewTen_OFF__c);
|
}
|
handleAgreeRenewTenOFF(event) {
|
this.estimate.AgreeRenewTen_OFF__c = event.detail.checked;
|
}
|
//保存
|
async handleSave(event){
|
//onclick
|
this.IsLoading = true;
|
let resEGFlgconfim = await this.EGFlgconfim('【贸易合规】--服务报价保存涉及警示产品');
|
if (resEGFlgconfim) {
|
this.allDataInfo();
|
// 2023/09/18 unCheckedAssets 后台方法未涉及该属性,直接置空,避免数据量过大,如果后台返回异常信息,则将原数据重新赋值
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
|
let saveDataStr = JSON.stringify(this.allData);
|
console.log('handleSave');
|
await save({
|
saveData: saveDataStr,
|
}).then(result => {
|
console.log('handleSave result',result);
|
if (result != null && result.indexOf('completion=5') != -1) {
|
//重新跳转该页面 携带参数
|
estimateUtility.toast.showToast(this, 'success', '保存好了');
|
window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateVM#id="+result.split('/')[1];
|
location.reload();
|
}else{
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值 - 页面数据并没有更改(未调用 handleunCheckedAssetColumnsAndData),页面数据不会异常
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
this.IsLoading = false;
|
});
|
//oncomplete
|
this.unblockUI();
|
}
|
this.IsLoading = false;
|
}
|
//
|
async EGFlgconfim(title) {
|
await this.getEstimateCost();
|
var cntWithKara = this.productCount;
|
// 新合同备品确保提供 是否改变
|
var alert1s = 0;
|
//20231222
|
var tradeTwoFlag = false;
|
var AccDealerBlacklist2 = this.contract.AccDealerBlacklist2__c; //WYL 贸易合规2期 黑名单,警示名单
|
var TradeComplianceStatusFlagFW = this.allData.TradeComplianceStatusFlagFW; //贸易合规开关
|
var violationName ='' //违规产品型号
|
for (var i = 0; i < cntWithKara; i++) {
|
var isManual =this.allData.checkedAssets[i].isManual;
|
var EGFlgtxt =this.allData.checkedAssets[i].mcae.EquipmentGuaranteeFlgTxt__c;
|
var EGFlgnow =this.allData.checkedAssets[i].etGFlg;
|
//20231214 sx 贸易合规add
|
var checked = this.allData.checkedAssets[i].rec_checkBox_c;
|
//补充 undefined的判定
|
if (EGFlgtxt != undefined && EGFlgnow != undefined && EGFlgtxt != EGFlgnow) {
|
alert1s = 1;
|
}
|
//选中的设备 只要有一个不合规就弹出提醒
|
console.log('checked===='+checked);
|
if(checked){
|
console.log(this.allData.checkedAssets[i].rec.Product2);
|
var ProTradeComplianceStatus = this.allData.checkedAssets[i].rec.Product2.ProTradeComplianceStatus__c;
|
if(ProTradeComplianceStatus == '0' && checked){
|
tradeTwoFlag = true;
|
violationName += this.allData.checkedAssets[i].rec.Product2.Name + '、';
|
}
|
}
|
}
|
if (alert1s == 1) {
|
let confirmResult = await estimateUtility.toast.handleConfirmClick("选择的保有设备[新合同备品确保提供]发生变化,是否继续?");
|
if (!confirmResult) {
|
return false;
|
}
|
}
|
//20231214 sx 贸易合规add start
|
if(TradeComplianceStatusFlagFW){
|
if(AccDealerBlacklist2 =='3' || AccDealerBlacklist2 =='4' || AccDealerBlacklist2 =='24'){
|
estimateUtility.toast.showToast(this, 'error', '黑名单:存在贸易合规风险,无法新建,有问题请联系法务部贸易合规窗口恽李娜。');
|
this.EmailSending(1,null,null);
|
return null;
|
}else if(AccDealerBlacklist2 =='1' || AccDealerBlacklist2 =='2' || AccDealerBlacklist2 =='12'){
|
estimateUtility.toast.showToast(this, 'error', '冻结清单:可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法新建,有问题请联系法务部贸易合规窗口恽李娜。');
|
return null;
|
}else if(AccDealerBlacklist2 =='5' || AccDealerBlacklist2 =='6' || AccDealerBlacklist2 =='56'){
|
if(tradeTwoFlag){
|
this.EmailSending(2,title,violationName.slice(0, -1));
|
if (!(await estimateUtility.toast.handleConfirmClick('您此次申请的业务可能存在贸易合规风险,是否继续申请,如有问题请联系法务本部贸易合规窗口恽李娜进一步评估(一般需5-10个工作日)'))) {
|
this.unblockUI();
|
return null;
|
}
|
}
|
}
|
}
|
//20231214 sx 贸易合规add end
|
return this.onclickCheckchangedAfterPrint('true','true');
|
}
|
|
//2024-1-3 WYL 贸易合规2期 邮件 add start
|
async EmailSending(type,title,violation){
|
accSendEmailFW({
|
mcid : this.mcid,
|
titles :title,
|
type :type,
|
violationName:violation
|
})
|
.then(result=>{
|
return;
|
}).catch(err=>{
|
console.log('邮件错误'+err);
|
})
|
}
|
//2024-1-3 WYL 贸易合规2期 邮件 add end
|
//ok 获取实际报价金额 按照上限比例算
|
getEstimateCost() {
|
// 行数
|
var rowcount = this.productCount;
|
// 6.合同价格
|
var mainteReal = parseFloat(this.estimate.Maintenance_Price__c);
|
// 5.修理总额
|
var assetRepairSumPrice = parseFloat(this.estimate.Asset_Repair_Sum_Price__c);
|
// 计算实际报价总金额
|
var realprice = mainteReal - assetRepairSumPrice;
|
// 标准价格的最高价总额
|
var GuidePriceUp = parseFloat(this.estimate.GuidePrice_Up__c);
|
for (var i = 0; i < rowcount; i++) {
|
// 去上限价格
|
var assetListPrice = parseFloat(this.allData.checkedAssets[i].mcae.Adjustment_Upper_price__c);
|
if(GuidePriceUp == 0){
|
this.allData.checkedAssets[i].mcae.Estimate_Cost__c = 0;
|
}else{
|
var Estimate_Cost = (realprice * (assetListPrice / GuidePriceUp)).toFixed(2);
|
//parseFloat 可能会为NAN
|
this.allData.checkedAssets[i].mcae.Estimate_Cost__c = isNaN(Estimate_Cost) ? 0 : Estimate_Cost;
|
}
|
}
|
}
|
//
|
async onclickCheckchangedAfterPrint(saveBtnDisabled, saveOrApproval) {
|
console.log('onclickCheckchangedAfterPrint');
|
var cntWithKara = this.productCount;
|
var alerts = 0;
|
// 新合同备品确保提供 是否改变
|
var alert1s = 0;
|
var today = new Date();
|
today.setMonth(today.getMonth() - 3);
|
|
for (var i = 0; i < cntWithKara; i++) {
|
var isManual = this.allData.checkedAssets[i].isManual;//value boolean
|
|
if (isManual) {
|
//原页面未找到对应id Assert_lkid
|
}
|
if (!isManual) {
|
var strDate = this.allData.checkedAssets[i].rec.Final_Examination_Date__c ? this.allData.checkedAssets[i].rec.Final_Examination_Date__c : '';
|
|
strDate = strDate.replace(/(^\s*)|(\s*$)/g, "");
|
if (strDate == "" || Date.parse(strDate) < Date.parse(today)) {
|
alerts = 1;
|
}
|
}
|
}
|
|
if (alerts == 1) {
|
let confirmResult = await estimateUtility.toast.handleConfirmClick("选择的保有设备[最后点检日]为空或已经超过三个月之前,是否继续?");
|
|
if (!confirmResult) {
|
return false;
|
}
|
}
|
if (saveOrApproval == "true") {
|
if (await this.saveBeforeCheckPriceChange()) {
|
let confirmResult = await estimateUtility.toast.handleConfirmClick("行信息有变化(服务合同价格),是否更新报价?");
|
|
if (confirmResult) {
|
this.allData.changedSubmitPrice = true;
|
}else{
|
this.allData.changedSubmitPrice = false;
|
this.unblockUI();
|
return false;
|
}
|
}
|
this.allData.isSaveOrApproval = true;
|
|
}
|
return true;
|
}
|
//
|
unblockUI(){
|
// 2021、8、26 合同报价页面的优化,无保有设备点检对象选择框变黑 fxk star
|
// disable1();
|
// 2021、8、26 合同报价页面的优化,无保有设备点检对象选择框变黑 fxk end
|
this.pageSetDisabled();
|
var isChange = this.allData.changedSubmitPrice;
|
if (isChange) {
|
this.allData.changedSubmitPrice = false;
|
//页面数据刷新 --checkAssetData reresh 后handleCheckedAssetColumnsAndData
|
this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
}
|
//未找到该id
|
|
}
|
//
|
async saveBeforeCheckPriceChange() {
|
console.log('saveBeforeCheckPriceChange');
|
var needClearId = false;
|
//this.productCount => this.allData.productCount
|
var rowCnt = this.productCount;
|
var assIds = "";
|
var proIds = "";
|
var priceMap = new Map();
|
var newProductMap = new Map();
|
var newProductCheck = false;
|
var nowDate = new Date();
|
var createdDate = null;
|
var createdDateShow = this.estimate.CreatedDate;
|
var contractDate = new Date(this.estimate.Contract_Start_Date__c);
|
if (createdDateShow && createdDateShow.trim() != '') {
|
createdDate = new Date(createdDateShow);
|
newProductCheck = true;
|
} else {
|
createdDate = new Date();
|
}
|
var threeMonthAfter = new Date(createdDate.setMonth(createdDate.getMonth() + 3));
|
createdDate = new Date(createdDate.setMonth(createdDate.getMonth() - 3));
|
for (var i = 0; i < rowCnt; i++) {
|
var isManual = this.allData.checkedAssets[i].isManual;
|
//mcae 不会为null
|
var isnew = this.allData.checkedAssets[i].mcae.IsNew__c;
|
var price = this.allData.checkedAssets[i].mcae.Estimate_List_Price__c ;
|
if (isManual) {
|
var a = this.allData.checkedAssets[i].mcae.Product_Manual__c;
|
//补充 a 有值的判定
|
if ( a != "000000000000000000" && a != "" && a) {
|
if (proIds == "") {
|
proIds = "'" + a + "'";
|
} else {
|
proIds = proIds + ",'" + a + "'";
|
}
|
if (isnew) {
|
priceMap.set(a, price/this.allData.isNewPriceAdj);
|
} else {
|
priceMap.set(a, price);
|
}
|
newProductMap.set(a, isnew);
|
|
} else {
|
continue;
|
}
|
}else {
|
var aId = this.allData.checkedAssets[i].rec.Id;
|
if (assIds == "") {
|
assIds = "'" + aId + "'";
|
} else if (aId) {////补充 aId 有值的判定
|
assIds = assIds + ",'" + aId + "'";
|
}
|
if (isnew) {
|
priceMap.set(aId, price/this.allData.isNewPriceAdj);
|
} else {
|
priceMap.set(aId, price);
|
}
|
newProductMap.set(aId, isnew);
|
}
|
}
|
|
// 选择设备后价格变更check
|
if (assIds.length > 0) {
|
//后台查询1
|
await saveBeforeCheckPriceChangeAsset({
|
assIds : assIds
|
}).then(asList => {
|
|
if (asList != null) {
|
for(var i=0;i<asList.length;i++) {
|
var asvar = asList[i];
|
var asId = asvar["Id"];
|
var mprice = asvar["Maintenance_Price_Month__c"];
|
var ptDt = asvar["Posting_Date__c"];
|
var postingDate = null;
|
if (ptDt != null && ptDt != '') {
|
postingDate = new Date(ptDt);
|
}
|
var inDt = asvar["InstallDate"];
|
var installDate = null;
|
if (inDt != null && inDt != '') {
|
installDate = new Date(inDt);
|
}
|
var priceShow = priceMap.get(asId);
|
var isNew = newProductMap.get(asId);
|
if (this.DecideBtnDisabled) {
|
if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
|
needClearId = true;
|
return needClearId;
|
}
|
}
|
}
|
}
|
}).catch(error => {
|
}).finally(() => {
|
});
|
}
|
console.log('proIds',proIds);
|
if (proIds.length > 0) {
|
if (!this.DecideBtnDisabled) {
|
var oldDateStr = this.estimate.Contract_Start_Date__c;
|
console.log('proIds oldDateStr',oldDateStr);
|
var oldDate = new Date();
|
if (oldDateStr != null && oldDateStr != '') {
|
oldDate = new Date(oldDateStr);
|
}
|
var crdt = new Date(this.estimate.CreatedDate);
|
var newContractDate = new Date(this.estimate.Contract_Start_Date__c);
|
var sixMonthAfter = new Date(crdt.setMonth(crdt.getMonth() + 6));
|
if ((newContractDate > sixMonthAfter && oldDate <= sixMonthAfter) || (newContractDate <= sixMonthAfter && oldDate > sixMonthAfter)) {
|
this.allData.changedAfterPrint = true;
|
return true;
|
}
|
} else {
|
//后台查询2
|
await saveBeforeCheckPriceChangeProduct2({
|
proIds : proIds
|
}).then(pdList => {
|
if (pdList != null) {
|
for(var i=0;i<pdList.length;i++) {
|
var pdvar = pdList[i];
|
var pdId = pdvar["Id"];
|
var mprice = pdvar["Maintenance_Price_Month__c"];
|
var priceShow = priceMap.get(pdId);
|
if (Number(mprice).toFixed(2) != Number(priceShow).toFixed(2)) {
|
needClearId = true;
|
return needClearId;
|
}
|
}
|
}
|
}).catch(error => {
|
}).finally(() => {
|
});
|
}
|
}
|
return needClearId;
|
}
|
|
// 不保存返回
|
cancel(event) {
|
if (this.allData.targetMaintenanceContractId) {
|
//返回原报价页面
|
this.navigateToOtherObj(this.allData.targetMaintenanceContractId);
|
}else{
|
location.reload();
|
}
|
}
|
// 保存返回
|
async handleSaveAndCancel(event){
|
this.IsLoading = true;
|
let resEGFlgconfim = await this.EGFlgconfim('【贸易合规】--服务报价保存涉及警示产品');
|
if (resEGFlgconfim) {
|
//onclick
|
let checkResult = await this.onclickCheckchangedAfterPrint('true','true');
|
if (checkResult) {
|
//修改值传回
|
this.allDataInfo();
|
// 2023/09/16 unCheckedAssets 后台方法未涉及该属性,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
//checkedAssets unCheckedAssetData 在更改的时候同步改动
|
let saveDataStr = JSON.stringify(this.allData);
|
console.log('saveDataStr',JSON.stringify(this.allData.estimate));
|
await saveAndCancel({
|
saveData: saveDataStr,
|
}).then(result => {
|
console.log('handleSaveAndCancel result',result);
|
if (result != null && result.indexOf('navigateTo') == -1) {
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}else if (result != null) {
|
this.navigateToOtherObj(result.split('=')[1]);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
});
|
}
|
}
|
this.IsLoading = false;
|
|
}
|
//行追加
|
handleAddNewRows(event){
|
this.IsLoading = true;
|
addNewRows({
|
checkedAssetsStr: JSON.stringify(this.allData.checkedAssets),
|
}).then(result => {
|
result = JSON.parse(result);
|
this.allData.checkedAssets = this.refreshAsset(result.length,result);
|
}).catch(error => {
|
}).finally(() => {
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
this.unblockUI();
|
this.IsLoading = false;
|
});
|
}
|
//合同对象设备 数据修改处理
|
handleTableProductManualChange(event) {
|
let index = event.currentTarget.dataset.index;
|
this.allData.checkedAssets[index].mcae.Product_Manual__c = event.detail.value[0] ? event.detail.value[0] : null;
|
refreshProductData({
|
checkedAssetsStr : JSON.stringify(this.allData.checkedAssets),
|
topProductModelStr : JSON.stringify(this.allData.TopProductModel),
|
productIdx : index,
|
isNewPriceAdj : this.allData.isNewPriceAdj,
|
}).then(result => {
|
result = JSON.parse(result);
|
console.log('handleTableProductManualChange result',result);
|
//对后台返回数据 进行处理
|
this.allData.checkedAssets = this.refreshAsset(result.length,result);
|
}).catch(error => {
|
}).finally(() => {
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
this.unblockUI();
|
});
|
}
|
//合同对象设备 机身编码跳转保有设备
|
handlePageNagivateTo(event) {
|
let param = event.currentTarget.dataset.param;
|
// console.log('index',param);
|
this.navigateToOtherObj(param);
|
}
|
//合同对象设备 全选
|
checkAllcheckedAsset(event){
|
this.IsCheckAllcheckedAsset = event.detail.checked;
|
for (var i = 0; i < this.allData.checkedAssets.length; i++) {
|
this.allData.checkedAssets[i].rec_checkBox_c = event.detail.checked;
|
}
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
}
|
handleTableRecCheckBox(event) {
|
let index = event.currentTarget.dataset.index;
|
this.allData.checkedAssets[index].rec_checkBox_c = event.detail.checked;
|
}
|
handleTableCheckObjectChange(event) {
|
let index = event.currentTarget.dataset.index;
|
this.allData.checkedAssets[index].mcae.Check_Object__c = event.detail.checked;
|
}
|
|
// ==changeAsset
|
async handleTableRepairPriceChange(event) {
|
// classic 参保修理金额 在实际保存时依旧只留两位小数
|
let num = event.currentTarget.value*1;
|
num = num.toFixed(2);
|
let index = event.currentTarget.dataset.index;
|
// event.detail.value = num;
|
this.allData.checkedAssets[index].mcae.Repair_Price__c = num;
|
//changeAsset 页面数据同步刷新--工具类中
|
this.allDataInfo();
|
console.log('this.allData.checkedAssets[index].mcae.Repair_Price__c before changeAsset',this.allData.checkedAssets[index].mcae.Repair_Price__c);
|
|
let changeAssetReturnData = await estimateUtility.handleInfo.changeAsset(this,this.allData.checkedAssets.length,this.allData.checkedAssets,this.PageDisabled,this.approvalDate,this.allData);
|
//changeAsset alert Info --工具类中alert
|
// estimateUtility.toast.showToast(this, 'error', '合同期最长只能选择60个月!');
|
this.allData = changeAssetReturnData.allData;
|
this.approvalDate = changeAssetReturnData.approvalDate;
|
// 仅保留两位小数
|
this.assetRepairSumNum = changeAssetReturnData.assetRepairSumNum.toFixed(2);
|
|
|
//页面相关数据初始化
|
this.handleInitSimpleData(this.allData);
|
this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
// examinationPriceCal(cnt);
|
this.getLastContractRate();
|
this.makeRealPrice(1);
|
//上限合同 20230214 hql start
|
var RequestquotationAmount = this.estimate.Request_quotation_Amount__c;
|
var AssetRepairSumPrice = this.estimate.Asset_Repair_Sum_Price__c;
|
var Limit_Price_Amount = (this.localParseFloat(AssetRepairSumPrice)+this.localParseFloat(RequestquotationAmount))*1.3;
|
Limit_Price_Amount = Math.round(Limit_Price_Amount);
|
var Limit_Price_AmountOne = this.estimate.Limit_Price_Amount__c;
|
var Limit_PriceHidden = this.allData.OldLimitPrice;
|
this.estimate.Limit_Price_Amount__c = Limit_Price_Amount;
|
var Limit_PriceHidden2 = this.allData.isLimitPrice;
|
if (Limit_PriceHidden2 == false) {
|
this.estimate.Limit_Price_Amount__c = '';
|
}
|
//上限合同 20230214 hql end
|
// 报价规则改善 20230315 start
|
this.allDataInfo();
|
let returnData = estimateUtility.handleInfo.seamlessRenew(this,this.allData.checkedAssets.length,this.allData,this.allData.checkedAssets,this.PageDisabled,this.IsContractEstiStartDateDisabled);
|
this.allData = returnData.allData;
|
this.handleInitSimpleData(this.allData);
|
this.allData.checkedAssets = returnData.checkedAssets;
|
// 2023/09/18 seamlessRenew 可能修改 IsContractEstiStartDateDisabled 值,handleInitSimpleData中未处理该禁用
|
this.IsContractEstiStartDateDisabled = returnData.IsContractEstiStartDateDisabled;
|
|
// 报价规则改善 20230315 end
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
this.makeRealPrice(1);
|
console.log('this.allData.checkedAssets[index].mcae.Adjustment_Lower_price__c before refresh',this.allData.checkedAssets[index].mcae.Adjustment_Lower_price__c);
|
// 刷新赋值
|
// num = this.allData.checkedAssets[index].mcae.Repair_Price__c;
|
// this.allData.checkedAssets[index].mcae.Repair_Price__c = 0;
|
// this.event1 = setTimeout(() => {
|
// this.allData.checkedAssets[index].mcae.Repair_Price__c = num.toFixed(2);
|
// }, 1);
|
// this.allData.checkedAssets[index].mcae = JSON.parse(JSON.stringify(this.allData.checkedAssets[index].mcae));
|
// console.log('this.allData.checkedAssets[index].mcae.Repair_Price__c',this.allData.checkedAssets[index].mcae.Repair_Price__c);
|
|
}
|
//page
|
getLastContractRate(){
|
var rowCnt = this.productCount;
|
var Contractrate = 0.00;
|
var count = 0;
|
for (var i = 0; i < rowCnt; i++) {
|
var LastMContractID = this.allData.checkedAssets[i].rec ? this.allData.checkedAssets[i].rec.CurrentContract_F__c : null;
|
if(LastMContractID){
|
var tempContractrate = parseFloat((this.allData.checkedAssets[i].mcae.Asset_Consumption_rate__c ? this.allData.checkedAssets[i].mcae.Asset_Consumption_rate__c : null)*1);
|
if(tempContractrate){
|
Contractrate = Contractrate + tempContractrate;
|
}
|
count++;
|
}
|
}
|
var allContractRate = '' + 0.00 + '%';
|
if( count > 0){
|
allContractRate = '' + (Contractrate/count).toFixed(2) + '%';
|
}
|
this.estimate.Combined_rate__c = parseFloat(allContractRate);
|
return allContractRate;
|
}
|
//合同对象设备 备注
|
handleTableCommentChange(event) {
|
let index = event.currentTarget.dataset.index;
|
this.allData.checkedAssets[index].mcae.Comment__c = event.detail.value;
|
}
|
//合同对象设备 第三方回归
|
handleTableThirdPartyReturnChange(event) {
|
let index = event.currentTarget.dataset.index;
|
this.allData.checkedAssets[index].mcae.Third_Party_Return__c = event.detail.checked;
|
}
|
// 合同对象设备 数据计算处理 todo 核对涉及变量
|
refreshAsset(cnt,checkedAssets) {
|
console.log('cnt',cnt);
|
// 提交后就页面不计算了
|
var isDisabled = this.PageDisabled;
|
// 报价页面【合同定价总额】字段添加 20230608 start
|
var TotalMaintenancePriceYear = 0.0;
|
// 报价页面【合同定价总额】字段添加 20230608 end
|
// 合同总理
|
var newCount = 0;
|
var isresduce = 0;
|
var oyearCount = 0;
|
var firstCCount = 0;
|
var conCCount = 0;
|
// row金額合計
|
var repairSum = 0;
|
var listSum = 0;
|
// 新品合同 判断
|
var newCon = true;
|
var contractStartDate = new Date(this.estimate.Contract_Start_Date__c);
|
|
//多年保续签合同数量 thh 20220316 start
|
var GuranteeCount = 0;
|
// 报价规则改善 20230310 start
|
// 2023/09/06 报价规则改善新增 - 显示页面部分整体处理
|
this.IsRenewTenOFFDisabled = true;
|
var renewTenOFF = this.estimate.renewTen_OFF__c;
|
|
// 2023/09/06 result 变量无意义,后面js 有同名变量重新赋值
|
var startime1 = new Date(this.allData.Past_Contract_end_day);
|
var startime2 = new Date(this.estimate.Contract_Esti_Start_Date__c);
|
var result = (startime2-startime1)/(3600*24*1000);
|
var VMProductCountAll = this.allData.VMProductCountAll;
|
var ProductCountAll = this.allData.VMProductCountAll;
|
if (VMProductCountAll ==ProductCountAll) {
|
result = 0;
|
}
|
|
if (renewTenOFF == true) {
|
this.IsContractEstiStartDateDisabled = true;
|
this.IsRequestQuotationAmountDisabled = true;
|
this.IsContractstartdateDisabled = true;
|
this.refreshAssetBtn = true;
|
this.refreshAssetBtnLWC = this.refreshAssetBtn;
|
//2023/09/06 同意无缝续签 禁用
|
this.AgreeRenewTenDisabled = true;
|
}
|
// 报价规则改善 20230310 end
|
//2022故障品加费 获取userInfo简档名称 是否为FSE start
|
var isFSE = this.allData.isFSE;
|
//2022故障品加费 获取userInfo简档名称 end
|
//20230208 上限合同开发 hql start
|
if (isFSE) {
|
this.IsLimitPriceAmountDisabled = true;
|
}
|
//20230208 上限合同开发 hql end
|
// 预定开始日
|
var startdate = new Date(this.estimate.Contract_Esti_Start_Date__c);
|
// 预定开始日-6个月
|
startdate.setMonth(startdate.getMonth() - 6);
|
// 申请日 当前日期
|
if(this.approvalDate != ''){
|
//申请日
|
this.approvalDate = new Date(this.approvalDate.toLocaleDateString());
|
if (Date.parse(this.approvalDate) < Date.parse(startdate)) {
|
newCon = false;
|
}
|
}
|
// 最高、最低价格合计
|
var downPriceSum = 0;
|
var upPriceSum = 0;
|
// 合同月数乗算 parseFloat(null.'',undefined) 为NAN 补充判断
|
var month = parseFloat(this.estimate.Contract_Range__c);
|
|
if (month == undefined || month == "" || isNaN(month)) {
|
month = 1;
|
}
|
var month2 = 0;
|
if (month > 12) {
|
month2 = month - 12;
|
month = 12;
|
}
|
for (var i = 0; i < cnt; i++) {
|
console.log('refreshAsset i'+i);
|
//字段按钮 默认可用
|
checkedAssets[i].ShowAssetSituation = true;
|
var strMoney = 0;
|
var repairMoney = 0;
|
// 行项目 最高、最低价格合计
|
// 续签价格取联动价格页面计算,首签或产品取 实际价格
|
// 下线价格
|
var downPrice = 0;
|
// 上线价格
|
var upPrice = 0;
|
// 12个月合同金额
|
var Price_YearTXT = 0;
|
var isManual = checkedAssets[i].isManual; //return boolean
|
var isnew = checkedAssets[i].mcae.IsNew__c; //return boolean
|
var assetListmonth = checkedAssets[i].mcae.Estimate_List_Price__c;
|
//市场多年保修价格开发 DC 2023/02/09 start
|
var VMassetListmonth = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F_asset__r ? checkedAssets[i].rec.CurrentContract_F_asset__r.Maintenance_Price_Year__c : '') : '';
|
//市场多年保修价格开发 DC 2023/02/09 end
|
// 报价页面【合同定价总额】字段添加 20230608 start
|
var Product2MaintenancePriceYear = checkedAssets[i].rec ? (checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Maintenance_Price_Year__c : '') : '';
|
//page outputField 原本就是 隐藏
|
Product2MaintenancePriceYear = this.localParseFloat(Product2MaintenancePriceYear);
|
TotalMaintenancePriceYear += Product2MaintenancePriceYear;
|
// 报价页面【合同定价总额】字段添加 20230608 end
|
if (isManual) {
|
var a = checkedAssets[i].mcae.Product_Manual__c ? checkedAssets[i].mcae.Product_Manual__c : '';
|
console.log('isManual true a',a);
|
if (a != '') {
|
strMoney = assetListmonth;
|
// alert(strMoney);
|
Price_YearTXT = strMoney * 12;
|
if (isnew) {
|
newCount ++;
|
strMoney = month * strMoney + month2 * strMoney / this.allData.isNewPriceAdj;
|
} else {
|
newCon = false;
|
strMoney = month * strMoney + month2 * strMoney;
|
}
|
//补充空指针
|
var b = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Contract_No_F__c : '') : '';
|
var LastMContractRecord = checkedAssets[i].rec ? (checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.RecordType_DeveloperName__c : '') : '';
|
console.log('b product',b);
|
if(b != ''){
|
conCCount ++;
|
var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_End_Date__c);
|
var lastContRange = 0;
|
if(LastMContractRecord == 'VM_Contract'){
|
newCount++;
|
//多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
|
GuranteeCount++;
|
newCon = false;
|
//多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
|
lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
|
lastContRange = 36;
|
}else{
|
lastContRange = checkedAssets[i].rec.CurrentContract_F__r.Contract_Range__c;
|
}
|
//最后结束日+1年
|
lastendDate.setMonth(lastendDate.getMonth() + 12);
|
if (Date.parse(contractStartDate) > Date.parse(lastendDate) ) {
|
oyearCount ++;
|
}
|
// 取联动价格
|
// 上一期合同实际报价月额
|
// * 1 避免 parseFloat(null) ->NAN
|
var LastMContract_Price = parseFloat(checkedAssets[i].mcae.LastMContract_Price__c * 1);
|
var Adjustment_ratio_Lower = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Lower__c * 1);
|
var Adjustment_ratio_Upper = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Upper__c * 1);
|
//计算惩罚率
|
var Punish = this.calculateNtoMRatio( lastContRange,(month + month2));
|
if(Punish == 0){
|
return;
|
}
|
// 判断有无报价:没有按照标准价格实际联动
|
var Estimate_Num = checkedAssets[i].rec.CurrentContract_F__r.Estimate_Num__c ;
|
if(Estimate_Num == 0){
|
if(LastMContractRecord == 'VM_Contract'){
|
// gzw 20220630 实际联动6个月价格区分
|
var nowdate = new Date();
|
lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
|
nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
|
//市场多年保修价格开发 DC 2023/1/30 start
|
var Maxcoefficient =0;
|
var Mincoefficient =0;
|
var ContractMonth = this.localParseFloat(this.estimate.Contract_Range__c);
|
var AssetRate = this.localParseFloat(checkedAssets[i].rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c);
|
checkedAssets[i].mcae.Asset_Consumption_rate__c = AssetRate;
|
if(AssetRate<= 50){
|
Maxcoefficient = (1-0.3);
|
Mincoefficient = (1-0.4);
|
}else if(AssetRate>50 &&AssetRate<=60){
|
Maxcoefficient = (1-0.2);
|
Mincoefficient = (1-0.3);
|
}else if(AssetRate>60 &&AssetRate<=70){
|
Maxcoefficient = (1-0.15);
|
Mincoefficient = (1-0.25);
|
}else if(AssetRate>70 &&AssetRate<=80){
|
Maxcoefficient = (1-0.1);
|
Mincoefficient = (1-0.2);
|
|
}else if(AssetRate>80 &&AssetRate<=90){
|
Maxcoefficient = (1-0.05);
|
Mincoefficient = (1-0.15);
|
}else if(AssetRate>90 &&AssetRate<=100){
|
Maxcoefficient = 1;
|
Mincoefficient = (1-0.05);
|
}else if(AssetRate>100 &&AssetRate<=110){
|
Maxcoefficient = (1+0.05);
|
Mincoefficient = 1;
|
}else if(AssetRate>110 &&AssetRate<=120){
|
Maxcoefficient = (1+0.1);
|
Mincoefficient = 1;
|
}else if(AssetRate>120 &&AssetRate<=130){
|
Maxcoefficient = (1+0.2);
|
Mincoefficient = (1+0.1);
|
}else if(AssetRate>130 &&AssetRate<=140){
|
Maxcoefficient = (1+0.25);
|
Mincoefficient = (1+0.15);
|
}else if(AssetRate>140){
|
Maxcoefficient = (1+0.3);
|
Mincoefficient = (1+0.2);
|
}
|
//市场多年保修价格开发 DC 2023/1/30 end
|
if(nowdate < Date.parse(lastendDate)){
|
// 市场多年保修价格开发 start DC 2023/01/19
|
//市场多年保设备小于2年半
|
var AssetModelNo = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Asset_Model_No__c : 0;
|
var Category4 = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Category4__c : '';
|
//设备设备消费率小于1.4
|
if(AssetRate<140){
|
upPrice = VMassetListmonth * ContractMonth /12;
|
if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
|
downPrice = upPrice;
|
}else{
|
downPrice = upPrice * 0.8;
|
}
|
}else{
|
upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
|
downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
|
}
|
// 市场多年保修价格开发 end DC 2023/01/19
|
}else{
|
//市场多年保修价格开发 DC 2023/1/30 start 设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
|
upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
|
downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
|
//市场多年保修价格开发 DC 2023/1/30 end
|
}
|
// gzw 20220630 实际联动6个月价格区分
|
}else{
|
upPrice = strMoney;
|
downPrice = strMoney * 0.8;
|
}
|
}else{
|
upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
|
downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
|
}
|
}else{
|
upPrice = strMoney;
|
downPrice = strMoney * 0.8;
|
}
|
// 上下限四舍五入
|
upPrice = upPrice.toFixed(2);
|
downPrice = downPrice.toFixed(2);
|
console.log('downPrice Product',downPrice);
|
// 12个月合同金额
|
if (!isDisabled) {
|
// 实际联动价格 start
|
//*1 转化为Number类型 结果保留两位小数
|
checkedAssets[i].mcae.Adjustment_Lower_price__c = (downPrice*1).toFixed(2);
|
checkedAssets[i].mcae.Adjustment_Upper_price__c = (upPrice*1).toFixed(2);
|
// 实际联动价格 end
|
}
|
checkedAssets[i].mcae.Estimate_List_Price_Page__c = strMoney * 1;
|
//Repair_Price__c null Number类型 .trim()
|
repairMoney = (checkedAssets[i].mcae.Repair_Price__c == undefined ? null : checkedAssets[i].mcae.Repair_Price__c ) *1;
|
} else {
|
// TODO 一時的な対応、なんで別行の金額リフレッシュされた?
|
checkedAssets[i].mcae.Estimate_List_Price_Page__c = '';
|
// 12个月合同金额
|
if (!isDisabled) {
|
// 实际联动价格 start
|
checkedAssets[i].mcae.Adjustment_Lower_price__c = '';
|
checkedAssets[i].mcae.Adjustment_Upper_price__c = '';
|
// 实际联动价格 end
|
}
|
}
|
}
|
else {
|
// 所有设备按安装日、发货日(最早的),距离合同开始日6个月内都是新品合同
|
var isNewDate = new Date( checkedAssets[i].rec.isNewDate_use__c);
|
isNewDate.setMonth(isNewDate.getMonth() + 6);
|
if (Date.parse(contractStartDate) > Date.parse(isNewDate)) {
|
newCon = false;
|
}
|
strMoney = assetListmonth ;
|
Price_YearTXT = strMoney * 12;
|
if (isnew) {
|
strMoney = month * strMoney + month2 * strMoney / this.allData.isNewPriceAdj;
|
} else {
|
strMoney = month * strMoney + month2 * strMoney;
|
}
|
var b = checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.Maintenance_Contract_No_F__c : '';
|
var LastMContractRecord = checkedAssets[i].rec.CurrentContract_F__r ? checkedAssets[i].rec.CurrentContract_F__r.RecordType_DeveloperName__c : '';
|
if(b != ''){
|
conCCount ++;
|
var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_End_Date__c);
|
var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F__r.Contract_End_Date__c);
|
var lastContRange = 0;
|
if(LastMContractRecord == 'VM_Contract'){
|
newCount++;
|
//多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 start
|
GuranteeCount++;
|
newCon = false;
|
//多年保续签合同数量,多年保续签到服务合同时视为首签设备 thh 20220316 end
|
lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c) ;
|
lastContRange = 36;
|
}else{
|
lastContRange = checkedAssets[i].rec.CurrentContract_F__r.Contract_Range__c;
|
}
|
//最后结束日+1年
|
lastendDate.setMonth(lastendDate.getMonth() + 12);
|
if (Date.parse(contractStartDate) > Date.parse(lastendDate)) {
|
oyearCount ++;
|
}
|
// 取联动价格
|
// 上一期合同实际报价月额
|
var LastMContract_Price = parseFloat(checkedAssets[i].mcae.LastMContract_Price__c * 1);
|
var Adjustment_ratio_Lower = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Lower__c * 1);
|
var Adjustment_ratio_Upper = parseFloat(checkedAssets[i].mcae.Adjustment_ratio_Upper__c * 1);
|
//计算惩罚率 return month 不可能为0
|
var Punish = this.calculateNtoMRatio( lastContRange,(month + month2));
|
if(Punish == 0){
|
return;
|
}
|
// 判断有无报价:没有按照标准价格实际联动
|
var Estimate_Num = checkedAssets[i].rec.CurrentContract_F__r.Estimate_Num__c ;
|
if(Estimate_Num == 0){
|
if(LastMContractRecord == 'VM_Contract'){
|
// gzw 20220630 实际联动6个月价格区分
|
var nowdate = new Date();
|
lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F_asset__r.endDateGurantee_Text__c);
|
nowdate = nowdate.setMonth(nowdate.getMonth() + 6);
|
//市场多年保修价格开发 DC 2023/1/30 start
|
var Maxcoefficient =0;
|
var Mincoefficient =0;
|
var ContractMonth = this.localParseFloat(this.estimate.Contract_Range__c);
|
var AssetRate = this.localParseFloat(checkedAssets[i].rec.CurrentContract_F_asset__r.Asset_Consumption_Rate__c);
|
checkedAssets[i].mcae.Asset_Consumption_rate__c = AssetRate;
|
if(AssetRate<= 50){
|
Maxcoefficient = (1-0.3);
|
Mincoefficient = (1-0.4);
|
}else if(AssetRate>50 &&AssetRate<=60){
|
Maxcoefficient = (1-0.2);
|
Mincoefficient = (1-0.3);
|
}else if(AssetRate>60 &&AssetRate<=70){
|
Maxcoefficient = (1-0.15);
|
Mincoefficient = (1-0.25);
|
}else if(AssetRate>70 &&AssetRate<=80){
|
Maxcoefficient = (1-0.1);
|
Mincoefficient = (1-0.2);
|
}else if(AssetRate>80 &&AssetRate<=90){
|
Maxcoefficient = (1-0.05);
|
Mincoefficient = (1-0.15);
|
}else if(AssetRate>90 &&AssetRate<=100){
|
Maxcoefficient = 1;
|
Mincoefficient = (1-0.05);
|
}else if(AssetRate>100 &&AssetRate<=110){
|
Maxcoefficient = (1+0.05);
|
Mincoefficient = 1;
|
}else if(AssetRate>110 &&AssetRate<=120){
|
Maxcoefficient = (1+0.1);
|
Mincoefficient = 1;
|
}else if(AssetRate>120 &&AssetRate<=130){
|
Maxcoefficient = (1+0.2);
|
Mincoefficient = (1+0.1);
|
}else if(AssetRate>130 &&AssetRate<=140){
|
Maxcoefficient = (1+0.25);
|
Mincoefficient = (1+0.15);
|
}else if(AssetRate>140){
|
Maxcoefficient = (1+0.3);
|
Mincoefficient = (1+0.2);
|
}
|
//市场多年保修价格开发 DC 2023/1/30 end
|
if(nowdate < Date.parse(lastendDate)){
|
// 市场多年保修价格开发 start DC 2023/01/19
|
//市场多年保设备小于2年半
|
var AssetModelNo = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Asset_Model_No__c : 0;
|
var Category4 = checkedAssets[i].rec.Product2 ? checkedAssets[i].rec.Product2.Category4__c : '';
|
//设备设备消费率小于1.4
|
if(AssetRate<140){
|
upPrice = VMassetListmonth *ContractMonth / 12;
|
if((AssetModelNo.includes('290')&&( Category4 =='BF'|| Category4=='BF扇扫'||Category4=='CF'))|| Category4 =='URF'){
|
downPrice = upPrice;
|
}else{
|
downPrice = upPrice * 0.8;
|
}
|
}else{
|
upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
|
downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
|
}
|
// 市场多年保修价格开发 end DC 2023/01/19
|
}else{
|
//市场多年保修价格开发 DC 2023/1/30 start 设备大于2年半 续签价格 = 定价 *消费率对应系数 / 12 *合同月数
|
upPrice = VMassetListmonth * ContractMonth *Maxcoefficient / 12;
|
downPrice = VMassetListmonth * ContractMonth * Mincoefficient / 12;
|
//市场多年保修价格开发 DC 2023/1/30 end
|
}
|
// gzw 20220630 实际联动6个月价格区分
|
}else{
|
upPrice = strMoney;
|
downPrice = strMoney * 0.8;
|
}
|
}else{
|
upPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Upper/100);
|
downPrice = (LastMContract_Price * Punish) * (1 + Adjustment_ratio_Lower/100);
|
}
|
}else{
|
if (isnew) {
|
newCount ++;
|
} else {
|
newCon = false;
|
firstCCount ++;
|
}
|
upPrice = strMoney;
|
downPrice = strMoney * 0.8;
|
}
|
// 上下限四舍五入
|
upPrice = upPrice.toFixed(2);
|
downPrice = downPrice.toFixed(2);
|
console.log('upPrice Asset',upPrice);
|
console.log('strMoney Asset',strMoney);
|
console.log('VMassetListmonth Asset',VMassetListmonth);
|
console.log('LastMContract_Price Asset',LastMContract_Price);
|
console.log('ContractMonth Asset',ContractMonth);
|
console.log('Maxcoefficient Asset',Maxcoefficient);
|
if (!isDisabled) {
|
// 实际联动价格 start
|
checkedAssets[i].mcae.Adjustment_Lower_price__c = (downPrice*1).toFixed(2);
|
checkedAssets[i].mcae.Adjustment_Upper_price__c = (upPrice*1).toFixed(2);
|
// 实际联动价格 end
|
}
|
console.log('checkedAssets[i].mcae.Adjustment_Upper_price__c Asset',checkedAssets[i].mcae.Adjustment_Upper_price__c );
|
checkedAssets[i].mcae.Estimate_List_Price_Page__c = strMoney * 1;
|
//<!-- (2022年12月上线)故障品加费 start -->
|
let Repair_Price_Auto = checkedAssets[i].Repair_Price_Auto;
|
repairMoney = checkedAssets[i].mcae.Repair_Price__c == undefined ? null : checkedAssets[i].mcae.Repair_Price__c;
|
// Repair_Price_pass__c 没有值为null 避免下面条件误判 == null ? undefined : checkedAssets[i].mcae.Repair_Price_pass__c
|
let Repair_Price_pass = checkedAssets[i].mcae.Repair_Price_pass__c;
|
if ((repairMoney+1)==1) {
|
checkedAssets[i].mcae.Repair_Price__c = Repair_Price_Auto;
|
repairMoney = Repair_Price_Auto;
|
}
|
if ((Repair_Price_pass+1)==1) {
|
checkedAssets[i].mcae.Repair_Price_pass__c = Repair_Price_Auto;
|
}
|
let repairMoney1 = parseFloat(repairMoney * 1);
|
let ISReducedpriceapproval = this.estimate.IS_Reduced_price_approval__c;
|
if (ISReducedpriceapproval =='有八折以下待审批' || ISReducedpriceapproval =='是' || isDisabled) {
|
checkedAssets[i].IsRepairPriceDisabled = true;
|
}else{
|
checkedAssets[i].IsRepairPriceDisabled = false;
|
}
|
if (repairMoney1> 0 && (repairMoney1 <Repair_Price_Auto*0.80)) {
|
isresduce = isresduce+1;
|
}
|
//+ '' 避免获取值是undefined 或者 null 导致引用异常
|
let ResonCannotWarranty = checkedAssets[i].rec.Reson_Can_not_Warranty__c + '';
|
if(!(ResonCannotWarranty.indexOf("弃修") != -1)&&(repairMoney+1)==1){
|
checkedAssets[i].ShowAssetSituation = false;
|
checkedAssets[i].mcae.Repair_Price__c = '';
|
}
|
//在该部分js代码 未使用变量
|
// let situation = checkedAssets[i].rec.Asset_situation__c + '';
|
}
|
repairSum = repairSum + parseFloat(repairMoney* 1);
|
listSum = listSum + parseFloat(strMoney* 1);
|
downPriceSum = downPriceSum + parseFloat(downPrice* 1);
|
upPriceSum = upPriceSum + parseFloat(upPrice* 1);
|
}
|
// 仅保留两位小数
|
this.assetRepairSumNum = (repairSum * 1).toFixed(2);
|
if (!isDisabled) {
|
this.estimate.GuidePrice_Up__c = Math.round(upPriceSum) * 1;
|
this.estimate.GuidePrice_Down__c = Math.round(downPriceSum) * 1;
|
}
|
this.estimate.Asset_Repair_Sum_Price__c = repairSum * 1;
|
var allcount = this.productCount3 ;
|
var result = '';
|
if (allcount == 0) {
|
result = null;
|
//如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 start
|
}else if(GuranteeCount > 0 && GuranteeCount == allcount){
|
result = '市场多年保续签合同';
|
//如果所有设备的上期合同都是多年保合同,则合同种类为市场多年保续签合同 thh 20220315 end
|
}else if (newCount > 0 && newCount == allcount && newCon == true) {
|
result = '新品合同';
|
}else if (((newCount > 0 && newCount == allcount) ||(newCount + firstCCount == allcount)) && newCon == false) {
|
result = '首签合同';
|
}else if(firstCCount > 0 && firstCCount == allcount){
|
result = '首签合同';
|
}else if(oyearCount > 0 && oyearCount == conCCount && allcount == oyearCount ){
|
// 20220328 ljh update LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备 start
|
result = '非续签合同(空白期一年以上)';
|
}else{
|
result = '续签合同';
|
}
|
console.log('result',result);
|
this.estimate.New_Contract_Type_TxT__c = result;
|
this.allData.typeresult = result;
|
// 取消酸化水
|
//NotUseOxygenatedWaterAmount(1);
|
//next makeRealPrice 暂时补充 examinationPriceCal--方法 目前可走逻辑:makeRealPrice(1)
|
// examinationPriceCal(cnt);
|
this.makeRealPrice(1);
|
this.getLastContractRate();
|
// 报价规则改善 20230315 start todo
|
this.allDataInfo();
|
let returnData = estimateUtility.handleInfo.seamlessRenew(this,checkedAssets.length,this.allData,checkedAssets,this.PageDisabled,this.IsContractEstiStartDateDisabled);
|
this.allData = returnData.allData;
|
this.handleInitSimpleData(this.allData);
|
// 2023/09/18 seamlessRenew 可能修改 IsContractEstiStartDateDisabled 值,handleInitSimpleData中未处理该禁用
|
this.IsContractEstiStartDateDisabled = returnData.IsContractEstiStartDateDisabled;
|
checkedAssets = returnData.checkedAssets;
|
// 报价规则改善 20230315 end
|
if (TotalMaintenancePriceYear!=0) {
|
TotalMaintenancePriceYear = this.localParseFloat(TotalMaintenancePriceYear).toFixed(2);
|
var ContractMonth1 = this.localParseFloat(this.estimate.Contract_Range__c).toFixed(2);
|
var result = ((TotalMaintenancePriceYear/12)*ContractMonth1).toFixed(2);
|
this.estimate.Total_Contract_Price__c = result;
|
}
|
// 报价页面【合同定价总额】字段添加 20230608 end
|
//返回处理后的结果给allData的checkAsset
|
this.makeRealPrice(1);
|
return checkedAssets;
|
}
|
//
|
calculateNtoMRatio(lastContRange, month ){
|
var lastContRangeYear = Math.ceil(parseFloat(lastContRange* 1)/12);
|
var currentMonthYear = Math.ceil(parseFloat(month* 1)/12);
|
if(currentMonthYear == lastContRangeYear || currentMonthYear == 1){
|
return month;
|
}else if(month <= 24) {
|
return 12+ (month- 12) *1.1;
|
}else if(month <= 36) {
|
return 25.2 + (month- 24) *1.21;
|
}else if(month <= 48) {
|
return 39.72 + (month- 36) *1.331;
|
}else if(month <= 60) {
|
return 55.692 + (month- 48) *1.4641;
|
}else {
|
estimateUtility.toast.showToast(this, 'error', '合同期最长只能选择60个月!');
|
return 0;
|
}
|
}
|
//未选择的保有设备 当前页 全选
|
checkAllUncheckedAsset(event){
|
this.IsCheckAllUncheckedAsset = event.detail.checked;
|
for (var i = 0; i < this.unCheckedAssetNowData.length; i++) {
|
let index = this.unCheckedAssetNowData[i].Id;
|
this.allData.unCheckedAssets.forEach(function(ar) {
|
if (ar.rec.Id == index && !(ar.rec.Maintenance_Price_Month__c == 0 || ar.rec.IF_Warranty_Service__c == '否')) {
|
ar.rec_checkBox_c = event.detail.checked;
|
}
|
});
|
}
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
}
|
//显示未选择保有设备
|
showUnCheckedAsset(event){
|
this.IsShowUnCheckedAsset = true;
|
}
|
//隐藏未选择保有设备
|
hiddenUnCheckedAsset(event){
|
this.IsShowUnCheckedAsset = false;
|
}
|
//未选择保有设备 搜索处理
|
handleChangeText1(event){
|
this.text1 = event.detail.value;
|
}
|
handleChangeCond1(event){
|
this.cond1 = event.detail.value;
|
}
|
handleChangeVal1(event){
|
this.val1 = event.detail.value;
|
}
|
//检索
|
searchJs(event){
|
this.IsLoading = true;
|
this.allData.text1 = this.text1;
|
this.allData.cond1 = this.cond1;
|
this.allData.val1 = this.val1;
|
this.allDataInfo();
|
// 2023/09/16 unCheckedAssets 后台方法重新赋值,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
searchBtn({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
result = JSON.parse(result);
|
console.log('searchJs result',result);
|
this.allData = result;
|
this.handleInitSimpleData(result);
|
//unCheckedAssets 处理
|
this.currentPage = 1;
|
this.handleunCheckedAssetColumnsAndData(result.unCheckedAssets);
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
// classic 一致,优化:改用flag,页面显示和后台处理条件不一致(清除条件时,页面显示为 S:AssetMark__c,实际为 '')
|
this.allData.text1 = this.allData.text1 == '' ? 'S:AssetMark__c' : this.allData.text1;
|
this.text1 = this.allData.text1;
|
this.cond1 = this.allData.cond1;
|
this.val1 = this.allData.val1;
|
this.IsLoading = false;
|
});
|
}
|
//清除条件
|
clearAndSearch() {
|
this.text1 = '';
|
this.cond1 = 'equals';
|
this.val1 = '';
|
this.searchJs();
|
}
|
//确认添加 -- 刷新行选中
|
handleExchangeAsset(template,event) {
|
this.IsLoading = true;
|
this.IsRefresh = false;
|
this.allDataInfo();
|
//2023/09/16 unCheckedAssets 仅保留勾选数据 后台unCheckedAssets 会重新查询赋值
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
let checkedNewUnCheckedAssets = [];
|
this.allData.unCheckedAssets.forEach(function(ar) {
|
if (ar.rec_checkBox_c) {
|
checkedNewUnCheckedAssets.push(ar);
|
}
|
});
|
this.allData.unCheckedAssets = checkedNewUnCheckedAssets;
|
exchangeAsset({
|
initDataStr:JSON.stringify(this.allData)
|
}).then(result => {
|
result = JSON.parse(result);
|
console.log('handleExchangeAsset result',result);
|
if (result != null) {
|
this.allData = result;
|
//页面相关数据初始化
|
this.handleInitSimpleData(result);
|
this.allData.checkedAssets = this.refreshAsset(result.checkedAssets.length,result.checkedAssets);
|
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
//param : unCheckedAssetsView
|
this.currentPage = 1;
|
this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets);
|
|
}else{
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}).catch(error => {
|
console.log(error);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
this.IsLoading = false;
|
this.IsShowUnCheckedAsset = false;
|
// 两个表格的 全选 勾选 清除
|
this.IsCheckAllUncheckedAsset = false;
|
this.IsCheckAllcheckedAsset = false;
|
this.IsRefresh = true;
|
});
|
}
|
//提交待审批
|
async handleApprove(event){
|
//onclick
|
this.IsLoading = true;
|
// WYL 贸易合规2期 update start
|
let resEGFlgconfim = await this.EGFlgconfim('【贸易合规】--服务报价提交待审批涉及警示产品');
|
if (resEGFlgconfim) {
|
let resKindsAndMonths = await this.KindsAndMonths();
|
await this.approvalJs();
|
if(resKindsAndMonths){
|
this.allDataInfo();
|
console.log('approvalProcess result');
|
// 2023/09/18 unCheckedAssets 后台方法未涉及该属性,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
await approvalProcess({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
console.log('approvalProcess result',result);
|
if (result.indexOf('navigateTo') != -1) {
|
this.navigateToOtherObj(result.split('=')[1]);
|
}else{
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
});
|
//oncomplete
|
this.unblockUI();
|
}
|
}
|
// WYL 贸易合规2期 update end
|
this.IsLoading = false;
|
}
|
async KindsAndMonths() {
|
// 故障品加费 系统检查修理减价审批完成 Start
|
let ISReduced = this.estimate.IS_Reduced_price_approval__c;
|
if( ISReduced == '审批中' || ISReduced == '有八折以下待审批'){
|
estimateUtility.toast.showToast(this, 'error', '请通过修理减价审批再提交');
|
return false;
|
}
|
// 故障品加费 系统检查修理减价审批完成 end
|
var months = parseFloat(this.estimate.Contract_Range__c == undefined ? null : this.estimate.Contract_Range__c);
|
var contrNew = this.estimate.New_Contract_Type_TxT__c;
|
if(months>12 && months<60 && contrNew == '新品合同'){
|
let confirmResult = await estimateUtility.toast.handleConfirmClick("本次您提交的报价为多年期新品合同,请您在正式提交报价前先将经销商与医院签订的多年期合同邮件发送服务本部报价窗口。若已经提交请点击确定,继续保存提交。");
|
return confirmResult;
|
}
|
// 先款后修-提交报价时如果是先款对象进行提示 thh 20220408 start
|
var FirstParagraphEnd = this.estimate.Is_RecognitionModel__c;
|
if(FirstParagraphEnd){
|
let confirmResult = await estimateUtility.toast.handleConfirmClick("本次签约经销商是先款对象,请确认是否提交报价?");
|
return confirmResult;
|
}
|
// 先款后修-提交报价时如果是先款对象进行提示 thh 20220408 end
|
return true;
|
}
|
approvalJs() {
|
this.approvalDate = new Date();
|
var rowCnt = this.productCount;
|
this.allData.checkedAssets = this.refreshAsset(rowCnt,this.allData.checkedAssets);
|
this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets);
|
}
|
// 过去三年维修实绩计算
|
async AlertPriceBtnJs(){
|
this.IsLoading = true;
|
var PStatus = this.estimate.Process_Status__c;
|
if(PStatus!='申请中'&& PStatus!='批准'){
|
await ComputeLTYRepair({
|
targetEstimateId: this.allData.targetEstimateId,
|
}).then(result => {
|
if (result != null) {
|
estimateUtility.toast.showToast(this, 'error', result);
|
}
|
}).catch(error => {
|
}).finally(() => {
|
|
});
|
}else if(PStatus == '申请中'||PStatus == '批准'){
|
await ShowLTYRepair({
|
targetEstimateId: this.allData.targetEstimateId,
|
}).then(result => {
|
result = JSON.parse(result);
|
if (result != null) {
|
//allData 赋值
|
this.allData.lastFriYearsPriceSum = result.lastFriYearsPriceSum;
|
this.allData.lastSecYearsPriceSum = result.lastSecYearsPriceSum;
|
this.allData.alertString = result.alertString;
|
this.allData.alertString2 = result.alertString2;
|
this.allData.alertString3 = result.alertString3;
|
}
|
}).catch(error => {
|
});
|
}
|
this.IsLoading = false;
|
}
|
// 提交修理减价审批
|
handleToApprovalProcess(){
|
this.IsLoading = true;
|
this.allDataInfo();
|
// 2023/09/18 unCheckedAssets 后台方法未涉及该属性,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
toApprovalProcess({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
if (result != null && result.indexOf('completion=5') != -1) {
|
//重新跳转该页面 携带参数
|
estimateUtility.toast.showToast(this, 'success', '提交修理减价审批成功');
|
window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateVM#id="+result.split('/')[1];
|
location.reload();
|
}else{
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
this.IsLoading = false;
|
});
|
}
|
// Decide
|
async decideJs() {
|
console.log('decideJs');
|
if(this.allData.MaintanceContractPackId && this.estimate.McpDecide__c == false) {
|
estimateUtility.toast.showToast(this, 'error', '只能对决定报价组合里的报价进行decide!');
|
return;
|
}
|
this.IsLoading = true;
|
if (await this.checkDecideDate()) {
|
if (await this.onclickCheckchangedAfterPrint('true','false')) {
|
var oldDate = this.allData.OldContractStartDate;
|
var contractDate = new Date(this.estimate.Contract_Start_Date__c);
|
var monthStr = '00' + (contractDate.getMonth()+1);
|
monthStr = monthStr.substring(monthStr.length-2, monthStr.length);
|
var dayStr = '00' + contractDate.getDate();
|
dayStr = dayStr.substring(dayStr.length-2, dayStr.length);
|
var contractDateStr = contractDate.getFullYear() + '/' + monthStr + '/' + dayStr;
|
//贸易合规 you 20230414 start
|
var AccDealerBlacklist = this.contract.AccDealerBlacklist__c;//黑名单,警示名单
|
var TradeComplianceStatusFlagFW = this.allData.TradeComplianceStatusFlagFW;//贸易合规开关
|
var IFTradeComplianceAlert = this.allData.IFTradeComplianceAlert;//贸易合规提醒
|
if(TradeComplianceStatusFlagFW=='true'){
|
if(AccDealerBlacklist =='1'){
|
estimateUtility.toast.showToast(this, 'warning', '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+IFTradeComplianceAlert);
|
var reflag = this.handleInterceptsend();//后台
|
this.unblockUI();
|
return null;
|
}else if(AccDealerBlacklist =='2'){
|
estimateUtility.toast.showToast(this, 'warning', '您所选择的经销商存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+IFTradeComplianceAlert);
|
var reflag = this.handleInterceptsend();
|
this.unblockUI();
|
return null;
|
}else if(AccDealerBlacklist =='12'){
|
estimateUtility.toast.showToast(this, 'warning', '您所选择的医院和经销商存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+IFTradeComplianceAlert);
|
var reflag = this.handleInterceptsend();
|
this.unblockUI();
|
return null;
|
}else if(AccDealerBlacklist =='5' || AccDealerBlacklist =='6' || AccDealerBlacklist =='56'){
|
//20231208 sx 贸易合规二期 修改 start
|
let tradeFlagTwo = false;
|
console.info('Decide=' + JSON.stringify(this.allData.checkedAssets));
|
var violationName='';
|
this.allData.checkedAssets.forEach(function(ass) {
|
if (ass.rec != null && ass.rec.Product2.ProTradeComplianceStatus__c === '0') {
|
tradeFlagTwo = true;
|
violationName+=ass.rec.Product2.Asset_Model_No__c+',';
|
}
|
});
|
if(tradeFlagTwo){
|
this.EmailSending(2,'【贸易合规】--服务报价Decide涉及警示产品',violationName.slice(0, -1));
|
if (!(await estimateUtility.toast.handleConfirmClick('您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口恽李娜进一步评估(一般需5-10个工作日)'))) {
|
this.unblockUI();
|
this.IsLoading = false;
|
return null;
|
}
|
}
|
//20231208 sx 贸易合规二期 修改 end
|
}
|
}
|
//贸易合规 you 20230414 end
|
if (oldDate == contractDateStr) {
|
this.allData.changedAfterPrint = false;
|
this.handleDecide();
|
} else {
|
var oldp = parseFloat(this.allData.OldMaintenancePrice*1);
|
var newp = parseFloat(this.estimate.Maintenance_Price__c);
|
console.log('oldp',oldp);
|
console.log('newp',newp);
|
if (oldp != newp) {
|
// 20201106 高章伟 提醒消息修改 start
|
this.allData.changedAfterPrint = true;
|
if (await estimateUtility.toast.handleConfirmClick("合同金额发生变化,请您确认。")) {
|
this.handleDecide();
|
} else {
|
estimateUtility.toast.showToast(this, 'warning', '请确认全部内容后点击Decide。');
|
this.estimate.Contract_Start_Date__c = oldDate;
|
this.allData.OldContractStartDate = '';
|
this.allData.changedAfterPrint = false;
|
this.handleDecideCancle();
|
}
|
} else {
|
this.allData.changedAfterPrint = false;
|
this.handleDecide();
|
}
|
// 20201106 高章伟 提醒消息修改 end
|
}
|
}else{
|
this.IsLoading = false;
|
|
}
|
}else{
|
this.IsLoading = false;
|
}
|
}
|
handleInterceptsend(){
|
this.allDataInfo();
|
interceptsend({
|
estimateStr: JSON.stringify(this.allData.estimate),
|
targetEstimateId: this.allData.targetEstimateId,
|
}).then(result => {
|
return result;
|
}).catch(error => {
|
}).finally(() => {
|
this.IsLoading = false;
|
});
|
}
|
//
|
async checkDecideDate() {
|
console.log('checkDecideDate');
|
// 报价有效期
|
var strSubmitDate = this.estimate.Submit_quotation_day__c;
|
// 上期合同结束日 取最晚的
|
var conEndDate = await this.getLastContractendDate();
|
console.log(11);
|
conEndDate = new Date(conEndDate);
|
// 今天
|
var submitDate = new Date();
|
var nowDate = new Date();
|
nowDate = new Date(nowDate.toLocaleDateString());
|
/// 报价中设备的机身编码为空时的新品合同有效期延长 20200710 gzw
|
var monthGap = 6;
|
var cntWithKara = this.productCount;
|
for (var i = 0; i < cntWithKara; i++) {
|
var isManual = this.allData.checkedAssets[i].isManual;
|
if (isManual != true) {
|
monthGap = 3;
|
break;
|
}
|
}
|
if (strSubmitDate != '') {
|
submitDate = new Date(strSubmitDate);
|
submitDate = new Date(submitDate.setMonth(submitDate.getMonth() + monthGap));
|
if(Date.parse(conEndDate) > Date.parse(submitDate)){
|
submitDate = new Date(conEndDate);
|
}
|
}
|
if (strSubmitDate != '' && nowDate > submitDate) {
|
estimateUtility.toast.showToast(this, 'error','已超出报价申请日'+ monthGap+'个月,不允许DECIDE。');
|
return false;
|
}
|
return true;
|
}
|
//
|
getLastContractendDate(){
|
console.log('getLastContractendDate');
|
var rowCnt = this.productCount;
|
var lastdate = null;
|
|
for (var i = 0; i < rowCnt; i++) {
|
var LastMContractID = this.allData.checkedAssets[i].rec ? this.allData.checkedAssets[i].rec.CurrentContract_F__c : null;
|
if(LastMContractID){
|
var endDate = new Date(this.allData.checkedAssets[i].rec.CurrentContract_End_Date__c);
|
if(lastdate == null){
|
lastdate = new Date(endDate);
|
}else if(Date.parse(endDate) > Date.parse(lastdate)){
|
lastdate = new Date(endDate);
|
}
|
}
|
}
|
return lastdate;
|
}
|
//decide
|
handleDecide(){
|
this.IsLoading = true;
|
this.allDataInfo();
|
// 2023/09/16 unCheckedAssets 后台方法重新赋值,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
decide({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
if (result != null && result.indexOf('completion=') != -1) {
|
//重新跳转该页面 携带参数
|
window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateVM#id="+result.split('/')[1];
|
location.reload();
|
}else{
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
this.IsLoading = false;
|
});
|
}
|
//decideCancle
|
handleDecideCancle(){
|
//后台页面跳转原页面 替换成location.reload();
|
this.IsLoading = true;
|
this.allDataInfo();
|
// 2023/09/16 unCheckedAssets 后台方法重新赋值,直接置空,后台处理后,页面重载,不考虑旧值 重新赋值
|
this.allData.unCheckedAssets = [];
|
decideCancle({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
}).catch(error => {
|
}).finally(() => {
|
location.reload();
|
this.IsLoading = false;
|
});
|
}
|
//取消Decide
|
handleUndecide(){
|
this.IsLoading = true;
|
this.allData.estimate = this.estimate;
|
undecide({
|
targetEstimateId: this.allData.targetEstimateId,
|
estimateStr: JSON.stringify(this.allData.estimate),
|
}).then(result => {
|
if (result != null && result.indexOf('completion=1') != -1) {
|
window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateVM#id="+result.split('/')[1];
|
location.reload();
|
}else{
|
estimateUtility.toast.showToast(this, 'error', result);
|
}
|
}).catch(error => {
|
}).finally(() => {
|
location.reload();
|
this.IsLoading = false;
|
});
|
}
|
//PDF打印按钮
|
async handlePrint(){
|
this.IsLoading = true;
|
// 20231120 hql 添加逻辑:页面锁定后无法点击且提示
|
var isdecide = this.estimate.Estimation_Decision__c;;
|
if (isdecide == true) {
|
estimateUtility.toast.showToast(this, 'error', '请前往文本信息录入页面进行打印');
|
this.IsLoading = false;
|
return;
|
}
|
// 20231120 hql 添加逻辑:页面锁定后无法点击且提示
|
if (await this.onclickCheckchangedAfterPrint(this.SaveBtnDisabled,'false')) {
|
this.allDataInfo();
|
// 2023/09/16 unCheckedAssets 后台方法重新赋值,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
print({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
if (result != null && result.indexOf('printAsset') == -1) {
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}else if (result != null) {
|
result = JSON.parse(result);
|
this.allData = result;
|
//页面相关数据初始化
|
this.handleInitSimpleData(result);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
//complete
|
this.PDFDataChang();
|
this.unblockUI();
|
ComputeLTYRepair({
|
targetEstimateId: this.allData.targetEstimateId,
|
}).then(result => {
|
if (result != null) {
|
estimateUtility.toast.showToast(this, 'error', result);
|
}
|
this.IsLoading = false;
|
}).catch(error => {
|
}).finally(() => {
|
});
|
});
|
}else{
|
this.IsLoading = false;
|
}
|
}
|
//page 后台js 方法 检测printAsset是否满足
|
PDFDataChang(){
|
if (this.allData.printAsset) {
|
var con = 0;
|
if (this.estimate.Print_ListPrice__c) {
|
con ++;
|
}
|
if (this.estimate.Print_Simplify__c) {
|
con ++;
|
}
|
if (this.estimate.Print_RepairPrice__c) {
|
con ++;
|
}
|
if (this.estimate.Print_SumPrice__c) {
|
con ++;
|
}
|
if(con != 1){
|
estimateUtility.toast.showToast(this, 'error', '请您勾选打印报价版本,只能勾选一个。');
|
}else{
|
window.open('/apex/MaintenanceContractEstimateVMPDF?id='+this.allData.targetEstimateId, 'MaintenanceContractEstimateVMPDF');
|
}
|
} else if (this.allData.printContract) {
|
window.open('/apex/MceConfigPDF?id='+this.allData.targetEstimateId+'&flag=printContract', 'MceConfigPDF');
|
} else if (this.allData.printTripartite) {
|
window.open('/apex/MceConfigPDF?id='+this.allData.targetEstimateId+'&flag=printTripartite', 'MceConfigPDF');
|
} else if (this.allData.printAgent) {
|
window.open('/apex/MceConfigPDF?id='+this.allData.targetEstimateId+'&flag=printAgent', 'MceConfigPDF');
|
}else {}
|
}
|
async handleSendEmail(){
|
this.IsLoading = true;
|
if (await this.EGFlgconfim()) {
|
this.allDataInfo();
|
// 2023/09/16 unCheckedAssets 后台方法重新赋值,直接置空
|
let oldUnCheckedAssets = JSON.stringify(this.allData.unCheckedAssets);
|
this.allData.unCheckedAssets = [];
|
sendEmail({
|
initDataStr: JSON.stringify(this.allData),
|
}).then(result => {
|
//判断是否返回initData targetEstimateId
|
if (result != null && result.indexOf('currPage') != -1) {
|
result = JSON.parse(result);
|
console.log('handleSendEmail result',result);
|
this.allData = result;
|
//页面相关数据初始化
|
this.handleInitSimpleData(result);
|
if (this.allData.sendEmailSuccess) {
|
estimateUtility.toast.showToast(this, 'success', '邮件发送成功!');
|
}else{
|
estimateUtility.toast.showToast(this, 'error', '邮件发送失败,请联系管理员!');
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}else{
|
estimateUtility.toast.showToast(this, 'error', result);
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}
|
}).catch(error => {
|
// 2023/09/18 返回异常,旧数据返回赋值
|
this.allData.unCheckedAssets = JSON.parse(oldUnCheckedAssets);
|
}).finally(() => {
|
this.unblockUI();
|
this.IsLoading = false;
|
});
|
}else{
|
this.IsLoading = false;
|
}
|
}
|
/*//计算预测消费率
|
consumptionbtnJs(){
|
this.IsLoading = true;
|
var mceId = this.allData.targetEstimateId;
|
console.log('报价=='+mceId);
|
// sforce.connection.sessionId = '{!$Api.Session_ID}';
|
ToConsumptionRate({
|
mceId: mceId,
|
}).then(flg => {
|
console.log('计算结果=='+flg);
|
if (flg == '计算完成') {
|
estimateUtility.toast.showToast(this, 'success', flg);
|
}else{
|
estimateUtility.toast.showToast(this, 'error', flg);
|
}
|
}).catch(error => {
|
}).finally(() => {
|
this.IsLoading = false;
|
});
|
}*/
|
//estimate contract 同步
|
allDataInfo(){
|
this.allData.estimate = this.estimate;
|
this.allData.contract = this.contract;
|
}
|
//parseFloat 避免NAN
|
localParseFloat(val){
|
val = val == undefined ? null : val;
|
return parseFloat(val*1);
|
}
|
//页面对象跳转
|
navigateToOtherObj(recordId){
|
// this.IsLoading = true;
|
this[NavigationMixin.Navigate]({
|
type:'standard__recordPage',
|
attributes:{
|
recordId:recordId,
|
objectApiName:'Account',
|
actionName:'view'
|
}
|
});
|
}
|
/* openQuoteExcelImport() {
|
this.showQuoteExcelImport = true;
|
}
|
|
// Excel导入态框关闭
|
cancelQuoteExcelImport(){
|
this.showQuoteExcelImport = false;
|
this.exceltextvalue = '';
|
}
|
//Excel导入保存
|
async SavesSQuoteExcelImport(){
|
|
|
}
|
get acceptedFormats() {
|
return ['.csv'];
|
}
|
handleUploadFinished(event) {
|
const file = event.detail.files[0];
|
let reader = new FileReader();
|
let that=this;
|
console.log("ddd");
|
console.log(this.allData.uncheckedAssets);
|
let addAssetsList=[];
|
reader.onload = function (e) {
|
var data = e.target.result;
|
var allTextLines = data.split(/\r\n|\n/);
|
|
readExcel({fileStr:allTextLines}).then(res=>{
|
console.log('解析结果');
|
console.log(res);
|
console.log(that.allData);
|
console.log(that.unCheckedAssetData);
|
for(let i=0;i<res.length;i++){
|
if(res[i][0]=='SerialNumber'){
|
console.log(that.allData);
|
console.log(that.unCheckedAssetData);
|
console.log(that.allData.uncheckedAssets);
|
for (var j = that.unCheckedAssetData.length - 1; j >= 0; j--) {
|
if(res[i].indexOf(that.unCheckedAssetData[j].SerialNumber)!=-1){
|
// that.unCheckedAssetData[i].rec_checkBox_c=true;
|
if(that.unCheckedAssetData[j].uncheckedDisable==false){
|
addAssetsList.push(that.unCheckedAssetData[j]);
|
}
|
|
}
|
}
|
console.log('匹对结果');
|
console.log(addAssetsList);
|
return;
|
}
|
}
|
})
|
}
|
reader.readAsText(file, 'gb2312');
|
}
|
|
|
@track
|
exceltextvalue;
|
//textArea事件
|
exceltextChange(event){
|
let value = event.detail.value;
|
this.exceltextvalue = value;
|
}*/
|
}
|