From bcc0985ef3c8d65326ad1dfd6fc874427b5049e5 Mon Sep 17 00:00:00 2001
From: zz <1842059105@qq.com>
Date: 星期一, 15 五月 2023 15:33:52 +0800
Subject: [PATCH] 签收单 查看附件和验收确认(医院修改)

---
 force-app/main/default/classes/ESignController.cls                                  |   57 +++++-----
 force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js         |   39 ++-----
 force-app/main/default/classes/LightingButtonConstant.cls                           |    1 
 force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js |  156 +++++++-----------------------
 4 files changed, 78 insertions(+), 175 deletions(-)

diff --git a/force-app/main/default/classes/ESignController.cls b/force-app/main/default/classes/ESignController.cls
index a997487..bdb7e66 100644
--- a/force-app/main/default/classes/ESignController.cls
+++ b/force-app/main/default/classes/ESignController.cls
@@ -3,20 +3,35 @@
     public static InitData ESignController (String recordId){
         InitData res = new initData();
         try{
-            eSignForm__c report = [SELECT Id,Group_purchase_PCL__c,OCM_man_province_cus__c,HPSignUpStatus__c,Sales_Root_Formula__c,HPSignUpDate__c  FROM eSignForm__c WHERE Id = :recordId LIMIT 1];
+            eSignForm__c report = [SELECT Id,Group_purchase_PCL__c,OCM_man_province_cus__c,HPSignUpStatus__c,Sales_Root_Formula__c,HPSignUpDate__c,agencyAutoSignUpStatus__c,agencySignUpDate__c  FROM eSignForm__c WHERE Id = :recordId LIMIT 1];
             res.Id = report.Id;
-            // res.RCManagerId = report.RC_ManagerId__c;
             res.GrouppurchasePCL = report.Group_purchase_PCL__c;
             res.OCMManProvinceCus = report.OCM_man_province_cus__c;
             res.HPSignUpStatus = report.HPSignUpStatus__c;
+            res.agencyAutoSignUpStatus = report.agencyAutoSignUpStatus__c;
             res.SalesRootFormula = report.Sales_Root_Formula__c;
             res.HPSignUpDate = report.HPSignUpDate__c;
+            res.agencySignUpDate = report.agencySignUpDate__c;
             res.profileId = UserInfo.getProfileId();
+            res.userId = UserInfo.getUserId();
+            res.systemProfileId = getProfileIdByName(LightingButtonConstant.SYSTEM_PROFILE_NAME);
+            res.OBA4_sinFor = getProfileIdByName(LightingButtonConstant.OBA4_sinFor);
             System.debug(LoggingLevel.INFO, '*** res: ' + res);
         }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;
     }
 
     //妫�绱CSM绠$悊鐪� 涓婄殑钀ヤ笟绠$悊閮ㄦ媴褰�
@@ -38,8 +53,6 @@
     public class InitData{
         @AuraEnabled
         public String Id;
-        // @AuraEnabled
-        // public String RCManagerId;
         @AuraEnabled
         public Boolean GrouppurchasePCL;
         @AuraEnabled
@@ -47,34 +60,20 @@
         @AuraEnabled
         public String HPSignUpStatus;
         @AuraEnabled
+        public String agencyAutoSignUpStatus;
+        @AuraEnabled
         public String SalesRootFormula;
         @AuraEnabled
         public Date HPSignUpDate;
         @AuraEnabled
-        public String profileId;
-    }
-
-        //鑾峰彇褰撳墠鐧诲綍浜虹殑 id
+        public Date agencySignUpDate;
         @AuraEnabled
