liuyn
2024-03-22 e8be4d964c6b336ed39dba5900b1b9a8f3181b96
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
import { LightningElement,wire,api,track } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import submitApproval from '@salesforce/apex/LexProductLimitApprovalCtrl.submitApproval';
 
export default class LexProductLimitApprovalLwc extends LightningElement {
 
    @api recordId;
    @track isShowSpinner = false;
    @track comment;
    @track sender;
 
    connectedCallback(){
 
    }
 
    commentChange(event){
        this.comment = event.detail.value;
    }
 
    senderChange(event){
        this.sender = event.detail.value;
    }
 
    confirm(){
        this.isShowSpinner = true;
        submitApproval({recordId : this.recordId, comment : this.comment, sender : this.sender})
        .then((result)=>{
            if (result.result == 'Success') {
                this.showToast('提交成功', '', 'success');
                this.isShowSpinner = false;
                this.refresh();
                this.cancel();
            }else{
                console.log('Error:' + result.errorMsg);
                this.isShowSpinner = false;
                this.showToast(result.errorMsg, '', 'error');
            }
        })
    }
 
    cancel(){
        this.dispatchEvent(new CustomEvent('close'));
    }
 
    refresh(){
        this.dispatchEvent(new CustomEvent('refresh'));
    }
 
    showToast(title, message, variant) {
        const evt = new ShowToastEvent({
            title: title,
            message: message,
            variant: variant
        });
        this.dispatchEvent(evt);
    }
}