From c7929dde5537a8f3ff63b13d7349778813129289 Mon Sep 17 00:00:00 2001
From: KKbes <1620284052@qq.com>
Date: 星期二, 23 五月 2023 14:27:56 +0800
Subject: [PATCH] OPD计划 无申请报告
---
force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.html | 3 +
force-app/main/default/classes/LexNoReportApplicationController.cls | 28 +++++++++
force-app/main/default/classes/LexNoReportApplicationController.cls-meta.xml | 5 +
force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js-meta.xml | 11 +++
force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js | 91 ++++++++++++++++++++++++++++++
5 files changed, 138 insertions(+), 0 deletions(-)
diff --git a/force-app/main/default/classes/LexNoReportApplicationController.cls b/force-app/main/default/classes/LexNoReportApplicationController.cls
new file mode 100644
index 0000000..39a753b
--- /dev/null
+++ b/force-app/main/default/classes/LexNoReportApplicationController.cls
@@ -0,0 +1,28 @@
+
+ // with lwc lexNoReportApplication
+ //author kkbes
+public class LexNoReportApplicationController {
+ @AuraEnabled
+ public static OPDPlan__c initGetOpdData(String recordId){
+ OPDPlan__c res = new OPDPlan__c();
+ try {
+ OPDPlan__c report = [select Id,Name,Status__c from OPDPlan__c where Id = :recordId];
+ res=report;
+ } 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/LexNoReportApplicationController.cls-meta.xml b/force-app/main/default/classes/LexNoReportApplicationController.cls-meta.xml
new file mode 100644
index 0000000..70f89f4
--- /dev/null
+++ b/force-app/main/default/classes/LexNoReportApplicationController.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/lexNoReportApplication/lexNoReportApplication.html b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.html
new file mode 100644
index 0000000..af9fa97
--- /dev/null
+++ b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.html
@@ -0,0 +1,3 @@
+<template>
+
+</template>
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js
new file mode 100644
index 0000000..21c94ae
--- /dev/null
+++ b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js
@@ -0,0 +1,91 @@
+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/LexNoReportApplicationController.initGetOpdData';
+import getProfileIdByName from'@salesforce/apex/LexNoReportApplicationController.getProfileIdByName';
+import { CloseActionScreenEvent } from 'lightning/actions';
+
+ const event = new ShowToastEvent({
+ title: '妫�鏌ョ姸鎬�',
+ message:
+ '鍙湁鐘舵�佷负寰呮彁浜ゆ姤鍛婄殑OPD璁″垝鎵嶈兘杩涜鏃犳姤鍛婄敵璇�',
+ });
+export default class lexNoReportApplication extends LightningElement {
+
+
+ @api recordId;
+
+
+ OPDPlan__c;
+ currentUserProfileId;
+ error;
+ NotSupportProfileId;
+
+
+
+
+ @wire(getRecord, { recordId: USER_ID, fields: [USERPROFILE_ID]})
+ userDetails({error, data}) {
+ if (data) {
+ this.currentUserProfileId = data.fields.ProfileId.value;
+
+ } else if (error) {
+ this.error = error ;
+ }
+ }
+
+ @wire(CurrentPageReference)
+ getStateParameters(currentPageReference) {
+ if (currentPageReference) {
+ const urlValue = currentPageReference.state.recordId;
+ if (urlValue) {
+ let str = `${urlValue}`;
+ this.recordId = str;
+
+ }
+ }
+ }
+
+
+
+ async connectedCallback(){
+ await init({
+ recordId: this.recordId
+ }).then(result=>{
+ this.OPDPlan__c=result;
+ this.NoReportApplication();
+ }).catch(error=>{
+ console.log("error");
+ console.log(error);
+ });
+ }
+
+
+
+ async NoReportApplication() {
+
+
+ //OPD璁″垝鐘舵��
+ var status = this.OPDPlan__c.Status__c;
+ this.NotSupportProfileId= await getProfileIdByName({Name : "绯荤粺绠$悊鍛�"});
+ //褰撳墠鐢ㄦ埛绠�妗d
+ var ProfileId = this.currentUserProfileId;
+ //璺宠繃绯荤粺绠$悊鍛�
+ if(status !='寰呮彁浜ゆ姤鍛�'&& ProfileId != this.NotSupportProfileId){
+ this.dispatchEvent(new CloseActionScreenEvent());
+ this.dispatchEvent(event);
+ return;
+ }
+ else{
+ this.dispatchEvent(new CloseActionScreenEvent());
+ window.open ('/apex/OPDNoReportApplication?id='+this.OPDPlan__c.Id+'&name='+this.OPDPlan__c.Name, '鏃犳姤鍛婄敵璇�',
+ 'height=400, width=700, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js-meta.xml b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js-meta.xml
new file mode 100644
index 0000000..15e0dfe
--- /dev/null
+++ b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js-meta.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="lexNoReportApplication">
+ <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