-        public static UserResult UserInfo_Owner() {
-            UserResult result = new UserResult();
-            ID myUserID = UserInfo.getUserId();
-            try { 
-                User tempUser = [select id from user where id = : myUserID ];
-                result.id = tempUser.id;
-            } catch (exception e) {
-                result.result = e.getMessage();
-            }
-            return result;
-        }
-
-        public class UserResult {
-            @AuraEnabled
-            public string result;
-            public UserResult( ) {
-                result = 'Success';
-            }
-            @AuraEnabled
-            public string id;
-        }
+        public String profileId;
+        @AuraEnabled
+        public String userId;
+        @AuraEnabled
+        public String systemProfileId;
+        @AuraEnabled
+        public String OBA4_sinFor;
+    }
 }
\ No newline at end of file
diff --git a/force-app/main/default/classes/LightingButtonConstant.cls b/force-app/main/default/classes/LightingButtonConstant.cls
index 6fe5385..df3b465 100644
--- a/force-app/main/default/classes/LightingButtonConstant.cls
+++ b/force-app/main/default/classes/LightingButtonConstant.cls
@@ -103,6 +103,7 @@
     public static final String TwoS8_Sales_Administrative_Assistant_Plan = '2S8_閿�鍞鏀垮姪鐞�(璁″垝浠〃鏉�)';
     public static final String TwoS9_Spare = '2S9_澶囧搧绐楀彛';
     public static final String OBA1_Tenderee = 'OBA1_鎷涙爣绠$悊';
+    public static final String OBA4_sinFor = 'OBA4_绛炬敹绠$悊';
     public static final String OBA7_Enquiry_Tenderee = 'OBA7_璇环+鎷涙爣绠$悊';
     public static final String TwoM4_Marketplace_Manager = '2M4_甯傚満浜у搧鏈儴鎷呭綋(璇环)';
     public static final String SOBJECT_NAME_OF_REPORT_SHARE ='Report__Share';
diff --git a/force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js b/force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js
index a5e8655..fee2011 100644
--- a/force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js
+++ b/force-app/main/default/lwc/lexESignAcceptanceHospital/lexESignAcceptanceHospital.js
@@ -3,23 +3,21 @@
 import { CloseActionScreenEvent } from 'lightning/actions';
 import  init  from '@salesforce/apex/ESignController.ESignController';
 import  OcsmResult  from '@salesforce/apex/ESignController.OcsmResult';
-import  UserInfo_Owner  from '@salesforce/apex/ESignController.UserInfo_Owner';
-import { updateRecord } from 'lightning/uiRecordApi';
 import { ShowToastEvent } from 'lightning/platformShowToastEvent';
