import { LightningElement,api, track, wire } from 'lwc';
|
import {CurrentPageReference} from 'lightning/navigation';
|
import { CloseActionScreenEvent } from 'lightning/actions';
|
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
|
import LightningConfirm from 'lightning/confirm';
|
|
import init from '@salesforce/apex/LexEventCancelController.init';
|
import getTaskC from '@salesforce/apex/LexEventCancelController.getTaskC';
|
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
|
import {loadStyle} from 'lightning/platformResourceLoader';
|
export default class lexEventDelay extends LightningElement {
|
@api recordId;
|
@api isDoneRendering;
|
IsLoading=true;
|
QuoteIraiId;
|
EventC_ID__c;
|
Task_ID__c;
|
StartDateTime;
|
EventStatus__c;
|
@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)
|
]);
|
init({recordId:this.recordId}).then(result=>{
|
this.EventC_ID__c=result.EventC_ID__c;
|
if(result.Task_ID__c==null)this.Task_ID__c='';
|
else this.Task_ID__c=result.Task_ID__c;
|
this.StartDateTime=result.StartDateTime;
|
this.EventStatus__c=result.EventStatus__c;
|
this.QuoteIraiId=result.Id;
|
this.cancelSubmit().then(res=>{
|
console.log(res);
|
this.IsLoading=false;
|
const passOneEvent = new CustomEvent('closem', {
|
detail: '111'
|
});
|
this.dispatchEvent(passOneEvent);
|
});
|
}).catch(err=>{
|
// console.log("error:");
|
// console.log(err.message);
|
}).finally(()=>{
|
this.dispatchEvent(new CloseActionScreenEvent());
|
});
|
}
|
|
|
|
async cancelSubmit(){
|
//2021-07-28 mzy update
|
//判断是否有生成报告一览
|
var IsHasEventC = this.EventC_ID__c==''?false:true;
|
//2021-07-28 mzy update
|
//2021-10-08 mzy 任务管理改善 已完成的任务,事件页面和日报页面不允许修改 start
|
var TaskCount = await getTaskC({recordId:this.Task_ID__c});
|
if(TaskCount!=null&&TaskCount.taskDifferent__c == '上级分配任务'){
|
// if(TaskCount!=null&&TaskCount.taskDifferent__c == '主动任务'){
|
const event = new ShowToastEvent({
|
message:'上级分配的任务不能延期',
|
variant: 'warning',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}else if(TaskCount!=null&&TaskCount.taskStatus__c == '03 完成'){
|
const event = new ShowToastEvent({
|
message:'已完成的任务不能修改',
|
variant: 'warning',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}else{
|
var date=new Date();
|
if((date > this.StartDateTime) || IsHasEventC && (date = this.StartDateTime)){
|
const event = new ShowToastEvent({
|
message:'不允许修改今天及以前的事件',
|
variant: 'warning',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}else if(this.EventStatus__c!=null && this.EventStatus__c!='' && this.EventStatus__c != '02 接受' ){
|
|
const event = new ShowToastEvent({
|
message:'不允许修改本事件',
|
variant: 'warning',
|
mode: 'sticky'
|
});
|
this.dispatchEvent(event);
|
}else{
|
var url= "/apex/EventHandle?Id="+this.recordId+"&isEventDelay=true";
|
window.open(url,'lexEventDelay');
|
// window.open("/apex/EventHandle?Id="+this.recordId+"&isEventDelay=true",'lexEventCancel', 'width=1000,height=500');
|
}
|
//2021-07-28 mzy update
|
}
|
}
|
|
}
|