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 { encodeDefaultFieldValues } from 'lightning/pageReferenceUtils';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
|
import init from '@salesforce/apex/LexSubmitCampaignController.initMeetingDelayApply';
|
import findQualified1 from '@salesforce/apex/LexSubmitCampaignController.findQualified1';
|
import findQualified2 from '@salesforce/apex/LexSubmitCampaignController.findQualified2';
|
import findQualified3 from '@salesforce/apex/LexSubmitCampaignController.findQualified3';
|
import getRecordIdByName from '@salesforce/apex/LexSubmitCampaignController.getRecordIdByName';
|
import changeCampaign from '@salesforce/apex/OpdPlanWebService.changeCampaign';
|
const event1 = new ShowToastEvent({
|
message:
|
"存在审批中的会议延期申请,无法再次提交延期申请!",
|
variant : "error" ,
|
mode :'sticky'
|
});
|
const event2 = new ShowToastEvent({
|
message:
|
"耗材借出申请的状态未处于`草案中`或`取消`,该会议只能取消,无法延期。",
|
variant : "error" ,
|
mode :'sticky'
|
});
|
const event3 = new ShowToastEvent({
|
message:
|
"备品借出申请的状态未处于`草案中`或`取消`,该会议只能取消,无法延期。",
|
variant : "error" ,
|
mode :'sticky'
|
});
|
const event4 = new ShowToastEvent({
|
message:
|
"该活动信息已发送到智慧医疗,请确认后再操作",
|
variant : 'warning' ,
|
mode :'sticky'
|
});
|
const event5 = new ShowToastEvent({
|
message:
|
"该会议不在公开中或申请中,只能取消,无法延期。",
|
variant : "error" ,
|
mode :'sticky'
|
});
|
export default class lexMeetingDelayApplyCampaign 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(res=>{
|
console.log(res);
|
this.Campaign=res;
|
console.log(this.Campaign.Id);
|
this.meetingDelayApply().then(res=>{
|
const passOneEvent = new CustomEvent('closem', {
|
detail: '111'
|
});
|
this.dispatchEvent(passOneEvent);
|
|
})
|
})
|
}
|
|
|
async meetingDelayApply(){
|
var hasError='0';
|
var CampaignId = this.Campaign.Id;
|
var PlanBackData= this.Campaign.PlanBackData__c;
|
var Meeting_Cooperate = this.Campaign.Meeting_Cooperate__c;
|
var Meeting_Cooperate2 = this.Campaign.Meeting_Cooperate2__c;
|
var Meeting_Cooperate3 = this.Campaign.Meeting_Cooperate3__c;
|
var Meeting_Cooperate4 = this.Campaign.Meeting_Cooperate4__c;
|
var MeetingType = this.Campaign.Meeting_Type__c;
|
var HostName = this.Campaign.HostName__c;
|
var cooperatorCompany = this.Campaign.cooperatorCompany__c;
|
var meetingStartDate = this.Campaign.StartDate;
|
var meetingEndDate = this.Campaign.EndDate;
|
//OBPM LY 20211221 start
|
var IFApproved = this.Campaign.IF_Approved__c;
|
//OBPM LY 20211221 end
|
var status = this.Campaign.Status;
|
var CampaignStatus = this.Campaign.CampaignStatus__c; // 20221201 ljh DB202211527935 add
|
var IF_Submit__c = this.Campaign.IF_Submit__c;
|
var MeetingApprovedNoId = this.Campaign.Meeting_Approved_No__c;
|
|
|
var meetingSize = await findQualified1({CampaignId : this.Campaign.Id});
|
if(meetingSize.length>0){
|
this.dispatchEvent(event1);
|
return;
|
}
|
|
var consumSize = await findQualified2({CampaignId : this.Campaign.Id});
|
console.log(consumSize);
|
console.log('123123123');
|
console.log(consumSize.length);
|
if(consumSize.length>0){
|
this.dispatchEvent(event2);
|
return;
|
}
|
|
var rentalSize = await findQualified3({CampaignId : this.Campaign.Id});
|
if(rentalSize.length>0){
|
this.dispatchEvent(event3);
|
return;
|
}
|
//活动信息已经发送给智慧医疗
|
if(IF_Submit__c != 0){
|
this.dispatchEvent(event4);
|
}
|
|
// 会议延期检查 SWAG-BVH3Q7 20201120
|
var rtn = await changeCampaign({campaignId:CampaignId});
|
if (rtn != 'OK') {
|
const event6 = new ShowToastEvent({
|
message:
|
rtn,
|
variant : "error" ,
|
mode :'sticky'
|
});
|
this.dispatchEvent(event6);
|
return;
|
}
|
// 20221201 ljh DB202211527935 add start
|
// 对于1 学会/会议和6 营业部专用会议这两种会议类型,请将公开中或申请中不允许提交变更申请的约束,改到会议状态字段。
|
var recordTypeId1= await getRecordIdByName({Name : '%学会/会议%'});
|
var recordTypeId2= await getRecordIdByName({Name : '%营业部专用会议%'});
|
//开发环境没有此recordType
|
var recordTypeId3= await getRecordIdByName({Name : '%会议延期%'});
|
let canDelayFlag = false;
|
console.log(this.Campaign.RecordTypeId == recordTypeId1);
|
console.log(this.Campaign.RecordTypeId == recordTypeId2);
|
console.log(recordTypeId1);
|
console.log(recordTypeId2);
|
console.log(this.Campaign.RecordTypeId == recordTypeId1);
|
console.log(this.Campaign.RecordTypeId == recordTypeId2);
|
console.log(CampaignStatus == '公开中');
|
console.log('this.Campaign.RecordTypeId = ' + this.Campaign.RecordTypeId);
|
console.log('recordTypeId1 = ' + recordTypeId1);
|
console.log('recordTypeId2 = ' + recordTypeId2);
|
console.log('CampaignStatus = ' + CampaignStatus);
|
console.log('status = ' + status);
|
if((this.Campaign.RecordTypeId == recordTypeId1 || this.Campaign.RecordTypeId == recordTypeId2)&&(CampaignStatus == '公开中' || CampaignStatus == '申请中' || CampaignStatus == '备品已申请')){
|
console.log('h1');
|
canDelayFlag = true;
|
}else if(!(this.Campaign.RecordTypeId == recordTypeId1 || this.Campaign.RecordTypeId == recordTypeId2)&& (status == '公开中' || status == '申请中')){
|
console.log('h2');
|
canDelayFlag = true;
|
}
|
console.log('canDelayFlag');
|
console.log(canDelayFlag);
|
if(canDelayFlag){
|
const defaultValues = encodeDefaultFieldValues({
|
campaign__c: CampaignId,
|
HostName__c: HostName,
|
cooperatorCompany__c: cooperatorCompany,
|
meeting_start_date__c: meetingStartDate,
|
meeting_end_date__c: meetingEndDate,
|
Meeting_Type__c: MeetingType,
|
IF_Approved__c: IFApproved,
|
dismantling_date__c: PlanBackData,
|
Meeting_Cooperate1__c:Meeting_Cooperate,
|
Meeting_Cooperate2__c: Meeting_Cooperate2,
|
Meeting_Cooperate3__c: Meeting_Cooperate3,
|
Meeting_Cooperate4__c:Meeting_Cooperate4,
|
MeetingApproved__c: MeetingApprovedNoId,
|
retURL : CampaignId
|
});
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'meeting_delay_apply__c',
|
actionName: 'new'
|
},
|
state: {
|
nooverride: '1',
|
defaultFieldValues: defaultValues,
|
recordTypeId : recordTypeId3
|
}
|
});
|
}else{
|
this.dispatchEvent(event5);
|
return;
|
}
|
|
|
}
|
|
}
|