liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import { LightningElement, track, wire, api } from 'lwc';
import { CurrentPageReference,NavigationMixin } from 'lightning/navigation';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { CloseActionScreenEvent } from 'lightning/actions';
import { updateRecord } from 'lightning/uiRecordApi';
 
import init from '@salesforce/apex/lexConsumApplyController.init';
import approvalCheck from '@salesforce/apex/ConsumApplyWebService.approvalCheck';
import setShipment_request from '@salesforce/apex/ConsumApplyWebService.setShipment_request';
import getLength1 from '@salesforce/apex/lexConsumApplyController.getLength1';
import getLength2 from '@salesforce/apex/lexConsumApplyController.getLength2';
import TradeComplianceStatusFlagBP from '@salesforce/label/c.TradeComplianceStatusFlagBP';
import IFTradeComplianceAlertBP from '@salesforce/label/c.IFTradeComplianceAlertBP';
import IFTradeComplianceAlert2 from '@salesforce/label/c.IFTradeComplianceAlert2';        //20240121 sx 贸易合规二期冻结名单和黑名单拆开 add
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';        //20240121 sx 贸易合规二期冻结名单和黑名单拆开 add
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
import LightningConfirm from 'lightning/confirm';
import IFTradeComplianceAlertName from '@salesforce/label/c.IFTradeComplianceAlertName'; // WYL 贸易合规2期 add
import tradeConsumTempleSend from '@salesforce/apex/SendEmailUtil.tradeConsumTempleSend';   //贸易合规二期 发邮件20240204
export default class lexLoanerArrangedEmailConsumApply extends LightningElement {
    @api recordId;
 
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        if(currentPageReference) {
            const urlValue = currentPageReference.state.recordId;
            if(urlValue) {
                let str = `${urlValue}`;
                this.recordId = str;
            }
        }
    }
 
    connectedCallback(){
        Promise.all([
            loadStyle(this,lwcCSS)
        ]);
        init({
            recordId: this.recordId
        }).then(res=>{
            console.log('res===='+ TradeComplianceStatusFlagBP);
            //贸易合规
            if(TradeComplianceStatusFlagBP){
                // if(res.accDealerBlacklist == '1'){
                //     this.showToast(IFTradeComplianceAlertBP,'warning');
                //     return;
                // }
                //20240121  sx 贸易合规二期冻结名单和黑名单拆开 add start
                console.log('res.accDealerBlacklist2'+res.accDealerBlacklist2);
                //冻结
                if(res.accDealerBlacklist2 == '1'){
                    this.showToast('医院在冻结清单中,可能存在贸易合规风险,目前正在评估中(一般需5-10个工作日),暂时无法出库指示,' + IFTradeComplianceAlert,'error');
                    tradeConsumTempleSend({consumlId: this.recordId, stepName:'出库指示'});            //贸易合规二期 发邮件20240204
                    return;
                }
                //黑名单
                if(res.accDealerBlacklist2 == '3'){
                    this.showToast('医院在黑名单中,存在贸易合规风险,无法出库指示,' + IFTradeComplianceAlert,'error');
                    tradeConsumTempleSend({consumlId: this.recordId, stepName:'出库指示'});            //贸易合规二期 发邮件20240204
                    return;
                }
                //20240121  sx 贸易合规二期冻结名单和黑名单拆开 add end
            }
            //贸易合规
            if(res.weiAssignedCnt > 0){
                this.showToast('申请单内存在未分配的耗材,请分配或分割申请单','warning');
                return;
            }else if(res.campaignStatus == '取消'){
                this.showToast('学会取消,不可出库指示','warning');
                return;
            }else if(res.consumApplyStatus == '已出库指示' && res.assignedNotShipment == 0){
                this.showToast('所有的耗材备品Set一览都进行过出库指示了','warning');
                return;
            }else if(res.assignedNotShipment == 0){
                this.showToast('没有可以出库指示的明细','warning');
                return;
            }else if(res.hgerqi == 'true' && res.accDealerBlacklist2 == '5'){     // WYL 贸易合规2期 start
                LightningConfirm.open({
                    message: '您此次申请的业务可能存在贸易合规风险,是否继续出库指示,如果有问题请联系法务本部贸易合规窗口'+IFTradeComplianceAlertName+'进一步评估(一般需5-10个工作日)。',
                    variant: 'headerless',
                    label: 'this is the aria-label value',
                    }).then(res=>{
                        if(res) {
                            approvalCheck({
                                ConsumApplyId: this.recordId
                            }).then(rs1=>{
                                console.log('rs1===='+rs1);
                                if(rs1 != '1'){
                                    this.showToast(rs1,'warning');
                                }else{
                                    setShipment_request({
                                        raid: this.recordId
                                    }).then(result=>{
                                        console.log('result===='+result);
                                        if(result == '状态更新到已出库指示'){
                                            this.showToast('状态更新到已出库指示','success');
                                            setTimeout(() => {
                                                window.open('/apex/ConsumTrialPDF?id=' + this.recordId);
                                            }, 3000);
                                            return;
                                        }else{
                                            this.showToast(result,'warning');
                                            return;
                                        }
                                    })
                                }
                            })
                        }else{
                            this.dispatchEvent(new CloseActionScreenEvent());
                            return;
                        }                 
                    });
            }else{ // WYL 贸易合规2期 end
                approvalCheck({
                    ConsumApplyId: this.recordId
                }).then(rs1=>{
                    console.log('rs1===='+rs1);
                    if(rs1 != '1'){
                        this.showToast(rs1,'warning');
                    }else{
                        setShipment_request({
                            raid: this.recordId
                        }).then(result=>{
                            console.log('result===='+result);
                            if(result == '状态更新到已出库指示'){
                                this.showToast('状态更新到已出库指示','success');
                                setTimeout(() => {
                                    window.open('/apex/ConsumTrialPDF?id=' + this.recordId);
                                }, 3000);
                                // if(res.bollowDate!= '' || res.bollowDate != null){
                                //     getLength1({recordId:this.recordId}).then(result1=>{
                                //         window.open('/apex/ConsumTrialPDF?id={!Consum_Apply__c.Id}'); 
                                //     })
                                // }else{
                                //     getLength2({recordId:this.recordId}).then(result2=>{
 
                                //     })
                                // }
                                //var length = size%10 ==0? size/10 : parseInt(size/10) +1;
                                //for(var i =0;i<length;i++){} 
                                return;
                            }else{
                                this.showToast(result,'warning');
                                return;
                            }
                        })
                    }
                })
            }
        })
        .catch(err=>{
            console.log('err===='+ err);
        })
    }
 
    showToast(msg,type) {
        if(type == 'success'){
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode: 'sticky'
            });
            this.updateRecordView(this.recordId);
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode: 'sticky'
            });
            this.dispatchEvent(event);
            this.dispatchEvent(new CloseActionScreenEvent());
        }
    }
 
    updateRecordView(recordId) {
        updateRecord({fields: { Id: recordId }});
    }
 
}