liwentao
2023-08-07 5ba06835141d1af5fa26a72055f1eee2fc8a4c52
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
87
88
89
90
91
92
93
94
95
import { LightningElement,api, track, wire } from 'lwc';
import { CurrentPageReference } from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import LightningConfirm from 'lightning/confirm';
import init from '@salesforce/apex/LexRequestCloseController.init';
import getProfileId from '@salesforce/apex/LexRequestCloseController.getProfileId';
import updateTask from '@salesforce/apex/LexRequestCloseController.updateTask';
import getProfileIds from '@salesforce/apex/LexRequestCloseController.getProfileIds';
 
 
export default class lexRequestClose extends LightningElement {
    @api recordId;
    @api isDoneRendering;
    IsLoading=true;
    isShow=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(){
        this.dispatchEvent(new CloseActionScreenEvent());
        console.log(this.recordId);
        init({recordId:this.recordId}).then(result=>{
            // this.dispatchEvent(new CloseActionScreenEvent());
            this.cancelSubmit().then(res=>{
                this.isShow=false;
                this.IsLoading=false;
                this.dispatchEvent(new CloseActionScreenEvent());
                const passOneEvent = new CustomEvent('closem', {
                detail: '111'
              });
              this.dispatchEvent(passOneEvent);
            });    
        }).catch(err=>{
            // console.log("error:");
            // console.log(err.message);
        }).finally(()=>{
            this.dispatchEvent(new CloseActionScreenEvent());
        });
    }
 
 
 
    async cancelSubmit(){
        var pro = await getProfileId();
        var fag = true;
        var ids = await getProfileIds();
        // pro='00e10000000s3Jp';
        if( ids.indexOf(pro) == -1 ){
            fag=false;
            const event = new ShowToastEvent({
                title: '提示信息',
                message:'不需要做授权确认',
            });
            this.dispatchEvent(event);    
        }
        if(fag){
            var Id = this.recordId;
            var Status = "完了";            await updateTask({
                recordId:Id,
                Status:Status
            }).then(res=>{
                if(res!=null&&res.success==false){
                    var messages=res.errors[0];
                    if (messages!=null&&messages!="") {
                        const event = new ShowToastEvent({
                            title: '提示信息',
                            message:"操作失败,提示信息:"+messages,
                        });        
                        this.dispatchEvent(event);
                        return;
                    }
                }
                else this.dispatchEvent(new CloseActionScreenEvent());
            }).catch(err=>{
                // console.log("updateRentalApplyC error:");
                // console.log(err.message);
            });
            window.location.reload();
        }
    }
 
}