From 3d312e60e65de7bd0194c50ae26d11c7a4d4fc73 Mon Sep 17 00:00:00 2001
From: 19626 <1962676589@qq.com>
Date: 星期二, 09 五月 2023 17:59:59 +0800
Subject: [PATCH] review update

---
 force-app/main/default/classes/ReportController.cls                                 |   39 ++++++++++++++++++-
 force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js                             |    3 -
 .vscode/settings.json                                                               |    3 +
 force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js                               |   30 ++++++++++++--
 force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js                             |   13 +++++-
 force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js |    4 +
 force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js                           |    3 -
 force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js                             |    4 +-
 force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js                       |    8 ++--
 force-app/main/default/classes/LightingButtonConstant.cls                           |    3 +
 force-app/main/default/classes/MonthlyReportController.cls                          |    7 ++-
 11 files changed, 92 insertions(+), 25 deletions(-)

diff --git a/.vscode/settings.json b/.vscode/settings.json
index 76decfb..ca137b3 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -3,5 +3,6 @@
     "**/node_modules": true,
     "**/bower_components": true,
     "**/.sfdx": true
-  }
+  },
+  "editor.suggest.snippetsPreventQuickSuggestions": false
 }
diff --git a/force-app/main/default/classes/LightingButtonConstant.cls b/force-app/main/default/classes/LightingButtonConstant.cls
index 32e127b..ef82288 100644
--- a/force-app/main/default/classes/LightingButtonConstant.cls
+++ b/force-app/main/default/classes/LightingButtonConstant.cls
@@ -86,6 +86,9 @@
     public static final String CN_NO = '鍚�';
     public static final String VOC_NAME = 'VOC';
     public static final String OK = 'OK';
+    public static final String LU_SHENG_NAME = '闄� 鑳�';
+    public static final String HU_DI_AN_NAME = '鑳� 杩畨';
+    public static final String SYSTEM_PROFILE_NAME = '绯荤粺绠$悊鍛�';
     public static final String SOBJECT_NAME_OF_REPORT_SHARE ='Report__Share';
     public static final String  SOBJECT_NAME_OF_VOC_SHARE = 'VOCShare__c';
     public static final String REPAIR_FIELD_DOJ_STATUS_NOT_OBJECT = '闈炲璞�';
diff --git a/force-app/main/default/classes/MonthlyReportController.cls b/force-app/main/default/classes/MonthlyReportController.cls
index 1448292..e1d3f65 100644
--- a/force-app/main/default/classes/MonthlyReportController.cls
+++ b/force-app/main/default/classes/MonthlyReportController.cls
@@ -5,7 +5,8 @@
         InitData res = new initData();
         try{
             Monthly_Report__c report = [SELECT 	OwnerId,Id,Next_week_plan__c FROM Monthly_Report__c WHERE Id = :recordId LIMIT 1];
-            res.OwnerId = report.OwnerId;
+            res.ownerId = report.OwnerId;
+            res.userId = UserInfo.getUserId();
             res.Id = report.Id;
             res.nextWeekPlan = report.Next_week_plan__c;
             System.debug(LoggingLevel.INFO, '*** res: ' + res);
@@ -73,7 +74,7 @@
         @AuraEnabled
         public String Id;
         @AuraEnabled
-        public String OwnerId;
+        public String ownerId;
         @AuraEnabled
         public String ownerEmail;
         @AuraEnabled
@@ -92,5 +93,7 @@
         public String drSumUrl;
         @AuraEnabled
         public String userEmail;
+        @AuraEnabled
+        public String userId;
     }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/ReportController.cls b/force-app/main/default/classes/ReportController.cls
index 790ccbc..d75f918 100644
--- a/force-app/main/default/classes/ReportController.cls
+++ b/force-app/main/default/classes/ReportController.cls
@@ -10,6 +10,10 @@
             Report__c report = [select Status__c from Report__c where Id = :recordId];
             res.status = report.Status__c;
             res.profileId = UserInfo.getProfileId();
