From e6068da47c1bef5517c9e5fdc8c726766867ad4e Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 14 七月 2023 15:10:02 +0800
Subject: [PATCH] Merge branch 'master' into LEXUpgrade2023-Deloitte

---
 force-app/main/default/pages/CM_SearchContactService.page |  225 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 179 insertions(+), 46 deletions(-)

diff --git a/force-app/main/default/pages/CM_SearchContactService.page b/force-app/main/default/pages/CM_SearchContactService.page
index b902684..497847b 100644
--- a/force-app/main/default/pages/CM_SearchContactService.page
+++ b/force-app/main/default/pages/CM_SearchContactService.page
@@ -6,9 +6,25 @@
     <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
     <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
     <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
+    <style>
+        .decrypt{position: absolute;
+        		top: 0;
+        		left: 100%;
+        		display: none;
+        		text-align: left;
+    			padding-left: 5px;
+        }
+		a:hover .decrypt{display: block;width: 150px}
+    </style>
     <script type="text/javascript">
 
         // 2022/02/15 寮犲崕寤� 鏀归�燩I start
+        //zhj 2022-02-04 鏂版柟妗堟敼閫� start
+        var accountId = '{!accountIdV2}'
+        var accountName = '';       
+        var dataIdManageCodeMap = {};                         
+        var staticResourcesV2 = JSON.parse('{!staticResourceContactV2}');     
+        //zhj 2022-02-04 鏂版柟妗堟敼閫� end 
         var staticResources = JSON.parse('{!staticResource}');
         var contactAWSIds = JSON.parse('{!contactAWSIds}');
         var LastName = '';
@@ -16,6 +32,18 @@
         var now_edit_id = '';
         var aws_result = {};
         searchContactAll();
+    	function Foo(){
+        	j$('[aws-id]').each(function(i,e){
+                let awsDataId = j$(e).attr('aws-id');
+                if (contact.hasOwnProperty(awsDataId)) {
+                    let piInformation = '濮撳悕:'+contact[awsDataId].lastName +'<br/>' +'鎵嬫満鍙�:'+ (contact[awsDataId].mobilePhone ? contact[awsDataId].mobilePhone :'');
+            	    j$(e).find('.decrypt').html(piInformation);
+                }else{
+                    console.log(awsDataId+' not in contact');
+                }
+                
+            });
+        }
 
         function preparePayloadForSearchContact(){
             let searchPayload = new Object();
@@ -34,11 +62,12 @@
                 for(var i=0;i<contacts.length;i++){
                     let temp = {}
                     temp.lastName = contacts[i].lastName;
-                    temp.phone = contacts[i].phone;
+                    temp.mobilePhone = contacts[i].mobilePhone;
 
                     contact[contacts[i].dataId] = temp;
                 }
                 console.log(JSON.stringify(contact));
+                Foo();
             };
             AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token);
         }
