From 900c50a247705d6fe8833e84d31b5d51616b7c26 Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 15 四月 2022 14:08:05 +0800 Subject: [PATCH] 20220415 --- force-app/main/default/pages/NewLoanerUser.page | 216 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 files changed, 192 insertions(+), 24 deletions(-) diff --git a/force-app/main/default/pages/NewLoanerUser.page b/force-app/main/default/pages/NewLoanerUser.page index 66989ea..f66ca52 100644 --- a/force-app/main/default/pages/NewLoanerUser.page +++ b/force-app/main/default/pages/NewLoanerUser.page @@ -1,26 +1,180 @@ -<apex:page standardController="loaner_user__c" extensions="NewLoanerUserController" showHeader="true" sidebar="false" action="{!init}" title="鏂板缓鏍锋満鍊熺敤瀹㈡埛"> -<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> -<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> -<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> -<script> - -function saveJs() { - if(confirm('鑱旂郴浜哄拰瀹㈡埛涓哄繀濉俊鎭�,濡傛灉涓虹┖灏嗕笉淇濆瓨姝ゆ潯璁板綍,鏄惁宸茬‘璁ゆ墍鏈夐渶瑕佷繚瀛樼殑淇℃伅璇ュ瓧娈甸兘涓嶄负绌�?')){ - blockme(); - updateUser(); +<apex:page standardController="loaner_user__c" extensions="NewLoanerUserController" id="allPage" showHeader="true" sidebar="false" action="{!init}" title="鏂板缓鏍锋満鍊熺敤瀹㈡埛"> +<!-- <apex:page standardController="loaner_user__c" extensions="NewLoanerUserController" showHeader="true" sidebar="false" action="{!init}" title="鏂板缓鏍锋満鍊熺敤瀹㈡埛"> --> + <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> + <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/> + <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/> + <!-- Update 20220317 By Yang Kaiyu Start --> + <apex:includeScript value="{!URLFOR($Resource.CommonUtilJs)}"/> + <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> + <apex:includeScript value="/soap/ajax/40.0/connection.js"/> + <!-- Update 20220317 By Yang Kaiyu End --> + <script> + // Update 20220317 By Yang Kaiyu Start + AWSService.sfSessionId = '{!GETSESSIONID()}'; + var staticResource = JSON.parse('{!staticResource}'); + var staticResourceContact = JSON.parse('{!staticResourceContact}'); + var aws_data = {}; + let conList = []; + //鏇挎崲vlookup + var closeField = ''; + var newSearchContactWindow = null; + var contactInfoStr = ''; + var conValue = '' + //鑷畾涔塴ookup鏌ヨ + function searchContact(contactNodeId,field,conValue,conid){ + closeField = conid; + this.conValue = conValue; + let accountValue = ""; + if (document.getElementById(field)!=null) { + accountValue = document.getElementById(field).value; + } + console.log(accountValue); + if(accountValue !='000000000000000'){ + let baseUrl = "/apex/SearchContactPage"; + let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue; + 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('璇峰厛閫夋嫨瀹㈡埛鍐嶉�夋嫨鑱旂郴浜�') + } + } + var dataLinesJson; + function replaceSearchContactLookup() { + conList = JSON.parse('{!conListJson}'); + dataLinesJson = JSON.parse('{!dataLinesJson}'); + console.log('dataLinesJson = ' + dataLinesJson); + for(var i = 0;i<dataLinesJson.length;i++){ + //if(document.getElementById('allpage:allForm:allBlock:lines:'+i+':customer') != null){ + let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'allPage:allForm:contactId\',\'allPage:allForm:allBlock:lines:'+i+':customer_lkid\',\'allPage:allForm:allBlock:lines:'+i+':contact_lkid\',\'allPage:allForm:allBlock:lines:'+i+':contact\')" 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:allBlock:lines:'+i+':contact').parentNode; + //parentNode.appendChild(lookUpNode); + parentNode.replaceChild(lookUpNode, document.getElementById('allPage:allForm:allBlock:lines:'+i+':contact').parentNode.children[2]); + //} + } + + } + function htmlToElement(html) { + var template = document.createElement('template'); + html = html.trim(); // Never return a text node of whitespace as the result + template.innerHTML = html; + return template.content.firstChild; + } + function closePopupWindow() { + if (null != newSearchContactWindow) { + newSearchContactWindow.close(); + } + contactInfoStr = document.getElementById('allPage:allForm:contactId').value; + console.log('closePopup:'+contactInfoStr); + let contactInfo = JSON.parse(contactInfoStr); + let contactNodeId = conValue; + document.getElementById(contactNodeId).value = contactInfo.ContactId; + document.getElementById(closeField).value = contactInfo.Name; + } + function DecryptAll(){ + let dataIds = []; + + //"{!conList}".each((i,e)=>{ + // console.log('------------------') + // console.log(e); + // let v = "{!conList}"[i].contactIdValue; + // if (v) { + // dataIds.push(v); + // } + //}); + conList = JSON.parse('{!conListJson}'); + if(conList){ + for(var i=0 ;i<conList.length;i++){ + if(conList[i]!=null){ + let v = conList[i].contactIdValue; + if (v) { + dataIds.push(v); + } + } + } + } + + Decrypt(dataIds); + } + j$(function(){ + DecryptAll(); + + }) + function Decrypt(dataIds){ + let Foo = function(){ + for (const id in dataIds) { + if (aws_data.hasOwnProperty(dataIds[id])) { + let d = aws_data[dataIds[id]]; + let $e =j$("[aws-id='"+d.dataId+ "']"); + //$e.html(d[$e.attr("aws-id")]); + $e.each(function(i,e){ + j$(e).val(d.lastName); + }) + } + } + } + let ids = []; + //for (const id in dataIds) { + // if (!aws_data.hasOwnProperty(id)) { + // ids.push(id); + // } + //} + for(var i =0 ;i<dataIds.length;i++){ + if (!aws_data.hasOwnProperty(dataIds[i])) { + ids.push(dataIds[i]); + } + } + if (ids.length > 0) { + blockme(); + AWSService.search(staticResourceContact.searchUrl, + JSON.stringify({ + "dataIds":ids + }), + function(data){ + unblockUI(); + if(data.object && data.object.length > 0){ + + for(let d in data.object){ + console.log('----------------') + console.log(d); + if(data.object[d].dataId){ + aws_data[data.object[d].dataId] = data.object[d]; + } + } + Foo(); + } + }, + staticResourceContact.token); + }else{ + Foo(); + } + } + // Update 20220317 By Yang Kaiyu End + function saveJs() { + if(confirm('鑱旂郴浜哄拰瀹㈡埛涓哄繀濉俊鎭�,濡傛灉涓虹┖灏嗕笉淇濆瓨姝ゆ潯璁板綍,鏄惁宸茬‘璁ゆ墍鏈夐渶瑕佷繚瀛樼殑淇℃伅璇ュ瓧娈甸兘涓嶄负绌�?')){ + blockme(); + updateUser(); + } } -} -</script> + </script> -<style type="text/css"> - .dateFormat{ - display: none; - } -</style> + <style type="text/css"> + .dateFormat{ + display: none; + } + </style> <apex:form id="allForm"> + <!-- Update 20220317 By Yang Kaiyu Start --> + <apex:inputHidden value="{!contactId}" id="contactId" /> + <!-- Update 20220317 By Yang Kaiyu End --> <apex:actionFunction name="updateUser" action="{!updateUser}" rerender="allForm,message,allPanel" onComplete="unblockUI();"></apex:actionFunction> <apex:outputPanel id="message"> <apex:messages /> @@ -42,23 +196,37 @@ <div style="overflow: scroll;height: 300px;width: 1260px; "> <apex:variable value="{!1}" var="cnt" /> <apex:repeat value="{!dataLines}" var="line" id="lines"> - <div style="width: 1260px;"> - {!$ObjectType.loaner_user__c.fields.Customer__c.label}: - <apex:inputField value="{!line.Customer__c}" /> + <div style="width: 1260px;"> + {!$ObjectType.loaner_user__c.fields.Customer__c.label}: + <!-- Update 20220317 By Yang Kaiyu Start --> + <apex:inputField id="customer" value="{!line.Customer__c}" /> + <!-- Update 20220317 By Yang Kaiyu End --> {!$ObjectType.loaner_user__c.fields.Contact__c.label}: - <apex:inputField value="{!line.Contact__c}" /> + <!-- Update 20220317 By Yang Kaiyu Start --> + <apex:inputField id="contact" value="{!line.Contact__c}" html-aws-id="{!line.Contact__r.AWS_Data_Id__c}" /> + <!-- <apex:inputText id="contact" html-aws-id="{!line.Contact__r.AWS_Data_Id__c}" disabled="false" value="{!line.Contact__r.LastName}" ></apex:inputText> --> + <!-- Update 20220317 By Yang Kaiyu End --> + {!$ObjectType.loaner_user__c.fields.FromThePeriod__c.label}: <apex:inputField value="{!line.FromThePeriod__c}"/> {!$ObjectType.loaner_user__c.fields.EndThePeriod__c.label}: <apex:inputField value="{!line.EndThePeriod__c}"/> - {!$ObjectType.loaner_user__c.fields.Follow_UP_Opp__c.label}: - <apex:inputField value="{!line.Follow_UP_Opp__c}"/> + {!$ObjectType.loaner_user__c.fields.Follow_UP_Opp__c.label}: + <apex:inputField value="{!line.Follow_UP_Opp__c}"/> {!$ObjectType.loaner_user__c.fields.Remarks__c.label}: <apex:inputField value="{!line.Remarks__c}"/> - <apex:variable value="{!cnt + 1}" var="cnt" /> </div> </apex:repeat> + <!-- Update 20220317 By Yang Kaiyu Start --> + <script> + sfdcPage.appendToOnloadQueue(function () { + //Replace Vlookup Field + + replaceSearchContactLookup(); + }) + </script> + <!-- Update 20220317 By Yang Kaiyu End --> </div> </apex:pageBlock> -- Gitblit v1.9.1