| | |
| | | <apex:page id="Page" controller="CM_SearchContact" sidebar="false" showHeader="false" action="{!init}"> |
| | | <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> |
| | | <!-- 2022/02/15 张华建 dependency start --> |
| | | <apex:includeScript value="{!URLFOR($Resource.AWSService, 'AWSService.js') }" /> |
| | | <!-- 2022/02/15 张华建 dependency end --> |
| | | <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> |
| | | <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> |
| | | <script type="text/javascript"> |
| | | // 2022/02/15 张华建 改造PI start |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | var contactAWSIds = JSON.parse('{!contactAWSIds}'); |
| | | var LastName = ''; |
| | | var contact = {}; |
| | | var now_edit_id = ''; |
| | | var aws_result = {}; |
| | | searchContactAll(); |
| | | |
| | | function preparePayloadForSearchContact(){ |
| | | let searchPayload = new Object(); |
| | | searchPayload.dataIds = contactAWSIds; |
| | | searchPayload.contactName = LastName; |
| | | return JSON.stringify(searchPayload); |
| | | } |
| | | |
| | | 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; |
| | | temp.phone = contacts[i].phone; |
| | | |
| | | contact[contacts[i].dataId] = temp; |
| | | } |
| | | console.log(JSON.stringify(contact)); |
| | | }; |
| | | AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token); |
| | | } |
| | | |
| | | |
| | | |
| | | function searchContactJs() { |
| | | blockme(); |
| | | searchContact(); |
| | | LastName = document.getElementById('Page:allForm:searchBlock:LastName').value; |
| | | let awsDataIdArray = []; |
| | | for(var key in contact){ |
| | | if(contact[key].lastName.includes(LastName)){ |
| | | awsDataIdArray.push(key); |
| | | } |
| | | } |
| | | console.log(awsDataIdArray) |
| | | if(awsDataIdArray.length == 0){ |
| | | clearLineInfoList(); |
| | | return; |
| | | } |
| | | searchContactAll(); |
| | | searchContact(awsDataIdArray.toString()); |
| | | } |
| | | // 2022/02/15 张华建 改造PI end |
| | | |
| | | function editContactJs(conid) { |
| | | blockme(); |
| | | now_edit_id=conid;// 2022/02/15 徐亮 改造PI |
| | | editContact(conid); |
| | | } |
| | | |
| | | function editSaveJs() { |
| | | |
| | | document.getElementById("errorMsg").innerHTML = ''; |
| | | if(!document.getElementById("Page:allForm:editBlock:Search_LastName__c").value){ |
| | | document.getElementById("errorMsg").innerHTML = '<strong>错误:</strong> 必须填写。'; |
| | | return; |
| | | } |
| | | |
| | | blockme(); |
| | | saveNew(); |
| | | ProcessPI({},GetEditObj()); |
| | | } |
| | | |
| | | function editClearJs() { |
| | |
| | | editClear(); |
| | | } |
| | | |
| | | function setContact(line) { |
| | | function setContact(line,awsDataId) { |
| | | var openLine = '{!openLine}'; |
| | | var cm = 'allPage:allForm:allBlock:records:'+ (openLine - 1) + ':contact'; |
| | | var cmid = 'allPage:allForm:allBlock:records:'+ (openLine - 1) + ':contactId'; |
| | | |
| | | |
| | | var conid = j$(escapeVfId('Page:allForm:listBlock:lineinfo:' + (line - 1) + ':conId')).value(); |
| | | var conname = j$(escapeVfId('Page:allForm:listBlock:lineinfo:' + (line - 1) + ':conName')).value(); |
| | | //var conname = j$(escapeVfId('Page:allForm:listBlock:lineinfo:' + (line - 1) + ':conName')).value(); |
| | | //2022/02/15 张华建 赋值成明文 start |
| | | var conname = contact[awsDataId].lastName; |
| | | //2022/02/15 张华建 赋值成明文 end |
| | | |
| | | j$(escapeVfId(cmid),window.opener.document).val(conid); |
| | | j$(escapeVfId(cm),window.opener.document).val(conname); |
| | |
| | | |
| | | 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 = '姓名:'+contact[awsDataId].lastName +'\n' +'电话:'+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); |
| | | parentNode.style.position = "relative"; |
| | | } |
| | | |
| | | function hidePIDiv(awsDataId){ |
| | | document.getElementById(awsDataId+'_PI').remove(); |
| | | } |
| | | |
| | | // 2022年2月15日 PI改造 徐亮 start |
| | | function sobjectToAws(){ |
| | | let aws_id = document.getElementById("Page:allForm:editBlock:AWS_Data_Id__c").value; |
| | | if(contact.hasOwnProperty(aws_id)){ |
| | | return contact[aws_id]; |
| | | } |
| | | else{ |
| | | console.log('not found aws data in contact obj'); |
| | | return {}; |
| | | } |
| | | } |
| | | |
| | | function GetAWSResultObj(){ |
| | | if(aws_result && aws_result.object && aws_result.object.length > 0){ |
| | | return aws_result.object[0]; |
| | | } |
| | | return null; |
| | | } |
| | | function ProcessPI(sobjJson, payloadForNewPI) { |
| | | |
| | | let url = staticResources.newUrl |
| | | if (now_edit_id) { |
| | | url = staticResources.updateUrl |
| | | } |
| | | AWSService.post(url, payloadForNewPI, function(result){ |
| | | aws_result = result; |
| | | SetEditObj(); |
| | | saveNew(); |
| | | }, staticResources.token); |
| | | } |
| | | |
| | | function Trans(){ |
| | | /* |
| | | jQuery.ajax({ |
| | | "type":"post", |
| | | "url":staticResources.transactionUrl, |
| | | "data":{ |
| | | "txId":aws_result.txId, |
| | | "isSuccess":1 |
| | | }, |
| | | beforeSend: function(request) { |
| | | request.setRequestHeader("pi-token",staticResources.token); |
| | | request.setRequestHeader('Content-Type', 'application/json'); |
| | | }, |
| | | success:function(data){ |
| | | console.log(data); |
| | | }, |
| | | error:function(jqXHR, textStatus, errorThrown) { |
| | | console.log(jqXHR); |
| | | console.log(textStatus); |
| | | console.log(errorThrown); |
| | | } |
| | | });*/ |
| | | |
| | | AWSService.post(staticResources.transactionUrl, JSON.stringify({ |
| | | "txId":aws_result.txId, |
| | | "isSuccess":1 |
| | | }), function(result){ |
| | | window.location.reload(); |
| | | }, staticResources.token); |
| | | } |
| | | |
| | | function assignUnencrypted(){ |
| | | let obj = sobjectToAws(); |
| | | document.getElementById("Page:allForm:editBlock:Search_LastName__c").value = obj.lastName; |
| | | document.getElementById("Page:allForm:editBlock:Phone").value = obj.phone; |
| | | unblockUI(); |
| | | } |
| | | |
| | | 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, |
| | | }]); |
| | | } |
| | | |
| | | function SetEditObj(){ |
| | | let obj = GetAWSResultObj(); |
| | | 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:Phone").value = obj.phone; |
| | | document.getElementById("Page:allForm:editBlock:Phone_Encrypted__c").value = obj.phoneEncrypt; |
| | | } |
| | | |
| | | } |
| | | |
| | | // 2022年2月15日 PI改造 徐亮 end |
| | | |
| | | </script> |
| | | |
| | | <apex:form id="allForm"> |
| | | <apex:actionFunction name="searchContact" action="{!searchContact}" rerender="allForm" onComplete="unblockUI();"> |
| | | <apex:param name="awsDataIdArray" assignTo="{!awsDataIdArray}" value="" /> |
| | | </apex:actionFunction> |
| | | <apex:actionFunction name="editContact" action="{!editContact}" rerender="allForm" onComplete="unblockUI();"> |
| | | <apex:actionFunction name="editContact" action="{!editContact}" rerender="allForm" onComplete="assignUnencrypted();"> |
| | | <apex:param name="firstParam" assignTo="{!conId}" value="" /> |
| | | </apex:actionFunction> |
| | | <apex:actionFunction name="saveNew" action="{!saveNew}" rerender="allForm" onComplete="unblockUI();"> |
| | | <apex:actionFunction name="saveNew" action="{!saveNew}" rerender="allForm" onComplete="Trans();"> |
| | | </apex:actionFunction> |
| | | <apex:actionFunction name="editClear" action="{!editClear}" rerender="allForm" onComplete="unblockUI();"> |
| | | </apex:actionFunction> |
| | | |
| | | <!-- 2022/02/15 张华建 清空LineInfoList start --> |
| | | <apex:actionFunction name="clearLineInfoList" action="{!clearLineInfoList}" rerender="allForm" onComplete="unblockUI();"> |
| | | </apex:actionFunction> |
| | | <!-- 2022/02/15 张华建 清空LineInfoList end --> |
| | | <apex:outputPanel id="allPanel"> |
| | | <apex:pageBlock id="searchBlock" title="检索条件"> |
| | | <table class="linetable" border="0" style="border-collapse: collapse;width:600px;table-layout:fixed;"> |
| | |
| | | </colgroup> |
| | | <tr> |
| | | <td>{!$ObjectType.Contact.fields.LastName.Label}</td> |
| | | <td><apex:inputField value="{!searchCon.Search_LastName__c}" style="width: 90%"/></td> |
| | | <td>{!$ObjectType.Contact.fields.FirstName.Label}</td> |
| | | <td><apex:inputField value="{!searchCon.Search_FirstName__c}" style="width: 90%"/></td> |
| | | <td><apex:inputField id="LastName" value="{!searchCon.Search_LastName__c}" style="width: 90%"/></td> |
| | | <!-- 2022/02/15 张华建 不需要FirstName start --> |
| | | <!-- <td>{!$ObjectType.Contact.fields.FirstName.Label}</td> |
| | | <td><apex:inputField id="FirstName" value="{!searchCon.Search_FirstName__c}" style="width: 90%"/></td> --> |
| | | <!-- 2022/02/15 张华建 不需要FirstName end --> |
| | | <td><input type="button" value="检索" onclick="searchContactJs(); return null;" /></td> |
| | | </tr> |
| | | </table> |
| | | </apex:pageBlock> |
| | | |
| | | <apex:pageBlock id="listBlock" title="检索结果"> |
| | | <div style="height: 200px; overflow-y: auto; overflow-x: hidden;"> |
| | | <table class="edittable" border="0" style="border-collapse: collapse;width:580px;table-layout:fixed;"> |
| | | <colgroup> |
| | | <col width="50px" /> |
| | | <col width="100px" /> |
| | | <col width="380px" /> |
| | | <col width="50px" /> |
| | | </colgroup> |
| | | <tr> |
| | | <th>No.</th> |
| | | <th>{!$ObjectType.Contact.fields.Name.Label}</th> |
| | | <th>{!$ObjectType.Contact.fields.AccountName__c.Label}</th> |
| | | <th>操作</th> |
| | | </tr> |
| | | <apex:repeat id="lineinfo" value="{!lineInfoList}" var="lineinfo"> |
| | | <tr> |
| | | <td>{!lineinfo.lineNo} |
| | | <apex:inputHidden id="conId" value="{!lineinfo.con.id}"/> |
| | | <apex:inputHidden id="conName" value="{!lineinfo.con.name}"/> |
| | | <apex:inputHidden id="accountName" value="{!lineinfo.con.AccountName__c}"/> |
| | | <apex:inputHidden id="accountid" value="{!lineinfo.con.accountid}"/> |
| | | </td> |
| | | <td><a href="#" onclick="setContact('{!lineinfo.lineNo}');">{!lineinfo.con.Name}</a></td> |
| | | <td>{!lineinfo.con.AccountName__c}</td> |
| | | <td><input style="width:90%;" type="button" value="编辑" onclick="editContactJs('{!lineinfo.con.Id}'); return null;" /></td> |
| | | </tr> |
| | | </apex:repeat> |
| | | </table> |
| | | </div> |
| | | <div style="height: 200px; overflow-y: auto; overflow-x: hidden;"> |
| | | <table class="edittable" border="0" style="border-collapse: collapse;width:580px;table-layout:fixed;"> |
| | | <colgroup> |
| | | <col width="50px" /> |
| | | <col width="100px" /> |
| | | <col width="380px" /> |
| | | <col width="50px" /> |
| | | </colgroup> |
| | | <tr> |
| | | <th>No.</th> |
| | | <th>{!$ObjectType.Contact.fields.Name.Label}</th> |
| | | <th>{!$ObjectType.Contact.fields.AccountName__c.Label}</th> |
| | | <th>操作</th> |
| | | </tr> |
| | | <apex:repeat id="lineinfo" value="{!lineInfoList}" var="lineinfo"> |
| | | <tr> |
| | | <td>{!lineinfo.lineNo} |
| | | <apex:inputHidden id="conId" value="{!lineinfo.con.id}"/> |
| | | <apex:inputHidden id="conName" value="{!lineinfo.con.name}"/> |
| | | <apex:inputHidden id="accountName" value="{!lineinfo.con.AccountName__c}"/> |
| | | <apex:inputHidden id="accountid" value="{!lineinfo.con.accountid}"/> |
| | | </td> |
| | | <!-- <td><a href="#" onclick="setContact('{!lineinfo.lineNo}');" id="943114607025717249" onmouseover="showPIDiv('943114607025717249')" onmouseout="hidePIDiv('943114607025717249')">{!lineinfo.con.Name}</a></td> --> |
| | | <!-- 2022/02/15 张华建 解密信息 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> |
| | | <!-- 2022/02/15 张华建 解密信息 end --> |
| | | <td>{!lineinfo.con.AccountName__c}</td> |
| | | <td><input style="width:90%;" type="button" value="编辑" onclick="editContactJs('{!lineinfo.con.Id}'); return null;" /></td> |
| | | </tr> |
| | | </apex:repeat> |
| | | </table> |
| | | </div> |
| | | </apex:pageBlock> |
| | | |
| | | <apex:pageBlock id="editBlock" title="联系人编辑"> |
| | |
| | | <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}"/> |
| | | <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> |
| | | <col width="50px" /> |
| | |
| | | <tr> |
| | | <td>{!$ObjectType.Contact.fields.LastName.Label}</td> |
| | | <td><span><div class="requiredInput"><div class="requiredBlock"></div> |
| | | <apex:inputField value="{!newCon.Search_LastName__c}" style="width: 90%"/> |
| | | <apex:inputField id="Search_LastName__c" value="{!newCon.Search_LastName__c}" style="width: 90%"/> |
| | | <div id="errorMsg" class="errorMsg"></div> |
| | | </div></span></td> |
| | | <td>{!$ObjectType.Contact.fields.FirstName.Label}</td> |
| | | <td><apex:inputField value="{!newCon.Search_FirstName__c}" style="width: 90%"/></td> |
| | | <!-- <td>{!$ObjectType.Contact.fields.FirstName.Label}</td> |
| | | <td><apex:inputField value="{!newCon.Search_FirstName__c}" style="width: 90%"/></td> --> |
| | | <td>{!$ObjectType.Contact.fields.Phone.Label}</td> |
| | | <td><apex:inputField value="{!newCon.Phone}" style="width: 90%"/></td> |
| | | <td><apex:inputField id="Phone" value="{!newCon.Phone}" style="width: 90%"/></td> |
| | | </tr> |
| | | <tr> |
| | | <td>{!$ObjectType.Contact.fields.Supplement__c.Label}</td> |