buli
2023-04-26 d6a096fadfe9c8f261f56a827cfceed663c36b8b
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
import { LightningElement,api, track, wire } from 'lwc';
import init  from '@salesforce/apex/EquipmentSetRentalController.init';
import AssignBtn  from '@salesforce/apex/RentalApplyWebService.AssignBtn';
import {CurrentPageReference} from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
export default class lexEquipmentSetRental_Order extends LightningElement {
 
     @api recordId;
     IsLoading;
     Rental_Apply__c;
 
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        if(currentPageReference){
            console.log(currentPageReference);
            console.log("进入获取page参数")
            const IdValue=currentPageReference.state.recordId;
            if(IdValue){
                let str=`${IdValue}`;
                this.recordId=str;
                console.log("recordId="+str);
            }
        }
    }
 
 
    connectedCallback(){
    init({recordId:this.recordId}).then(res=>{
        if(res!=null){
        this.IsLoading=false;
        console.log("res");
        console.log(res);
        console.log("进入初始化对象其他属性");
        this.Rental_Apply__c=res;
        console.log(this.Rental_Apply__c);
        this.distribution();
        }
        else{
             var a="没进distribution";
 console.log(a);
        }
    }).catch(error =>{
        console.log("error");
        console.log(error.message);
    }).finally(()=>{
 
    });
    }
 
 
 
    async distribution(){
          var raid = this.Rental_Apply__c.Id;
        var rtn = await AssignBtn(raid);
        if(this.Rental_Apply__c.Status__c == '取消' && this.Rental_Apply__c.Rental_Apply_Equipment_Set_Cnt__c != '0') {
            window.open("/apex/EquipmentRentalApply?raid="+URLENCODE(this.Rental_Apply__c.Id));
        } else if((this.Rental_Apply__c.demo_purpose2__c == '学会/展台' ||
            this.Rental_Apply__c.demo_purpose2__c == '课题研究' || 
            this.Rental_Apply__c.demo_purpose2__c == '培训中心'
            )
            && this.Rental_Apply__c.Status__c == '草案中') {
            alert("不能引当,请确认申请的状态");
        } else if(
            (this.Rental_Apply__c.demo_purpose2__c == '试用(无询价)' ||
            this.Rental_Apply__c.demo_purpose2__c == '试用(有询价)' || 
            this.Rental_Apply__c.demo_purpose2__c == '动物实验' ||
            this.Rental_Apply__c.demo_purpose2__c == '一般维修代用' ||
            this.Rental_Apply__c.demo_purpose2__c == '保修合同用户维修代用' ||
            this.Rental_Apply__c.demo_purpose2__c == '已购待货'
            )
            && this.Rental_Apply__c.Status__c != '批准完了'
            && this.Rental_Apply__c.Status__c != '引当完了'
            && this.Rental_Apply__c.Status__c != '出库指示完了') {
                alert("不能引当,请确认申请的状态");
        } else if(rtn == 'Fin') {
            window.open("/apex/EquipmentRentalApply?raid="+URLENCODE(this.Rental_Apply__c.Id));
        } else{
            alert(rtn);
        }      
 
    }
}