binxie
2024-01-18 b1d36ea3e6653e59bd767aa192c688ee0d9d4c58
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import { LightningElement,wire,track,api} from 'lwc';
import { CurrentPageReference,NavigationMixin } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import  init  from '@salesforce/apex/InquiryFormController.init';
import  sqlResult  from '@salesforce/apex/InquiryFormController.sqlResult';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
//import { AWSService } from 'c/piUtils';   //deloitte-zhj 20231123 PIPL还原
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
export default class lexInquiryFormCustomLink1 extends NavigationMixin(LightningElement) {
    @api recordId;//OwnerId
    IsLoading = true;
    Id= "";
    ServiceStatus= "";
    userId= "";
    Status= "";
    LeadLink= "";
    OppNameSearch= "";
    ContactName= "";
    ContactId = "";
    HospitalName= "";
    HospitalID= "";
    DepartmentClass= "";
    DepartmentID = "";
    OppNameSearchID= "";
    Campaign= "";
    CampaignID= "";
    Name= "";
    CancelReason= "";
    Phone= "";
    Email= "";
    LastName= "";
    LeadSource= "";
    OpportunityDivision= "";
    Request1= "";
    Urgent = false;
    FSEOwner= "";
    FamilyName= "";
    // //add by Deloitte-王雪琴 2023/08/08 start
    Company = "";
    //AWSDataId = "";   //deloitte-zhj 20231123 PIPL还原
    InquiryNum = "";
    //staticResource = "";   //deloitte-zhj 20231123 PIPL还原
    //InquiryAWSDataId = "";  //deloitte-zhj 20231123 PIPL还原
    //AWSService;   //deloitte-zhj 20231123 PIPL还原
    // //add by Deloitte-王雪琴 2023/08/08 end
    @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)
        ]);
 
        //this.AWSService = new AWSService();
        init({
            recordId: this.recordId
        }).then(result => {
            this.IsLoading = false;
            this.Id = result.Id != undefined ? result.Id : "";
            this.ServiceStatus = result.ServiceStatus != undefined ? result.ServiceStatus : "";
            this.userId = result.userId != undefined ? result.userId : "";
            this.Status = result.Status != undefined ? result.Status : "";
            this.LeadLink = result.LeadLink != undefined ? result.LeadLink : "";
            this.OppNameSearch = result.OppNameSearch != undefined ? result.OppNameSearch : "";
            this.ContactName = result.ContactName != undefined ? result.ContactName : "";
            this.ContactId = result.ContactId != undefined ? result.ContactId : "";
            this.HospitalName = result.HospitalName != undefined ? result.HospitalName : "";
            this.HospitalID = result.HospitalID != undefined ? result.HospitalID : "";
            this.DepartmentClass = result.DepartmentClass != undefined ? result.DepartmentClass : "";
            this.DepartmentID = result.DepartmentID != undefined ? result.DepartmentID : "";
            this.OppNameSearchID = result.OppNameSearchID != undefined ? result.OppNameSearchID : "";
            this.Campaign = result.Campaign != undefined ? result.Campaign : "";
            this.CampaignID = result.CampaignID != undefined ? result.CampaignID : "";
            this.Name = result.Name != undefined ? result.Name : "";
            this.CancelReason = result.CancelReason != undefined ? result.CancelReason : "";
            this.Phone = result.Phone != undefined ? result.Phone : "";
            this.Email = result.Email != undefined ? result.Email : "";
            this.LastName = result.LastName != undefined ? result.LastName : "";
            this.LeadSource = result.LeadSource != undefined ? result.LeadSource : "";
            this.OpportunityDivision = result.OpportunityDivision != undefined ? result.OpportunityDivision : "";
            this.Request1 = result.Request1 != undefined ? result.Request1 : "";
            this.FSEOwner = result.FSEOwner != undefined ? result.FSEOwner : "";
            this.FamilyName = result.FamilyName != undefined ? result.FamilyName : "";
            this.Urgent = result.Urgent == 0 ? 0 :1;
            this.Standard = result.Standard != undefined ? result.Standard : "";
            //add by Deloitte-王雪琴 2023/08/08 start
            this.Company = result.Company != undefined ? result.Company : "";
            //this.AWSDataId = result.AWSDataId != undefined ? result.AWSDataId : "";  //deloitte-zhj 20231123 PIPL还原
            this.InquiryNum = result.InquiryNum != undefined ? result.InquiryNum : "";
            //deloitte-zhj 20231123 PIPL还原 start
            this.CustomLink1();
            // debugger
            // this.staticResource = JSON.parse(result.staticResource);
            // console.log('this.staticResource.queryUrl = ' + this.staticResource.queryUrl);
            // this.InquiryAWSDataId = result.InquiryAWSDataId != undefined ? result.InquiryAWSDataId : "";
            // var that = this;
            // //解密产品咨询单
            // debugger
            // this.AWSService.query(this.staticResource.queryUrl,this.InquiryAWSDataId,function(data){
            //     console.log('queryLeadFromAWSIFS data = ' + JSON.stringify(data));
            //     if (data.object) {
            //         //update by Deloitte-张春旭 2023/08/25 start
            //         // that.Email = data.object['email'];
            //         that.Email = data.object['email'] != null ? data.object['email'] : "" ;
            //         //update by Deloitte-张春旭 2023/08/25 end
 
            //         //update by Deloitte-张春旭 2023/09/13 start
            //         // that.Phone = data.object['phone'] ;
            //         that.Phone = data.object['phone'] != null ? data.object['phone'] : "" ; ;
            //         //update by Deloitte-张春旭 2023/09/13 end
            //     }
            //     that.CustomLink1();
            // },this.staticResource.token)
            // //add by Deloitte-王雪琴 2023/08/08 end
            //deloitte-zhj 20231123 PIPL还原 end
            //this.CustomLink1();
        })       
    }
    // 产品咨询单 新建意向
    CustomLink1(){
        debugger
        var lead = "";
        var search = "";
        sqlResult({id:this.recordId}).then(records=>{
            var Request = '';
            if(records[0].Request_Detail__c != null){
            Request = records[0].Request_Detail__c.toString();
            }
            var lead = this.LeadLink;
            var search = this.OppNameSearch;
            //zyh add-search
            var name = this.ContactName;
            name = name.replace(" ","");
            // this.CustomLink1();
            var defaultValues = null;
            if(lead){
                // alert('已经有意向了,不能再创建新的意向。');
                this.showToast("已经有意向了,不能再创建新的意向。","error");
                return;
            }else{
            if(search !=  "" && search != null){
                defaultValues = encodeDefaultFieldValues({
                    RecordTypeId:this.Standard,  //潜在客户记录类型
                    Hospital_Name__c:this.HospitalID, //医院名
                    Department_Class__c:this.DepartmentID, //战略科室分类
                    Opp_Name_Search__c:this.OppNameSearchID, //已有询价名称
                    Campaign__c:this.CampaignID, //主要学会
                    //update by Deloitte-王雪琴 2023/08/08 start
                    accountName:this.Company,
                    contactName:this.ContactName,
                    //awsDataId:this.AWSDataId,   //deloitte-zhj 20231123 PIPL还原
                    Contact_Name__c:this.ContactId, //客户姓名   //deloitte-zhj 20240104 改成大写
                    Phone:this.Phone.trim(), //电话 
                    Email:this.Email.trim(), //电子邮件 
                    LeadSource:this.LeadSource, // 来源 
                    Inquiry_Num__c:this.InquiryNum, //咨询单编码
                    //update by Deloitte-王雪琴 2023/08/08 end
                    // Contact_Name__c:this.ContactName,
                    // Contact_Id__c:this.ContactId,
                    // Hospital_Name__c:this.HospitalName, //
                    // Hospital_ID__c:this.HospitalID,
                    // Department_Class__c:this.DepartmentClass,
                    // Department_ID__c:this.DepartmentID,
                    // Opp_Name_Search__c:this.OppNameSearch,
                    // Opp_Name_Search_ID__c:this.OppNameSearchID,
                    // Campaign__c:this.Campaign,
                    // Campaign_ID__c:this.CampaignID,
                    Name:this.Name, // 名称
                    Lead_Inquiry_form__c:this.Id, // 会议询问单
                    Cancel_Reason__c:this.CancelReason, //取消原因
                    Request_Detail__c:Request, // 委托事项详细
                    lea13:'未跟进',
                    lea3:this.HospitalName,
                    name_lastlea2:name,
                    name_firstlea2:this.LastName,
                    Request__c:this.Request1, // 委托事项
                    Opportunity_Division__c:this.OpportunityDivision, // 意向区分
                    Urgent__c:this.Urgent, // 紧急
                    Opp_Name__c:this.OppNameSearch, // 询价名称
                });
            }else{
                 defaultValues = encodeDefaultFieldValues({
                    //update by Deloitte-王雪琴 2023/08/08 start
                    accountName:this.Company,
                    contactName:this.ContactName, 
                    //awsDataId:this.AWSDataId,  //deloitte-zhj 20231123 PIPL还原
                    Contact_Name__c:this.ContactId,   //deloitte-zhj 20240104 改成大写
                    Phone:this.Phone.trim(),
                    Email:this.Email.trim(),
                    LeadSource:this.LeadSource,
                    Inquiry_Num__c:this.InquiryNum,
                    //update by Deloitte-王雪琴 2023/08/08 end
                    RecordTypeId:this.Standard, //潜在客户记录类型
                    Hospital_Name__c:this.HospitalID, //医院名
                    Department_Class__c:this.DepartmentID,
                    Opp_Name_Search__c:this.OppNameSearchID,
                    Campaign__c:this.CampaignID,
                    Name:this.Name,
                    Lead_Inquiry_form__c:this.Id,
                    Cancel_Reason__c:this.CancelReason,
                    Request_Detail__c:Request,
                    lea13:'未跟进',
                    lea3:this.HospitalName,
                    lea8:this.Phone.trim(),
                    lea11:this.Email.trim(),
                    name_lastlea2:name,
                    name_firstlea2:this.LastName,
                    lea5:this.LeadSource,
                    Request__c:this.Request1,
                    Opportunity_Division__c:this.OpportunityDivision,
                    Urgent__c:this.Urgent,
                });
            }
            this[NavigationMixin.Navigate]({
                type: 'standard__objectPage',
                attributes: {
                    objectApiName: 'Lead',
                    actionName: 'new'
                },
                state:{
                    defaultFieldValues: defaultValues
                }
            }); 
            this.dispatchEvent(new CloseActionScreenEvent());
            }
        })
    }
 
    showToast(msg,type) {
        if(type == "success"){
            const event = new ShowToastEvent({
                message: msg,
                variant: type
            });
            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());
        }
    }
}