import { LightningElement, api , track, wire } from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
|
import init from '@salesforce/apex/LexNewIntentionController.init';
|
import getAccountByLongName from '@salesforce/apex/LexNewIntentionController.getAccountByLongName';
|
import getAccountByShortName from '@salesforce/apex/LexNewIntentionController.getAccountByShortName';
|
|
|
|
|
const event1 = new ShowToastEvent({
|
title: '提示',
|
message:
|
'请从询价画面新建报价委托',
|
});
|
export default class lexNewIntention extends LightningElement {
|
|
@api recordId;
|
AgencyOpportunity;
|
IsLoading=true;
|
|
|
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
console.log(str);
|
this.recordId = str;
|
}
|
}
|
}
|
|
|
|
connectedCallback(){
|
console.log(this.recordId);
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
console.log(result);
|
if (result != null) {
|
this.AgencyOpportunity = result;
|
this.newIntention().then(result=>{
|
IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
}).catch(error => {
|
console.log("error");
|
console.log(error);
|
});
|
|
}
|
|
|
|
async newIntention(){
|
if(this.AgencyOpportunity.Is_Transformed__c == true){
|
this.dispatchEvent(event1);
|
return;
|
}
|
var accountName = this.AgencyOpportunity.Department_Class_Opp_Name__c + ' '
|
+ this.AgencyOpportunity.Department_Name_Text__c;
|
var accountrecords = await getAccountByLongName({Name: accountName});
|
var accountID = '';
|
if(accountrecords.length > 0){
|
accountID = accountrecords[0].Id;
|
console.log('长name返回长度大于0')
|
}
|
if (accountID == '') {
|
accountName = this.AgencyOpportunity.Department_Class_Opp_Name__c;
|
accountrecords = await getAccountByShortName({Name : accountName});
|
if(accountrecords.length > 0){
|
accountID = accountrecords[0].Id;
|
console.log('shortName return size 》 0')
|
}
|
}
|
var url = '/apex/NewAndEditLead?' + '00N10000009HKSP=' + this.AgencyOpportunity.Id
|
+ '&LeadSource=经销商' + '&00N10000006qOFb=' + this.AgencyOpportunity.StageName__c
|
+ '&00N10000006qOF0=' + this.AgencyOpportunity.Close_Forecasted_Date__c
|
+ '&00N10000002EjE1=' + this.AgencyOpportunity.Name
|
+ '&00N10000008rqHf=' + this.AgencyOpportunity.Purchase_Reason__c
|
+ '&00N10000008rqHd=' + this.AgencyOpportunity.Fund_Basis__c
|
+ '&00N10000008rqHg=' + this.AgencyOpportunity.Purchase_Type__c
|
+'&00N10000008rqHj=' + this.AgencyOpportunity.Sales_Method__c
|
+ '&00N10000008rqHi=' + this.AgencyOpportunity.Request__c
|
+ '&00N10000008rqHh=' + this.AgencyOpportunity.Request_Detail__c
|
+ '&CF00N10000002CvC5=' + accountName
|
+ '&CF00N10000002CvC5_lkid=' + accountID
|
+ '&RecordTypeId=01210000000QiRf' + '&retURL=%2F' + this.AgencyOpportunity.Id;
|
|
window.open(url);
|
|
|
|
}
|
|
|
}
|