liangxiaozhen
2023-08-06 1d17c4022a928eacff7309016cde76f29ad257fb
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import UserInfo_Owner  from '@salesforce/apex/NewAgencyContractController.UserInfo_Owner';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import { CloseActionScreenEvent } from 'lightning/actions';
 
export default class LexNewAgencyContract extends NavigationMixin(LightningElement) {
    @api recordId;
    ProfileId;
    IsLoading=true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                this.recordId=str;
            }
        }
    }
 
    connectedCallback(){
        UserInfo_Owner().then(res => {
            console.log('result===>',res)
            if (res.id == '00510000002YSBIAA4' || res.ProfileId == '00e10000000Y3o5AAC') {
                this.showToast('会自动分配新建合同的客户编码,保留旧编码的时候请用复制合同。','success');
                const defaultFieldValues = encodeDefaultFieldValues({
                    Agent_Ref__c:this.recordId,
                });
                this[NavigationMixin.Navigate]({
                    type: 'standard__objectPage',
                    attributes: {
                        objectApiName: 'Account',
                        actionName:'new'
                    },
                    state:{
                        defaultFieldValues:defaultFieldValues,
                        recordTypeId:res.RecordTypeId
                    }
                });
            } else {
                this.showToast('没有新建的权限','error');
            }
        }).catch(err => {
            console.log('err:',err)
        })
        
    }
 
    showToast(msg,type) {
        const event = new ShowToastEvent({
            message: msg,
            variant: type
        });
        this.IsLoading = false;
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}