buli
2023-04-21 43fdbff49764d55c7b3a19a1d6e7d8aeb62072ef
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
101
import { LightningElement, track, wire,api } from 'lwc';
import {CurrentPageReference,NavigationMixin} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import LightningConfirm from 'lightning/confirm';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 
 
 
import applyPermission from '@salesforce/apex/TransferApplyController.applyPermission';
import submitApply from '@salesforce/apex/TransferApplyWebService.submitApply';
 
export default class lexSubmitApprovalProcess extends LightningElement {
    @api recordId;
    transferApplyPermission;
    IsLoading=true;
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
        console.log(currentPageReference);
 
        if(currentPageReference) {
            const urlValue = currentPageReference.state.recordId;
            if(urlValue) {
                let str = `${urlValue}`;
                console.log("str");
                console.log(str);
                this.recordId = str;
 
            }
        }
    }
 
    connectedCallback() {
        console.log('this.transferApplyId:' + this.recordId);
        applyPermission().then(result => {
            console.log(result);
            this.transferApplyPermission = result;            
            this.cancelSubmit();    
                    
        }).catch( error =>{
            console.log(error);
        });
    }
    
    cancelSubmit(){
        if (this.transferApplyPermission == false) {
            this.showToast('','没有提交申请的权限','warning');
        } else{
            LightningConfirm.open({
                message: '一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?',
                variant: 'headerless',
              
            }).then(cancel=>{
                if(cancel) {
                    submitApply({taId:this.recordId}).then(submitRes=>{
                        if(submitRes == '1'){
                            this.showToast('','提交成功','success');
                            window.location.href = window.location;
                        }else{
                            this.showToast("",submitRes,"warning");
                        }
                        this.IsLoading=false;
                        this.dispatchEvent(new CloseActionScreenEvent());
                    });    
                }
            });
            
        }        
    }
    
    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')}
var result = sforce.connection.describeSObject('TransferApply__c');
if (result.createable == 'false') {
    alert('没有提交申请的权限');
}
else{
    if (confirm("一旦提交此记录以待批准,根据您的设置您可能不再能够编辑此记录或将他从批准过程中调回。是否继续?")) {
        var rs = sforce.apex.execute("TransferApplyWebService","submitApply",{taId:'{!TransferApply__c.Id}'});
        if(rs == '1'){
            alert('提交成功');
            window.location.href = window.location;
        }
        else{
            alert(rs);
        }
    }
}
*/