binxie
2024-01-18 b1d36ea3e6653e59bd767aa192c688ee0d9d4c58
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
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 init from '@salesforce/apex/DealerVisitDetailsController.init';
import  ReportId  from '@salesforce/apex/HosipitalToDeptController.ReportId';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';        
import {loadStyle} from 'lightning/platformResourceLoader'    
export default class LexDealerVisitDetails extends NavigationMixin(LightningElement) {
    @api recordId;
    IsLoading=true;
    @wire(CurrentPageReference)
    getStateParameters(currentPageReference){
        console.log("进入页面");
        console.log(currentPageReference);
        if(currentPageReference){
            const urvalue=currentPageReference.state.recordId;
            if(urvalue){
                let str=`${urvalue}`;
                console.log('str');
                console.log(str);
                this.recordId=str;
            }
        }
    }
 
    connectedCallback(){
        Promise.all([            
            loadStyle(this, lwcCSS)            
        ]);    
        init({recordId:this.recordId}).then(res => {
            console.log(res,'<======res')
            let whiteList = [
                '2S4_销售管理者',
                '2S4_销售管理者(总监)',
                '2S6-1_销售本部窗口',
                '2S6-2_营业助理',
                // '00e10000000NbCE',
                '系统管理员',
                '2J2_特约店担当'
            ]
            if(res != null){
                if(whiteList.indexOf(res.profileId) == -1){
                    this.showToast("你没有操作权限",'error');
                    return;
                }
                var accountType = res.departmentClassLabel;
                var sectionMap = new Map();
                sectionMap['消化科'] = 'GI';sectionMap['ET'] = 'ET';
                sectionMap['呼吸科'] = 'BF';sectionMap['普外科'] = 'GS';
                sectionMap['泌尿科'] = 'URO';sectionMap['妇科'] = 'GYN';
                sectionMap['耳鼻喉科'] = 'ENT';sectionMap['其他'] = 'OTH';
                var sectionApi= sectionMap[accountType];
                //医院的传参
                if(res.recordTypeId == 'ok'){
                    ReportId({TypeName:'DealerVisitDetailsHospital'}).then(request => {
                        // window.open('/'+ request +'?fv0='+res.name)
                        window.location.href = '/lightning/r/Report/'+ request +'/view'+'?fv0='+res.name
                    })
                } else {
                    //战略科室的传参
                    ReportId({TypeName:'Agency_Activity'}).then(request => {
                        // window.open('/'+ request +'?fv0='+ res.name +'&fv1='+sectionApi)
                        window.location.href = '/lightning/r/Report/'+ request +'/view'+'?fv0='+ res.name +'&fv1='+sectionApi
                    })
                }
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        })
    
    }
 
    showToast(msg, type) {
        if(type == 'success'){
            const event = new ShowToastEvent({
                message: msg,
                variant: type
            });
            this.dispatchEvent(event);
        }else{
            const event = new ShowToastEvent({
                message: msg,
                variant: type,
                mode:'Sticky'
            });
            this.dispatchEvent(event);
        }
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}