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, track, wire,api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { CurrentPageReference } from "lightning/navigation";
import { CloseActionScreenEvent } from 'lightning/actions';
import USER_ID from '@salesforce/user/Id';
import lwcCSS from '@salesforce/resourceUrl/lwcCSS';
import {loadStyle} from 'lightning/platformResourceLoader';
const event1 = new ShowToastEvent({
                    message:
                    "批准后不能添加参会人员,如需添加请联系服务企划部!",
                    variant : 'error',
                    mode :'sticky'
});
import getProfileId from'@salesforce/apex/LexGetUserInfoUtils.getProfileId';
import init  from '@salesforce/apex/LexSubmitCampaignController.initMember';
import getProfileIdByName  from '@salesforce/apex/LexMeetingCostsController.getProfileIdByName';
export default class lexCampaignMemberService extends LightningElement {
    @api recordId;
    IsLoading=true;
    Campaign;
 
 
 
    // @wire(CurrentPageReference)
 //    getStateParameters(currentPageReference) {
 //        if (currentPageReference) {
 //             console.log('11111111');
 //          const urlValue = currentPageReference.state.recordId;
 //          console.log(urlValue);
 //          console.log(currentPageReference);
 //          console.log(currentPageReference.state.recordId);
 //          if (urlValue) {
 //              console.log('22222222');
 //            let str = `${urlValue}`;
 //            console.log(str);
 //            this.recordId = str;
 //            console.log('recordId');
 //            console.log(this.recordId);
 //          }
 //        }
 //    }
 
    connectedCallback(){
        Promise.all([
            loadStyle(this, lwcCSS)
        ]);        
        init({
            recordId: this.recordId
        }).then(result => {
            if (result != null) {
                this.Campaign = result;
                this.campaignMemberService().then(result=>{
                   this.IsLoading=false;
                this.dispatchEvent(new CloseActionScreenEvent());
                const passOneEvent = new CustomEvent('closem', {
                        detail: '111'
              });
              this.dispatchEvent(passOneEvent);
            });
            }
        }).catch(error => {
            console.log(error);
            const eventInItError = new ShowToastEvent({
                   message:
                error,
                variant : 'error'
            });
            this.dispatchEvent(eventInItError);
        });   
 
    }
 
    async campaignMemberService(){
        var ProfileId= await getProfileIdByName({Name : "系统管理员"}); 
        var cstatus = this.Campaign.Status;
        var  userProfileId = await getProfileId();
        if (cstatus =='草案中' || this.Campaign.ServiceDesignDepId__c == USER_ID
        || userProfileId == ProfileId ){
            window.open("/apex/CampaignMemberService?id=" + this.Campaign.Id,'CampaignMember','height=400,width=890,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no');
 
        } else {
            this.dispatchEvent(event1);
            return;
        }
    }
 
}