binxie
2024-01-20 e0de9222da210f9c8eb1a9f5400f936a14923e11
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import { LightningElement, track, wire ,api} from 'lwc';
import LightningConfirm from 'lightning/confirm';
import jquery183minjs from '@salesforce/resourceUrl/jquery183minjs';
import PleaseWaitDialog from '@salesforce/resourceUrl/PleaseWaitDialog';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
import { CurrentPageReference } from 'lightning/navigation';
import { CloseActionScreenEvent } from 'lightning/actions';
import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW';
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
    
import init  from "@salesforce/apex/lexMaintenanceContractUrlController.lexCustomNewContract";
import accSendEmailFW  from "@salesforce/apex/OpportunityWebService.accSendEmailFW";
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
 
export default class lexCustomNewContract extends NavigationMixin(LightningElement) {
    @api recordId;
    IsLoading=true;
    name;
    Hospital;
    Department_Class;
    Department;
    Service_Contract_Staff;
    Estimate_Target;
    Dealer;
    recordtypeId;
    accDealerBlacklist;
    a=IFTradeComplianceAlert;
    b=TradeComplianceStatusFlagFW;
 
@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(){
          Promise.all([
            loadStyle(this, lwcCSS)
        ]);
        init({
            recordId: this.recordId
        }).then(result => {
           
            if (result != null) {
                this.IsLoading = false;
                this.name = result.name;
                this.Hospital = result.hospital;
                this.Department_Class = result.department_Class;
                this.Service_Contract_Staff = result.service_Contract_Staff;
                this.Department = result.department;
                this.Estimate_Target = result.estimate_Target;
                this.Dealer = result.dealer;
                this.recordtypeId = result.recordtypeId;
                this.accDealerBlacklist = result.accDealerBlacklist;
                this.invid();
            }
        }).catch(error => {
            console.log(error);
        })
           
    }
    navigateToNewObjectPage() {
        // console.log('RepairApplicantName=='+this.RepairApplicantName);
        // console.log('this.id=='+this.id);
        const defaultFieldValues =encodeDefaultFieldValues({
 
          Name: 'Copy of '+this.name,
          Hospital__c: this.Hospital,
          Department_Class__c: this.Department_Class,
          Service_Contract_Staff__c: this.Service_Contract_Staff,
          Department__c: this.Department,
          Estimate_Target__c:this.Estimate_Target,
          Dealer__c:this.Dealer,
          Last_year_service_contract__c:this.recordId,
          CopyFlg__c : true,
          NotUse_Oxygenated_Water__c : false,
          copyOfMc__c:this.recordId
        });
         console.log('合同名='+this.name);
            this[NavigationMixin.Navigate]({
              type: 'standard__objectPage',
              attributes: {
                objectApiName: 'Maintenance_Contract__c',
                actionName: 'new'
              },
              state: {
                nooverride: '1',
                defaultFieldValues: defaultFieldValues,
                recordTypeId: this.recordtypeId
              }
            });
        this.dispatchEvent(new CloseActionScreenEvent());
      }
      invid() {
            console.log('IFTradeComplianceAlert=='+this.a);
            console.log('TradeComplianceStatusFlagFW=='+this.b);
            console.log('accDealerBlacklist=='+this.accDealerBlacklist);
            if(this.b=='true'){
                var oppflag=false;
                if(this.accDealerBlacklist==1){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    oppflag=true;
                }else if(this.accDealerBlacklist==2){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    oppflag=true;
                }else if(this.accDealerBlacklist==12){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院和经销商存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                         mode: 'sticky'
                    });
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                    oppflag=true;
                }else if(this.accDealerBlacklist==5){
                    LightningConfirm.open({
                        message: '您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                        variant: 'headerless',
                        label: 'this is the aria-label value',
                        
                    }).then(cancel=>{
                        if(cancel) {
                            this.navigateToNewObjectPage(); 
                        } else {
                            this.IsLoading=false;
                            this.dispatchEvent(new CloseActionScreenEvent());
                            return;
                        }
                        
                    });
                }else if(this.accDealerBlacklist==6){
                    LightningConfirm.open({
                        message: '您所选择的经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                        variant: 'headerless',
                        label: 'this is the aria-label value',
                        
                    }).then(cancel=>{
                        if(cancel) {
                            this.navigateToNewObjectPage(); 
                        } else {
                            this.IsLoading=false;
                            this.dispatchEvent(new CloseActionScreenEvent());
                            return;
                        }
                        
                    });
                }else if(this.accDealerBlacklist==56){
                    LightningConfirm.open({
                        message: '您所选择的医院和经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                        variant: 'headerless',
                        label: 'this is the aria-label value',
                        
                    }).then(cancel=>{
                        if(cancel) {
                            this.navigateToNewObjectPage(); 
                        } else {
                            this.IsLoading=false;
                            this.dispatchEvent(new CloseActionScreenEvent());
                            return;
                        }
                        
                    });
                }else{
                    this.navigateToNewObjectPage(); 
                }
                console.log('oppflag=='+oppflag);
                if(oppflag){
                    var FSEStr1 = new Array();
                    accSendEmailFW({
                        AccDealerBlacklist:this.accDealerBlacklist,
                        accname:this.Hospital,
                        angency:this.Dealer,
                        mcid:this.recordId,
                        sendalert:'Main_Con',
                        FSEStr:FSEStr1
                        })
                    .then(result=>{
                        return;
                    }).catch(err=>{
                        console.log(error);
                    })
                }
            } else {
                this.navigateToNewObjectPage(); 
 
            }
            
 
      }
 
}