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
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
219
220
221
222
223
224
225
226
227
import {
    LightningElement,
    wire,
    api
} from 'lwc';
import {
    CurrentPageReference
} from "lightning/navigation";
import {
    CloseActionScreenEvent
} from 'lightning/actions';
import init from '@salesforce/apex/buttonAccountCtl.init';
import {
    NavigationMixin
} from 'lightning/navigation';
import {
    encodeDefaultFieldValues
} from 'lightning/pageReferenceUtils';
import LightningConfirm from 'lightning/confirm';
import TradeComplianceStatusFlagFW from '@salesforce/label/c.TradeComplianceStatusFlagFW';
import IFTradeComplianceAlert from '@salesforce/label/c.IFTradeComplianceAlert';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
import accSendEmailFW from '@salesforce/apex/OpportunityWebService.accSendEmailFW';
 
 
export default class lexCreateNewServiceContract extends NavigationMixin(LightningElement) {
    @api recordId;
    str;
    IsLoading = true;
    Id;
    HospitalC;
    HospitalIdC;
    DepartmentClassC;
    DepartmentClassIdC;
    Name;
    recordTypeId;
    a=IFTradeComplianceAlert;
    b=TradeComplianceStatusFlagFW;
    IFTradeComplianceIntercept;
 
    @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)
        ]);
        console.log(this.recordId);
        init({
            recordId: this.recordId
        }).then(result => {
            console.log(result);
            debugger;
            if (result != null) {
 
                this.IsLoading = false;
                this.Id = result.Id;
                this.HospitalC = result.HospitalC == undefined ? "" : result.HospitalC;;
                this.HospitalIdC = result.HospitalIdC == undefined ? "" : result.HospitalIdC;;
                this.DepartmentClassC = result.DepartmentClassC == undefined ? "" : result.DepartmentClassC;;
                this.DepartmentClassIdC = result.DepartmentClassIdC == undefined ? "" : result.DepartmentClassIdC;;
                this.Name = result.Name;
                this.recordTypeId = result.recordTypeId;
                this.IFTradeComplianceIntercept = result.IFTradeComplianceIntercept;
                this.invid();
                // this.CreateNewServiceContract();
                // this.dispatchEvent(new CloseActionScreenEvent());
            }
        }).catch(error => {
            console.log(error);
        })
    }
 
    // 新建新服务合同    
    CreateNewServiceContract() {
        console.log('执行CreateNewServiceContract');
        const url = encodeDefaultFieldValues({
            Hospital__c: this.HospitalC,
            Department_Class__c: this.DepartmentClassC,
            Department__c: this.Id,
            // RecordType:'01210000000gTYq'
        });
        console.log(url);
 
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Maintenance_Contract__c',
                actionName: 'new'
            },
            state: {
                nooverride: '1',
                defaultFieldValues: url,
                recordTypeId:this.recordTypeId
            }
        });
        this.dispatchEvent(new CloseActionScreenEvent());
 
        
    }
    invid() {
        console.log('执行invid');
            var  oppflag = false;
            if(this.b == 'true') {
                if(this.IFTradeComplianceIntercept=='intercept'){
                    const evt = new ShowToastEvent({
                        title : '您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+this.a,
                        message: '',
                        variant: 'error',
                        mode: 'sticky'
                    });
                    oppflag=true;
                    this.dispatchEvent(evt);
                    this.dispatchEvent(new CloseActionScreenEvent());
                }
                //20231211 sx 贸易合规二期注释 start
                // else if(this.IFTradeComplianceIntercept=='WarningList'){
                //     LightningConfirm.open({
                //         // message: '您所选择的医院和经销商存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+this.a,
                //         message:'您此次申请的业务可能存在贸易合规风险,请联系法务本部贸易合规窗口恽李娜进一步评估(一般需5-10个工作日)',
                //         variant: 'headerless',
                //         label: 'this is the aria-label value',
                        
                //     }).then(cancel=>{
                //         if(cancel) {
                //             this.CreateNewServiceContract(); 
                //         } else {
                //             this.IsLoading=false;
                //             this.dispatchEvent(new CloseActionScreenEvent());
                //             return;
                //         }  
                //     });
                // }
                //20231211 sx 贸易合规二期注释 end
                else{
                    this.CreateNewServiceContract(); 
                }
                console.log('oppflag=='+oppflag);
                if(oppflag){
                    var FSEStr1 = new Array();
                    accSendEmailFW({
                        AccDealerBlacklist:this.IFTradeComplianceIntercept,
                        accname:this.Name,
                        angency:'',
                        mcid:this.recordId,
                        sendalert:'Main_Con',
                        FSEStr:FSEStr1
                        })
                    .then(result=>{
                        return;
                    }).catch(err=>{
                        console.log(error);
                    })
                }
            } else {
               this.CreateNewServiceContract(); 
            }            
 
      }
}
 
