From 0953b3b5fcf19c627c6479a6b86648df653c40db Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 09 五月 2022 17:50:33 +0800
Subject: [PATCH] SF PIPL Page Fix Lookup Required issue

---
 force-app/main/default/pages/TSRepair.page |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/force-app/main/default/pages/TSRepair.page b/force-app/main/default/pages/TSRepair.page
index 82b343c..6c2bf36 100644
--- a/force-app/main/default/pages/TSRepair.page
+++ b/force-app/main/default/pages/TSRepair.page
@@ -395,25 +395,32 @@
         }
 
         var contactIdValue = '';
-        function searchContact(contactNodeId,field1,field2,field3){
+        function searchContact(contactNodeId,field1,field2,field3,accountValueId){
             closeField = field1;
             closePhone = field2;
             contactIdValue = field3;
-            let baseUrl = "/apex/SearchContactPage";
-            let suffixUrl = "?contactId="+contactNodeId;
-            let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
-            newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
-            if (window.focus) {
-                newSearchContactWindow.focus();
+            var accountValueLkid = document.getElementById(accountValueId+'_lkid').value;
+            var searchContactKeyWord = document.getElementById(field1).value;
+            if (accountValueLkid != '000000000000000') {
+                let baseUrl = "/apex/SearchContactPage";
+                let suffixUrl = "?contactId="+contactNodeId+ "&accountId=" + accountValueLkid;
+                let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
+                newSearchContactWindow = window.open(baseUrl+suffixUrl, 'Popup', newSearchContactParam);
+                if (window.focus) {
+                    newSearchContactWindow.focus();
+                }
+                return false;
+            }else {
+                alert('璇峰厛閫夋嫨瀹㈡埛鍗曚綅');
             }
-            return false;
         }
 
         var currentLastName = '';
         var currentPhoneId = '';
         
-        function replaceSearchContactLookup() {   
+        function replaceSearchContactLookup() { 
             blockme();
+            var RepairInfoListStr = JSON.parse('{!RepairInfoListStr}');
             sforce.connection.sessionId = '{!GETSESSIONID()}';
             let queryContactBack = function(data,number){
                 document.getElementById(currentLastName).value = data.object.lastName;
@@ -432,8 +439,8 @@
                     AWSService.queryTSRepair(staticResourceContact.queryUrl, awsDataId, queryContactBack, staticResourceContact.token,number);
                 }
             }
-            for(var i = 0;i<3;i++){
-                let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:RepairInfoList:'+i+':Contacts__c\',\'allPage:allForm:RepairInfoList:'+i+':j_id91\',\'allPage:allForm:RepairInfoList:'+i+':contactIdValue\')" alt="Reference Document Number Lookup" class="lookupIcon"  title="Reference Document Number Lookup (New Window)"/>';
+            for(var i = 0;i<RepairInfoListStr.length;i++){
+                let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:RepairInfoList:'+i+':Contacts__c\',\'allPage:allForm:RepairInfoList:'+i+':j_id91\',\'allPage:allForm:RepairInfoList:'+i+':contactIdValue\',\'allPage:allForm:RepairInfoList:'+i+':BusinessACustomerUnit\')" alt="Reference Document Number Lookup" class="lookupIcon"  title="Reference Document Number Lookup (New Window)"/>';
                 let lookUpNode = htmlToElement(contactHtmlString);
                 console.log(lookUpNode);
                 let parentNode = document.getElementById('allPage:allForm:RepairInfoList:'+i+':contactIdValue').parentNode;
@@ -475,7 +482,7 @@
         <apex:form id="allForm">
             <apex:inputHidden value="{!contactId}" id="contactId"/>
              <!-- 鐜嬮箯浼� 鐐瑰嚮鎸夐挳鏇存柊鐘舵�佸紑濮� -->
-            <apex:actionFunction name="setStatus" action="{!setStatus}" reRender="Activities,message,Activities1" oncomplete="unblockUI();">
+            <apex:actionFunction name="setStatus" action="{!setStatus}" reRender="Activities,message,Activities1" oncomplete="unblockUI();replaceSearchContactLookup();">
            
                 <apex:param name="status" assignTo="{!status}" value="" />
             </apex:actionFunction>
@@ -946,7 +953,10 @@
                                     <th style="text-align: center;" >瀹㈡埛鍗曚綅</th>
                                     <td style="text-align: left;"><apex:outputField value="{!repairInfo.ba.BusinessAAccount__c}" style="width: 80%"/></td>
                                     <th style="text-align: center;">鑱旂郴浜�</th>
-                                    <td align="left" ><apex:outputField value="{!repairInfo.ba.BusinessAContact__c}" style="width: 80%"/></td>
+                                    <td align="left" >
+                                        <apex:outputField value="{!repairInfo.ba.BusinessAContact__c}" style="width: 80%"/>
+                                        <apex:inputHidden id="contactIdValue" value="{!repairInfo.ba.BusinessAContact__c}"/>
+                                    </td>
                                     <th style="text-align: center;">鑱旂郴鐢佃瘽</th>
                                     <td align="left" ><apex:outputField value="{!repairInfo.ba.BusinessAPhone_F__c}"/></td>
                                 </tr>

--
Gitblit v1.9.1