import { LightningElement,api, track, wire } from 'lwc'; import getUserId from '@salesforce/apex/LexRentalApplyControllerLWT.getUserId'; import getProfileId from '@salesforce/apex/LexRentalApplyControllerLWT.getProfileId'; import init from '@salesforce/apex/LexRentalApplyControllerLWT.initFromCancelSubmitButton'; import selectRentalApplyEquipmentSetDetailByRacId from '@salesforce/apex/LexRentalApplyControllerLWT.selectRentalApplyEquipmentSetDetailByRacId'; import selectQISReportById from '@salesforce/apex/LexRentalApplyControllerLWT.selectQISReportById'; import selectRepairById from '@salesforce/apex/LexRentalApplyControllerLWT.selectRepairById'; import selectCampaignById from '@salesforce/apex/LexRentalApplyControllerLWT.selectCampaignById'; import selectRentalApplyEquipmentSetByRacId from '@salesforce/apex/LexRentalApplyControllerLWT.selectRentalApplyEquipmentSetByRacId'; import selectRentalApplyById from '@salesforce/apex/LexRentalApplyControllerLWT.selectRentalApplyById'; import selectUserById from '@salesforce/apex/LexRentalApplyControllerLWT.selectUserById'; import selectQISreportById2 from '@salesforce/apex/LexRentalApplyControllerLWT.selectQISreportById2'; // import setSObjectShare from '@salesforce/apex/LexRentalApplyControllerLWT.setSObjectShare'; import updateRentalApplyC from '@salesforce/apex/LexRentalApplyControllerLWT.updateRentalApplyC'; import updateRentalApplyOPD from '@salesforce/apex/LexRentalApplyControllerLWT.updateRentalApplyOPD'; //备品智能化add sx import getMainProfileId from '@salesforce/apex/LexRentalApplyControllerLWT.getMainProfileId'; // import RentalApplyCheckForSAoneEle from '@salesforce/apex/LexRentalApplyControllerLWT.RentalApplyCheckForSAoneEle'; import RentalApplyCheckForSAoneEle from '@salesforce/apex/RentalApplyWebService.RentalApplyCheckForSAoneEle'; import raesCountCheck from '@salesforce/apex/OpdPlanWebService.raesCountCheck'; import {CurrentPageReference} from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import STATUS_PROCESS_STATE from '@salesforce/label/c.StatusProcessState'; import TradeComplianceStatusFlagBP from '@salesforce/label/c.TradeComplianceStatusFlagBP'; import IFTradeComplianceAlertBP from '@salesforce/label/c.IFTradeComplianceAlertBP'; import setSObjectShare from '@salesforce/apex/ControllerUtil.setSObjectShare'; import { ShowToastEvent } from 'lightning/platformShowToastEvent'; import LightningConfirm from 'lightning/confirm'; import { updateRecord } from 'lightning/uiRecordApi'; import Id from '@salesforce/user/Id'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName'; // wyl 贸易合规2期 add import tradeTempleSend from '@salesforce/apex/SendEmailUtil.tradeTempleSend'; //贸易合规二期 发邮件20240130 export default class lexSubmitApprovalProcessLWC extends LightningElement { contactFirstName = 'Yan'; contactLastName = 'Khang'; opportunityName = 'Possible deal'; clickedButtonLabel; @api recordId; @track StatusProcessState=STATUS_PROCESS_STATE; @track TradeComplianceStatusFlagBP = TradeComplianceStatusFlagBP; @track IFTradeComplianceAlertBP = IFTradeComplianceAlertBP; Rental_Apply__c; Status__c; Id; Yi_loaner_arranged__c; RA_Status__c; IsLoading=true; IsReload=true; RecordTypeId; @wire(CurrentPageReference) getStateParameters(currentPageReference){ console.log("进入页面"); console.log(currentPageReference); if(currentPageReference){ const urvalue=currentPageReference.state.recordId; if(urvalue){ let str=`${urvalue}`; this.recordId=str; } } } async connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); console.log(this.recordId); await init({recordId:this.recordId}).then(result=>{ console.log(result); if(result!=null){ this.Rental_Apply__c=result.rac; this.RecordTypeId=result.RecordTypeId; this.Status__c=result.rac.Status__c; this.Yi_loaner_arranged__c=result.rac.Yi_loaner_arranged__c; this.Id=result.rac.Id; this.RA_Status__c=result.rac.RA_Status__c; this.sumit().then(res=>{ console.log("关闭窗口"); this.IsLoading=false; this.dispatchEvent(new CloseActionScreenEvent()); //https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Rental_Apply__c/a0t0l000001Lu5mAAC/view if(this.IsReload){ window.location.href='/lightning/r/Rental_Apply__c/' + this.recordId + '/view'; } console.log('reload===='); }).catch(err=>{ console.log("error:"); console.log(err.message); this.showToast("操作失败,提示信息:"+err.message,'warning'); }).finally(()=>{ console.log('finally====='); //this.updateRecordView(this.recordId); console.log('刷新====='); }) } }).catch(err=>{ console.log("initerror:"+err.message); }) } async sumit(){ let buttons = document.getElementsByName('submit_approval_process'.toLowerCase()); for (let i=0; i{ console.log(result); if(result!=null){ raesdList=result; let stoppedSet = new Set(); for(let i=0;i 0) { this.showToast(Array.from(stoppedSet).join(',') + ' 产品注册证状态为停止,不可申请','warning'); return; } } }).catch(err=>{ console.log("selectRentalApplyEquipmentSetDetailByRacId error:"+err); }) //20231229 sx DB202312530994 课题start 1229上线验证注释 var creatDate = new Date(this.Rental_Apply__c.CreatedDate); var GoLiveDate = new Date("2024-01-01"); if(this.Rental_Apply__c.direct_send__c == '医疗机构' && creatDate > GoLiveDate && ((this.Rental_Apply__c.Medical_Institution_Address__c == '' || this.Rental_Apply__c.Medical_Institution_Address__c == undefined) || (this.Rental_Apply__c.Medical_Institution_Address_sup__c == '' || this.Rental_Apply__c.Medical_Institution_Address_sup__c == undefined ) ) ){ this.showToast('医疗机构地址和医疗机构地址补充不能为空,请点击按钮【选择医疗地址】进行选择','warning'); return; } //20231229 sx DB202312530994 课题end //20231106 sx 课题DB202310484652 add start console.log('this.Rental_Apply__c.direct_send__c'+this.Rental_Apply__c.direct_send__c); if(this.Rental_Apply__c.direct_send__c =='办事处' || this.Rental_Apply__c.direct_send__c =='经销商' || this.Rental_Apply__c.direct_send__c =='上门自提'){ const directResult = await LightningConfirm.open({ message: "备品发送地为非医疗机构或会场,还请确认是否继续提交?", variant: 'headerless', label: '提示信息', // setting theme would have no effect }); if(!directResult){ this.IsReload = false; return; } } //20231106 sx 课题DB202310484652 add end console.log('this.Rental_Apply__c.repeatFixtureTXT__c===' + this.Rental_Apply__c.repeatFixtureTXT__c); if(!(this.Rental_Apply__c.repeatFixtureTXT__c == '' || this.Rental_Apply__c.repeatFixtureTXT__c == null || this.Rental_Apply__c.repeatFixtureTXT__c == undefined)){ //20231222 sx 备品智能化 重复配套add 有重复配套需要提醒 start const repateResult = await LightningConfirm.open({ message: "重复配套申请将审批到副总裁,还请确认是否继续提交?", variant: 'headerless', label: '提示信息', // setting theme would have no effect }); if(!repateResult){ this.IsReload = false; return; } //20231222 sx 备品智能化 重复配套add 有重复配套需要提醒 end } if(this.Rental_Apply__c.demo_purpose2__c == '索赔QIS'){ let DeliveryGood = new Array(); await selectQISReportById({recordId:this.Rental_Apply__c.QIS_number__c}).then(result=>{ console.log(result); DeliveryGood=result; }).catch(err=>{ console.log("select1 error:"); console.log(err.message); }).finally(()=>{ }); console.log(DeliveryGood); let records= DeliveryGood; if(records.length == 0 || !modelSet.has(records[0].nonyushohin__r.Product2.Fixture_Model_No_T__c)){ //'申请的型号必须与QIS申请型号一致' this.showToast('申请的型号必须与QIS申请型号一致','warning'); return; } } if(this.Rental_Apply__c.Repair__c==null){ console.log("Repair__c为空"); }else{ if( this.Rental_Apply__c.Repair__c != ''){ console.log("hhh7.1.1"); let DeliveryGood ; let records; await selectRepairById({recordId:this.Rental_Apply__c.Repair__c}).then(result=>{ console.log(result); DeliveryGood=result; records=result; }).catch(err=>{ console.log("select1 error:"); console.log(err.message); }).finally(()=>{ }); if(records==null||records.length==0){ console.log("records为空"); }else{ if(this.Rental_Apply__c.Demo_purpose1__c == '维修代用' && this.Rental_Apply__c.demo_purpose2__c != '索赔QIS') { if(!modelSet.has(records[0].Delivered_Product__r.Product2.Fixture_Model_No_T__c)){ //alert('申请的型号必须与送修的型号一致'); this.showToast('申请的型号必须与送修的型号一致','warning'); return; } } if(this.Rental_Apply__c.Demo_purpose1__c==null){ console.log("Demo_purpose1__c为空"); }else if(this.Rental_Apply__c.Demo_purpose1__c == '维修代用' && this.Rental_Apply__c.demo_purpose2__c == '一般用户' ){ if (records[0].Repair_Estimated_date_formula__c == null) { //alert('一般维修无报价日,不可借用备品'); this.showToast('一般维修无报价日,不可借用备品','warning'); return; } else if (records[0].Repair_Estimated_date_formula__c < '2019-07-01' && records[0].Agreed_Date__c == null) { //alert('报价日在2019/7/1之前且户同意日为空,不可借用备品'); this.showToast('报价日在2019/7/1之前且户同意日为空,不可借用备品','warning'); return; } //20210608 ljh SFDC-C3CCN4 start if(records[0].Repair_Rank__c == '' || records[0].Repair_Rank__c == null){ //alert('报价等级为空不能申请备品'); this.showToast('报价等级为空不能申请备品','warning'); return; }else{ if(records[0].DW_Sign_Txt__c == 'false' && records[0].Repair_Rank__c == 'DW'){ //alert('DW报价等级下此型号不符合备品申请借用条件'); this.showToast('DW报价等级下此型号不符合备品申请借用条件','warning'); return; } if(records[0].Repair_Rank__c == 'D1' ||records[0].Repair_Rank__c == 'D2' ||records[0].Repair_Rank__c == 'D3' ||records[0].Repair_Rank__c == 'E2'){ //alert('报价等级不符合备品申请借用条件'); this.showToast('报价等级不符合备品申请借用条件','warning'); return; } } //20210608 ljh SFDC-C3CCN4 end } if(this.Rental_Apply__c.Demo_purpose1__c ==null){ console.log("Demo_purpose1__c为空"); }else if(this.Rental_Apply__c.Demo_purpose1__c == '维修代用' && this.Rental_Apply__c.demo_purpose2__c == '市场多年保修' ){ if (records[0].FSE_ApplyForRepair_Day__c == null) { // alert('市场多年保修,没有[FSE修理申请日],不可借用备品'); this.showToast('市场多年保修,没有[FSE修理申请日],不可借用备品','warning'); return; } } if(this.Rental_Apply__c.Demo_purpose1__c == '维修代用' && this.Rental_Apply__c.demo_purpose2__c == '故障排查' ){ if (records[0].FSE_ApplyForRepair_Day__c == null) { //alert('故障排查,没有[FSE修理申请日],不可借用备品'); this.showToast('故障排查,没有[FSE修理申请日],不可借用备品','warning'); return; } if(records[0].Repair_Ordered_Date__c != null) { //alert('故障排查,[4.修理品RC受理日]必须为空'); this.showToast('故障排查,[4.修理品RC受理日]必须为空','warning'); return; } if(records[0].IfCheckFixture__c == 'false'){ //alert('不满足故障排查目的'); this.showToast('不满足故障排查目的','warning'); return; } } let profileId=""; let mainProfiledId=''; await getMainProfileId().then(result=>{ console.log(result); mainProfiledId=result.substring(0,15); }).catch(err=>{ console.log("getProfileId error:"); console.log(err.message); }).finally(()=>{ }); await getProfileId().then(result=>{ console.log(result); profileId=result.substring(0,15); }).catch(err=>{ console.log("getProfileId error:"); console.log(err.message); }).finally(()=>{ }); console.log("=========================================="); console.log('管理员id:'+ mainProfiledId); console.log('当前用户id: '+ profileId); console.log('RecordTypeId: '+ this.RecordTypeId); console.log('this.Rental_Apply__c.RecordTypeId: '+ this.Rental_Apply__c.RecordTypeId); console.log('records[0].NewProductGuaranteeObject__c: '+ records[0].NewProductGuaranteeObject__c); console.log('records[0]: '+ records[0]); console.log(records[0]); if(this.Rental_Apply__c.RecordTypeId==null){ console.log("RecordTypeId为空"); }else if (this.Rental_Apply__c.RecordTypeId != this.RecordTypeId && profileId != mainProfiledId && records[0].NewProductGuaranteeObject__c == '8: 市场多年保修' && this.Rental_Apply__c.demo_purpose2__c != '市场多年保修') { //alert('无偿区别标志为8: 市场多年保修,必须选择市场多年保修。'); this.showToast('无偿区别标志为8: 市场多年保修,必须选择市场多年保修。','warning'); return; } if(records[0].Repair_Final_Inspection_Date__c != null){ //alert('存在修理最终检测日,不可借用备品'); this.showToast('存在修理最终检测日,不可借用备品','warning'); return; } if(records[0].Repair_Shipped_Date__c != null){ //alert('存在RC修理返送日,不可借用备品'); this.showToast('存在RC修理返送日,不可借用备品','warning'); return; } if(records[0].Status1__c =='0.删除' ||records[0].Status1__c =='0.取消' ||records[0].Status1__c =='5.完毕' ){ //alert('修理已经结束,不能申请备品'); this.showToast('修理已经结束,不能申请备品','warning'); return; } if ( this.Rental_Apply__c.demo_purpose2__c == '再修理' && records[0].ReRepairObject_F__c == 'false') { //alert('不属于再受理参考对象,不可借用备品'); this.showToast('不属于再受理参考对象,不可借用备品','warning'); return; } if (this.Rental_Apply__c.RecordTypeId != this.RecordTypeId && this.Rental_Apply__c.demo_purpose2__c != '保修用户' && this.Rental_Apply__c.demo_purpose2__c != '市场多年保修' && records[0].Number_of_EffectiveContract__c == '有' ) { //alert('有维修合同,必须选择保修用户.'); this.showToast('有维修合同,必须选择保修用户.','warning'); return; } let AssetModelNo = records[0].Delivered_Product__r.Product2.Asset_Model_No__c; if (this.Rental_Apply__c.RecordTypeId != this.RecordTypeId && records[0].Number_of_EffectiveContract__c == '无' && (records[0].NewProductGuaranteeObject__c == '2: 服务多年保修' && (AssetModelNo == 'LTF-190-10-3D' || AssetModelNo == 'LTF-S190-5' || AssetModelNo == 'CYF-VHA' || AssetModelNo == 'CYF-VA2' || AssetModelNo == 'CYF-5A'|| AssetModelNo == 'LTF-S190-10'|| AssetModelNo == 'OER-AW'|| AssetModelNo == 'URF-V'|| AssetModelNo == 'URF-V2'|| AssetModelNo == 'URF-P6')) && this.Rental_Apply__c.demo_purpose2__c != '保修用户' ) { //alert('此设备型号多年保修,请选择保修用户.'); this.showToast('此设备型号多年保修,请选择保修用户.','warning'); return; } if (this.Rental_Apply__c.RecordTypeId != this.RecordTypeId && records[0].NewProductGuaranteeObject__c == '2: 服务多年保修' && (AssetModelNo == 'CV-V1' || AssetModelNo == 'CV-V1(A)' || AssetModelNo == 'CV-V1(B)' || AssetModelNo == 'GIF-LV1' || AssetModelNo == 'CF-LV1L' || AssetModelNo == 'CF-LV1I' || AssetModelNo == 'MAJ-1910') && (this.Rental_Apply__c.demo_purpose2__c == '一般用户' || this.Rental_Apply__c.demo_purpose2__c == '再修理') ) { //alert('奥辉设备,保修期内不提供备品.'); this.showToast('奥辉设备,保修期内不提供备品.','warning'); return; } // 借用机会可视化---修理预计完成日提醒 by:zyh 2023-12-11 start if(records[0].Planned_Repair_Completed_Date__c != null){ if(!confirm('修理预计完成日为'+records[0].Planned_Repair_Completed_Date__c+',是否确认提交申请单?')){ return; } } // 借用机会可视化---修理预计完成日提醒 by:zyh 2023-12-11 end } } } console.log("t"); if(this.Rental_Apply__c.SupplementCreated__c==null){ console.log("SupplementCreated__c为空"); }else if (this.Rental_Apply__c.SupplementCreated__c == '1' && this.Rental_Apply__c.OPDPlan__c != '') { console.log('tttt'); let raId = this.Id.substring(0,15); console.log(this.Id); console.log(this.recordId); //kk let raesCountCheckt = await raesCountCheck({rentalApplyId: raId}); console.log(raesCountCheckt); if(raesCountCheckt != 'OK'){ //alert(raesCountCheck); this.showToast(raesCountCheckt,'warning'); return; } } if(this.Rental_Apply__c.Campaign__c==null){ console.log("Campaign__c为空"); }else if( this.Rental_Apply__c.Campaign__c != ''){ let DeliveryGood = new Array(); // 20220324 ljh obpm update start //kk1 let statusSting = this.StatusProcessState; let statusList = statusSting.split(','); // DeliveryGood = sforce.connection.query("select Status, Rental_Apply_Flag__c from Campaign where id ='{!Rental_Apply__c.Campaign__c}'"); // DeliveryGood = await selectCampaignById(this.Rental_Apply__c.Campaign__c); await selectCampaignById({recordId:this.Rental_Apply__c.Campaign__c}).then(result=>{ console.log(result); DeliveryGood=result; }).catch(err=>{ console.log("selectCampaignById error:"); console.log(err.message); }) // 20220324 ljh obpm update start //kk let records= DeliveryGood; let interval = records[0].Status; let records_Date = records[0].Rental_Apply_Flag__c; if (interval==null ) { //alert("请确认学会状态"); this.showToast('请确认学会状态','warning'); return; } else if (interval == '草案中') { //alert('学会状态为草案中,不能提交'); this.showToast('学会状态为草案中,不能提交','warning'); return; } else if (interval == '申请中') { //alert('学会状态为申请中,不能提交'); this.showToast('学会状态为申请中,不能提交','warning'); return; } else if (interval == '已结束') { // alert('学会状态为已结束,不能提交'); this.showToast('学会状态为已结束,不能提交','warning'); return; } else if (interval == '已提交报告') { // alert('学会状态为已提交报告,不能提交'); this.showToast('学会状态为已提交报告,不能提交','warning'); return; } else if (interval == '取消申请中') { // alert('学会状态为取消申请中,不能提交'); this.showToast('学会状态为取消申请中,不能提交','warning'); return; } else if (interval == '取消') { // alert('学会状态为取消,不能提交'); this.showToast('学会状态为取消,不能提交','warning'); return; } //kk if(this.Rental_Apply__c.Request_shipping_day__c==null){ // alert("请确认希望到货日期"); this.showToast('请确认希望到货日期','warning'); return; }else{ if (d >= this.Rental_Apply__c.Request_shipping_day__c -7) { // alert("必须提前于希望到货日7天以上提交申请"); this.showToast('必须提前于希望到货日7天以上提交申请','warning'); return; } // 20220324 ljh obpm add start if (records != null && records[0].IF_Approved__c == "true" && (records[0].Meeting_Approved_No__c == null || records[0].Meeting_Approved_No__c == "") ) { // alert("没有决裁号的,暂不能出借,请更新裁决信息。"); this.showToast('没有决裁号的,暂不能出借,请更新裁决信息。','warning'); return; } if (records != null && records[0].IF_Approved__c == "true" && records[0].Meeting_Approved_No__c != "" && statusList.indexOf(records[0].Approved_Status__c) != -1 && records[0].Approved_Status__c != '草稿' ) { // alert("已申请决裁但决裁状态不符合条件。"); this.showToast('已申请决裁但决裁状态不符合条件。','warning'); return; } } // 20220324 ljh obpm add end } if (this.Rental_Apply__c.QIS_number__c == null) { console.log("QIS_number__c 是空的"); }else{ if( this.Rental_Apply__c.QIS_number__c != ''){ let DeliveryGood = new Array(); // DeliveryGood =await selectQISreportById2(this.Rental_Apply__c.QIS_ID_Line__c); await selectQISreportById2({recordId:this.Rental_Apply__c.QIS_ID_Line__c}).then(result=>{ console.log(result); DeliveryGood=result; }).catch(err=>{ console.log("selectCampaignById error:"); console.log(err.message); }).finally(()=>{ }); let records= DeliveryGood; let interval = records[0].next_action__c; if (interval == '送回') { // alert("QIS 已送回,不能再申请备品了"); this.showToast('QIS 已送回,不能再申请备品了','warning'); return; } } } // zq 20231107 修改共享 start // // share // let userAccess = new Array(); // //kk // console.log("dd"); // let t=this.Rental_Apply__c.applyUser__c+'_Edit'; // userAccess.push(t); // console.log("hhh"); // let rtn ; // await setSObjectShare({sobjectName:'Rental_Apply__Share',rowCause:'ApplyUserShare__c',parentId:this.Rental_Apply__c.Id,userAccess:userAccess,ownerId:this.Rental_Apply__c.OwnerId}).then(result=>{ // console.log('result===='+result); // rtn=result; // }).catch(err=>{ // console.log("setSObjectShare error:"+err); // }) let userAccess = new Array(); if(this.applyUser != undefined){userAccess.push(this.applyUser+'_Edit');} let rtn = await setSObjectShare({ sobjectName:'Rental_Apply__Share', rowCause:'ApplyUserShare__c', parentId:this.Rental_Apply__c.Id, userAccess:userAccess, ownerId:this.Rental_Apply__c.OwnerId }); // zq 20231107 修改共享 end if(rtn==null){ // alert("rtn为空"); this.showToast('rtn为空','warning'); return; }else{ if (rtn != 'OK'){ // alert(rtn); this.showToast(rtn,'warning'); return; } } if(this.Rental_Apply__c.Status__c == null){ // alert('请备品申请状态确认,不能为空'); this.showToast('请备品申请状态确认,不能为空','warning'); return; }else{ if (this.Rental_Apply__c.Status__c == '填写完毕' || this.Rental_Apply__c.Status__c == '申请中' || this.Rental_Apply__c.Status__c == '已批准' || this.Rental_Apply__c.Status__c == '申请中(OPD未通过)' || //20231213 sx 备品智能化添加 //现在申请书的Status__c已经没有引当完了状态。所以这里不需要判断 //'{!Rental_Apply__c.Status__c}' == '引当完了' || this.Rental_Apply__c.Status__c == '已出库指示' || this.Rental_Apply__c.Status__c == '删除' || this.Rental_Apply__c.Status__c == '取消' ) { // alert('请备品申请状态确认,已经提交过的申请,不能重复提交'); this.showToast('请备品申请状态确认,已经提交过的申请,不能重复提交','warning'); return; } } // 没有明细的一览check let raesList = new Array(); // raesList = selectRentalApplyEquipmentSetByRacId(this.recordId); await selectRentalApplyEquipmentSetByRacId({recordId:this.recordId}).then(result=>{ console.log(result); raesList=result; }).catch(err=>{ console.log("selectRentalApplyEquipmentSetByRacId="+err); }) let records= raesList; if(records.length > 0){ // alert('有没有明细的借出备品配套一览,不能提交'); this.showToast('有没有明细的借出备品配套一览,不能提交','warning'); return; } let racs ; await selectRentalApplyById({recordId:this.recordId}).then(result=>{ console.log(result); racs=result; }).catch(err=>{ console.log("selectRentalApplyById error:"+err); }) //20231007 sx 备品智能化新加 start console.log('result.rac.OPDPlan__c'+ this.Rental_Apply__c.OPDPlan__c + 'result.rac.Demo_purpose1__c' + this.Rental_Apply__c.Demo_purpose1__c + 'result.rac.OPDPlanStatus__c' + this.Rental_Apply__c.OPDPlanStatus__c); if(this.Rental_Apply__c.OPDPlan__c != null && this.Rental_Apply__c.Demo_purpose1__c == '产品试用' && (this.Rental_Apply__c.OPDPlanStatus__c=='草案中' || this.Rental_Apply__c.OPDPlanStatus__c=='提交' || this.Rental_Apply__c.OPDPlanStatus__c=='审批中')){ this.IsReload = true; console.log('IsReload===' + this.IsReload); await updateRentalApplyOPD({recordId:this.recordId, updateStatus:'申请中(OPD未通过)'}).then(res=>{ //20240107 sx修改 智能化上线不想要这个提醒 //this.showToast("OPD计划还没审批通过,请先审批OPD!" + JSON.stringify(res),'warning'); console.log('updateRentalApplyOPDres===' + JSON.stringify(res)); }).catch(err=>{ console.log('err'+ JSON.stringify(err)); }) return; }else{ let racNew = racs[0]; let id=this.Rental_Apply__c.Id; let Status__c="填写完毕"; let userId; await getUserId().then(result=>{ console.log(result); userId=result; }).catch(err=>{ console.log("selectCampaignById error:"+err); }) let manageUsers; await selectUserById({recordId:userId}).then(result=>{ console.log(result); manageUsers=result; }).catch(err=>{ console.log("selectUserById error:"+err); }) let SalesManagerSubmit__c; let OPDManagerApprover__c; let BuchangApprovalManagerSalesSubmit__c; let OPDBuchangApprover__c; if(manageUsers[0].JingliEquipmentManager__c != null){ SalesManagerSubmit__c = manageUsers[0].JingliEquipmentManager__r.Name; // 20220930 ljh SWAG-CJR8S7 start if(racNew.OPDPlan__c != null){ OPDManagerApprover__c = SalesManagerSubmit__c == racNew.OPDPlan__r.SalesManager_Txt__c?SalesManagerSubmit__c:' '; } // 20220930 ljh SWAG-CJR8S7 end } if(manageUsers[0].Buzhang_Equipment_Manager__c != null){ BuchangApprovalManagerSalesSubmit__c = manageUsers[0].Buzhang_Equipment_Manager__r.Name; //2022-07-22 zyh // 20220930 ljh SWAG-CJR8S7 start if(racNew.OPDPlan__c != null){ OPDBuchangApprover__c = BuchangApprovalManagerSalesSubmit__c == racNew.OPDPlan__r.BuchangApprovalManagerSales_Txt__c?BuchangApprovalManagerSalesSubmit__c:' '; } // 20220930 ljh SWAG-CJR8S7 end } let resultt; await updateRentalApplyC({ recordId:id, SalesManagerSubmitC:SalesManagerSubmit__c, StatusC:Status__c, OPDManagerApproverC:OPDManagerApprover__c, BuchangApprovalManagerSalesSubmitC:BuchangApprovalManagerSalesSubmit__c, OPDBuchangApproverC:OPDBuchangApprover__c }).then(res=>{ console.log('updateRentalApplyCsuccess==='+JSON.stringify(res)); if(res!=null&&res.success==false){ resultt=res; let messages =""; messages=resultt.errors[0]; if (messages!=null&&messages!="") { this.showToast("操作失败,提示信息:"+messages,'warning'); return; } }else{ console.log('===刷新==='); //this.updateRecordView(this.recordId); } }).catch(err=>{ console.log("updateRentalApplyC error:"+err); console.log(err); console.log(err.message); }) this.dispatchEvent(new CloseActionScreenEvent()); } //20231007 sx 备品智能化新加 end }; showToast(msg,type) { if(type == 'success'){ const event = new ShowToastEvent({ message: msg, variant: type }); this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); }else{ const event = new ShowToastEvent({ message: msg, variant: 'error', // duration: 30000 mode: 'sticky' }); this.IsReload=false; this.dispatchEvent(event); this.dispatchEvent(new CloseActionScreenEvent()); } } updateRecordView(recordId) { updateRecord({fields: { Id: recordId }}); } }