liuyn
2024-03-22 e8be4d964c6b336ed39dba5900b1b9a8f3181b96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { LightningElement,wire,track,api } from 'lwc';
import { CurrentPageReference,NavigationMixin } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import HospitalAccountrecordTypeId from '@salesforce/label/c.HospitalAccountrecordTypeId';
 
 
export default class LexCreateHospital 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
        // console.warn('recordId'+this.recordId);
        // var url = '/001/e?' + '00N10000009HFQT=基建项目&AccountSource=基建项目' + '&RecordType=01210000000QemG' + '&retURL=%2F' + this.recordId;
        // window.open(url);
        const defaultValues = encodeDefaultFieldValues({
            Hospital_Source__c: '基建项目',
            AccountSource: '基建项目',
            Infrastructure_Project__c : this.recordId //DB202311157614 WYL new
        });
        console.log('defaultValues = ' + defaultValues);
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Account',
                actionName: 'new'
            },
            state: {
                nooverride: '1',
                defaultFieldValues: defaultValues,
                recordTypeId: HospitalAccountrecordTypeId
            }
        });
        this.dispatchEvent(new CloseActionScreenEvent());
    }
 
}