import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import { NavigationMixin } from 'lightning/navigation'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import recordTypeId from '@salesforce/apex/toBatchOwnerController.TypeId'; export default class LexAssignTaskButtonAccount extends NavigationMixin(LightningElement) { @api recordId; IsLoading=true; @wire(CurrentPageReference) getStateParameters(currentPageReference){ console.log("进入页面"); console.log(currentPageReference); if(currentPageReference){ const urvalue=currentPageReference.state.recordId; if(urvalue){ let str=`${urvalue}`; console.log('str'); console.log(str); this.recordId=str; } } } connectedCallback(){ recordTypeId().then(res => { const defaultValues = encodeDefaultFieldValues({ account__c: this.recordId, taskStatus__c: '01 分配', taskDifferent__c: '上级分配任务' }); this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'task__c', actionName: 'new' }, state: { nooverride: '1', defaultFieldValues: defaultValues, recordTypeId: res.recordTypeId } }); }).catch(err => { console.log('err======>',err) }) this.dispatchEvent(new CloseActionScreenEvent()); } }