FUYU
2023-12-13 4488f711dbc01a8db6753907cae2ef4021dede68
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
96
97
98
99
100
import { LightningElement, track, wire, api } from 'lwc';
import LightningConfirm from 'lightning/confirm';
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
 
import cancelApply from '@salesforce/apex/TransferApplyWebService.cancelApply';
 
export default class lexCancelApply extends LightningElement {
     @api recordId;
     IsLoading=true;
     cancelResult;
  
 
    @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('this.raeSetId:' + this.recordId);
        
        LightningConfirm.open({
            message: '确定取消?',
            variant: 'headerless',
            label: 'this is the aria-label value',
            
        }).then(cancel=>{
      //       this.IsLoading=false;
            // this.dispatchEvent(new CloseActionScreenEvent());
            if(cancel) {
                cancelApply({
                    taId : this.recordId
                }).then(result => {
                    this.cancelResult = result;
                    this.cancelSubmit().then(res=>{
                        this.IsLoading=false;
                        this.dispatchEvent(new CloseActionScreenEvent());
                    });    
                            
                }).catch( error =>{
                    console.log(error);
                }).finally(()=>{
 
                    
                });
            }
            
        });
        
        
    }
 
    async cancelSubmit(){
        if(this.cancelResult == '1') {
            await this.showToast("",'取消成功',"success"); 
            window.location.href = window.location;
                    
        } else {
            console.log("result:",this.cancelResult);
            await this.showToast("",this.cancelResult,"warning");     
        }
            
    }
    showToast(_title,_message,_variant) {
        const event = new ShowToastEvent({
            title: _title,
            message:_message,
            variant: _variant,
        });
        this.dispatchEvent(event);
    }
    
}
 
//old js
 
// {!REQUIRESCRIPT('/soap/ajax/51.0/connection.js')}
// {!REQUIRESCRIPT('/soap/ajax/51.0/apex.js')}
// if (confirm("确定取消?")) {
// var rs = sforce.apex.execute("TransferApplyWebService","cancelApply",{taId:'{!TransferApply__c.Id}'});
// if(rs == '1'){
// alert('取消成功');
// window.location.href = window.location;
// }
// else{
// alert(rs);
// }
// }