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
import { LightningElement,api, track, wire } from 'lwc';
import {CurrentPageReference} from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import execute from '@salesforce/apex/SoakupHPDeptTeam.execute';
import init from '@salesforce/apex/SoakupTeamController.init';
 
import { CloseActionScreenEvent } from 'lightning/actions';
export default class LexSoakupTeam extends LightningElement {
    @api recordId;
    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(){
        init({recordId:this.recordId}).then(res => {
            if (confirm(res.ConfirmSoakupHPDeptTeam)) {
                execute({deptClassId: res.id}).then(rep => {
                    if (rep != 'OK') {
                        this.showToast(rep,'error');
                    } else {
                    
                        this.showToast('反映完成','success');
                    }
                }).catch((e) => {
                    if (e.faultcode == 'sf:INSUFFICIENT_ACCESS') {
                        this.showToast('没有执行权限','error');
                    } else {
                        this.showToast(e,'success');
                    }
                });
            }
        }).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());
    }
}