-export default class Submit extends LightningElement {
+export default class lexESignAcceptanceHospital extends LightningElement {
     @api recordId;//OwnerId
-    ownerId;//鎵�鏈変汉id
     id;//杩斿洖鍊肩殑id
     IsLoading = true;
-    profileId = '';
-    arrMessage = [];
-    RCManagerId = null;
-    GrouppurchasePCL = null;
-    OCMManProvinceCus = null;
-    HPSignUpStatus = null;
-    SalesRootFormula = null;
-    HPSignUpDate = null;
-    salesManage = null;
+    profileId = '';//褰撳墠鐧诲綍浜虹殑鏉冮檺
+    GrouppurchasePCL = null; //鏄惁闆嗛噰璇环
+    OCMManProvinceCus = null; //OCSM绠$悊鐪�
+    HPSignUpStatus = null; //鍖婚櫌瀹℃壒鐘舵��
+    SalesRootFormula = null; // 閿�鍞笭閬�(鏂囨湰)
+    HPSignUpDate = null;// 鍖婚櫌绛炬敹鏃�
+    userId; // 褰撳墠鐧诲綍浜�
+    systemProfileId;//绯荤粺绠$悊鍛�
+    OBA4_sinFor;//OBA4_绛炬敹绠$悊
+
 
     @wire(CurrentPageReference)
      getStateParameters(currentPageReference) {
@@ -36,46 +34,32 @@
         init({
             recordId: this.recordId
         }).then(result => {
-            console.log(result);
-            // this.RCManagerId = result.RCManagerId;
             this.GrouppurchasePCL = result.GrouppurchasePCL;
             this.OCMManProvinceCus = result.OCMManProvinceCus;
             this.HPSignUpStatus = result.HPSignUpStatus;
             this.SalesRootFormula = result.SalesRootFormula;
             this.HPSignUpDate = result.HPSignUpDate;
-            this.profileId = result.profileId.slice(0,15);
+            this.profileId = result.profileId;
+            this.userId = result.userId;
+            this.systemProfileId = result.systemProfileId;
+            this.OBA4_sinFor = result.OBA4_sinFor;
             this.IsLoading = false;
             this.AcceptanceHospital();
+            this.dispatchEvent(new CloseActionScreenEvent());
         })       
     }
+    //绛炬敹鍗� 楠屾敹纭(鍖婚櫌)
     AcceptanceHospital(){
         //鍏堝垽鏂槸鍚︿负闆嗛噰璇�
-        // var Group_purchase_PCL ;
-        // var Group_purchase_PCLFlag = "{!eSignForm__c.Group_purchase_PCL__c}";
-        // if(Group_purchase_PCLFlag == 1){
-        // Group_purchase_PCL = '闆嗛噰璇�';
-        // }else{
-        // Group_purchase_PCL = "{!eSignForm__c.OCM_man_province_cus__c}";
-        // }
-        console.log(this.GrouppurchasePCL,this.OCMManProvinceCus,'111111111')
         var Group_purchase_PCL ;
-        // if(this.GrouppurchasePCL == 1){
-        // Group_purchase_PCL = '闆嗛噰璇�';
-        // }else{
-        Group_purchase_PCL = this.OCMManProvinceCus;
-        // }
+        if(this.GrouppurchasePCL == 1){
+            Group_purchase_PCL = '闆嗛噰璇�';
+        }else{
+            Group_purchase_PCL = this.OCMManProvinceCus;
+        }
         //妫�绱CSM绠$悊鐪� 涓婄殑钀ヤ笟绠$悊閮ㄦ媴褰�
-        // var sql = "select id, Name, SalesManage__c from OCM_Management_Province__c where Name = "+"\'"+Group_purchase_PCL+"\'";
-        // var ocsmResult = sforce.connection.query(sql);
-        // var ocsm = ocsmResult.getArray("records");
-        // //钀ヤ笟绠$悊閮ㄦ媴褰搃d
-        // var salesManage;
-        // if (ocsm) {
-        // salesManage = ocsm[0].SalesManage__c;
-        // }
-        console.log(Group_purchase_PCL,this.profileId,'77777777777')
         OcsmResult({GrouppurchasePCL:Group_purchase_PCL}).then(res=>{
-            console.log(res)
+            //钀ヤ笟绠$悊閮ㄦ媴褰搃d
             var salesManage;
             salesManage = res[0].SalesManage__c;
             //鐢靛瓙绛炬敹鍗昳d
@@ -86,20 +70,20 @@
             var status = this.HPSignUpStatus;
             //閿�鍞笭閬�
             var sales_Root_Formula = this.SalesRootFormula;
-            if (salesManage || this.profileId == '00e10000000Y3o5') {
-                UserInfo_Owner().then(res => {
-                    var userId = '';
-                    userId = res.id;
-                    if (salesManage != userId && this.profileId != '00e10000000Y3o5' && this.profileId != '00e10000000s2cp') {
-                        alert('鎮ㄥ彧鑳藉鎵硅惀涓氱鐞嗛儴鎷呭綋鏄嚜宸辩殑绛炬敹鍗曪紒');
-                        return;
-                    } else if (status != '鐢宠涓�') {
-                        alert('鎮ㄥ彧鑳藉鎵圭敵璇蜂腑鐨勭鏀跺崟锛�')
-                        return;
-                    } else if (this.HPSignUpDate) {
-                        alert('鍖婚櫌绛炬敹鏃ヤ负绌烘椂锛屼笉鍙互纭锛�');
-                        return;
-                    }else{
+            if (salesManage || this.profileId == this.systemProfileId) {
+                if (salesManage != this.userId && this.profileId != this.systemProfileId && this.profileId != this.OBA4_sinFor) {
+                    // alert('鎮ㄥ彧鑳藉鎵硅惀涓氱鐞嗛儴鎷呭綋鏄嚜宸辩殑绛炬敹鍗曪紒');
+                    this.showToast("鎮ㄥ彧鑳藉鎵硅惀涓氱鐞嗛儴鎷呭綋鏄嚜宸辩殑绛炬敹鍗曪紒","error");
+                    return;
+                } else if (status != '鐢宠涓�') {
+                    // alert('鎮ㄥ彧鑳藉鎵圭敵璇蜂腑鐨勭鏀跺崟锛�')
+                    this.showToast("鎮ㄥ彧鑳藉鎵圭敵璇蜂腑鐨勭鏀跺崟锛�","error");
+                    return;
+                } else if (this.HPSignUpDate == undefined) {
+                    // alert('鍖婚櫌绛炬敹鏃ヤ负绌烘椂锛屼笉鍙互纭锛�');
+                    this.showToast("鍖婚櫌绛炬敹鏃ヤ负绌烘椂锛屼笉鍙互纭锛�","error");
+                    return;
+                }else{
                     if(sales_Root_Formula == 'OCM鐩存帴璨╁2'){
                         window.open ('/apex/HPDirectSalesConfirmPage?id='+this.recordId, '鍖婚櫌纭',
                         'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
@@ -107,13 +91,9 @@
                         window.open ('/apex/HPConfirmPage?id='+this.recordId, '鍖婚櫌纭',
                         'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
                     }
-                    }
-                })
+                }
             }
         })
-    }
-    updateRecordView() {
-        updateRecord({fields: { Id: this.recordId }});
     }
     showToast(msg,type) {
         const event = new ShowToastEvent({
@@ -121,66 +101,6 @@
             variant: type
         });
         this.dispatchEvent(event);
-        if(type == 'success'){
-            this.updateRecordView();
-        }
         this.dispatchEvent(new CloseActionScreenEvent());
     }
 }
-
-// var foo = function() {
-//     //褰撳墠鐢ㄦ埛鐧诲綍id
-//     var userId = "{!CASESAFEID($User.Id)}";
-//     //褰撳墠鐢ㄦ埛绠�妗d
-//     var ProfileId = "{!$Profile.Id}";
-//     // var RC_Manager = "{!eSignForm__c.RC_ManagerId__c }";
-//     //鍏堝垽鏂槸鍚︿负闆嗛噰璇�
-//     var Group_purchase_PCL ;
-//     var Group_purchase_PCLFlag = "{!eSignForm__c.Group_purchase_PCL__c}";
-//     if(Group_purchase_PCLFlag == 1){
-//     Group_purchase_PCL = '闆嗛噰璇�';
-//     }else{
-//     Group_purchase_PCL = "{!eSignForm__c.OCM_man_province_cus__c}";
-//     }
-//     //妫�绱CSM绠$悊鐪� 涓婄殑钀ヤ笟绠$悊閮ㄦ媴褰�
-//     var sql = "select id, Name, SalesManage__c from OCM_Management_Province__c where Name = "+"\'"+Group_purchase_PCL+"\'";
-//     var ocsmResult = sforce.connection.query(sql);
-//     var ocsm = ocsmResult.getArray("records");
-//     //钀ヤ笟绠$悊閮ㄦ媴褰搃d
-//     var salesManage;
-//     if (ocsm) {
-//     salesManage = ocsm[0].SalesManage__c;
-//     }
-    
-//     //鐢靛瓙绛炬敹鍗昳d
-//     var id = "{!eSignForm__c.Id}";
-//     //new 涓�涓璞�
-//     var eSignForm;
-//     //鍖婚櫌鐘舵��
-//     var status = "{!eSignForm__c.HPSignUpStatus__c}";
-//     //閿�鍞笭閬�
-//     var sales_Root_Formula = "{!eSignForm__c.Sales_Root_Formula__c}";
-    
-//     if (salesManage || ProfileId == '00e10000000Y3o5') {
-//     if (salesManage != userId && ProfileId != '00e10000000Y3o5' && ProfileId != '00e10000000s2cp') {
-//     alert('鎮ㄥ彧鑳藉鎵硅惀涓氱鐞嗛儴鎷呭綋鏄嚜宸辩殑绛炬敹鍗曪紒');
-//     return;
-//     } else if (status != '鐢宠涓�') {
-//     alert('鎮ㄥ彧鑳藉鎵圭敵璇蜂腑鐨勭鏀跺崟锛�')
-//     return;
-//     } else if (!'{!eSignForm__c.HPSignUpDate__c}') {
-//     alert('鍖婚櫌绛炬敹鏃ヤ负绌烘椂锛屼笉鍙互纭锛�');
-//     return;
-//     }else{
-//     if(sales_Root_Formula == 'OCM鐩存帴璨╁2'){
-//     window.open ('/apex/HPDirectSalesConfirmPage?id='+"{!eSignForm__c.Id}", '鍖婚櫌纭',
-//     'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
-//     }else{
-//     window.open ('/apex/HPConfirmPage?id='+"{!eSignForm__c.Id}", '鍖婚櫌纭',
-//     'height=340, width=600, top=200, left=400, toolbar=no, menubar=no, scrollbars=no, location=no, status=no');
-//     }
-    
-//     }
-//     }
-//     }
-//     foo();
\ No newline at end of file
diff --git a/force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js b/force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js
index 611281c..3291613 100644
--- a/force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js
+++ b/force-app/main/default/lwc/lexESignFormAttachment/lexESignFormAttachment.js
@@ -1,11 +1,11 @@
 import { LightningElement,wire,track,api} from 'lwc';
 import { CurrentPageReference } from "lightning/navigation";
 import { CloseActionScreenEvent } from 'lightning/actions';
-import { ShowToastEvent } from 'lightning/platformShowToastEvent';
-import { updateRecord } from 'lightning/uiRecordApi';
+import  init  from '@salesforce/apex/ESignController.ESignController';
 
 export default class lexESignFormAttachment extends LightningElement {
 	@api recordId;
+    id;
 	IsLoading = true;
 	@wire(CurrentPageReference)
      getStateParameters(currentPageReference) {
@@ -17,32 +17,15 @@
            }
          }
     }
-
+    //绛炬敹鍗� 鏌ョ湅闄勪欢
     connectedCallback () {
-        this.IsLoading = false;
-        this.Attachment();
-        this.dispatchEvent(new CloseActionScreenEvent());
-    }
-
-    Attachment(){
-        window.open( `/apex/eSignFormAttachment?parentId=${this.recordId}`);
-    }
-
-    // 寮圭獥
-    ShowToastEvent(msg, type) {
-        const event = new ShowToastEvent({
-            message: msg,
-            variant: type
-        });
-        this.dispatchEvent(event);
-    }
-    updateRecordView(recordId) {
-        updateRecord({fields: { Id: recordId }});
+        init({
+            recordId: this.recordId
+        }).then(result => {
+            this.IsLoading = false;
+            this.id = result.Id
+            window.open( `/apex/eSignFormAttachment?parentId=${this.id}`);
+            this.dispatchEvent(new CloseActionScreenEvent());
+        })
     }
 }
-
-
-// var From= function(){
-//     window.open( "/apex/eSignFormAttachment?parentId={!URLENCODE(eSignForm__c.Id)}");
-//     }
-//     From();
\ No newline at end of file

--
Gitblit v1.9.1