import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import UserInfo_Owner from '@salesforce/apex/NewAgencyContractController.UserInfo_Owner';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader'
|
import LightningConfirm from 'lightning/confirm';
|
|
export default class LexNewAgencyContract extends NavigationMixin(LightningElement) {
|
@api recordId;
|
ProfileId;
|
IsLoading=false;
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference){
|
console.log("进入页面");
|
console.log(currentPageReference);
|
if(currentPageReference){
|
const urvalue=currentPageReference.state.recordId;
|
if(urvalue){
|
let str=`${urvalue}`;
|
this.recordId=str;
|
}
|
}
|
}
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
UserInfo_Owner().then(res => {
|
console.log('result===>',res,this.recordId)
|
if (res.id == '李东凤' || res.profileId == '系统管理员') {
|
this.IsLoading = false;
|
LightningConfirm.open({
|
message: '会自动分配新建合同的客户编码,保留旧编码的时候请用复制合同。',
|
variant: 'headerless',
|
label: 'this is the aria-label value',
|
}).then(cancel=>{
|
if(!cancel){
|
this.dispatchEvent(new CloseActionScreenEvent());
|
return;
|
}else{
|
const defaultFieldValues = encodeDefaultFieldValues({
|
Agent_Ref__c:this.recordId,
|
ParentId:this.recordId,
|
retURL:this.recordId,
|
Name:'*'
|
});
|
console.log(defaultFieldValues)
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'Account',
|
actionName:'new'
|
},
|
state:{
|
defaultFieldValues:defaultFieldValues,
|
recordTypeId:res.recordTypeId
|
}
|
});
|
}
|
})
|
|
} else {
|
this.showToast('没有新建的权限','error');
|
}
|
}).catch(err => {
|
console.log('err:',err)
|
})
|
|
}
|
|
showToast(msg,type) {
|
if(type == 'success'){
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type
|
});
|
this.dispatchEvent(event);
|
}else{
|
const event = new ShowToastEvent({
|
message: msg,
|
variant: type,
|
mode:'Sticky'
|
});
|
this.dispatchEvent(event);
|
}
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
}
|