buli
2023-04-20 f0bccccbb88d93ac05010c17d4b2e0cb22a2ce9a
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
102
103
104
105
106
107
108
109
110
import { LightningElement,api, track, wire } from 'lwc';
import init from '@salesforce/apex/RentalApplyCancleButtonController.initRentalApplyCanle'
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
export default class lexRentalApplyCanleButton extends LightningElement {
 
 
    @api recordId;
    Yi_loaner_arranged__c;
    Id;
    RA_Status__c;
    IsLoading=true;
    @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;
            }
        }
    }
 
        currentDay(){
        var date=new Date();    
        var toDay=new Date();
        toDay='';
        toDay+=date.getFullYear()+'/';
        toDay+=date.getMonth()+1+'/';
        toDay+=date.getDate();
        return toDay;
    }
 
 
    connectedCallback(){
        console.log(this.recordId);
        init({recordId:this.recordId}).then(result=>{
            console.log(result);
            if(result!=null){
                this.IsLoading=false;
                var a=new Array('a');
                a.push('12');
                console.log('a='+a);
                this.Yi_loaner_arranged__c=result.YiLoanerArranged;
                this.Id=result.Id;
                this.RA_Status__c=result.RAStatus;
                console.log("end");
                console.log("RA_Status__c="+this.RA_Status__c);
                console.log("Yi_loaner_arranged__c="+this.Yi_loaner_arranged__c);
                this.cancelSubmit();    
            }
        }).catch(err=>{
            console.log("error:");
            console.log(err);
        }).finally(()=>{
 
        });
    }
 
 
 
    cancelSubmit(){
        console.log('进入方法');
        if (this.RA_Status__c  == "取消") {
            this.dispatchEvent(new CloseActionScreenEvent());
            // alert("已经取消!");
            const event = new ShowToastEvent({
                title: '提示信息',
                message:"已经取消!"
            });
            this.dispatchEvent(event);
            console.log('10');
            return;
        }
        console.log("1  if  end ");
        if (this.RA_Status__c == "删除" ) {
            this.dispatchEvent(new CloseActionScreenEvent());
            // alert("已经删除!");
            const event = new ShowToastEvent({
                title: '提示信息',
                message:"已经删除!"
            });
            this.dispatchEvent(event);
            console.log('20');
            return;
        }
        console.log('2  if  end');
        if(this.RA_Status__c  == "已出库" || this.Yi_loaner_arranged__c > 0) {
            this.dispatchEvent(new CloseActionScreenEvent());
            // alert("备品已经出库,不能取消!");
            const event = new ShowToastEvent({
                title: '提示信息',
                message:"备品已经出库,不能取消!"
            });
            this.dispatchEvent(event);
            console.log('2');
            return;
        }
        console.log("111111111111111111111111");
        var raid = this.Id;
        console.log("raid="+raid)
        window.open("/apex/RentalApplyCancel?objId="+raid, 'RentalApplyCancel', 'width=500,height=250');
        
    }
}