liangxiaozhen
2023-08-06 8d9fdd2c68656e04ea4115e994f20051b2358c90
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import init from '@salesforce/apex/AccountDelayApplyController.init';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
export default class LexAccountDelayApplyButton extends NavigationMixin(LightningElement) {
    @api recordId;
    IsLoading=true;
    label;
    @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(){
        console.log("进入页面111111");
        console.log("进入页面111111" + this.recordId);
        init({recordId:this.recordId}).then(result=>{
            console.log('result==========',result);
            this.IsLoading = false;
            if(result!=null){
                if(result.AccSize.length > 0){
                    this.showToast('存在申请中的客户变更申请,无法再次提交变更申请。','error')
                    return
                }
                if(result.status == '有効'){
                    const data = encodeDefaultFieldValues({
                        Hospital__c:this.recordId,
                        Grade__c:result.accgrade,
                        HospitalName__c:result.accname,
                        Alias_Name2__c:result.AliasName2,
                        Abbreviation_old__c:result.Abbreviation,
                        Abbreviation__c:result.AttributeType,
                        Postal_Code__c:result.PostalCode,
                        Speciality_Type__c:result.SpecialityType,
                        State_Master__c:result.shengId,
                        Town__c:result.Town,
                        City_Master__c:result.shiId,
                        Street__c:result.Street,
                        Field3_companyname__c:result.Field3companyname,
                        Site__c:result.Site
                    });
                    this[NavigationMixin.Navigate]({
                        type: 'standard__objectPage',
                        attributes: {
                            objectApiName: 'Account_Delay_Apply__c', 
                            actionName: 'new'
                        },
                        state:{
                            defaultFieldValues:data
                        }
                    });
 
                }else{
                    this.showToast('该客户不在有效中,不可进行客户变更','error')
                }
            }
            this.dispatchEvent(new CloseActionScreenEvent());
        }).catch(err=>{
            console.log("error:====",err);
            console.log(err);
        }).finally(()=>{});
    }
 
    showToast(msg, type) {
        const event = new ShowToastEvent({
          title: "",
          message: msg,
          variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}