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()); } } }