import { LightningElement, track, wire, api } from 'lwc'; import { CurrentPageReference,NavigationMixin } from 'lightning/navigation'; import { CloseActionScreenEvent } from 'lightning/actions'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import init from '@salesforce/apex/NewTransferApplyController.init'; import getRecordId from '@salesforce/apex/NewTransferApplyController.getRecordId'; export default class lexNewTransferApply extends LightningElement { @api recordId; IsLoading = true; raId; raName; @wire(CurrentPageReference) getStateParameters(currentPageReference){ if(currentPageReference) { const urlValue = currentPageReference.state.recordId; if(urlValue) { let str = `${urlValue}`; this.recordId = str; } } } connectedCallback(){ init({ recordId: this.recordId }).then(result =>{ console.log(this.recordId); this.raId = result.raId; this.raName = result.raName; let raDetailSet = result.rae; console.log(raDetailSet); let IsCanCreateTransfer = false; if(raDetailSet.length > 0){ if(raDetailSet[0].Rental_Apply__r.RecordType.DeveloperName != 'AgencyRequest'){ alert('此记录类型不支持新建调拨单'); }else{ for(let i=0; i{ const defaultValues = encodeDefaultFieldValues({ recordId: res, Name: '*', Rental_Apply__c: this.recordId }); this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'TransferApply__c', actionName: 'new' }, state:{ defaultFieldValues: this.defaultValues } }) }) }else{ alert('该申请没有符合条件的借出备品配套一览明细!'); } } }else{ alert('该申请没有符合条件的借出备品配套一览明细!'); } }) .catch(err=>{ this.dispatchEvent(new CloseActionScreenEvent()); console.log('init==='+err); }) } }