From f66abb6dad1b8caa18aca9d65dceb34a34c022b6 Mon Sep 17 00:00:00 2001
From: KKbes <1620284052@qq.com>
Date: 星期五, 11 八月 2023 11:42:16 +0800
Subject: [PATCH] review

---
 force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js |   74 +++++++++++++++---------------------
 1 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js
index 21c94ae..d7500af 100644
--- a/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js
+++ b/force-app/main/default/lwc/lexNoReportApplication/lexNoReportApplication.js
@@ -1,42 +1,29 @@
 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 getProfileId from'@salesforce/apex/LexGetUserInfoUtils.getProfileId';
 import { CloseActionScreenEvent } from 'lightning/actions';
 
  const event = new ShowToastEvent({
-            title: '妫�鏌ョ姸鎬�',
             message:
                 '鍙湁鐘舵�佷负寰呮彁浜ゆ姤鍛婄殑OPD璁″垝鎵嶈兘杩涜鏃犳姤鍛婄敵璇�',
+            variant: 'error'
         });
 export default class lexNoReportApplication extends LightningElement {
 
 
 	@api recordId;
-
-
+    IsLoading=true;
 	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) {
@@ -45,47 +32,48 @@
            if (urlValue) {
              let str = `${urlValue}`;
              this.recordId = str;
-
            }
          }
      }
 
     
 
-    async connectedCallback(){
-       await init({
+    connectedCallback(){
+        init({
             recordId: this.recordId
         }).then(result=>{
             this.OPDPlan__c=result;
-            this.NoReportApplication();
+            this.NoReportApplication().then(result=>{
+                this.IsLoading=false;
+                this.dispatchEvent(new CloseActionScreenEvent());
+            });
         }).catch(error=>{
-            console.log("error");
-            console.log(error);
+            const eventError = new ShowToastEvent({
+                title: '椤甸潰鍒濆鍖栭敊璇�',
+                message:
+                error.message,
+            });
+            this.dispatchEvent(eventError);
         });
     }
 
 
 
     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');
-	
-	}
-	}
+    	//OPD璁″垝鐘舵��
+    	var status = this.OPDPlan__c.Status__c;
+    	this.NotSupportProfileId= await getProfileIdByName({Name : "绯荤粺绠$悊鍛�"});
+    	//褰撳墠鐢ㄦ埛绠�妗d   
+        var ProfileId = await getProfileId();   
+    	//璺宠繃绯荤粺绠$悊鍛�
+    	if(status !='寰呮彁浜ゆ姤鍛�'&& ProfileId != this.NotSupportProfileId){
+    		this.dispatchEvent(event);	
+    		return;
+    	}
+    	else{
+    		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

--
Gitblit v1.9.1