import { LightningElement, track, wire,api } from 'lwc';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import { CurrentPageReference } from "lightning/navigation";
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
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 event3 = new ShowToastEvent({
|
message:
|
"必须输入取消理由",
|
variant : 'error',
|
mode :'sticky'
|
});
|
import init from '@salesforce/apex/LexSubmitCampaignController.initCancleService';
|
import getRecordIdByName from '@salesforce/apex/LexSubmitCampaignController.getRecordIdByName';
|
import queryUserIdByName from '@salesforce/apex/LexSubmitCampaignController.queryUserIdByName';
|
import submitApprovalRequest from '@salesforce/apex/LexSubmitCampaignController.submitApprovalRequest';
|
import newAndUpdateCampaignCancle from '@salesforce/apex/LexSubmitCampaignController.newAndUpdateCampaignCancle';
|
import cancleServiceNewAndUpdate from '@salesforce/apex/LexSubmitCampaignController.cancleServiceNewAndUpdate';
|
export default class lexCancelInService 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;
|
}
|
}
|
}
|
|
connectedCallback(){
|
Promise.all([
|
loadStyle(this, lwcCSS)
|
]);
|
init({
|
recordId: this.recordId
|
}).then(result => {
|
if (result != null) {
|
this.Campaign = result;
|
console.log('cancelInService');
|
console.log(this.Campaign);
|
this.cancelInService().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 cancelInService(){
|
var checkUpdate=0;
|
var Status =this.Campaign.Status;
|
if (this.Campaign.Status == '取消') {
|
this.dispatchEvent(event1);
|
return;
|
}
|
if (this.Campaign.Status != '草案中' && this.Campaign.Status != '公开中') {
|
const event2 = new ShowToastEvent({
|
message : Status +"状态不能取消" ,
|
variant : 'error',
|
mode :'sticky'
|
});
|
this.dispatchEvent(event2);
|
return;
|
}
|
|
var IsCancelFromOpen = false;
|
console.log(this.Campaign.Status);
|
if (this.Campaign.Status == '公开中') {
|
IsCancelFromOpen = true;
|
}
|
// await cancleServiceNewAndUpdate({
|
// Id: this.Campaign.Id, Status : '取消申请中', IsCancelFromOpen : IsCancelFromOpen}).then(result1=>{
|
// if(result1 != 'success'){
|
// const event4 = new dispatchEvent({
|
// message : result1,
|
// variant : 'error',
|
// mode :'sticky'
|
// });
|
// checkUpdate+=1;
|
// this.dispatchEvent(event4);
|
// }
|
// if(checkUpdate!=0){
|
// return;
|
// }
|
// });
|
var ProfileId = await getRecordIdByName({Name : '取消申请'});
|
// var CL5Id = null;
|
// var CL5Name = null;
|
// var CL6Id = null;
|
// var CL6Name = null;
|
// var fwId = null;
|
// var fwName = null;
|
var CL5 = this.Campaign.BuchangApprovalManager__c;
|
var CL6 = this.Campaign.JingliApprovalManager__c;
|
var fw = this.Campaign.ServiceDesignDep__c;
|
// var UserSize = await queryUserIdByName({Name : CL5});
|
// var UserSize1 = await queryUserIdByName({Name : CL6});
|
// var UserSize2 = await queryUserIdByName({Name : fw});
|
// console.log(UserSize);
|
// console.log(UserSize1);
|
// console.log(UserSize2);
|
// if(UserSize.length > 0){
|
// CL5Id = UserSize[0].Id;
|
// CL5Name = UserSize[0].Name;
|
// }
|
|
// if(UserSize1.length > 0){
|
// CL6Id = UserSize1[0].Id;
|
// CL6Name = UserSize1[0].Name;
|
// }
|
|
// if(UserSize2.length> 0){
|
// fwId = UserSize2[0].Id;
|
// fwName = UserSize2[0].Name;
|
// }
|
|
var CampaignId = this.Campaign.Id;
|
var CampaignName= this.Campaign.Name;
|
const defaultFieldValues = encodeDefaultFieldValues({
|
campaign__c: CampaignId,
|
minister__c:CL5,
|
manager__c: CL6,
|
ServiceDesignDep__c: fw
|
})
|
this[NavigationMixin.Navigate]({
|
type: 'standard__objectPage',
|
attributes: {
|
objectApiName: 'meeting_delay_apply__c', // 要新建的对象API
|
actionName: 'new',
|
},
|
state:{
|
nooverride: '1',
|
defaultFieldValues: defaultFieldValues,
|
recordTypeId : ProfileId
|
|
}
|
});
|
|
}
|
|
}
|