liuyn
2024-03-11 a87f1c3df03078814ee97ad0c8ac200a232419e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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
        }
    }
 
}