import { LightningElement,wire,track,api} from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import init from '@salesforce/apex/HosipitalToDeptController.init';
|
import updataAccount from '@salesforce/apex/HosipitalToDeptController.updataAccount';
|
import executeWebSide from '@salesforce/apex/AccountDailyUpdateBatch.executeWebSide';
|
import LightningConfirm from 'lightning/confirm';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader'
|
export default class LexHosipitalToDept extends LightningElement {
|
@api recordId;
|
IsLoading=true;
|
@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(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({recordId:this.recordId}).then(res => {
|
console.log(res,'<========res')
|
if(res.giMain == ''){
|
this.showToast('请填写GI主担当','error');
|
}else if(res.bfowner == ''){
|
this.showToast('请填写BF主担当','error');
|
}else if(res.etowner == ''){
|
this.showToast('请填写ET主担当','error');
|
}else if(res.spmain == ''){
|
this.showToast('请填写GS主担当','error');
|
}else if(res.uroownerID == ''){
|
this.showToast('请填写URO主担当','error');
|
}else if(res.gynowner == ''){
|
this.showToast('请填写GYN主担当','error');
|
}else if(res.entownerID == ''){
|
this.showToast('请填写ENT主担当','error');
|
}else{
|
LightningConfirm.open({
|
message: res.soakupHPDeptTeam,
|
variant: 'headerless',
|
label: '提示信息',
|
// setting theme would have no effect
|
}).then(submit => {
|
if(submit){
|
updataAccount({recordId:this.recordId,HosipitalToDept:true}).catch(err => {
|
this.showToast(err.body.message,'error');
|
})
|
executeWebSide({Hospitalid: this.recordId}).then(resp => {
|
this.IsLoading = false
|
if (resp != 'OK') {
|
this.showToast(resp,'error');
|
console.log(resp,'err')
|
} else {
|
updataAccount({recordId:this.recordId,HosipitalToDept:false}).catch(err => {
|
this.showToast(err.body.message,'error');
|
})
|
this.showToast('反映完成','success');
|
window.location.href = '/lightning/r/Account/'+this.recordId+'/view';
|
}
|
}).catch(err => {
|
console.log(err,'<======err')
|
if (err.faultcode == 'sf:INSUFFICIENT_ACCESS') {
|
this.showToast('没有执行权限','error');
|
} else {
|
this.showToast(err.body.message,'error');
|
}
|
})
|
}else{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
}
|
})
|
}
|
this.IsLoading = false
|
})
|
}
|
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());
|
}
|
}
|