/* * @Description: * @version: * @Author: chen jing wu * @Date: 2023-09-09 13:31:12 * @LastEditors: chen jing wu * @LastEditTime: 2023-09-14 16:09:41 */ import { LightningElement,wire,track,api} from 'lwc'; import { CurrentPageReference } from "lightning/navigation"; import { CloseActionScreenEvent } from 'lightning/actions'; import init from '@salesforce/apex/lexSolutionProjectRequirementsController.initForApplyAgainButton'; import { NavigationMixin } from 'lightning/navigation'; import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils'; import lwcCSS from '@salesforce/resourceUrl/lwcCSS'; import {loadStyle} from 'lightning/platformResourceLoader'; export default class LexApplyAgainLwc extends NavigationMixin(LightningElement) { @api recordId; departmentClassId; hospitalId; @wire(CurrentPageReference) getStateParameters(currentPageReference) { console.log(111); console.log(currentPageReference); if (currentPageReference) { const urlValue = currentPageReference.state.recordId; if (urlValue) { let str = `${urlValue}`; console.log("str"); console.log(str); this.recordId = str; } } } connectedCallback(){ Promise.all([ loadStyle(this, lwcCSS) ]); init({ recordId: this.recordId }).then(result=>{ console.log(result); this.departmentClassId = result.departmentClass; this.hospitalId = result.hospital; this.ApplyAgain(); }); } ApplyAgain(){ const defaultValues = encodeDefaultFieldValues({ old_Project_No__c: this.recordId, Department_Class__c: this.departmentClassId, Hospital__c: this.hospitalId, Name: '*' }); this[NavigationMixin.Navigate]({ type: 'standard__objectPage', attributes: { objectApiName: 'SolutionProjectRequirements__c', actionName: 'new' }, state: { nooverride: '1', defaultFieldValues: defaultValues } }); this.dispatchEvent(new CloseActionScreenEvent()); } }