buli
2023-07-11 0c4796706fc9473d069b620321a54b20a119906c
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-04-03 14:21:56
 * @Author: @zyh
 * @LastEditTime: 2023-04-04 15:15:17
 * @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/OPDLwcController.initOPDCancelSubmit';
import RecordType from '@salesforce/apex/OPDLwcController.RecordType';
import opdSelect from '@salesforce/apex/OPDLwcController.opdSelect';
// import applySelect from '@salesforce/apex/OPDLwcController.applySelect';
import changeTrade from '@salesforce/apex/OpdPlanWebService.changeTrade';
import datacheck from '@salesforce/apex/OpdPlanWebService.dataCheck';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
 
export default class OpdSupplementaryApplication extends NavigationMixin(LightningElement) {
    @api recordId;
    Status;
    Name;
    Id;
    supplementaryApplication;
    OriginalOpdPlanRental;
    Rental_Apply2;
    @wire(CurrentPageReference)
    getStateParmeters(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('zheli'+this.recordId);
        init({
            recordId: this.recordId
        }).then(result => {
            console.log('zheli11'+result);
 
            console.log(result);
            if(result != null) {
                this.IsLoading = false;
                this.Id = result.Id;
                this.Status = result.Status;
                this.Name = result.Name;
                this.supplementaryApplication = result.supplementaryApplication;
                this.OriginalOpdPlanRental = result.OriginalOpdPlanRental;
                this.Rental_Apply2 = result.Rental_Apply2;
                console.log("123");
                console.log(this.Id);
                console.log(this.Status);
                console.log(this.Name);
                console.log(this.supplementaryApplication);
                console.log(this.OriginalOpdPlanRental);
                this.SupApplication();
                // this.updateDateSubmit();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
            
        });
    }
    SupApplication(){
        var opdList = [];
        if(this.Status != '计划中'){
            alert("只有OPD计划状态为计划中,才能进行OPD补充申请");
            return;
        }
        if(this.supplementaryApplication == '1'){
            alert('OPD计划无法进行补充申请');
            return;
        }
        if(this.OriginalOpdPlanRental != ''){
            alert('请转至OPD计划原单进行申请');
            return;
        }
        datacheck({
            rentalApplyId : this.Rental_Apply2
        }).then( result => {
            console.log(result);
            if(result != 'OK'){
                alert(result);
                return;
            }
        });
        opdSelect({
            OpdId : this.Id
        }).then( result => {
            console.log(result);
            opdList = result;
            var records = opdList.getArray("records");
            if(records != null && records.length > 0){
                alert('OPD计划已进行过补充申请,无法再次进行补充申请');
                return;
            }
        });
    }
}