liangxiaozhen
2023-08-06 1d17c4022a928eacff7309016cde76f29ad257fb
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
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/AccountUrlRecordTypeIdController.ReportId';
 
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(){
        init({recordId:this.recordId}).then(res => {
            console.log(res,'<======res')
            let whiteList = [
                '00e10000000xnpHAAQ',
                '00e10000000hkasAAA',
                '00e10000000xyK6AAI',
                '00e10000000xnpRAAQ',
                // '00e10000000NbCE',
                '00e10000000Y3o5AAC'
            ]
            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 == '01210000000QemGAAS'){
                    ReportId({TypeName:'DealerVisitDetailsHospital'}).then(request => {
                        window.open('/'+ request +'?pv='+res.Name)
                    })
                } else {
                    ReportId({TypeName:'Agency_Activity'}).then(request => {
                        window.open('/'+ request +'?pv='+ res.HospitalDepartmentClass +'&pv='+sectionApi)
                    })
                }
                this.dispatchEvent(new CloseActionScreenEvent());
            }
        })
    
    }
 
    showToast(msg, type) {
        const event = new ShowToastEvent({
          message: msg,
          variant: type
        });
        this.dispatchEvent(event);
        this.dispatchEvent(new CloseActionScreenEvent());
    }
}