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';
|
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= "";
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
}
|
}
|
}
|
connectedCallback(){
|
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 : "";
|
this.CustomLink1();
|
})
|
}
|
// 产品咨询单 新建意向
|
CustomLink1(){
|
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,
|
Contact_Name__c:this.ContactId,
|
Hospital_Name__c:this.HospitalID,
|
Department_Class__c:this.DepartmentID,
|
Opp_Name_Search__c:this.OppNameSearchID,
|
Campaign__c:this.CampaignID,
|
// 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,
|
lea8:this.Phone.trim(),
|
lea11:this.Email.trim(),
|
name_lastlea2:name,
|
name_firstlea2:this.LastName,
|
lea5:this.LeadSource,
|
Request1__c:this.Request1,
|
Opportunity_Division__c:this.OpportunityDivision,
|
Urgent__c:this.Urgent,
|
Opp_Name__c:this.OppNameSearch,
|
});
|
}else{
|
defaultValues = encodeDefaultFieldValues({
|
RecordTypeId:this.Standard,
|
Contact_Name__c:this.ContactId,
|
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,
|
Request1__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) {
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|