import { LightningElement,wire,track,api } from 'lwc';
|
import { CurrentPageReference,NavigationMixin } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import LeadNewDailyReportId from '@salesforce/label/c.LeadNewDailyReportId';
|
import selectinfrastructureById from '@salesforce/apex/LexinfrastructureProjectController.selectInfrastructureProject';
|
|
export default class LexCreateLead extends NavigationMixin(LightningElement) {
|
@api recordId;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
console.log(currentPageReference);
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
console.warn("str");
|
console.warn(str);
|
this.recordId = str;
|
}
|
}
|
}
|
connectedCallback(){
|
debugger
|
selectinfrastructureById({recordId:this.recordId}).then(item=>{
|
// var url = '/00Q/e?' + 'Infrastructure_Project__c=' + '{!Infrastructure_Project__c.Id}'
|
// + '&LeadSource=基建项目' + '&RecordTypeId=01210000000QiRf' + '&retURL=%2F' + '{!Infrastructure_Project__c.Id}' ;
|
// window.open(url);
|
const defaultValues = encodeDefaultFieldValues({
|
Infrastructure_Project__c: this.recordId,
|
LeadSource: '基建项目',
|
Hospital_Name__c:item.OCSM_Hospital__c,
|
RecordTypeId:LeadNewDailyReportId
|
});
|
console.log('defaultValues = ' + defaultValues);
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Lead',
|
actionName: 'new'
|
},
|
state: {
|
// nooverride: '1',
|
defaultFieldValues: defaultValues
|
}
|
});
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
}
|