buli
2023-07-14 5b5c1e16deaa3a9d6d0ed1ffca390655ed103df7
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * @Date: 2023-03-28 13:58:54
 * @Author: @zyh
 * @LastEditTime: 2023-04-17 16:40:08
 * @Descripttion: 
 */
import { LightningElement,wire,track,api } from 'lwc';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import { NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init from '@salesforce/apex/OPDLwcController.initOPDCancelSubmit';
import changeTrade from '@salesforce/apex/OpdPlanWebService.changeTrade';
 
export default class OpdReportSubmit extends LightningElement {
    @api recordId;
    Status;
    Name;
    Id;
    Rental_Apply1_Status_New;
    Rental_Apply2_Status_New;
    Rental_Apply3_Status_New;
    Rental_Apply4_Status_New;
    Rental_Apply5_Status_New;
    Related_Opportunity1_ID;
    Related_Opportunity1_Name;
    Related_Opportunity2_ID;
    Related_Opportunity2_Name;
    Activity_Type2;
    Account_Laboratory;
    OCM_category_ID;
    OCM_category_Name;
    HospitalID;
    HospitalName;
    Rental_Apply2;
    IsLoading = true;
 
    @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);
            console.log('123123111' + result.Related_Opportunity1_ID);
            if(result != null) {
                this.IsLoading = false;
                this.Id = result.Id;
                this.Status = result.Status;
                this.Name = result.Name;
                this.Rental_Apply1_Status_New = result.Rental_Apply1_Status_New;
                this.Rental_Apply2_Status_New = result.Rental_Apply2_Status_New;
                this.Rental_Apply3_Status_New = result.Rental_Apply3_Status_New;
                this.Rental_Apply4_Status_New = result.Rental_Apply4_Status_New;
                this.Rental_Apply5_Status_New = result.Rental_Apply5_Status_New;
                this.Related_Opportunity1_ID = result.Related_Opportunity1_ID;
                this.Related_Opportunity1_Name = result.Related_Opportunity1_Name;
                this.Related_Opportunity2_ID = result.Related_Opportunity2_ID;
                this.Related_Opportunity2_Name = result.Related_Opportunity2_Name;
                this.Activity_Type2 = result.Activity_Type2;
                this.Account_Laboratory = result.Account_Laboratory;
                this.OCM_category_ID = result.OCM_category_ID;
                this.OCM_category_Name = result.OCM_category_Name;
                this.HospitalID = result.HospitalID;
                this.HospitalName = result.HospitalName;
                this.Rental_Apply2 = result.Rental_Apply2;
                console.log("123");
                console.log(this.Id);
                console.log(this.Status);
                console.log(this.Name);
                console.log(this.Rental_Apply2_Status_New);
                this.opdReportSubmit();
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log("error");
            console.log(error);
        }).finally(() => {
            
        });
    }
    opdReportSubmit(){
        if(this.Status == '取消' || this.Status == '完毕' ){
            const evt = new ShowToastEvent({
                title : 'Error',
                message : 'OPD计划的状态为取消或完毕时,不能新建OPD报告',
                variant : 'error'
            });
            this.dispatchEvent(evt);
            // alert('OPD计划的状态为取消或完毕时,不能新建OPD报告');
            return;
        }
        if( this.Rental_Apply1_Status_New != "已出库" && this.Rental_Apply1_Status_New != "申请者已收货" && 
            this.Rental_Apply1_Status_New != "医院已装机确认" && this.Rental_Apply1_Status_New != "已回寄" && 
            this.Rental_Apply1_Status_New != "已回收" && this.Rental_Apply1_Status_New != "完了" && this.Rental_Apply1_Status_New != "欠品中" && 
            this.Rental_Apply2_Status_New != "已出库" && this.Rental_Apply2_Status_New != "申请者已收货" && 
            this.Rental_Apply2_Status_New != "医院已装机确认" && this.Rental_Apply2_Status_New != "已回寄" && 
            this.Rental_Apply2_Status_New != "已回收" && this.Rental_Apply2_Status_New != "完了" && this.Rental_Apply2_Status_New != "欠品中" && 
            this.Rental_Apply3_Status_New != "已出库" && this.Rental_Apply3_Status_New != "申请者已收货" && 
            this.Rental_Apply3_Status_New != "医院已装机确认" && this.Rental_Apply3_Status_New != "已回寄" && 
            this.Rental_Apply3_Status_New != "已回收" && this.Rental_Apply3_Status_New != "完了" && this.Rental_Apply3_Status_New != "欠品中" && 
            this.Rental_Apply4_Status_New != "已出库" && this.Rental_Apply4_Status_New != "申请者已收货" && 
            this.Rental_Apply4_Status_New != "医院已装机确认" && this.Rental_Apply4_Status_New != "已回寄" && 
            this.Rental_Apply4_Status_New != "已回收" && this.Rental_Apply4_Status_New != "完了" && this.Rental_Apply4_Status_New != "欠品中" && 
            this.Rental_Apply5_Status_New != "已出库" && this.Rental_Apply5_Status_New != "申请者已收货" && 
            this.Rental_Apply5_Status_New != "医院已装机确认" && this.Rental_Apply5_Status_New != "已回寄" && 
            this.Rental_Apply5_Status_New != "已回收" && this.Rental_Apply5_Status_New != "完了" && this.Rental_Apply5_Status_New != "欠品中"
            ){
            const evt = new ShowToastEvent({
                title : 'Error',
                message : '没有出库的申请不允许创建OPD报告!',
                variant : 'error'
            });
            this.dispatchEvent(evt);
            // alert("没有出库的申请不允许创建OPD报告!");
            // return;
        }
        var strs='';
        if(""!=this.Related_Opportunity1_ID && null!=this.Related_Opportunity1_ID){
            strs='&CF00N10000002DT68='+this.Related_Opportunity1_Name +
            '&CF00N10000002DT68_lkid='+ this.Related_Opportunity1_ID +
            '&CF00N10000002DYCZ=' + this.Related_Opportunity2_Name +
            '&CF00N10000002DYCZ_lkid=' + this.Related_Opportunity2_ID +
            '&00N10000002DHk5=跟进询价'
            // alert('123');
        }
        var urlStr = '';
 
        urlStr += '&CF00N10000002CWW4='+ this.Account_Laboratory +
        '&CF00N10000002CWW4_lkid='+ this.Account_Laboratory +
        '&CF00N10000002Dh0f_lkid='+ this.OCM_category_ID +
        '&CF00N10000002Dh0f='+ this.OCM_category_Name +
        '&CF00N10000002DPUD_lkid='+ this.HospitalID +
        '&CF00N10000002DPUD='+ this.HospitalName;
 
        urlStr += '&CF00N10000004maf3='+ this.Rental_Apply2 +
        '&CF00N10000008ps6d='+ this.Name +
        '&CF00N10000008ps6d_lkid=' + this.Id;
        window.open('/setup/ui/recordtypeselect.jsp?ent=01I10000000SWfe&retURL=%2F'+ this.Id +'&save_new_url=%2Fa0B%2Fe%3FretURL%3D%252Fa0B%252Fo'+urlStr +strs)
    }
}