buli
2023-05-23 07390e2fcb4adf27c928335bf27ae7939c5a80ad
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
/*
 * @Date: 2023-05-16 13:32:13
 * @Author: @zyh
 * @LastEditTime: 2023-05-17 14:02:00
 * @Descripttion: 
 */
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import  init  from '@salesforce/apex/lexRentalApply_FromRepCtl.rentalApp';
import  rentalApp  from '@salesforce/apex/lexRentalApply_FromRepCtl.init';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import  changeTrade  from '@salesforce/apex/OpportunityWebService.changeTrade';
import  selectAgencyHospital  from '@salesforce/apex/OtherButtonOppCtl.selectAgencyHospital';
import  selectRecordType  from '@salesforce/apex/OtherButtonOppCtl.selectRecordType';
import  selectFieldDefinition  from '@salesforce/apex/OtherButtonOppCtl.selectFieldDefinition';
 
export default class LexEquipmentRentalApply_FromRepair2 extends LightningElement {
    @api recordId;//OpportunityId
    stauts1;
    inspectionDate;
    shippedDate;
    assetModelNo;
    qisRepairId;
    qisRepairName;
    repairSource;
    maintenanceContract;
    purpose2;
    IsLoading = true;
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference) {
            console.log(111);
            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.recordId);
        rentalApp({
            recordId: this.recordId
        }).then(result => {
            console.log('rentalApp============' + result);
            if(result.lenth > 0){
                const evt = new ShowToastEvent({
                    title : 'Error',
                    message : '同一个型号的修理记录不能重复申请备品',
                    variant : 'error'
                });
                this.dispatchEvent(evt);
                return;
            }
            init({
                recordId: this.recordId
            }).then(result => {
                // console.log(result);
                // const evt = new ShowToastEvent({
                //     title : 'Error',
                //     message : '同一个型号的修理记录不能重复申请备品1111111',
                //     variant : 'error'
                // });
                // this.dispatchEvent(evt);
                // return;
                if (result != null) {
                    
                    this.IsLoading = false;
                    this.currencyIsoCode = result.currencyIsoCode;
                    this.status = result.stageName;
                    this.quostatus = result.estimationDecision;
                    this.win = result.SAPSendOK;
                    this.Auth = result.IfAuthorizingLock;
                    this.agency1Id = result.agency1Id;
                    this.agencyOpportunity = result.agencyOpportunity;
                    this.trade = result.trade;
                    this.oppName = result.oppName;
                    this.opp = result.opp;
    
                    // this.changeContractType();
                    this.dispatchEvent(new CloseActionScreenEvent());
                    // window.location.reload();
                }
            }).catch(error => {
                console.log("error");
                console.log(error);
            }).finally(() => {
                
            });
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
 
        });
        
                
    }
    insertApplyRepair(){
        
    }
}