From 3ba0123db48f8bab81ddf0913e1b95280ef545e8 Mon Sep 17 00:00:00 2001 From: Li Jun <buli@deloitte.com.cn> Date: 星期四, 31 三月 2022 17:56:53 +0800 Subject: [PATCH] Deploy0331 --- force-app/main/default/pages/SearchVisitor.page | 293 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 270 insertions(+), 23 deletions(-) diff --git a/force-app/main/default/pages/SearchVisitor.page b/force-app/main/default/pages/SearchVisitor.page index a032a0f..d754bb0 100644 --- a/force-app/main/default/pages/SearchVisitor.page +++ b/force-app/main/default/pages/SearchVisitor.page @@ -1,7 +1,17 @@ <apex:page id="Page" controller="SearchVisitorController" sidebar="false" showHeader="false" > <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> + <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> + <!-- 20220217 Li Jun for PIPL start --> + <apex:includeScript value="{!URLFOR($Resource.AWSService, 'AWSService.js') }" /> + <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script> + <!-- 20220217 Li Jun for PIPL End --> <script type="text/javascript"> + AWSService.sfSessionId = '{!GETSESSIONID()}'; + //鍍忓尰鐢熷尯鍒�(鑱屽姟)涓嬫媺鍒楄〃鍔犲叆**** + // var o = new Option(); + // o.text = '****'; + // document.getElementById('Page:mainForm:idSearchVisitor:updateContactDoctorDivision').add(o); function addContact(){ window.opener.showModal(); @@ -33,8 +43,12 @@ for(var i=0; i<5; i++){ if(j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value() != ''){ sltList[j] = new Array(); - sltList[j][0] = document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddName').innerHTML; - sltList[j][1] = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value(); + //Add by Li Jun for PIPL 20220218 Start + let accountId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value(); + sltList[j][0] = contactInfo[sfIdToAWSIdMapValue.get(accountId)].lastName; + //Add by Li Jun for PIPL 20220218 End + //sltList[j][0] = document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddName').innerHTML; // Commented by Li Jun for PIPL + sltList[j][1] = accountId; j++; } } @@ -47,8 +61,11 @@ } for(var a=0; a<5; a++){ - window.opener.document.getElementById(setVisitor[a][0]).value = sltList[a][0]; - window.opener.document.getElementById(setVisitor[a][1]).value = sltList[a][1]; + //Updated by Li Jun 20220228 + if(window.opener.document.getElementById(setVisitor[a][0])&&window.opener.document.getElementById(setVisitor[a][1])){ + window.opener.document.getElementById(setVisitor[a][0]).value = sltList[a][0]; + window.opener.document.getElementById(setVisitor[a][1]).value = sltList[a][1]; + } } window.close(); @@ -61,7 +78,7 @@ var addJob = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idJob').innerHTML; var addPhone = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idPhone').innerHTML; var addMyDr = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idMyDr').innerHTML; - var addPlease_Delete = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idPlease_Delete').innerHTML; + var addPlease_Delete = document.getElementById('Page:mainForm:idSearchVisitor:idRezultVisitor:' + index + ':idPlease_Delete').innerHTML; for(var i=0; i<5; i++){ if(j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddHiddenId')).value() == addId){ @@ -77,7 +94,7 @@ document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddDep').innerHTML = addDep; document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddJob').innerHTML = addJob; document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddPhone').innerHTML = addPhone; - document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddMyDr').innerHTML = addMyDr; + document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + i + ':idAddMyDr').innerHTML = addMyDr; break; } } @@ -92,7 +109,214 @@ document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddPhone').innerHTML = '銆�'; document.getElementById('Page:mainForm:idSearchVisitor:idAddVisitor:' + index + ':idAddMyDr').innerHTML = '<img src=\"/img/checkbox_unchecked.gif\" width=\"16\" height=\"16\" class=\"checkImg\" />'; } + + //Add By Li Jun 20220228 Start for PIPL + // var sfIdToAWSContact = new Object(); + var staticResources = JSON.parse('{!staticResource}'); + var contactAWSIds = JSON.parse('{!contactAWSIds}'); + var searchByLastName = ''; + var contactInfo = {}; + var sfIdToAWSIdMapValue = new Map(); + var aws_result = {}; + var selectedEditIndex = 0; + var selectedAwsDataId = ''; + searchContactAll(); + function preparePayloadForSearchContact(){ + let searchPayload = new Object(); + searchPayload.dataIds = contactAWSIds; + searchPayload.contactName = searchByLastName; + return JSON.stringify(searchPayload); + } + + //Search Contact From AWS + function searchContactAll(){ + let data = preparePayloadForSearchContact(); + let searchCallBack = function searchCallBack(result){ + let contacts = result.object; + if(contacts == null){ + return; + } + for(var i=0;i<contacts.length;i++){ + let temp = {} + temp.lastName = contacts[i].lastName?contacts[i].lastName:''; + temp.phone = contacts[i].phone?contacts[i].phone:''; + temp.doctorDivision1 = contacts[i].doctorDivision1? contacts[i].doctorDivision1:''; + temp.type = contacts[i].type? contacts[i].type:''; + contactInfo[contacts[i].dataId] = temp; + if(contacts[i].sfRecordId){ + sfIdToAWSIdMapValue.put(contacts[i].sfRecordId,contacts[i].dataId); + } + } + console.log('AWS Contact Result:'+JSON.stringify(contactInfo)); + }; + AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token); + } + + function queryContactProcess(){ + console.log('Query Contact process.'); + //1. get contact name from search box + let searchByLastName = document.getElementById('Page:mainForm:idSearchVisitor:searchContactName').value; + //2. inovke aws service + let contactAwsIds = new Set(); + for(var key in contactInfo){ + if(contactInfo[key].lastName.indexOf(searchByLastName) != -1){ + contactAwsIds.add(key); + } + } + if(contactAwsIds.size == 0){ + clearLineInfoList(); + return; + } + searchContactAll(); + //3. render the current page + serContact(JSON.stringify(Array.from(contactAwsIds))); + } + + function showPIDiv(dataId,obj){ + console.log('Selected Record:'+dataId); + //check sf id + let awsDataId = dataId; + if(dataId.length == 1){ + let sfId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + dataId + ':idAddHiddenId')).val() + awsDataId = sfIdToAWSIdMapValue.get(sfId);聽 + } + if(awsDataId){ + console.log('AWS Data Id:'+ awsDataId); + console.log('AWS Data Info:'+ JSON.stringify(contactInfo)); + let parentNode = document.getElementById(obj.id); + let createDiv = document.createElement("div"); + createDiv.id = parentNode.id+"_PI"; + let piInformation = '{!$Label.Visitor_Name}:'+contactInfo[awsDataId].lastName +'\n{!$ObjectType.Contact.fields.Doctor_Division1__c.Label}:'+contactInfo[awsDataId].doctorDivision1+'\n{!$ObjectType.Lead.fields.Phone.Label}:'+contactInfo[awsDataId].phone + createDiv.innerText = piInformation; + let x=window.event.x; + let y=window.event.y; + createDiv.style.left=x; + createDiv.style.top=y; + createDiv.style.marginLeft='20px'; + createDiv.style.marginTop='-40px'; + createDiv.style.height='80px'; + createDiv.style.width='120px'; + createDiv.style.background = "#dddddd"; + createDiv.style.position = "absolute"; + parentNode.appendChild(createDiv); + parentNode.style.position = "relative"; + } + } + + function hidePIDiv(obj){ + document.getElementById(obj.id+'_PI').remove(); + } + + function setSelectedEditIndex(index){ + selectedEditIndex = index; + console.log('Selected edit index:'+selectedEditIndex); + } + + function assignDencrypted(){ + let selectedEditSFId = j$(escapeVfId('Page:mainForm:idSearchVisitor:idAddVisitor:' + selectedEditIndex + ':idAddHiddenId')).val() + selectedAwsDataId = sfIdToAWSIdMapValue.get(selectedEditSFId); + console.log('edit awsId:'+selectedAwsDataId); + document.getElementById('Page:mainForm:AWS_Data_Id__c').value = selectedAwsDataId; + if(contactInfo.hasOwnProperty(selectedAwsDataId)){ + let selectedAWSData = contactInfo[selectedAwsDataId]; + let contactTypeNode = document.getElementById("Page:mainForm:idSearchVisitor:updateContactType"); + contactTypeNode.value = selectedAWSData.type; + if(contactTypeNode.value){ + jQuery(contactTypeNode).change(); + } + document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value = selectedAWSData.lastName; + document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value = selectedAWSData.phone; + document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value = selectedAWSData.doctorDivision1; + } + } + + function GetAWSResultObj(){ + if(aws_result && aws_result.object && aws_result.object.length > 0){ + return aws_result.object[0]; + } + return null; + } + + function SetEditObj(){ + let obj = GetAWSResultObj(); + if(obj){ + console.log('Result from AWS:'+JSON.stringify(obj)); + document.getElementById('Page:mainForm:AWS_Data_Id__c').value = obj.dataId; + + document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value = obj.lastName; + document.getElementById("Page:mainForm:LastName_Encrypted__c").value = obj.lastNameEncrypt; + + document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value = obj.phone; + document.getElementById("Page:mainForm:Phone_Encrypted__c").value = obj.phoneEncrypt; + + document.getElementById("Page:mainForm:idSearchVisitor:updateContactType").value = obj.type; + document.getElementById("Page:mainForm:Type_Encrypted__c").value = obj.typeEncrypt; + + document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value = obj.doctorDivision1; + document.getElementById("Page:mainForm:Doctor_Division1_Encrypted__c").value = obj.doctorDivision1Encrypt; + } + + } + + function ProcessPIForAWS(sobjJson, payloadForNewPI) { + let url = staticResources.newUrl + let moduleName = AWSService.insertModule; + if (selectedAwsDataId) { + moduleName = AWSService.updateModule; + url = staticResources.updateUrl + } + console.log('Payload for AWS:'+payloadForNewPI + ' Module Name:'+moduleName); + AWSService.postAWS(url,moduleName, payloadForNewPI, function(result){ + aws_result = result; + SetEditObj(); + saveNew(); + }, staticResources.token); + } + + function GetEditObj(){ + return JSON.stringify([{ + lastName : document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value, + phone : document.getElementById("Page:mainForm:idSearchVisitor:updateContactPhone").value, + type : document.getElementById("Page:mainForm:idSearchVisitor:updateContactType").value, + doctorDivision1 : document.getElementById("Page:mainForm:idSearchVisitor:updateContactDoctorDivision").value, + dataId:selectedAwsDataId + }]); + } + + function saveContactForAWS(){ + document.getElementById("errorMsg").innerHTML = ''; + if(!document.getElementById("Page:mainForm:idSearchVisitor:updateContactLastName").value){ + document.getElementById("errorMsg").innerHTML = '<strong>閿欒:</strong> 蹇呴』濉啓銆�'; + return; + } + blockme(); + let es = document.getElementsByTagName('select') + for(let ei in es){ + let e = es[ei]; + for(let opi in e.options){ + let op = e.options[opi]; + if(!op)continue; + if(op.value == "*****" && op.selected){ + unblockUI(); + alert('涓嬫媺妗嗕笉鑳戒富鍔ㄩ�夋嫨瀵嗘枃閫夐」') + return; + } + } + } + ProcessPIForAWS({},GetEditObj()); + } + function Trans(){ + console.log('SFRcordId:'+document.getElementById('Page:mainForm:sfContactId').value); + AWSService.postAWS(staticResources.transactionUrl,AWSService.confirmTrans, JSON.stringify({ + "txId":aws_result.txId, + "sfRecordId":document.getElementById('Page:mainForm:sfContactId').value, + "isSuccess":1 + }), function(result){ + window.location.reload(); + }, staticResources.token); + } + //Add By Li Jun 20220228 for PIPL End </script> <style type="text/css"> div#iframelike { @@ -111,15 +335,34 @@ </style> <apex:outputPanel id="all"> <apex:form id="mainForm"> + <!-- Search Contact By Li Jun 20220214 Start--> + <apex:actionFunction name="serContact" action="{!serContact}" rerender="idRezultVisitor"> + <apex:param name="awsContactIds" assignTo="{!awsContactIds}" value="" /> + </apex:actionFunction> + <apex:actionFunction name="clearLineInfoList" action="{!clearLineInfoList}" rerender="mainForm" onComplete="unblockUI();"> + </apex:actionFunction> + <!-- Search Contact By Li Jun 20220214 End--> <apex:actionFunction name="updContactP" action="{!updContactP}" rerender="idRezultVisitor,idRegistration"> <apex:param name="index" assignTo="{!index}" value="" /> </apex:actionFunction> <apex:actionFunction name="updContactM" action="{!updContactM}" rerender="idRezultVisitor"> <apex:param name="index" assignTo="{!index}" value="" /> </apex:actionFunction> - <apex:actionFunction name="editVistor" action="{!editVistor}" rerender="idRegistration" oncomplete="setButtonDisable(document.getElementById('Page:mainForm:idSearchVisitor:idRegSave'), false);"> - <apex:param name="index" assignTo="{!index}" value=""/> + <apex:actionFunction name="editVistor" action="{!editVistor}" rerender="idRegistration" oncomplete="assignDencrypted();setButtonDisable(document.getElementById('Page:mainForm:idSearchVisitor:idRegSave'), false);"> + <apex:param name="index" assignTo="{!index}" value=""/> </apex:actionFunction> + <apex:actionFunction name="saveNew" action="{!regContact}" rerender="idRegistration,idRezultVisitor,idAddVisitor,idMessage,sfContactId" onComplete="Trans()"> + </apex:actionFunction> + <!-- Add By Li Jun for PIPL 20220228 Start --> + <apex:inputHidden id="LastName_Encrypted__c" value="{!rc.LastName_Encrypted__c}"/> + <apex:inputHidden id="Phone_Encrypted__c" value="{!rc.Phone_Encrypted__c}"/> + + <apex:inputHidden id="Type_Encrypted__c" value="{!rc.Type_Encrypted__c}"/> + <apex:inputHidden id="Doctor_Division1_Encrypted__c" value="{!rc.Doctor_Division1_Encrypted__c}"/> + + <apex:inputHidden id="AWS_Data_Id__c" value="{!rc.AWS_Data_Id__c}"/> + <apex:inputHidden id="sfContactId" value="{!sfContactId}"/> + <!-- Add By Li Jun for PIPL 20220221 End --> <apex:pageBlock id="idSearchVisitor" > <table width="1060" height="50" border="0"> <tr> @@ -154,7 +397,7 @@ <th>{!$Label.Search_Condition}</th> <td> </td> <th>{!$Label.Last_Name}</th> - <th>{!$Label.First_Name}</th> + <!-- <th>{!$Label.First_Name}</th> --> <td> </td> <th>{!$Label.Attribute}</th> <td> </td> @@ -170,8 +413,9 @@ <td> </td> <td> </td> <td> </td> - <td><apex:inputText value="{!sc.Search_LastName__c}" style="width:80px" required="false"/></td> - <td><apex:inputText value="{!sc.Search_FirstName__c}" style="width:80px" required="false"/></td> + <!-- Add Id for pipl by Li Jun 20220214 --> + <td><apex:inputText id="searchContactName" value="{!sc.Search_LastName__c}" style="width:80px" required="false"/></td> + <!-- <td><apex:inputText value="{!sc.Search_FirstName__c}" style="width:80px" required="false"/></td> commented for pipl by Li Jun 20220214--> <td> </td> <th><apex:inputField value="{!sc.Type__c}" /></th> <td> </td> @@ -181,7 +425,9 @@ <td> </td> <th> </th> <td> </td> - <td><apex:commandButton value="{!$Label.Search}" action="{!serContact}" style="width:100px" rerender="idRezultVisitor" /></td> + <!-- Updated By Li Jun for PIPL 20220214 --> + <td><input class="btn" type="Button" value="{!$Label.Search}" onclick="queryContactProcess()" style="width:100px" /></td> + <!-- <td><apex:commandButton value="{!$Label.Search}" action="{!serContact}" style="width:100px" rerender="idRezultVisitor" /></td> --> </tr> <tr> <td style="border-bottom: 1px solid #888;" colspan="15"> </td> @@ -194,11 +440,11 @@ <apex:pageBlockTable id="idRezultVisitor" value="{!scwl}" var="scw" border="1" columns="8" columnsWidth="47px,90px,,90px,180x,90px,40px,200px"> <apex:column > <apex:facet name="header">{!$Label.Selected}</apex:facet> - <input type="button" id="idSlt" value="{!$Label.Selected}" onclick="sltContact('{!scw.index}');" class="btn" style="width:40px"/> + <input type="button" id="idSlt" value="{!$Label.Selected}" onclick="sltContact('{!scw.index}');" class="btn" style="width:40px"/> </apex:column> <apex:column > <apex:facet name="header">{!$Label.Visitor_Name}</apex:facet> - <apex:outputLink value="/{!scw.con.Id}" id="idName" target="_blank">{!scw.con.Name}</apex:outputLink> + <apex:outputLink onmouseover="showPIDiv('{!scw.con.AWS_Data_Id__c}',this)" onmouseout="hidePIDiv(this)" value="/{!scw.con.Id}" id="idName" target="_blank">{!scw.con.Name}</apex:outputLink> <apex:inputText id="idHiddenId" value="{!scw.conid}" style="display:none" /> </apex:column> <apex:column > @@ -247,7 +493,8 @@ </apex:column> <apex:column > <apex:facet name="header">{!$Label.Visitor_Name}</apex:facet> - <apex:outputText id="idAddName" value="{!IF(acw.con.Name==null,'銆�',acw.con.Name)}" /> + <!-- <apex:outputText id="idAddName" value="{!IF(acw.con.Name==null,'銆�',acw.con.Name)}" /> --> + <apex:outputLink onmouseover="showPIDiv('{!acw.index}',this)" onmouseout="hidePIDiv(this)" value="/{!acw.conid}" id="idAddName" target="_blank">{!IF(acw.con.Name==null,'銆�',acw.con.Name)}</apex:outputLink> <apex:inputText id="idAddHiddenId" value="{!acw.conid}" style="display:none" /> </apex:column> <apex:column > @@ -268,7 +515,7 @@ </apex:column> <apex:column > <apex:facet name="header">{!$Label.Edit}</apex:facet> - <input type="button" id="idEdit" value="{!$Label.Edit}" onclick="setButtonDisable(document.getElementById('Page:mainForm:idSearchVisitor:idRegSave'), true);editVistor('{!acw.index}');" class="btn" style="width:40px"/> + <input type="button" id="idEdit" value="{!$Label.Edit}" onclick="setSelectedEditIndex('{!acw.index}');setButtonDisable(document.getElementById('Page:mainForm:idSearchVisitor:idRegSave'), true);editVistor('{!acw.index}');" class="btn" style="width:40px"/> </apex:column> </apex:pageBlockTable> </div> @@ -283,7 +530,7 @@ <input type="button" value="{!$Label.Set}" onclick="addContact();" class="btn"/> </td> <td style="text-align:right"> - <apex:commandButton id="idRegSave" value="{!$Label.Registration}" action="{!regContact}" style="width:60px" rerender="idRegistration,idRezultVisitor,idAddVisitor,idMessage"/> + <apex:commandButton id="idRegSave" value="{!$Label.Registration}" onclick="saveContactForAWS();" style="width:60px" rerender="dummy" /> </td> </tr></table> </td></tr> @@ -298,13 +545,13 @@ <tr> <td width= "20"> </td> <th width= "80">{!$Label.Attribute}</th> - <th width= "80" ><apex:inputField value="{!rc.Type__c}" style="width:66px"/></th> + <th width= "80" ><apex:inputField id="updateContactType" value="{!rc.Type__c}" style="width:66px"/></th> <th width= "80" style="text-align:right">{!$Label.Last_Name}</th> - <td width= "80" ><span><div class="requiredInput"><div class="requiredBlock"></div><apex:inputField value="{!rc.Search_LastName__c}" style="width:70px" /></div></span></td> - <th width= "80" style="text-align:right">{!$Label.First_Name}</th> - <td width= "160" colspan="2" rowspan="2"><apex:inputField value="{!rc.FirstName}" style="width:150px" /></td> + <td width= "80" ><span><div class="requiredInput"><div class="requiredBlock"></div><apex:inputField id="updateContactLastName" value="{!rc.Search_LastName__c}" style="width:70px" /><div id="errorMsg" class="errorMsg"></div></div></span></td> + <!-- <th width= "80" style="text-align:right">{!$Label.First_Name}</th> + <td width= "160" colspan="2" rowspan="2"><apex:inputField value="{!rc.FirstName}" style="width:150px" /></td> --> <th width= "80" style="text-align:right">{!$ObjectType.Lead.fields.Phone.Label}</th> - <td width= "80"><apex:inputField value="{!rc.phone}" style="width:110px" /></td> + <td width= "80"><apex:inputField id="updateContactPhone" value="{!rc.phone}" style="width:110px" /></td> <th width= "80" style="text-align:right">{!$ObjectType.Contact.fields.Supplement__c.Label}</th> <th width= "130" colspan="2" rowspan="3"><apex:inputField value="{!rc.Supplement__c}" style="width:130px" /></th> @@ -313,7 +560,7 @@ <tr> <td> </td> <th colspan="2">{!$ObjectType.Contact.fields.Doctor_Division1__c.Label}</th> - <th colspan="2"><apex:inputField value="{!rc.Doctor_Division1__c}" style="width:150px"/></th> + <th colspan="2"><apex:inputField id="updateContactDoctorDivision" value="{!rc.Doctor_Division1__c}" style="width:150px"/></th> <th style="text-align:right">{!$Label.Department_Name}</th> <th colspan="3"><apex:inputField value="{!rc.Account_Visitor_Search__c}" style="width:280px" /></th> <th>{!$Label.MyDr}</th> -- Gitblit v1.9.1