binxie
2024-01-20 e0de9222da210f9c8eb1a9f5400f936a14923e11
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
import { LightningElement ,api, track, wire } from 'lwc';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
import { CurrentPageReference } from "lightning/navigation";
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import init from'@salesforce/apex/LexNoReportApplicationController.initGetOpdData';
import getProfileIdByName from'@salesforce/apex/LexNoReportApplicationController.getProfileIdByName';
import getProfileId from'@salesforce/apex/LexGetUserInfoUtils.getProfileId';
import { CloseActionScreenEvent } from 'lightning/actions';
 
 const event = new ShowToastEvent({
            message:
                '只有状态为待提交报告的OPD计划才能进行无报告申请',
            variant: 'error',
            mode :'sticky'
        });
export default class lexNoReportApplication extends LightningElement {
 
 
    @api recordId;
    IsLoading=true;
    OPDPlan__c;
    NotSupportProfileId;
 
 
 
 
 
 
    @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=>{
            this.OPDPlan__c=result;
            this.NoReportApplication().then(result=>{
                this.IsLoading=false;
                this.dispatchEvent(new CloseActionScreenEvent());
            });
        }).catch(error=>{
            const eventError = new ShowToastEvent({
                message:
                error.message,
                variant: 'error',
                mode :'sticky'
            });
            this.dispatchEvent(eventError);
        });
    }
 
 
 
    async NoReportApplication() {
        //OPD计划状态
        var status = this.OPDPlan__c.Status__c;
        this.NotSupportProfileId= await getProfileIdByName({Name : "系统管理员"});
        //当前用户简档id   
        var ProfileId = await getProfileId();   
        //跳过系统管理员
        if(status !='待提交报告'&& ProfileId != this.NotSupportProfileId){
            this.dispatchEvent(event);    
            return;
        }
        else{
            window.open ('/apex/OPDNoReportApplication?id='+this.OPDPlan__c.Id+'&name='+this.OPDPlan__c.Name, '无报告申请',
            'height=400, width=900, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
        
        }
    }
 
}