import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { NavigationMixin } from 'lightning/navigation';
|
import init from '@salesforce/apex/AccountDelayApplyController.init';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
export default class LexAccountDelayApplyButton extends NavigationMixin(LightningElement) {
|
@api recordId;
|
IsLoading=true;
|
label;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
console.log("进入页面");
|
console.log(currentPageReference);
|
if(currentPageReference){
|
const urvalue=currentPageReference.state.recordId;
|
if(urvalue){
|
let str=`${urvalue}`;
|
console.log('str');
|
console.log(str);
|
this.recordId=str;
|
}
|
}
|
}
|
|
connectedCallback(){
|
console.log("进入页面111111");
|
console.log("进入页面111111" + this.recordId);
|
init({recordId:this.recordId}).then(result=>{
|
console.log('result==========',result);
|
this.IsLoading = false;
|
if(result!=null){
|
if(result.accSize.length > 0){
|
this.showToast('存在申请中的客户变更申请,无法再次提交变更申请。','error')
|
return
|
}
|
if(result.status == '有効'){
|
const data = encodeDefaultFieldValues({
|
Hospital__c:this.recordId,
|
Grade__c:result.accgrade,
|
HospitalName__c:result.accname,
|
Alias_Name2__c:result.aliasName2,
|
Abbreviation_old__c:result.abbreviation,
|
Abbreviation__c:result.attributeType,
|
Postal_Code__c:result.postalCode,
|
Speciality_Type__c:result.specialityType,
|
State_Master__c:result.shengId,
|
Town__c:result.town,
|
City_Master__c:result.shiId,
|
Street__c:result.street,
|
Field3_companyname__c:result.field3companyname,
|
Site__c:result.site
|
});
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Account_Delay_Apply__c',
|
actionName: 'new'
|
},
|
state:{
|
defaultFieldValues:data
|
}
|
});
|
|
}else{
|
this.showToast('该客户不在有效中,不可进行客户变更','error')
|
}
|
}
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}).catch(err=>{
|
console.log("error:====",err);
|
console.log(err);
|
}).finally(()=>{});
|
}
|
|
showToast(msg, type) {
|
const event = new ShowToastEvent({
|
title: "",
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|