+            res.userId = UserInfo.getUserId();
+            res.luShengId = getUserIdByName(LightingButtonConstant.LU_SHENG_NAME);
+            res.huDiAnId = getUserIdByName(LightingButtonConstant.HU_DI_AN_NAME);
+            res.systemProfileId = getProfileIdByName(LightingButtonConstant.SYSTEM_PROFILE_NAME);
             System.debug(LoggingLevel.INFO, '*** res: ' + res);
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -26,6 +30,10 @@
             res.isVOC = report.IsVOC__c;
             res.personId = report.Responsible_Person__r.Id;
             res.profileId = UserInfo.getProfileId();
+            res.userId = UserInfo.getUserId();
+            res.luShengId = getUserIdByName(LightingButtonConstant.LU_SHENG_NAME);
+            res.huDiAnId = getUserIdByName(LightingButtonConstant.HU_DI_AN_NAME);
+            res.systemProfileId = getProfileIdByName(LightingButtonConstant.SYSTEM_PROFILE_NAME);
             System.debug(LoggingLevel.INFO, '*** res: ' + res);
         } catch (Exception e) {
             System.debug(LoggingLevel.INFO, '*** e: ' + e);
@@ -218,10 +226,10 @@
 
     //缁欐彁浜ょ浉搴旂殑js鎻愪緵鍒濆鍖栨暟鎹�
     @AuraEnabled
-    public static String updateForSubmitButton(String reocrdId){
+    public static String updateForSubmitButton(String recordId){
         try {
             Report__c rac = new Report__c();
-            rac.Id = reocrdId;
+            rac.Id = recordId;
             rac.Status__c = LightingButtonConstant.RECORD_TYPE_NAME_BY_SUBMIT;
             rac.Submit_time__c = Datetime.now();
             rac.Submit_report_day__c = Date.today();
@@ -539,6 +547,26 @@
             return eMessage.substring(left,right);
         }
     }
+    @AuraEnabled
+    public static string getUserIdByName(String name){
+        User user = null;
+        try {
+            user = [select Id from User where Name =:name]; 
+        } catch (Exception e) {
+            throw new AuraHandledException(e.getMessage());
+        }
+        return user.Id;
+    }
+    @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;
+    }
     public class InitData{
         @AuraEnabled
         public String status;
@@ -576,7 +604,12 @@
         public String DeveloperName;
         @AuraEnabled
         public String userId;
-
+        @AuraEnabled
+        public String luShengId;
+        @AuraEnabled
+        public String huDiAnId;
+        @AuraEnabled
+        public String systemProfileId;
         
 
 
diff --git a/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js
index 17d0216..e4d87c9 100644
--- a/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js
+++ b/force-app/main/default/lwc/lexCancelSubmit/lexCancelSubmit.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-04-07 09:02:03
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-11 11:17:24
+ * @LastEditTime: 2023-05-09 17:42:28
  */
 import { LightningElement,wire,track,api} from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
@@ -19,6 +19,7 @@
     @api recordId;//OwnerId
     ownerId;
     monthlyReportId;
+    userId;
     IsLoading = true;
 
 
@@ -46,9 +47,9 @@
             console.log(result);
             if (result != null) {
                 this.ownerId = result.ownerId;
+                this.userId = result.userId;
                 this.monthlyReportId = result.Id;
                 this.cancelSubmit();
-                console.log("end");
                 //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Monthly_Report__c/" + this.monthlyReportId + "/view");
             }
         }).catch(error => {
@@ -69,8 +70,7 @@
         updateRecord({fields: { Id: recordId }});
     }
     cancelSubmit () {
-        //闇�瑕佸畬鍠�
-        if(this.ownerId == UserInfo_Owner.Id) {
+        if(this.ownerId == this.userId) {
             cancel({
                 recordId: this.recordId
             }).then(result=>{
diff --git a/force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js b/force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js
index b4a883a..eb74567 100644
--- a/force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js
+++ b/force-app/main/default/lwc/lexOCSMNoToReportForReport/lexOCSMNoToReportForReport.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-03-28 15:59:44
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-11 11:24:51
+ * @LastEditTime: 2023-05-09 15:20:58
  */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
@@ -13,6 +13,7 @@
 import updateForOCSMNoToReportButton  from '@salesforce/apex/ReportController.updateForOCSMNoToReportButton';
 import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
+import insertAwareDate from '@salesforce/apex/ReportController.updateForOCSMNoToReportButton';
 export default class LexOCSMNoToReportForReport extends LightningElement {
     @api recordId;
     IsLoading = true;
@@ -78,6 +79,7 @@
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
         }
+        this.AwareDate = Date.now();
         if(this.AwareDate != undefined ){
            updateForOCSMNoToReportButton({
                 recordId: this.recordId
diff --git a/force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js b/force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js
index 99cc31c..5100340 100644
--- a/force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js
+++ b/force-app/main/default/lwc/lexVOCAnswer/lexVOCAnswer.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-03-27 14:05:59
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-11 11:30:45
+ * @LastEditTime: 2023-05-09 10:21:25
  */
 import { LightningElement, wire, track, api } from "lwc";
 import { CurrentPageReference } from "lightning/navigation";
@@ -70,6 +70,7 @@
   update() {
     if (this.status != "宸插垎閰�") {
       this.showToast("涓嶆槸宸插垎閰嶄笉鑳界偣鍑�", "error");
+      this.dispatchEvent(new CloseActionScreenEvent());
       return;
     }
     updateForVOCAnswerButton({
@@ -78,7 +79,6 @@
       if (result) {
         this.showToast(result,"error");
       } else {
-        this.showToast("鎴愬姛", "success");
         this.updateRecordView(this.recordId);
       }
       this.Isloading = false;
diff --git a/force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js b/force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js
index edccdf5..1356a5d 100644
--- a/force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js
+++ b/force-app/main/default/lwc/lexVOCCheck/lexVOCCheck.js
@@ -6,7 +6,8 @@
 import VOCCheck  from '@salesforce/apex/ReportController.updateForVOCCheckButton';
 import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
-
+import getUserIdByName from '@salesforce/apex/ReportController.getUserIdByName';
+import getProfileIdByName from '@salesforce/apex/ReportController.getProfileIdByName';
 export default class LexVOCCheck extends LightningElement {
     
     @api recordId;
@@ -14,6 +15,10 @@
     isVOC;
     personId;
     profileId;
+    userId;
+    systemProfileId;
+    luShengId;
+    huDiAnId;
     Isloading = true;
 
     @wire(CurrentPageReference)
@@ -40,11 +45,14 @@
         }).then(result => {
             console.log(result);
             if (result != null) {  
-          
+                this.userId = result.userId;
                 this.status = result.status;
                 this.isVOC = result.isVOC;
                 this.personId = result.personId;
                 this.profileId = result.profileId;
+                this.systemProfileId = result.systemProfileId;
+                this.luShengId = result.luShengId;
+                this.huDiAnId = result.huDiAnId;
                 console.log(this.status); 
                 this.check();
                 //window.location.replace("https://ocsm--partial.sandbox.lightning.force.com/lightning/r/Report__c/" + this.recordId + "/view");
@@ -68,10 +76,23 @@
         });
         this.dispatchEvent(event);
       }
-
+    getUserId(userName){
+        getUserIdByName({
+            name : userName
+        }).then(reuslt=>{
+            return reuslt;
+        });
+    }
+    getProfileId(profileName){
+        getProfileIdByName({
+            name : profileName
+        }).then(reuslt=>{
+            return reuslt;
+        });
+    }
     check (){
         // 闄嗚儨锛岃儭杩畨锛岀郴缁熺鐞嗗憳鍙偣(闇�瑕佽皟鏁�)
-        if (UserInfo_Owner.Id != "00510000000gWAE" && UserInfo_Owner.Id != "00510000004reg2" && this.profileId != "00e10000000Y3o5AAC") {
+        if (this.userId != this.luShengId && this.userId != this.huDiAnId && this.profileId != this.systemProfileId) {
                 this.showToast("浣犳病鏈夊垽瀹歏OC鐨勬潈闄�","error");
                 this.dispatchEvent(new CloseActionScreenEvent());
                 return;
@@ -96,7 +117,6 @@
                 if(result){
                     this.showToast(result,"error");
                 }else{
-                    this.showToast("鎴愬姛","success");
                     this.updateRecordView(this.recordId);
                 }
                 this.Isloading = false;   
diff --git a/force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js b/force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js
index 1f3ffdf..0cb39f5 100644
--- a/force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js
+++ b/force-app/main/default/lwc/lexVOCConfirm/lexVOCConfirm.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-03-27 14:08:56
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-11 11:33:01
+ * @LastEditTime: 2023-05-09 10:04:33
  */
 import { LightningElement,wire,track,api} from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
@@ -94,7 +94,6 @@
                 this.showToast(result,"error");
             }else{
                 this.updateRecordView(this.recordId);
-                this.showToast("鎴愬姛","success");
             }
             this.Isloading = false;
             this.dispatchEvent(new CloseActionScreenEvent());
diff --git a/force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js b/force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js
index edcb0f1..65809d7 100644
--- a/force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js
+++ b/force-app/main/default/lwc/lexVOCFinish/lexVOCFinish.js
@@ -4,14 +4,13 @@
  * @Author: chen jing wu
  * @Date: 2023-03-27 14:11:17
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-11 11:34:01
+ * @LastEditTime: 2023-05-09 17:10:14
  */
 import { api, wire,LightningElement } from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
 import init  from '@salesforce/apex/ReportController.initForVOCFinishButton';
 import update  from '@salesforce/apex/ReportController.updateForVOCFinishButton';
-import UserInfo_Owner from '@salesforce/apex/TaskFeedbackController.UserInfo_Owner';
 import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
 export default class LexVOCFinish extends LightningElement {
@@ -19,6 +18,10 @@
     status;
     IsLoading = true;
     profileId;
+    luShengId;
+    userId;
+    huDiAnId;
+    systemProfileId;
 
     @wire(CurrentPageReference)
     getStateParameters(currentPageReference) {
@@ -45,6 +48,10 @@
             if (result != null) {
                 this.status = result.status;
                 this.profileId = result.profileId;
+                this.userId = result.userId;
+                this.luShengId = result.luShengId;
+                this.huDiAnId = result.huDiAnId;
+                this.systemProfileId = result.systemProfileId;
                 this.VOCFinish();
             }
         }).catch(error => {
@@ -70,7 +77,7 @@
     }
 
     VOCFinish () {
-        if (UserInfo_Owner.Id != "00510000000gWAE" && UserInfo_Owner.Id != "00510000004reg2" && this.profileId != "00e10000000Y3o5AAC") {
+        if (this.userId != this.luShengId && this.userId != this.huDiAnId && this.profileId != this.systemProfileId) {
             this.showToast("浣犳病鏈夊畬姣昖OC鐨勬潈闄�","error");
             this.dispatchEvent(new CloseActionScreenEvent());
             return;
diff --git a/force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js b/force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js
index 62acb75..c531771 100644
--- a/force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js
+++ b/force-app/main/default/lwc/lexVOCSubmit/lexVOCSubmit.js
@@ -4,7 +4,7 @@
  * @Author: chen jing wu
  * @Date: 2023-03-27 13:39:23
  * @LastEditors: chen jing wu
- * @LastEditTime: 2023-04-11 11:35:31
+ * @LastEditTime: 2023-05-09 10:15:43
  */
 import { LightningElement,wire,track,api} from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
@@ -81,7 +81,6 @@
                 if(result){
                     this.showToast(result,"error");
                 }else{
-                    this.showToast("鎴愬姛","success");
                     this.updateRecordView(this.recordId);
                 }
                 this.IsLoading = false;

--
Gitblit v1.9.1