import { LightningElement, track, wire,api } from 'lwc';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import getRecordIdByName from '@salesforce/apex/LexSubmitCampaignController.getRecordIdByName';
|
import queryUserIdByName from '@salesforce/apex/LexSubmitCampaignController.queryUserIdByName';
|
import { NavigationMixin } from 'lightning/navigation';
|
import { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
const event1 = new ShowToastEvent({
|
message:
|
"已经取消!",
|
variant : "error",
|
mode :'sticky'
|
});
|
const event4 = new ShowToastEvent({
|
message:
|
"会议结束,不能取消!",
|
variant : "error",
|
mode :'sticky'
|
});
|
|
const event5 = new ShowToastEvent({
|
message:
|
"该活动信息已发送到智慧医疗,请确认后再操作",
|
variant : 'warning'
|
});
|
import init from '@salesforce/apex/LexSubmitCampaignController.initCancle';
|
import changeCampaign from '@salesforce/apex/OpdPlanWebService.changeCampaign';
|
import submitApprovalRequest from '@salesforce/apex/LexSubmitCampaignController.submitApprovalRequest';
|
import newAndUpdateCampaignCancle from '@salesforce/apex/LexSubmitCampaignController.newAndUpdateCampaignCancle';
|
import UpdateCampagin from '@salesforce/apex/LexSubmitCampaignController.UpdateCampagin';
|
|
export default class lexCancleCampaign extends NavigationMixin(LightningElement) {
|
@api recordId;
|
IsLoading=true;
|
Campaign;
|
|
@wire(CurrentPageReference)
|
getStateParameters(currentPageReference) {
|
if (currentPageReference) {
|
const urlValue = currentPageReference.state.recordId;
|
if (urlValue) {
|
let str = `${urlValue}`;
|
this.recordId = str;
|
console.log(this.recordId);
|
}
|
}
|
}
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
if (result != null) {
|
this.Campaign = result;
|
console.log('lexCancleCampaign');
|
console.log(this.Campaign);
|
this.cancle().then(result=>{
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
const passOneEvent = new CustomEvent('closem', {
|
detail: '111'
|
});
|
this.dispatchEvent(passOneEvent);
|
});
|
}
|
}).catch(error => {
|
const eventInItError = new ShowToastEvent({
|
message:
|
error.message,
|
variant : 'error',
|
mode :'sticky'
|
});
|
this.dispatchEvent(eventInItError);
|
});
|
|
}
|
|
|
async cancle(){
|
console.log(this.Campaign);
|
var checkUpdate=0;
|
if(this.Campaign.Status =='取消'){
|
this.dispatchEvent(event1);
|
return;
|
}
|
if(this.Campaign.Status !='草案中' && this.Campaign.Status !='公开中' && this.Campaign.Status !='取消'){
|
const event2 = new ShowToastEvent({
|
message : this.Campaign.Status +'状态不能取消',
|
variant : 'error',
|
mode :'sticky'
|
});
|
this.dispatchEvent(event2);
|
return;
|
}
|
|
if(this.Campaign.IF_Submit__c != 0){
|
this.dispatchEvent(event5);
|
}
|
var ProfileId = await getRecordIdByName({Name : '取消申请'});
|
var CL5 = this.Campaign.BuchangApprovalManager__c;
|
var CL6 = this.Campaign.JingliApprovalManager__c;
|
var CL4 = this.Campaign.ZongjianApprovalManager_CancleShen__c;
|
console.log('cl4='+this.Campaign.ZongjianApprovalManager_CancleShen__c);
|
console.log('CL6= '+this.Campaign.JingliApprovalManager__c);
|
var CampaignId = this.Campaign.Id;
|
var CampaignName= this.Campaign.Name;
|
var Today = new Date();
|
if(this.Campaign.Status =='草案中'){
|
await UpdateCampagin({Id : this.Campaign.Id,Status : '取消',CancelDay : Today}).then(result=>{
|
if(result!='success'){
|
const updateError = new ShowToastEvent({
|
message:
|
result,
|
variant : 'error',
|
mode :'sticky'
|
});
|
this.dispatchEvent(updateError);
|
}
|
else{
|
const updateSuc = new ShowToastEvent({
|
message:
|
'会议已取消',
|
variant : 'success'
|
});
|
//2秒自动刷新
|
this.dispatchEvent(updateSuc);
|
setTimeout(function () {
|
//2秒后执行刷新
|
window.location.reload();
|
}, 2000); //单位是毫秒
|
}
|
})
|
|
}else if(this.Campaign.Status =='公开中'){
|
var time=new Date().toISOString();
|
console.log(this.Campaign.EndDate);
|
console.log(time);
|
console.log(time >=this.Campaign.EndDate);
|
// 20230215 ljh DB202301265636 学会结束后不可以取消 start
|
if( time >=this.Campaign.EndDate ){
|
this.dispatchEvent(event4);
|
return;
|
}
|
const defaultFieldValues = encodeDefaultFieldValues({
|
campaign__c: CampaignId,
|
minister__c:CL5,
|
manager__c: CL6,
|
ZongjianApprovalManager_CancleShen__c : CL4
|
})
|
this.IsLoading=false;
|
this.dispatchEvent(new CloseActionScreenEvent());
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'meeting_delay_apply__c', // 要新建的对象API
|
actionName: 'new',
|
},
|
state:{
|
nooverride: '1',
|
defaultFieldValues: defaultFieldValues,
|
recordTypeId : ProfileId
|
|
}
|
});
|
}
|
|
}
|
|
|
}
|