From 636afc2e565e2a188cb5e5d2ffe894a219a38661 Mon Sep 17 00:00:00 2001
From: KKbes <1620284052@qq.com>
Date: 星期二, 23 五月 2023 13:50:53 +0800
Subject: [PATCH] 会议费用情况按钮  学会培训

---
 force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js          |  146 ++++++++++++++++++++++++++++++++++++
 force-app/main/default/classes/LexMeetingCostsController.cls           |   42 ++++++++++
 force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.html        |    3 
 force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js-meta.xml |   11 ++
 force-app/main/default/classes/LexMeetingCostsController.cls-meta.xml  |    5 +
 5 files changed, 207 insertions(+), 0 deletions(-)

diff --git a/force-app/main/default/classes/LexMeetingCostsController.cls b/force-app/main/default/classes/LexMeetingCostsController.cls
new file mode 100644
index 0000000..a3a748b
--- /dev/null
+++ b/force-app/main/default/classes/LexMeetingCostsController.cls
@@ -0,0 +1,42 @@
+public with sharing class LexMeetingCostsController {
+    
+    @AuraEnabled
+    public static Campaign  init(String recordId){
+        Campaign res = new Campaign();
+        try{
+                res=[SELECT Id,OwnerId,JingliApprovalManager__c,BuchangApprovalManager__c,
+                ZongjianApprovalManager__c,Sponsor_Ones_Post__c   FROM  Campaign  WHERE Id = : recordId ];
+        }
+        catch (Exception e) {
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+
+
+
+    @AuraEnabled
+    public static groupmember  judgeMumber(String UserId){
+        groupmember res =new groupmember();
+        try{
+            res=[SELECT Id FROM groupmember WHERE 
+            group.developername = 'X00_Meetingfee_Huabei' and userorgroupid = :UserId];
+        }
+        catch (Exception e) {
+            System.debug(LoggingLevel.INFO, '*** e: ' + e);
+        }
+        return res;
+    }
+
+     @AuraEnabled
+    public static String  getProfileIdByName(String Name){
+        Profile profile = null;
+        try {
+            profile = [select Id from Profile where Name =:name];
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return profile.Id;
+
+    }
+}
\ No newline at end of file
diff --git a/force-app/main/default/classes/LexMeetingCostsController.cls-meta.xml b/force-app/main/default/classes/LexMeetingCostsController.cls-meta.xml
new file mode 100644
index 0000000..70f89f4
--- /dev/null
+++ b/force-app/main/default/classes/LexMeetingCostsController.cls-meta.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
+    <apiVersion>51.0</apiVersion>
+    <status>Active</status>
+</ApexClass>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.html b/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.html
new file mode 100644
index 0000000..af9fa97
--- /dev/null
+++ b/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.html
@@ -0,0 +1,3 @@
+<template>
+
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js b/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js
new file mode 100644
index 0000000..8433064
--- /dev/null
+++ b/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js
@@ -0,0 +1,146 @@
+import { LightningElement, api , track, wire } from 'lwc';
+
+import { CurrentPageReference } from "lightning/navigation";
+import { getRecord } from 'lightning/uiRecordApi';
+import USER_ID from '@salesforce/user/Id';
+import USERPROFILE_ID from '@salesforce/schema/User.ProfileId';
+import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+
+import init  from '@salesforce/apex/LexMeetingCostsController.init';
+import judgeMember  from '@salesforce/apex/LexMeetingCostsController.judgeMumber';
+import getProfileIdByName  from '@salesforce/apex/LexMeetingCostsController.getProfileIdByName';
+
+  // author: kkbes
+
+  const event = new ShowToastEvent({
+            title: '鏉冮檺涓嶈冻',
+            message:
+                '鏃犳潈鏌ョ湅浼氳璐圭敤鎯呭喌',
+        });
+export default class lexMeetingCosts extends LightningElement {
+
+	@api recordId;
+    Campaign;
+    IsLoading = true;
+    userId = USER_ID;
+    currentUserProfileId;
+    NotSupportProfileId;
+
+    @wire(CurrentPageReference)
+    getStateParameters(currentPageReference) {
+            console.log(111);
+            console.log(currentPageReference);
+
+        if (currentPageReference) {
+          const urlValue = currentPageReference.state.recordId;
+          if (urlValue) {
+            let str = `${urlValue}`;
+            console.log("str");
+            console.log(str);
+            this.recordId = str;
+          }
+        }
+    }
+
+     @wire(getRecord, { recordId: USER_ID, fields: [USERPROFILE_ID]}) 
+         userDetails({error, data}) {
+            console.log('222');
+            if (data) {
+                this.currentUserProfileId = data.fields.ProfileId.value;
+                console.log(this.currentUserProfileId);
+               
+            } else if (error) {
+                this.error = error ;
+            }
+    }
+
+
+
+    connectedCallback(){
+        console.log(this.recordId);
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            console.log(result);
+            if (result != null) {
+                this.Campaign = result;
+                console.log(this.Campaign);
+                console.log(this.userId);
+                this.MeetingCosts();
+            }
+        }).catch(error => {
+            console.log("error");
+            console.log(error);
+        });
+
+    }
+
+
+
+    async MeetingCosts(){
+
+    	var logUser = this.userId;
+
+    	var records = await judgeMember({ UserId : this.userId});
+
+    	var ProfileId= await getProfileIdByName({Name : "绯荤粺绠$悊鍛�"}); 
+
+        console.log('scscscsccsc');
+        console.log(records);
+        console.log(ProfileId);
+
+
+    	if(records.length>0 && this.Campaign.Sponsor_Ones_Post__c == '1.鍗庡寳'){
+        console.log('if');
+		window.open("/apex/CampaignMeetingcost?id=" + this.Campaign.Id ,'CampaignMember','height=500,width=950');
+		}
+		else if (logUser == this.Campaign.OwnerId 
+			|| logUser == this.Campaign.JingliApprovalManager__c 
+			|| logUser == this.Campaign.BuchangApprovalManager__c 
+			|| logUser == this.Campaign.ZongjianApprovalManager__c  
+			|| this.currentUserProfileId == ProfileId){
+        console.log('else if');
+		window.open("/apex/CampaignMeetingcost?id=" + this.Campaign.Id ,'CampaignMember','height=500,width=950');
+		}
+		else {
+		this.dispatchEvent(event);
+		return;
+		}
+
+    }
+
+
+
+
+
+}
+
+
+
+// old  js
+// {!RequireScript("/soap/ajax/51.0/connection.js")}
+// {!RequireScript("/soap/ajax/51.0/apex.js")}
+// {!RequireScript("/resource/CommonUtilJs")}
+// var foo = function(){
+// var logUser = "{!$User.Id}";
+// var owner = "{!Campaign.OwnerId}";
+// var Jingli = "{!Campaign.JingliApprovalManagerId__c}";
+// var Buchang = "{!Campaign.BuchangApprovalManagerId__c}";
+// var Zongjian = "{!Campaign.ZongjianApprovalManagerId__c}";
+// var Sponsor = "{!Campaign.Sponsor_Ones_Post__c}";
+
+
+// //鍒ゆ柇鏄惁鏄� 00 鍗庡寳甯傚満璐圭敤鍏变韩缁勬垚鍛�
+// var myquery = "SELECT Id FROM groupmember WHERE group.developername = 'X00_Meetingfee_Huabei' and userorgroupid = '{!$User.Id}'";
+// sqlResult = sforce.connection.query(myquery);
+// records = sqlResult.getArray("records");
+// if(records.length>0 && Sponsor == '1.鍗庡寳'){
+// window.open("/apex/CampaignMeetingcost?id=" + '{!Campaign.Id}' ,'CampaignMember','height=500,width=950');
+// }else if (logUser == owner || logUser == Jingli || logUser == Buchang || logUser == Zongjian || "{!$User.ProfileId}" == '00e10000000Y3o5'){
+// window.open("/apex/CampaignMeetingcost?id=" + '{!Campaign.Id}' ,'CampaignMember','height=500,width=950');
+// }else {
+// alert("鏃犳潈鏌ョ湅浼氳璐圭敤鎯呭喌");
+// return;
+// }
+// };
+// foo();
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js-meta.xml b/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js-meta.xml
new file mode 100644
index 0000000..43fe438
--- /dev/null
+++ b/force-app/main/default/lwc/lexMeetingCosts/lexMeetingCosts.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexMeetingCosts">
+    <apiVersion>51.0</apiVersion>
+    <isExposed>true</isExposed>
+        <targets>
+        <target>lightning__AppPage</target>
+        <target>lightning__RecordPage</target>
+        <target>lightning__HomePage</target>
+        <target>lightning__RecordAction</target>
+    </targets>
+</LightningComponentBundle>
\ No newline at end of file

--
Gitblit v1.9.1