import { LightningElement, track, wire, api} from 'lwc'; import { NavigationMixin } from 'lightning/navigation'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import { CurrentPageReference } from "lightning/navigation"; import estimateUtility from 'c/lexSelectEstimateUtility'; import init from "@salesforce/apex/lexSelectAssetEstimateURFController.init"; import save from "@salesforce/apex/lexSelectAssetEstimateURFController.save"; import saveAndCancel from "@salesforce/apex/lexSelectAssetEstimateURFController.saveAndCancel"; import searchBtn from "@salesforce/apex/lexSelectAssetEstimateURFController.searchBtn"; import saveBeforeCheckPriceChangeAsset from "@salesforce/apex/lexSelectAssetEstimateURFController.saveBeforeCheckPriceChangeAsset"; import saveBeforeCheckPriceChangeProduct2 from "@salesforce/apex/lexSelectAssetEstimateURFController.saveBeforeCheckPriceChangeProduct2"; import ComputeLTYRepair from "@salesforce/apex/lexSelectAssetEstimateURFController.ComputeLTYRepair"; import ShowLTYRepair from "@salesforce/apex/lexSelectAssetEstimateURFController.ShowLTYRepair"; import approvalProcess from "@salesforce/apex/lexSelectAssetEstimateURFController.approvalProcess"; import onChDealerUpdate from "@salesforce/apex/lexSelectAssetEstimateURFController.onChDealerUpdate"; import refreshProductData from "@salesforce/apex/lexSelectAssetEstimateURFController.refreshProductData"; import exchangeAsset from "@salesforce/apex/lexSelectAssetEstimateURFController.exchangeAsset"; import print from "@salesforce/apex/lexSelectAssetEstimateURFController.print"; //分页后台 - del // import recordNumChange from "@salesforce/apex/lexSelectAssetEstimateURFController.recordNumChange"; // import firstPage from "@salesforce/apex/lexSelectAssetEstimateURFController.firstPage"; // import previousPage from "@salesforce/apex/lexSelectAssetEstimateURFController.previousPage"; // import nextPage from "@salesforce/apex/lexSelectAssetEstimateURFController.nextPage"; // import endPage from "@salesforce/apex/lexSelectAssetEstimateURFController.endPage"; import interceptsend from "@salesforce/apex/lexSelectAssetEstimateURFController.interceptsend"; import decide from "@salesforce/apex/lexSelectAssetEstimateURFController.decide"; import undecide from "@salesforce/apex/lexSelectAssetEstimateURFController.undecide"; import getMCAEIsCreateable from "@salesforce/apex/lexSelectAssetEstimateURFController.getMCAEIsCreateable"; import addNewRows from "@salesforce/apex/lexSelectAssetEstimateURFController.addNewRows"; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; import lexSendNfm103 from '@salesforce/resourceUrl/lexSendNfm103'; import VMhql2 from '@salesforce/label/c.VMhql2'; import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2'; //sx 贸易合规2期 20231208 add import accSendEmailFW from "@salesforce/apex/lexSelectAssetEstimateVMController.accSendEmailFW"; import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName';// WYL 贸易合规2期 add export default class lexSelectAssetEstimateURF extends NavigationMixin(LightningElement){ activeSections = ['A', 'B','C','D','E']; IsLoading = true; otherParams; //遗留参数问题 -- 原页面跳转 params; goTo; IsParams; activeSectionsMessage = ''; objName = 'Maintenance_Contract_Estimate__c'; checkedAssetRelatedMaintenanceContractAssetEstimate = 'Maintenance_Contract_Asset_Estimate__c'; recordId = ''; @track estimate = {}; contract = {}; decideBtnDisabled = true; //报价提交对象 变更按钮 Disabled DecideBtnDisabled DecideBtnDisabled = true; IsControlDisabled; allData; //页面补充显示 IsShowUnCheckedAsset = false; //页面数据处理 checkedAssetData = []; unCheckedAssetData = []; //未选择保有设备 当前页是否全选 IsCheckAllUncheckedAsset; unCheckedAssetDataLength; //保有设备 搜索条件 text1 = 'S:AssetMark__c'; // 对象 cond1 = 'equals'; // 条件 //分页处理 currentPage = 1; pageDataLimit = 20; pageCount; //当前页数据 unCheckedAssetNowData = [{name:'123',website:'123',phone:'123'}]; //页面初始化 contractDisabled = {}; targetMaintenanceContractId=''; //合同对象设备的size productCount; productCount3; //todo 后台返回结果 ApprovalBtnNewDisabled; PageDisabled; hasSendEmail; //相关字段改动导致禁用或不显示 IsContractstartdateDisabled; IsContractEstiStartDateDisabled; IsDealerDisabled; IsFirstParagraphEndDisabled; AgreeRenewTenDisabled; IsRequestQuotationAmountDisabled; IsLimitPriceAmountDisabled; //前端判断按钮是否可以点击 SaveBtnDisabled; ApprovalBtnDisabled; //页面数据刷新 IsRefresh = true; EstimateTargetIsDealer; approvalDate = ''; //pdf 打印flag printFlag = true; //行追加 lineAddBtn; //三方协议 勾选是否显示 EnablePrintContract; //URF-V,-P isURFVChange=true; isURFPChange=true; // 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() { this.IsControlDisabled = this.decideBtnDisabled; Promise.all([ loadStyle(this, lwcCSS), loadStyle(this, lexSendNfm103) ]); if (this.goTo) { init({ recordId: this.recordId, initFlag: this.params[0],//传参 id,copyid,mcid }).then(result => { result = JSON.parse(result); console.info('数据打印:'+JSON.stringify(result)); if (result != null) { this.allData = result; this.handleInitSimpleData(result); this.targetMaintenanceContractId=result.targetMaintenanceContractId; this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets); this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets); this.mcid = result.estimate.Maintenance_Contract__c; } }).catch(error => { estimateUtility.toast.showToast(this, 'error', '无法显示维修合同报价'); }).finally(() => { this.IsLoading = false; }); } } //页面相关数据的初始化 --单数据赋值,页面显示点击 handleInitSimpleData(result) { this.estimate = result.estimate; this.handleEstimateTargetIsHospitalTrue(); //复选框设置false Is_RecognitionModel__c == null || !this.estimate.Is_RecognitionModel__c 显示是勾选 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; //判断处理 todo后台验证 // 見積もりsaveできない条件の判断 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; }else{ this.SaveBtnDisabled = false; this.ApprovalBtnDisabled = false; this.PageDisabled = false; } 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 => { this.lineAddBtn = this.PageDisabled || !result; }).catch(error => { }).finally(() => { }); //逻辑应该改正为 刷新选中按钮 需要可点击 逻辑判断:合同对象中包含Asset 或者 未选择的保有设备有数据有允许修改的数据,才允许点击 --在表格数据处理禁用 // this.refreshAssetBtn = this.SaveBtnDisabled || result.productCount2==0; this.calonLoad(); //editForm 的recordId更改 this.recordId = this.allData.targetEstimateId; } //end 页面按钮禁用初始化 async calonLoad() { 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; if (await estimateUtility.toast.handleConfirmClick("已超过创建日3个月,是否更新报价?")) { window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateURF#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; if (await estimateUtility.toast.handleConfirmClick("已超过创建日6个月,是否更新报价?")) { window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateURF#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; } } handleCheckedAssetColumnsAndData(checkedAssets){ this.IsRefresh = false; let checkedAssetsData = []; let index = 0; let assetsCount = 1; let allAssetCount = 0; let refreshAssetBtnLWCDisabled = true; checkedAssets.forEach(function(ar) { //有效计入 if(!ar.isManual || ar.isManual && ar.mcae != null && ar.mcae.Product_Manual__c != null){ allAssetCount++; } assetsCount++; let objData = {}; // //其他字段 hidden display:none 判断条件 objData['assetsCount'] = assetsCount; objData['lineNo'] = ar.lineNo; objData['rec_checkBox_c'] = ar.rec_checkBox_c; objData['IsManual'] = ar.isManual; objData['Repair_Price_Auto'] =ar.Repair_Price_Auto; objData['CheckRows'] =ar.CheckRows; objData['uFRSerial'] = ar.uFRSerial; //共有字段 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; // objData['Adjustment_Upper_price__c'] = ar.mcae.Adjustment_Upper_price__c; // objData['Adjustment_Lower_price__c'] = ar.mcae.Adjustment_Lower_price__c; if (typeof ar.mcae.Adjustment_Upper_price__c === 'number') { objData['Adjustment_Upper_price__c'] = new Intl.NumberFormat('en-US', { style: 'decimal', // currency: 'USD', minimumFractionDigits: 2 }).format(ar.mcae.Adjustment_Upper_price__c); } if (typeof ar.mcae.Adjustment_Lower_price__c === 'number') { objData['Adjustment_Lower_price__c'] = new Intl.NumberFormat('en-US', { style: 'decimal', // currency: 'USD', minimumFractionDigits: 2 }).format(ar.mcae.Adjustment_Lower_price__c); } 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['CurrentContract_F__c'] = ar.rec.CurrentContract_F__c; objData['IsCurrentContract_F__c'] = ar.rec.CurrentContract_F__c != null; } if (ar.isManual == true && ar.mcae != null) { objData['Name'] = ar.mcae.Product_Manual__c; }else if ( ar.isManual == false) { if (ar.rec != null) { objData['Name'] = ar.rec.Name; // 合同对象包含Asset--刷新选中按钮禁用 refreshAssetBtnLWCDisabled = false; objData['Asset_situation__c'] = ar.rec.Asset_situation__c; objData['SerialNumber'] = ar.rec.SerialNumber; //机身编码跳转id objData['recId'] = ar.rec.Id; objData['InstallDate'] = ar.rec.InstallDate; objData['Department_Name__c'] = ar.rec.Department_Name__c; if (ar.rec.CurrentContract_F__r != null) { 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['IsRepairPriceDisabled'] = ar.IsRepairPriceDisabled; objData['ShowAssetSituation'] = ar.ShowAssetSituation; objData['ISCommentDisabled'] = ar.ISCommentDisabled; checkedAssetsData.push(objData); }); this.checkedAssetData = checkedAssetsData; //已选择保有设备 this.productCount3 = allAssetCount; this.allData.productCount3 = allAssetCount; this.refreshAssetBtnLWC = this.SaveBtnDisabled || refreshAssetBtnLWCDisabled; this.IsRefresh = true; } handleunCheckedAssetColumnsAndData(unCheckedAssets){ let uncheckedAssetsData = []; let refreshAssetBtnDisabled = true; unCheckedAssets.forEach(function(ar) { let objData = {}; // //其他字段 hidden display:none 判断条件 //共有字段 objData['rec_checkBox_c'] = ar.rec_checkBox_c; objData['uFRSerial'] = ar.uFRSerial; objData['uFRPrice'] = ar.uFRPrice; if (ar.mcae != null) { } if (ar.rec != null) { objData['Id'] = ar.rec.Id; 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__c'] = ar.rec.IF_Warranty__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['Maintenance_Price_Month__c'] = ar.rec.Maintenance_Price_Month__c; //勾选禁用 objData['uncheckedDisable'] = ar.rec.IF_Warranty__c == '否'; console.log('objData[uncheckedDisable]',objData['uncheckedDisable']); // 未选择有可勾选 if (!objData['uncheckedDisable']) { // 未选择 有可以勾选的数据--未选择-确认添加 禁用 refreshAssetBtnDisabled = false; } } uncheckedAssetsData.push(objData); }); this.unCheckedAssetData = uncheckedAssetsData; this.getUnCheckedAssetNowData(); this.refreshAssetBtn = this.SaveBtnDisabled || refreshAssetBtnDisabled; } //分页按钮禁用与否 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; } //不保存返回 cancel(event) { if (this.allData.targetMaintenanceContractId) { //返回原报价页面 this.navigateToOtherObj(this.allData.targetMaintenanceContractId); }else{ location.reload(); } } //保存 async handleSave(event){ this.IsLoading = true; let resEGFlgconfim = await this.EGFlgconfim(); if (resEGFlgconfim) { this.allDataInfo(); let saveDataStr = JSON.stringify(this.allData); //20231208 sx 贸易合规二期 修改 start var AccDealerBlacklist = this.contract.AccDealerBlacklist__c; //黑名单,警示名单 var AccDealerBlacklist2 = this.contract.AccDealerBlacklist2__c; // WYL 贸易合规2期add 黑名单,警示名单 var TradeComplianceStatusFlagFW = this.allData.TradeComplianceStatusFlagFW; //贸易合规开关 let trandeFlagTwo = false; let violationName = ''; if(TradeComplianceStatusFlagFW == 'true'){ //经销商或者医院是冻结、黑名单时,进行拦截提醒,不允许保存 if(AccDealerBlacklist2 =='3' || AccDealerBlacklist2 =='4' || AccDealerBlacklist2 =='24'){ estimateUtility.toast.showToast(this, 'error', '黑名单:存在贸易合规风险,无法保存,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。'); this.IsLoading = false; this.EmailSending(1,null,null); return null; }else if(AccDealerBlacklist2 =='1' || AccDealerBlacklist2 =='2' || AccDealerBlacklist2 =='12'){ estimateUtility.toast.showToast(this, 'error', '冻结清单:可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法保存,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。'); this.IsLoading = false; return null; } //经销商或者医院是警示名单时,对所选的合同对象设备进行判断,判断涉及产品是否符合条件,如不符合合规规则,则弹出一条消息,消息里面把每一条不合规的设备列出 else if(AccDealerBlacklist2 =='5' || AccDealerBlacklist2 =='6' || AccDealerBlacklist2 =='56'){ for(var ass in this.allData.checkedAssets){ if(ass.Product2.ProTradeComplianceStatus__c == '0'){ trandeFlagTwo = true; violationName += ass.Product2.Name + '、'; } } if(trandeFlagTwo){ if (!(await estimateUtility.toast.handleConfirmClick('您所选择的客户/经销商和最新报价里的产品,存在贸易合规警示风险,不建议做授权申请,请您确认是否继续申请,'+ IFTradeComplianceAlert2 + '涉及到的设备有:' + violationName))) { this.unblockUI(); return null; } } } } //20231208 sx 贸易合规二期 修改 end await save({ saveData: saveDataStr, }).then(result => { if (result != null && result.indexOf('completion=5') == -1) { estimateUtility.toast.showToast(this, 'error', result); }else{ //重新跳转该页面 携带参数 estimateUtility.toast.showToast(this, 'success', '保存好了'); window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateURF#id="+result.split('/')[1]; location.reload(); } }).catch(error => { }).finally(() => { this.IsLoading = false; }); //oncomplete } this.IsLoading = false; } async EGFlgconfim() { await this.getEstimateCost(); var cntWithKara = this.productCount; // 新合同备品确保提供 是否改变 var alert1s = 0; 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; //补充 undefined的判定 if (EGFlgtxt != undefined && EGFlgnow != undefined && EGFlgtxt != EGFlgnow) { alert1s = 1; } } if (alert1s == 1) { let confirmResult = await estimateUtility.toast.handleConfirmClick("选择的保有设备[新合同备品确保提供]发生变化,是否继续?"); if (!confirmResult) { return false; } } return this.onclickCheckchangedAfterPrint('true','true'); } // async onclickCheckchangedAfterPrint(saveBtnDisabled, saveOrApproval) { var cntWithKara = this.productCount; var alerts = 0; // 新合同备品确保提供 是否改变 var alert1s = 0; var today = new Date(); today.setMonth(today.getMonth() - 3); //URF限次合同2期 LY 20220811 start var uRFSeriesMap =''; var valURFV = this.estimate.URF_V_MaxRepairCount__c ? this.estimate.URF_V_MaxRepairCount__c : ""; var valURFP = this.estimate.URF_P_MaxRepairCount__c ? this.estimate.URF_P_MaxRepairCount__c : ""; for (var i = 0; i < cntWithKara; i++) { var isManual = this.allData.checkedAssets[i].isManual;//value boolean //id未找到 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; } } //URF限次合同2期 LY 20220811 start var uRFSeries = this.allData.checkedAssets[i].uFRSerial; uRFSeriesMap += uRFSeries; uRFSeriesMap +=',' //URF限次合同2期 LY 20220811 end } console.log('valURFP',valURFP); console.log('uRFSeriesMap',uRFSeriesMap); console.log(111); //URF限次合同2期 LY 20220811 start if ((valURFV == null || valURFV == "" || valURFV == "0") && uRFSeriesMap.includes('URF-V')){ this.estimate.URF_V_MaxRepairCount__c = ""; estimateUtility.toast.showToast(this, 'error', "合同对象设备中含有URF-V系列,必须选择URF-V的最大大修次数!"); return; } console.log(222); if ((valURFP == null || valURFP == "" || valURFP == "0") && uRFSeriesMap.includes('URF-P')){ this.estimate.URF_P_MaxRepairCount__c = "0"; estimateUtility.toast.showToast(this, 'error', "合同对象设备中含有URF-P系列,必须选择URF-P的最大大修次数!"); return; } if (uRFSeriesMap.includes('URF-V')==false) { this.estimate.URF_V_MaxRepairCount__c = "0"; } if (uRFSeriesMap.includes('URF-P')==false) { this.estimate.URF_P_MaxRepairCount__c = "0"; } //URF限次合同2期 LY 20220811 end 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; } //初始化设定画面项目不可用 pageSetDisabled(){ //故障品加费 end var isDisabled = this.PageDisabled; if (isDisabled) { //此处的 disabled 可以用PageDisabled替换 this.IsContractEstiStartDateDisabled = true; var rowCnt = this.productCount; for (var i = 0; i < rowCnt; i++) { //补充默认值 IsAssertDisabled 不存在则为false var isManual = this.allData.checkedAssets[i].isManual; if (isManual == true) { this.allData.checkedAssets[i].IsAssertDisabled = true; } //id 禁用未使用 this.allData.checkedAssets[i].IsRepairPriceDisabled = true; this.allData.checkedAssets[i].ISCommentDisabled = true; } //Examination_Count,disPercent,disMoney 未找到 this.IsRequestQuotationAmountDisabled = true; this.IsContractstartdateDisabled = true; var target = this.estimate.Estimate_Target__c; if (target != '医院') { this.IsDealerDisabled = true; this.IsFirstParagraphEndDisabled = true; } } if (!this.DecideBtnDisabled) { this.IsContractstartdateDisabled = false; } //补充页面数据处理 this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); } // unblockUI(){ 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 } //ok 合同对象设备 数据计算处理 refreshAsset(cnt,checkedAssets) { console.log('refreshAsset'); // 提交后就页面不计算了 var isDisabled = this.PageDisabled; 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); //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 = this.localParseFloat(this.estimate.Contract_Range__c); var estimateURFVMaxRepairCount= this.localParseFloat(this.estimate.URF_V_MaxRepairCount__c); var estimateURFPMaxRepairCount= this.localParseFloat(this.estimate.URF_P_MaxRepairCount__c); console.log('estimateURFVMaxRepairCount',estimateURFVMaxRepairCount); var Contract_year = 0; if (month == undefined || month == "" || isNaN(month) || month <= 12) { Contract_year = 1; }else{ Contract_year = Math.ceil(month / 12); } var month2 = 0; if (month > 12) { month2 = month - 12; month = 12; } for (var i = 0; i < cnt; 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; if (isManual) { var a = checkedAssets[i].mcae.Product_Manual__c ? checkedAssets[i].mcae.Product_Manual__c : ''; if (a != '') { strMoney = assetListmonth; var uRFSeries= checkedAssets[i].uFRSerial; var strMoneyMax; var strMoneyMin; console.log('refresh isManual true'+i,uRFSeries); if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==2) { strMoneyMax = checkedAssets[i].uFRMaxPrice; strMoneyMin = checkedAssets[i].uFRMinPrice; }else if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==0) { strMoneyMax = 0; strMoneyMin = 0; }else if (uRFSeries=='URF-P' && estimateURFPMaxRepairCount==0){ strMoneyMax = 0; strMoneyMin = 0; }else{ strMoneyMax = checkedAssets[i].uFRMaxPrice3; strMoneyMin = checkedAssets[i].uFRMinPrice3; } // alert(strMoney); Price_YearTXT = strMoney * 12; if (isnew) { newCount ++; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start strMoneyMin = Contract_year * strMoneyMin; strMoneyMax = Contract_year * strMoneyMax; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end } else { newCon = false; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start strMoneyMin = Contract_year * strMoneyMin; strMoneyMax = Contract_year * strMoneyMax; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end } //补充空指针 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 : '') : ''; if(b != ''){ conCCount ++; // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。) // 2.一年以上的合同,在结束前6个月开始可以开放续签报价。 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 ; upPrice = strMoneyMax; downPrice = strMoneyMin; }else{ //firstCCount ++; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start upPrice = strMoneyMax; // downPrice = strMoney * 0.8; downPrice = strMoneyMin; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end } // 上下限四舍五入 upPrice = upPrice.toFixed(2); downPrice = downPrice.toFixed(2); if (!isDisabled) { // 实际联动价格 start checkedAssets[i].mcae.Adjustment_Lower_price__c = downPrice * 1; checkedAssets[i].mcae.Adjustment_Upper_price__c = upPrice * 1; // 实际联动价格 end } checkedAssets[i].mcae.Estimate_List_Price_Page__c = strMoney * 1; repairMoney = (checkedAssets[i].mcae.Repair_Price__c == undefined ? null : checkedAssets[i].mcae.Repair_Price__c ) *1; } else { // checkedAssets[i].mcae.Estimate_List_Price_Page__c = ''; 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 ; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start //URF限次合同2期 LY 20220811 start var uRFSeries= checkedAssets[i].uFRSerial; console.log('refresh isManual false'+i,uRFSeries); if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==2) { strMoneyMax = checkedAssets[i].uFRMaxPrice; strMoneyMin = checkedAssets[i].uFRMinPrice; }else if (uRFSeries=='URF-V' && estimateURFVMaxRepairCount==0) { strMoneyMax = 0; strMoneyMin = 0; }else if (uRFSeries=='URF-P' && estimateURFPMaxRepairCount==0){ strMoneyMax = 0; strMoneyMin = 0; }else{ strMoneyMax = checkedAssets[i].uFRMaxPrice3; strMoneyMin =checkedAssets[i].uFRMinPrice3; } Price_YearTXT = strMoney * 12; console.log('isManual false isnew',isnew); if (isnew) { // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start strMoneyMin = Contract_year * strMoneyMin; strMoneyMax = Contract_year * strMoneyMax; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end } else { // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start strMoneyMin = Contract_year * strMoneyMin; strMoneyMax = Contract_year * strMoneyMax; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end } 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 : ''; console.log('isManual false b',b); if(b != ''){ conCCount ++; // 1.合同期不满一年时,合同期超过一半才可开始续签报价。(eg:11个月的合同从6个月后才可报价。) // 2.一年以上的合同,在结束前6个月开始可以开放续签报价。 var lastendDate = new Date(checkedAssets[i].rec.CurrentContract_F__r.Contract_End_Date__c); console.log('lastendDate',lastendDate); var lastContRange = 0; if(LastMContractRecord == 'VM_Contract'){ newCount++; 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); console.log('Adjustment_ratio_Upper',Adjustment_ratio_Upper); //计算惩罚率 var Punish = this.calculateNtoMRatio( lastContRange,(month + month2)); console.log('Punish',Punish); if(Punish == 0){ return; } // 判断有无报价:没有按照标准价格实际联动 var Estimate_Num = checkedAssets[i].rec.CurrentContract_F__r.Estimate_Num__c ; upPrice = strMoneyMax; downPrice = strMoneyMin; }else{ if (isnew == true) { newCount ++; } else { newCon = false; firstCCount ++; } //firstCCount ++; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 start upPrice = strMoneyMax; // downPrice = strMoney * 0.8; downPrice = strMoneyMin; // XLIU-CE7AVC【委托】URF限次修理合同的最高价格修改 thh 20220509 end } // 上下限四舍五入 upPrice = upPrice.toFixed(2); downPrice = downPrice.toFixed(2); if (!isDisabled) { // 实际联动价格 start checkedAssets[i].mcae.Adjustment_Lower_price__c = downPrice * 1; checkedAssets[i].mcae.Adjustment_Upper_price__c = upPrice * 1; // 实际联动价格 end } checkedAssets[i].mcae.Estimate_List_Price_Page__c = strMoney * 1; repairMoney = (checkedAssets[i].mcae.Repair_Price__c == undefined ? null : checkedAssets[i].mcae.Repair_Price__c ) *1; } repairSum = repairSum + parseFloat(repairMoney* 1); listSum = listSum + parseFloat(strMoney* 1); downPriceSum = downPriceSum + parseFloat(downPrice* 1); upPriceSum = upPriceSum + parseFloat(upPrice* 1); } console.log('repairSum',repairSum); 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 (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 = '首签合同'; // 20220328 ljh update LJPH-C8FB4P【委托】配合PBI设备覆盖率的数据准备 start // }else if(oyearCount > 0 && oyearCount == conCCount){ }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; // 取消酸化水 //方法 目前可走逻辑:makeRealPrice(1) // examinationPriceCal(cnt); this.makeRealPrice(1); this.getLastContractRate(); return checkedAssets; } calculateNtoMRatio(lastContRange, month ){ var lastContRangeYear = Math.ceil(parseFloat(lastContRange* 1)/12); var currentMonthYear = Math.ceil(parseFloat(month* 1)/12); //if(!lastendDate || currentMonthYear <= lastContRangeYear){ 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; } } /*end * @param t 1: 金額により割引 */ makeRealPrice(t) { console.log('makeRealPrice'); // 実際金額合計 // 申请报价金额 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) + '%'; this.estimate.Service_discount_Rate__c = parseFloat(disMP); } // 修理総額を計上 let sum = sum1 + this.localParseFloat(sum2*1); this.estimate.Maintenance_Price__c = sum*1; } // 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 + '%'; this.estimate.Combined_rate__c = parseFloat(allContractRate); return allContractRate; } // async saveBeforeCheckPriceChange() { var needClearId = false; 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; if (a && a != VMhql2 && 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 { 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 { }).finally(() => { }); } if (proIds.length > 0) { if (!this.DecideBtnDisabled) { var oldDateStr = this.estimate.Contract_Start_Date__c; 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 { }).finally(() => { }); } } return needClearId; } // 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); // 标准价格的最低价总额 var GuidePriceDown = parseFloat(this.estimate.GuidePrice_Down__c); for (var i = 0; i < rowcount; i++) { // 去上限价格 var assetListPrice = parseFloat(this.allData.checkedAssets[i].mcae.Adjustment_Upper_price__c); // 取下限价格 var assetLowerPrice = parseFloat(this.allData.checkedAssets[i].mcae.Adjustment_Lower_price__c); var Estimate_Cost = 0; if (realprice == GuidePriceUp) { Estimate_Cost = assetListPrice; }else if (realprice == GuidePriceDown){ Estimate_Cost = assetLowerPrice; }else{ Estimate_Cost = (realprice * (assetListPrice / GuidePriceUp)).toFixed(2); } //parseFloat 可能会为NAN this.allData.checkedAssets[i].mcae.Estimate_Cost__c = isNaN(Estimate_Cost) ? 0 : Estimate_Cost; } } // Decide async decideJs() { 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;//贸易合规提醒 debugger; 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'){ // if (!(await estimateUtility.toast.handleConfirmClick('您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+IFTradeComplianceAlert))) { //20231208 sx 贸易合规二期 修改 start let tradeFlagTwo = false; var violationName=''; debugger; console.info('checkedAssets打印:'+JSON.stringify(this.allData.checkedAssets)); this.allData.checkedAssets.forEach(function(ass) { if (ass.rec != null && ass.rec.Product2.ProTradeComplianceStatus__c === '0') { tradeFlagTwo = true; violationName+=ass.AssetModelNoc+','; } }); if(tradeFlagTwo){ this.EmailSending(2,'【贸易合规】--服务报价Decide涉及警示产品',violationName.slice(0, -1)); if (!(await estimateUtility.toast.handleConfirmClick('您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需5-10个工作日)'))) { this.unblockUI(); this.IsLoading = false; return null; } } //20231208 sx 贸易合规二期 修改 end } // else if(AccDealerBlacklist =='6'){ // if (!confirm('您所选择的经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+IFTradeComplianceAlert)) { // this.unblockUI(); // return null; // } // }else if(AccDealerBlacklist =='56'){ // if (!(await estimateUtility.toast.handleConfirmClick('您所选择的医院和经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+IFTradeComplianceAlert))) { // this.unblockUI(); // return null; // } // } } //贸易合规 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); 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; } } //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 // async checkDecideDate() { // 报价有效期 var strSubmitDate = this.estimate.Submit_quotation_day__c; // 上期合同结束日 取最晚的 var conEndDate = await this.getLastContractendDate(); conEndDate = new Date(conEndDate); // 今天 var submitDate = new Date(); var nowDate = new Date(); nowDate = new Date(nowDate.toLocaleDateString()); /// 报价中设备的机身编码为空时的新品合同有效期延长 20200710 gzw // 默认为3月,全是产品为6月; 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(){ 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; } // handleInterceptsend(){ this.allDataInfo(); interceptsend({ estimateStr: JSON.stringify(this.allData.estimate), targetEstimateId: this.allData.targetEstimateId, }).then(result => { return result; }).catch(error => { }).finally(() => { this.IsLoading = false; }); } //decide handleDecide(){ this.IsLoading = true; this.allDataInfo(); decide({ initDataStr: JSON.stringify(this.allData), }).then(result => { if (result != null && result.indexOf('completion=') != -1) { //重新跳转该页面 携带参数 window.location.href=window.location.origin+"/lightning/n/lexSelectAssetEstimateURF#id="+result.split('/')[1]; location.reload(); }else{ estimateUtility.toast.showToast(this, 'error', result); } }).catch(error => { }).finally(() => { this.IsLoading = false; }); } //decideCancle handleDecideCancle(){ //后台页面跳转原页面 替换成location.reload(); this.IsLoading = true; this.allDataInfo(); 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/lexSelectAssetEstimateURF#id="+result.split('/')[1]; location.reload(); }else{ estimateUtility.toast.showToast(this, 'error', result); } }).catch(error => { }).finally(() => { location.reload(); this.IsLoading = false; }); } //estimate contract 同步 allDataInfo(){ this.allData.estimate = this.estimate; this.allData.contract = this.contract; } //保存返回 async handleSaveAndCancel(event){ //20231208 sx 贸易合规二期 add start var AccDealerBlacklist = this.contract.AccDealerBlacklist__c; //黑名单,警示名单 var AccDealerBlacklist2 = this.contract.AccDealerBlacklist2__c; //WYL 贸易合规2期 黑名单,警示名单 var TradeComplianceStatusFlagFW = this.allData.TradeComplianceStatusFlagFW; //贸易合规开关 let trandeFlagTwo = false; let violationName = ''; if(TradeComplianceStatusFlagFW == 'true'){ //经销商或者医院是冻结、黑名单时,进行拦截提醒,不允许保存 if(AccDealerBlacklist2 =='3' || AccDealerBlacklist2 =='4' || AccDealerBlacklist2 =='24'){ estimateUtility.toast.showToast(this, 'error', '黑名单:存在贸易合规风险,无法保存,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。'); this.EmailSending(1,null,null); return null; }else if(AccDealerBlacklist2 =='1' || AccDealerBlacklist2 =='2' || AccDealerBlacklist2 =='12'){ estimateUtility.toast.showToast(this, 'error', '冻结清单:可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法保存,有问题请联系法务部贸易合规窗口'+IFTradeComplianceAlertName+'。'); return null; } //经销商或者医院是警示名单时,对所选的合同对象设备进行判断,判断涉及产品是否符合条件,如不符合合规规则,则弹出一条消息,消息里面把每一条不合规的设备列出 else if(AccDealerBlacklist2 =='5' || AccDealerBlacklist2 =='6' || AccDealerBlacklist2 =='56'){ for(var ass in this.allData.checkedAssets){ if(ass.Product2.ProTradeComplianceStatus__c == '0'){ trandeFlagTwo = true; violationName += ass.Product2.Name + '、'; } } if(trandeFlagTwo){ if (!(await estimateUtility.toast.handleConfirmClick('您所选择的客户/经销商和最新报价里的产品,存在贸易合规警示风险,不建议做授权申请,请您确认是否继续申请,'+ IFTradeComplianceAlert2 + '涉及到的设备有:' + violationName))) { this.unblockUI(); return null; } } } } //20231208 sx 贸易合规二期 add end this.IsLoading = true; let checkResult = await this.onclickCheckchangedAfterPrint('true','true'); if (checkResult) { //修改值传回 this.allDataInfo(); //checkedAssets unCheckedAssetData 在更改的时候同步改动 let saveDataStr = JSON.stringify(this.allData); saveAndCancel({ saveData: saveDataStr, }).then(result => { if (result != null && result.indexOf('navigateTo') == -1) { estimateUtility.toast.showToast(this, 'error', result); }else if (result != null) { this.navigateToOtherObj(result.split('=')[1]); }else{ location.reload(); } }).catch(error => { }).finally(() => { this.IsLoading = false; }); } this.IsLoading = false; } //过去三年维修实绩计算 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; } //提交待审批 async handleApprove(event){ //onclick this.IsLoading = true; let resKindsAndMonths = await this.KindsAndMonths(); let resEGFlgconfim = await this.EGFlgconfim(); await this.approvalJs(); if (resKindsAndMonths && resEGFlgconfim) { await approvalProcess({ initDataStr: JSON.stringify(this.allData), }).then(result => { if (result.indexOf('navigateTo') != -1) { this.navigateToOtherObj(result.split('=')[1]); }else{ estimateUtility.toast.showToast(this, 'error', result); location.reload(); } }).catch(error => { }).finally(() => { }); //oncomplete this.unblockUI(); } this.IsLoading = false; } // async KindsAndMonths() { // 故障品加费 系统检查修理减价审批完成 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); } //分页Limit get pageDataLimitOptions() { return [ { label: '10', value: '10' }, { label: '20', value: '20' }, { label: '50', value: '50' }, { label: '100', value: '100' }, { label: '200', value: '200' }, ]; } //Page Limit 分页后台处理 handlePageLimitChange(event) { this.pageDataLimit = event.detail.value; this.allData.selRecordOption = event.detail.value; this.allData.selctRecordNum = this.allData.selRecordOption *1; this.IsLoading = true; // recordNumChange({ // initDataStr: JSON.stringify(this.allData), // }).then(result => { // this.handlePageBtnReturn(result); // }).catch(error => { // }).finally(() => { // }); // 前端 处理 this.currentPage = 1; this.allData.currPage = 1; // this.getUnCheckedAssetNowData(); this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets); this.IsLoading = false; } //首页 toFirst(event) { this.IsLoading = true; // firstPage({ // initDataStr: JSON.stringify(this.allData), // }).then(result => { // this.handlePageBtnReturn(result); // }).catch(error => { // }).finally(() => { // }); // 前端 处理 this.currentPage = 1; this.allData.currPage = 1; // this.getUnCheckedAssetNowData(); this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets); this.IsLoading = false; } //上一页 toPre(event) { this.IsLoading = true; if (this.currentPage <= 1) { this.IsLoading = false; return; } else { this.currentPage--; } //数据重载 // previousPage({ // initDataStr: JSON.stringify(this.allData), // }).then(result => { // this.handlePageBtnReturn(result); // }).catch(error => { // }).finally(() => { // }); // 前端 处理 this.allData.currPage = this.currentPage; 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++; } //数据重载 // nextPage({ // initDataStr: JSON.stringify(this.allData), // }).then(result => { // this.handlePageBtnReturn(result); // }).catch(error => { // }).finally(() => { // }); // 前端 处理 this.allData.currPage = this.currentPage; this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets); this.IsLoading = false; } //尾页 toEnd(event) { this.IsLoading = true; this.currentPage = this.pageCount; // endPage({ // initDataStr: JSON.stringify(this.allData), // }).then(result => { // this.handlePageBtnReturn(result); // }).catch(error => { // }).finally(() => { // }); // 前端 处理 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' }, ]; } //页面数据处理 //报价提交对象 变更 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'); } //报价提交对象 handleChangeEstimateTarget(event) { this.estimate.Estimate_Target__c = event.detail.value; //resetDealer 处理页面隐藏 this.handleEstimateTargetIsHospitalTrue(); } handleEstimateTargetIsHospitalTrue(){ this.EstimateTargetIsDealer = this.estimate.Estimate_Target__c == '经销商'; } //经销商名 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', '请注意,当前经销商为先款对象。'); } }); } //先款标识(经销商 todo 参照vm 改动? handleIsRecognitionModel(event) { this.estimate.Is_RecognitionModel__c = event.detail.checked; } //申请报价金额 ==checkDiscount handleRequestQuotationAmount(event) { this.IsRefresh = false; let val = event.currentTarget.value; if (val == null || val == "") { event.currentTarget.value = '' 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', '请输入数值'); event.currentTarget.value = 0.00; this.estimate.Request_quotation_Amount__c = 0.00; this.IsRefresh = true; return; } val = this.localParseFloat(val); val = Math.round(val); this.estimate.Request_quotation_Amount__c = val*1; this.makeRealPrice(1); this.estimate.Request_quotation_Amount__c = 0; this.event1 = setTimeout(() => { this.estimate.Request_quotation_Amount__c = Math.round(val); console.log('setTimeout',this.estimate.Request_quotation_Amount__c); }, 1); // this.estimate = JSON.parse(JSON.stringify(this.estimate)); // console.log('this.estimate.Request_quotation_Amount__c 01',this.estimate.Request_quotation_Amount__c); this.IsRefresh = true; } //最终价格决定形式 handleFinalPriceDecideWay(event) { this.estimate.finalPriceDecideWay__c = event.target.value; } //是否销售附带 handleSalesIncidental(event) { this.estimate.Sales_incidental__c = event.target.value; } //主要谈判次数 handleMainTalksTime(event) { this.estimate.mainTalksTime__c = event.target.value; } //谈判的开始时间 handleTalksStartDate(event) { this.estimate.talksStartDate__c = event.target.value; } //经销商和医院的价格 handleAgencyHosPrice(event) { // this.estimate.AgencyHos_Price__c = event.target.value; console.log('handleAgencyHosPrice',event.currentTarget.value); 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.target.value; } //消费率改善方案 handleImproveConsumptionRateIdea(event) { this.estimate.Improve_ConsumptionRate_Idea__c = event.target.value; } //合同对象设备 全选 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; } //合同对象设备 参保修理金额 handleTableRepairPriceChange(event) { let index = event.currentTarget.dataset.index; // classic 参保修理金额 在实际保存时依旧只留两位小数 let num = event.currentTarget.value*1; num = num.toFixed(2); this.allData.checkedAssets[index].mcae.Repair_Price__c = num; this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets); this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); } //合同对象设备 备注 handleTableCommentChange(event) { let index = event.currentTarget.dataset.index; this.allData.checkedAssets[index].mcae.Comment__c = event.target.value; } //URF-V最大大修次数: 判断值是否符合保存要求,page可能会为值可能为0,但保存时依旧会提示错误 handleChangeURFV(event) { var uRFSeriesMap =''; var originalVal = this.estimate.URF_V_MaxRepairCount__c; let val = event.target.value; for (var i = 0; i < this.productCount; i++) { let uRFSeries = 'checkedAssetsData:' + this.allData.checkedAssets[i].uFRSerial; uRFSeriesMap +=uRFSeries; uRFSeriesMap +=','; } // 选择 '/' val 为0 if (uRFSeriesMap.includes('URF-V')==false && (val !=null || val != "" || val != "0" || val !="/")) { // this.showToastMessage('URF-V系列', '合同对象设备中不含有URF-V系列,URF-V的最大大修次数必须选择/!', 'error');//错误 estimateUtility.toast.showToast(this, 'error', 'URF-V系列 合同对象设备中不含有URF-V系列,URF-V的最大大修次数必须选择/!'); this.estimate.URF_V_MaxRepairCount__c = '0'; this.isURFVChange = !this.isURFVChange; }else if ((val == null || val == "" || val == "0" || val =="/") && uRFSeriesMap.includes('URF-V')){ // this.showToastMessage('URF-V系列', '合同对象设备中含有URF-V系列,必须选择URF-V的最大大修次数!', 'error');//错误 estimateUtility.toast.showToast(this, 'error', 'URF-V系列 合同对象设备中含有URF-V系列,必须选择URF-V的最大大修次数!'); this.estimate.URF_V_MaxRepairCount__c = originalVal; this.isURFVChange = !this.isURFVChange; }else if ((val == "3") && uRFSeriesMap.includes('URF-V')){ // this.showToastMessage('URF-V系列', '合同对象设备中URF-V系列目前不能选择3次!', 'error');//错误 estimateUtility.toast.showToast(this, 'error', 'URF-V系列 合同对象设备中URF-V系列目前不能选择3次!'); this.estimate.URF_V_MaxRepairCount__c = originalVal; this.isURFVChange = !this.isURFVChange; }else{ this.estimate.URF_V_MaxRepairCount__c = val; } this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets ); this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); } //URF-P最大大修次数: handleChangeURFP(event) { console.log('handleChangeURFP'); var uRFSeriesMap =''; var originalVal = this.estimate.URF_P_MaxRepairCount__c; let val = event.target.value; for (var i = 0; i < this.productCount; i++) { var uRFSeries = 'checkedAssetsData' + i + this.allData.checkedAssets[i].uFRSerial; uRFSeriesMap +=uRFSeries; uRFSeriesMap +=','; } //!val 选择无 0 != null true (val !=null || val != "" || val != 0 || val !="/") if (uRFSeriesMap.includes('URF-P')==false && (val != 0 || !val)) { // this.showToastMessage('URF-P系列', '合同对象设备中不含有URF-P系列,URF-P的最大大修次数必须选择/!', 'error');//错误 estimateUtility.toast.showToast(this, 'error', 'URF-P系列 合同对象设备中不含有URF-P系列,URF-P的最大大修次数必须选择/!'); this.estimate.URF_P_MaxRepairCount__c = '0'; this.isURFPChange = !this.isURFPChange; }else if ((val == null || val == "" || val == "0" || val =="/") && uRFSeriesMap.includes('URF-P')){ // this.showToastMessage('URF-P系列', '合同对象设备中含有URF-P系列,必须选择URF-P的最大大修次数!', 'error');//错误 estimateUtility.toast.showToast(this, 'error', 'URF-P系列 合同对象设备中含有URF-P系列,必须选择URF-P的最大大修次数!'); this.estimate.URF_P_MaxRepairCount__c = originalVal; this.isURFPChange = !this.isURFPChange; }else{ this.estimate.URF_P_MaxRepairCount__c = val; } 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); // val = new Date(val); // this.estimate.Contract_Esti_End_Date__c = val.getFullYear()+'-'+(val.getMonth()+1+this.estimate.Contract_Range__c)+'-'+val.getDate(); this.estimate.Contract_Esti_End_Date__c = date; } console.log('this.estimate.Contract_Esti_End_Date__c',this.estimate.Contract_Esti_End_Date__c); } //获取当前页 未选择的保有设备 getUnCheckedAssetNowData(){ // if(this.unCheckedAssetData && this.unCheckedAssetData.length > 0){ // this.unCheckedAssetDataLength = this.allData.totalRecords; // console.log('this.unCheckedAssetDataLength',this.unCheckedAssetDataLength); // // this.unCheckedAssetNowData = this.unCheckedAssetData.slice((this.currentPage-1)*this.allData.selRecordOption,this.currentPage*this.allData.selRecordOption); // this.unCheckedAssetNowData = this.unCheckedAssetData; // }else{ // this.unCheckedAssetNowData = []; // } if(this.unCheckedAssetData && this.unCheckedAssetData.length > 0){ this.unCheckedAssetNowData = this.unCheckedAssetData.slice((this.currentPage-1)*this.allData.selRecordOption,this.currentPage*this.allData.selRecordOption); }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(); } //显示未选择保有设备 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(); searchBtn({ initDataStr: JSON.stringify(this.allData), }).then(result => { result = JSON.parse(result); this.allData = result; this.handleInitSimpleData(result); //unCheckedAssets 处理 this.handleunCheckedAssetColumnsAndData(result.unCheckedAssets); }).catch(error => { }).finally(() => { this.text1 = this.allData.text1 == '' ? 'S:AssetMark__c' : 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(); } //未选择的保有设备 当前页 全选 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.IF_Warranty__c == '否')) { ar.rec_checkBox_c = event.detail.checked; } }); } this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets); } //未选择的保有设备 勾选 handleTableUncheckedRecCheckBox(event) { let id = event.currentTarget.dataset.id; console.log('handleTableUncheckedRecCheckBox id',id); console.log('handleTableUncheckedRecCheckBox event.detail.checked',event.detail.checked); this.allData.unCheckedAssets.forEach(function(ar) { if (ar.rec.Id == id) { ar.rec_checkBox_c = event.detail.checked; } }); } //未选择的保有设备 确认添加 -- 刷新行选中 handleExchangeAsset(template,event) { this.IsLoading = true; this.IsRefresh = false; this.allDataInfo(); console.log('handleExchangeAsset unCheckedAssets',this.allData.unCheckedAssets); exchangeAsset({ initDataStr:JSON.stringify(this.allData) }).then(result => { result = JSON.parse(result); console.log('handleExchangeAsset result',result); if (result != null) { console.log(111); this.allData = result; //页面相关数据初始化 this.handleInitSimpleData(result); console.log(222); this.allData.checkedAssets = this.refreshAsset(result.checkedAssets.length,result.checkedAssets); console.log(333); this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); //param : unCheckedAssetsView console.log('handleExchangeAsset this.allData.unCheckedAssets',this.allData.unCheckedAssets); this.handleunCheckedAssetColumnsAndData(this.allData.unCheckedAssets); } }).catch(error => { }).finally(() => { this.IsLoading = false; this.IsShowUnCheckedAsset = false; // 两个表格的 全选 勾选 清除 this.IsCheckAllUncheckedAsset = false; this.IsCheckAllcheckedAsset = false; this.IsRefresh = true; }); this.unblockUI(); } //打印报价 复选框选择 单选 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; } //del 页面暂注释 三方协议 勾选 handlePrintContract(event) { let param = event.currentTarget.dataset.param; this.estimate[param] = event.detail.checked; } //PDF印刷 async handlePrint(){ this.IsLoading = true; // 20240117 hql 添加逻辑:页面锁定后无法点击且提示 var isdecide = this.estimate.Estimation_Decision__c;; if (isdecide == true) { estimateUtility.toast.showToast(this, 'error', '请前往文本信息录入页面进行打印'); this.IsLoading = false; return; } // 20240117 hql 添加逻辑:页面锁定后无法点击且提示 if (await this.onclickCheckchangedAfterPrint(this.SaveBtnDisabled,'false')) { this.allDataInfo(); print({ initDataStr: JSON.stringify(this.allData), }).then(result => { if (result != null && result.indexOf('printAsset') == -1) { estimateUtility.toast.showToast(this, 'error', result); }else if (result != null) { result = JSON.parse(result); console.log('print result',result); this.allData = result; //页面相关数据初始化 this.handleInitSimpleData(result); } }).catch(error => { }).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 {} } //合同开始日 handleContractStartDate(event) { this.estimate.Contract_Start_Date__c = event.detail.value; this.changeContractStartdate(this.estimate.Contract_Start_Date__c); } //行追加 handleAddNewRows(event){ this.IsLoading = true; addNewRows({ checkedAssetsStr: JSON.stringify(this.allData.checkedAssets), }).then(result => { console.log(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; }); } //estimate contract 同步 allDataInfo(){ this.allData.estimate = this.estimate; this.allData.contract = this.contract; } //合同对象设备 机身编码跳转保有设备 handlePageNagivateTo(event) { let param = event.currentTarget.dataset.param; // console.log('index',param); this.navigateToOtherObj(param); } //页面对象跳转 navigateToOtherObj(recordId){ this.IsLoading = true; this[NavigationMixin.Navigate]({ type:'standard__recordPage', attributes:{ recordId:recordId, objectApiName:'Account', actionName:'view' } }); } //服务合同 内容修改 通过传入参数,制定字段值 //科室 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 = val; // 2023/09/01 合同结束预订日 显示同步 this.handleChangeContractEstiEndDate(this.estimate.Contract_Esti_Start_Date__c); this.allDataInfo(); // 报价规则改善 20230310 end if (!this.SaveBtnDisabled) { this.estimate.Contract_Start_Date__c =val; this.changeContractStartdate(val); } this.IsRefresh = true; } // async changeContractStartdate(val) { var oldDateStr = 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; //blockme(); //contractStartDateChange(); this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets); this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); } } //合同月数 == 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 = ''; // }else{ // this.estimate.Contract_Range__c = event.target.value; // } if (errorMsg != '') { estimateUtility.toast.showToast(this, 'error', errorMsg); //页面值同步刷新 event.target.value = ''; } this.estimate.Contract_Range__c = event.target.value; // 2023/09/01 合同结束预订日 显示同步 this.handleChangeContractEstiEndDate(this.estimate.Contract_Esti_Start_Date__c); //页面数据刷新 --checkAssetData reresh this.allData.checkedAssets = this.refreshAsset(this.allData.checkedAssets.length,this.allData.checkedAssets); this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); } //合同对象设备 数据修改处理 保有设备名 handleTableProductManualChange(event) { //补充原page的信息判断 弹出提示后,页面值无法清除,但也不会添加到list中 if (!this.estimate.Contract_Esti_Start_Date__c) { estimateUtility.toast.showToast(this, 'error', '合同开始预定日: 必须输入一个值'); return; } // Contract_Esti_End_Date__c 字段有计算逻辑,页面填写无意义 // if (!this.estimate.Contract_Esti_End_Date__c) { // estimateUtility.toast.showToast(this, 'error', '合同结束预订日: 必须输入一个值'); // return; // } 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 => { if (result.includes('不是限次产品,请重新选择!')) { estimateUtility.toast.showToast(this, 'error', result); this.allData.checkedAssets[index].mcae.Product_Manual__c = null; }else{ result = JSON.parse(result); //对后台返回数据 进行处理 this.allData.checkedAssets = this.refreshAsset(result.length,result); } }).catch(error => { }).finally(() => { this.handleCheckedAssetColumnsAndData(this.allData.checkedAssets); this.unblockUI(); }); } //parseFloat 避免NAN localParseFloat(val){ val = val == undefined ? null : val; return parseFloat(val*1); } }