/*{!RequireScript("/soap/ajax/51.0/connection.js")}
{!RequireScript("/soap/ajax/51.0/apex.js")}
{!RequireScript("/resource/CommonUtilJs")}
var foo = function() {
//贸易合规 you
//拦截+邮件提醒
var FSEStr = new Array();
var angency = '';//不涉及经销商
var accname = '{!Account.Hospital__c}';
var mcid = '{!Account.Id}';
var TradeComplianceStatusFlagFW = "{!$Label.TradeComplianceStatusFlagFW}";//贸易合规开关
var IFTradeComplianceAlert = "{!$Label.IFTradeComplianceAlert}";//贸易合规提醒
if(TradeComplianceStatusFlagFW=='true'){
var oppflag=false;
var sql = "select id,IFTradeComplianceIntercept__c from Account where id ='{!Account.HospitalId__c}'";//只有科室上有此按钮,所以不涉及经销商
var sqlResult = sforce.connection.query(sql);
var records = sqlResult.getArray("records");
if(null!=records && records.length>0){
var AccDealerBlacklist = records[0].IFTradeComplianceIntercept__c;//判断客户/经销商是否为黑名单
if(AccDealerBlacklist=='intercept'){
alert('您所选择的医院存在贸易合规风险,无法签订服务合同,建议您向客户做好不签约说明,'+IFTradeComplianceAlert);
oppflag=true;
}
if(AccDealerBlacklist=='WarningList'){
if(!confirm('您所选择的医院存在贸易合规警示风险,不建议签订服务合同,请您确认是否继续申请,'+IFTradeComplianceAlert)){
return;
}
}
if(oppflag){
var opprtn = sforce.apex.execute("OpportunityWebService", "accSendEmailFW",{"AccDealerBlacklist":AccDealerBlacklist,"accname":accname,"angency":angency,"mcid":mcid,"sendalert":"Main_Con","FSEStr":FSEStr});
if (opprtn = true) {
return;
}
}
}
}
 
//贸易合规 you
 
var Hospital = '{!URLENCODE(Account.Hospital__c)}';
var Hospitalid = '{!URLENCODE(Account.HospitalId__c)}';
var Department = '{!URLENCODE(Account.Department_Class__c)}';
var Departmentid = '{!URLENCODE(Account.Department_ClassId__c)}';
var accountname = '{!URLENCODE(Account.Name)}';
var accountid = '{!URLENCODE(Account.Id)}';
 
 
var url = '/a0H/e?CF00N10000002Dx56=' + Hospital +'&CF00N10000002Dx56_lkid='
+ Hospitalid + '&CF00N10000002Dx4p=' + Department + '&CF00N10000002Dx4p_lkid='
+ Departmentid + '&CF00N10000002Dx4q=' + accountname + '&CF00N10000002Dx4q_lkid='
+ accountid + '&RecordType=01210000000gTYq';
window.open(url);
 
}
 
foo();*/