@@ -69,6 +98,7 @@
         }
 
         function editSaveJs() {
+            hiddenErrorMsgNode();       //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24
 
             document.getElementById("errorMsg").innerHTML = '';
             if(!document.getElementById("Page:allForm:editBlock:Search_LastName__c").value){
@@ -112,25 +142,29 @@
             window.close();
         }
 
-        function showPIDiv(awsDataId){
-            console.log('awsDataId Value:'+awsDataId);
-            let parentNode = document.getElementById(awsDataId);
-            let createDiv = document.createElement("div");  
-            createDiv.id = awsDataId+"_PI";  
-            let piInformation = 'Name:'+contact[awsDataId].lastName +'\n' +'Phone:'+contact[awsDataId].phone
-            //let piInformation = 'Name:'+contact['943114607025717249'].lastName +'\n' +'Phone:'+contact['943114607025717249'].phone
-            createDiv.innerText = piInformation;
-            let x=window.event.x;
-            let y=window.event.y; 
-            createDiv.style.left=x;  
-            createDiv.style.top=y;  
-            createDiv.style.background="#dddddd";
-            createDiv.style.position = "absolute";
-            parentNode.appendChild(createDiv);  
+        function showPIDiv(dataId,awsDataId){
+            // console.log('awsDataId Value:'+awsDataId);
+            // let parentNode = document.getElementById(awsDataId);
+            // let createDiv = document.createElement("div");  
+            // createDiv.id = awsDataId+"_PI";  
+            // let piInformation = 'Name:'+contact[awsDataId].lastName +'\n' +'Phone:'+contact[awsDataId].phone
+            // //let piInformation = 'Name:'+contact['943114607025717249'].lastName +'\n' +'Phone:'+contact['943114607025717249'].phone
+            // createDiv.innerText = piInformation;
+            // let x=window.event.x;
+            // let y=window.event.y; 
+            // createDiv.style.left=x;  
+            // createDiv.style.top=y;  
+            // createDiv.style.background="#dddddd";
+            // createDiv.style.position = "absolute";
+            // parentNode.appendChild(createDiv);  
+            console.log('dataId:'+dataId+'awsDataId Value:'+awsDataId);
+            let piInformation = '濮撳悕:'+contact[awsDataId].lastName +'\n' +'鐢佃瘽:'+ (contact[awsDataId].mobilePhone?contact[awsDataId].mobilePhone:'');
+            document.getElementById(dataId+'_'+awsDataId).innerText = piInformation;
         }
 
-        function hidePIDiv(awsDataId){
-            document.getElementById(awsDataId+'_PI').remove();
+        function hidePIDiv(dataId,awsDataId){
+            // document.getElementById(awsDataId+'_PI').remove();
+            document.getElementById(dataId+'_'+awsDataId).innerText = '';
         }
 
         // 2022骞�2鏈�15鏃� PI鏀归�� 寰愪寒 start
@@ -152,23 +186,45 @@
             return null;
         }
         function ProcessPI(sobjJson, payloadForNewPI) {
-            //blockme();
-            let url = staticResources.newUrl
-            if (now_edit_id) {
-            	url = staticResources.updateUrl
-            }
-            AWSService.post(url, payloadForNewPI, function(result){
-                aws_result = result;
-                SetEditObj();
-                saveNew();
-            }, staticResources.token);
+            // //blockme();
+            // //zhj 2022-02-04 鏂版柟妗堟敼閫� start
+            // // let url = staticResources.newUrl
+            // // if (now_edit_id) {
+            // // 	url = staticResources.updateUrl
+            // // }
+            // let url = staticResourcesV2.newUrl
+            // if (now_edit_id) {
+            // 	url = staticResourcesV2.updateUrl
+            // }
+            // //zhj 2022-02-04 鏂版柟妗堟敼閫� end
+            // AWSService.post(url, payloadForNewPI, function(result){
+            //     aws_result = result;
+            //     //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 start
+            //     if(r.status == '129'){
+            //         alertErrorMessage('瀹㈡埛 [ '+accountName+ ' ],宸插瓨鍦ㄧ浉鍚屽悕瀛楃殑鑱旂郴浜� 浜哄憳绠$悊缂栫爜 ['+dataIdManageCodeMap[r.object[0].dataId]+' ] 锛屼笉鑳介噸澶嶅垱寤猴紝璇蜂簡瑙�');
+            //         unblockUI();
+            //         return
+            //     }
+            //     if(r.status == '130'){
+            //         if(r.object[0] && r.object[0].sfRecordId != null && r.object[0].sfRecordId != '')
+            //             alertErrorMessage('宸叉壘鍒伴噸澶嶅�硷細 UniqueNumber__c 涓庤褰曞�奸噸澶嶏紝ID 涓�: '+r.object[0].sfRecordId+'瀹㈡埛浜哄憳淇℃伅');
+            //         else
+            //             alertErrorMessage('鏁版嵁涓瓨鍦ㄩ噸澶嶇殑鐢佃瘽鍙风爜');
+            //         unblockUI();
+            //         return
+            //     }
+            //     //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 end
+            //     SetEditObj();
+            //     saveNew();
+            // }, staticResources.token);
         }
 
         function Trans(){
-            
+            debugger
             AWSService.post(staticResources.transactionUrl, JSON.stringify({
                 "txId":aws_result.txId,
-                "isSuccess":1
+                "isSuccess":1,
+                "sfRecordId":document.getElementById('Page:allForm:sfContactId').value,
             }), function(result){
                 window.location.reload();
             }, staticResources.token);
@@ -182,11 +238,61 @@
         }
 
         function GetEditObj(){
-            return JSON.stringify([{
-                lastName : document.getElementById("Page:allForm:editBlock:Search_LastName__c").value,
-                //phone : document.getElementById("Page:allForm:editBlock:Phone").value,
-                dataId:document.getElementById("Page:allForm:editBlock:AWS_Data_Id__c").value,
-            }]);
+            //zhj 2022-02-04 鏂版柟妗堟敼閫� start
+            Visualforce.remoting.Manager.invokeAction(
+                'CM_SearchContactServiceController.searchContactByAccountId', 
+                accountId,
+                function (result, event) {
+                    if(result.status == 'fail'){
+                        alertErrorMessage(result.message);
+                        return
+                    }
+                    console.log('result = ' + JSON.stringify(result));
+                    accountName = result.accountName;
+                    dataIdManageCodeMap = result.dataIdManageCodeMap;
+                    var contactList = '';
+                    for(var i = 0; i<result.contactList.length; i++){
+                        if(result.contactList[i].AWS_Data_Id__c)
+                            contactList += ',' + result.contactList[i].AWS_Data_Id__c;
+                    }
+                    contactList = contactList.substring(1);
+                    var payloadForNewPI =  JSON.stringify([{
+                        lastName : document.getElementById("Page:allForm:editBlock:Search_LastName__c").value,
+                        mobilePhone : '',
+                        dataId : document.getElementById("Page:allForm:editBlock:AWS_Data_Id__c").value,
+                        contactIds : contactList,
+                        isMobileVerif : result.isMobileVerif,
+                        isNameMobileVerif : result.isNameMobileVerif
+                    }]);
+                    console.log('payloadForNewPI = ' + JSON.stringify(payloadForNewPI));
+                    debugger
+                    let url = staticResourcesV2.newUrl
+                    if (now_edit_id) {
+                        url = staticResourcesV2.updateUrl
+                    }
+                    //zhj 2022-02-04 鏂版柟妗堟敼閫� end
+                    AWSService.post(url, payloadForNewPI, function(result){
+                        aws_result = result;
+                        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 start
+                        if(result.status == '129'){
+                            alertErrorMessage('瀹㈡埛 [ '+accountName+ ' ],宸插瓨鍦ㄧ浉鍚屽悕瀛楃殑鑱旂郴浜� 浜哄憳绠$悊缂栫爜 ['+dataIdManageCodeMap[result.object[0].dataId]+' ] 锛屼笉鑳介噸澶嶅垱寤猴紝璇蜂簡瑙�');
+                            unblockUI();
+                            return
+                        }
+                        if(result.status == '130'){
+                            if(result.object[0] && result.object[0].sfRecordId != null && result.object[0].sfRecordId != '')
+                                alertErrorMessage('宸叉壘鍒伴噸澶嶅�硷細 UniqueNumber__c 涓庤褰曞�奸噸澶嶏紝ID 涓�: '+result.object[0].sfRecordId+'瀹㈡埛浜哄憳淇℃伅');
+                            else
+                                alertErrorMessage('鏁版嵁涓瓨鍦ㄩ噸澶嶇殑鐢佃瘽鍙风爜');
+                            unblockUI();
+                            return
+                        }
+                        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 end
+                        SetEditObj();
+                        saveNew();
+                    }, staticResources.token);
+                });
+                //zhj 2022-02-04 鏂版柟妗堟敼閫� end
         }
 
         function SetEditObj(){
@@ -194,31 +300,44 @@
             if(obj){
                 document.getElementById("Page:allForm:editBlock:AWS_Data_Id__c").value = obj.dataId;
                 document.getElementById("Page:allForm:editBlock:Search_LastName__c").value = obj.lastName;
-                document.getElementById("Page:allForm:editBlock:LastName_Encrypted__c").value = obj.lastNameEncrypt;
+                //document.getElementById("Page:allForm:editBlock:LastName_Encrypted__c").value = obj.lastNameEncrypt; //zhj 鏂版柟妗堟敼閫� 2022-12-05 
                 //document.getElementById("Page:allForm:editBlock:Phone").value = obj.phone;
-                document.getElementById("Page:allForm:editBlock:Phone_Encrypted__c").value = obj.phoneEncrypt;
+                //document.getElementById("Page:allForm:editBlock:Phone_Encrypted__c").value = obj.phoneEncrypt;  //zhj 鏂版柟妗堟敼閫� 2022-12-05 
             }
             
         }
-        
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 start
+        function alertErrorMessage(errorMsg) {
+            let errorMsgNode = document.getElementById("Page:allForm:editBlock:msgContent");
+            errorMsg = '閿欒锛氭棤鏁堟暟鎹��' + '\n' + errorMsg;
+            errorMsgNode.innerText = errorMsg;
+            errorMsgNode.className = 'pbError';
+        }
+        function hiddenErrorMsgNode() {
+            let errorMsgNode = document.getElementById("Page:allForm:editBlock:msgContent");
+            errorMsgNode.innerText = '';
+            errorMsgNode.className = '';
+        }
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-24 end
         // 2022骞�2鏈�15鏃� PI鏀归�� 寰愪寒 end
 
     </script>
 
     <apex:form id="allForm">
-        <apex:actionFunction name="searchContact" action="{!searchContact}" rerender="allForm,allPanel" onComplete="unblockUI();">
+        <apex:actionFunction name="searchContact" action="{!searchContact}" rerender="allForm,allPanel,sfContactId" onComplete="unblockUI();Foo()">
             <apex:param name="awsDataIdArray" assignTo="{!awsDataIdArray}" value="" />
         </apex:actionFunction>
-        <apex:actionFunction name="editContact" action="{!editContact}" rerender="allForm,allPanel" onComplete="assignUnencrypted();">
+        <apex:actionFunction name="editContact" action="{!editContact}" rerender="allForm,allPanel,sfContactId" onComplete="assignUnencrypted();">
             <apex:param name="firstParam" assignTo="{!conId}" value="" />
         </apex:actionFunction>
-        <apex:actionFunction name="saveNew" action="{!saveNew}" rerender="allForm,allPanel" onComplete="Trans();">
+        <apex:actionFunction name="saveNew" action="{!saveNew}" rerender="allForm,allPanel,sfContactId" onComplete="Trans();">
         </apex:actionFunction>
-        <apex:actionFunction name="editClear" action="{!editClear}" rerender="allForm,allPanel" onComplete="unblockUI();">
+        <apex:actionFunction name="editClear" action="{!editClear}" rerender="allForm,allPanel,sfContactId" onComplete="unblockUI();searchContactAll()">
         </apex:actionFunction>
         <!-- 2022/02/15 寮犲崕寤� 娓呯┖LineInfoList start -->
         <apex:actionFunction name="clearLineInfoList" action="{!clearLineInfoList}" rerender="allForm" onComplete="unblockUI();">
         </apex:actionFunction>
+        <apex:inputHidden id="sfContactId" value="{!sfContactId}"/> <!-- zhj 2022-12-02 sfId -->
         <!-- 2022/02/15 寮犲崕寤� 娓呯┖LineInfoList end -->
         <apex:outputPanel id="allPanel">
             <apex:pageBlock id="searchBlock" title="妫�绱㈡潯浠�">
@@ -247,7 +366,7 @@
                 <table class="edittable" border="0" style="border-collapse: collapse;width:580px;table-layout:fixed;">
                     <colgroup>
                         <col width="50px" />
-                        <col width="100px" />
+                        <col width="200px" />
                         <col width="380px" />
                         <col width="50px" />
                     </colgroup>
@@ -270,7 +389,13 @@
                         </td>
                         <!-- <td><a href="#" onclick="setContact('{!lineinfo.lineNo}');" id="943114607025717249" onmouseover="showPIDiv('943114607025717249')" onmouseout="hidePIDiv('943114607025717249')">{!lineinfo.con.Name}</a></td> -->
                         <!-- 2022/02/15 寮犲崕寤� 瑙e瘑淇℃伅 start -->
-                        <td><a href="#" onclick="setContact('{!lineinfo.lineNo}','{!lineinfo.con.AWS_Data_Id__c}');" id="{!lineinfo.con.AWS_Data_Id__c}" onmouseover="showPIDiv('{!lineinfo.con.AWS_Data_Id__c}')" onmouseout="hidePIDiv('{!lineinfo.con.AWS_Data_Id__c}')">{!lineinfo.con.Name}</a></td>
+                        <td>
+                            <a target="_blank" onclick="setContact('{!lineinfo.lineNo}','{!lineinfo.con.AWS_Data_Id__c}');" aws-id="{!lineinfo.con.AWS_Data_Id__c}" style="position:relative">
+                                <span class="encrypt">{!lineinfo.con.Name}</span>
+                                <span class="decrypt"></span>
+                            </a>
+                            
+                        </td>
                         <!-- 2022/02/15 寮犲崕寤� 瑙e瘑淇℃伅 end -->
                         <td>{!lineinfo.con.AccountName__c}</td>
                         <td><input style="width:90%;" type="button" value="缂栬緫" onclick="editContactJs('{!lineinfo.con.Id}'); return null;" /></td>
@@ -285,8 +410,16 @@
                     <apex:commandButton onclick="editClearJs();" value="娓呯┖" rerender="dummy"/>
                     <apex:commandButton onclick="editSaveJs();" value="淇濆瓨" rerender="dummy"/>
                 </apex:pageBlockButtons>
-                <apex:inputHidden id="LastName_Encrypted__c" value="{!newCon.LastName_Encrypted__c}"/>
-                <apex:inputHidden id="Phone_Encrypted__c" value="{!newCon.Phone_Encrypted__c}"/>
+                <!-- Error Msg-->
+                <div style="text-align: center;">
+                    <apex:outputPanel id="errorMsg">
+                        <apex:pageMessages id="msgContent" escape="false" />
+                    </apex:outputPanel>
+                </div>
+                <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05  start-->
+                <!-- <apex:inputHidden id="LastName_Encrypted__c" value="{!newCon.LastName_Encrypted__c}"/>
+                <apex:inputHidden id="Phone_Encrypted__c" value="{!newCon.Phone_Encrypted__c}"/> -->
+                <!-- zhj 鏂版柟妗堟敼閫� 2022-12-05  end-->
                 <apex:inputHidden id="AWS_Data_Id__c" value="{!newCon.AWS_Data_Id__c}"/>
                 <table class="edittable" border="0" style="border-collapse: collapse; width:600px; table-layout:fixed;">
                     <colgroup>

--
Gitblit v1.9.1