From ba1c90575c47f9cb5c2ce0a20da90d3b1739b5fa Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期二, 26 四月 2022 11:47:45 +0800 Subject: [PATCH] 0425 Commit --- force-app/main/default/pages/NewAndEditOrder.page | 133 ++++++++++++++++++++++++++++++++------------ 1 files changed, 96 insertions(+), 37 deletions(-) diff --git a/force-app/main/default/pages/NewAndEditOrder.page b/force-app/main/default/pages/NewAndEditOrder.page index 54bf8cc..04b7129 100644 --- a/force-app/main/default/pages/NewAndEditOrder.page +++ b/force-app/main/default/pages/NewAndEditOrder.page @@ -176,7 +176,7 @@ } let phone = document.querySelector(textPhone); - if(false && phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ + if(phone && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){ error_msg += ';鐢佃瘽鍙风爜閿欒'; } @@ -245,7 +245,20 @@ } return result; } - function QuerySobjectFromAWS() { + function QuerySobjectFromAWS(EndUserLkid) { + if(EndUserLkid){ + //query contact + sforce.connection.sessionId = '{!GETSESSIONID()}'; + let result = sforce.connection.query("SELECT AWS_Data_Id__c from Contact where id = '" + EndUserLkid + "'"); + let records = result.getArray("records"); + let awsDataId = records[0].AWS_Data_Id__c; + let queryContactBack = function(data){ + console.log('ContactData = ' + data.object);//To Do later + document.querySelector("[data-id='EndUser__c']").value = data.object.lastName; + unblockUI(); + } + AWSService.query(staticResourcesContact.queryUrl, awsDataId, queryContactBack, staticResources.token); + } AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token); } function queryBack(data) { @@ -495,7 +508,8 @@ } if (accountValue != ''){ let baseUrl = "/apex/SearchContactPage"; - let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue; + let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; + let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue+"&searchContactKeyWord=" + searchContactKeyWord; 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) { @@ -510,7 +524,8 @@ accountValue = ForeignTradeCompanyValue; } let baseUrl = "/apex/SearchContactPage"; - let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue; + let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; + let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue+"&searchContactKeyWord=" + searchContactKeyWord; 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) { @@ -545,7 +560,8 @@ } if (accountValueD != ''){ let baseUrl = "/apex/SearchContactPage"; - let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD; + let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; + let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD+"&searchContactKeyWord=" + searchContactKeyWord; 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) { @@ -560,7 +576,8 @@ accountValueD = ForeignTradeCompanyDValue; } let baseUrl = "/apex/SearchContactPage"; - let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD; + let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; + let suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValueD+"&searchContactKeyWord=" + searchContactKeyWord; 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) { @@ -570,7 +587,8 @@ } } else { let baseUrl = "/apex/SearchContactPage"; - let suffixUrl = "?contactId="+contactNodeId; + let searchContactKeyWord = document.querySelector("[data-id="+field+"]").value; + let suffixUrl = "?contactId="+contactNodeId+"&searchContactKeyWord=" + searchContactKeyWord; 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) { @@ -585,28 +603,34 @@ if (null != newSearchContactWindow) { newSearchContactWindow.close(); } - if(document.querySelector("[data-id='SpecialDeliveryContact2__c']") != null){ - if (null != newSearchContactWindow) { - newSearchContactWindow.close(); - } - let contactInfoStr = document.getElementById('page:form:contactId').value; - console.log('closePopup:'+contactInfoStr); - let contactInfo = JSON.parse(contactInfoStr); - let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; - document.getElementById(contactNodeId).value = contactInfo.ContactId; - document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; - } - if(document.querySelector("[data-id='SpecialDeliveryContact2_D__c']") != null){ - if (null != newSearchContactWindow) { - newSearchContactWindow.close(); - } - let contactInfoStr = document.getElementById('page:form:contactId').value; - console.log('closePopup:'+contactInfoStr); - let contactInfo = JSON.parse(contactInfoStr); - let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; - document.getElementById(contactNodeId).value = contactInfo.ContactId; - document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; - } + // if(document.querySelector("[data-id='SpecialDeliveryContact2__c']") != null){ + // if (null != newSearchContactWindow) { + // newSearchContactWindow.close(); + // } + // let contactInfoStr = document.getElementById('page:form:contactId').value; + // console.log('closePopup:'+contactInfoStr); + // let contactInfo = JSON.parse(contactInfoStr); + // let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; + // document.getElementById(contactNodeId).value = contactInfo.ContactId; + // document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; + // } + // if(document.querySelector("[data-id='SpecialDeliveryContact2_D__c']") != null){ + // if (null != newSearchContactWindow) { + // newSearchContactWindow.close(); + // } + // let contactInfoStr = document.getElementById('page:form:contactId').value; + // console.log('closePopup:'+contactInfoStr); + // let contactInfo = JSON.parse(contactInfoStr); + // let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; + // document.getElementById(contactNodeId).value = contactInfo.ContactId; + // document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; + // } + let contactInfoStr = document.getElementById('page:form:contactId').value; + console.log('closePopup:'+contactInfoStr); + let contactInfo = JSON.parse(contactInfoStr); + let contactNodeId = document.querySelector("[data-id="+closeField+"]").id + '_lkid'; + document.getElementById(contactNodeId).value = contactInfo.ContactId; + document.querySelector("[data-id="+closeField+"]").value = contactInfo.Name; } @@ -642,7 +666,7 @@ <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> <h2 class="mainTitle">{! SobjectLabel}<apex:outputText rendered="{!isNewMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode)}">{!$Label.Edit}</apex:outputText></h2> </td> - <td class="pbButton" id="topButtonRow"> + <td class="pbButton" id="topButtonRow" style="pointer-events: none; opacity: 0.4;"> <input class="btn" type="Button" value="{!$Label.Save}" onclick="saveSobjectProcess()" /> <input class="btn" type="Button" value="{!$Label.SaveAndNew}" onclick="saveSobjectProcess(1)" /> <apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" /> @@ -664,8 +688,14 @@ <!--Each section has layoutFields, let's iterate them as well--> <apex:repeat value="{!layoutSection.layoutFields}" var="layoutField"> - <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" - required="{!layoutField.isRequired}" /> + <!-- <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" + required="{!layoutField.isRequired}" /> --> + <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}" + required="{!layoutField.isRequired}" /> + <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI!='RecordTypeId'}" + required="{!layoutField.isRequired}" /> + <apex:outputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Order[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&¬(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}" + /> <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}"> </apex:pageblocksectionitem> </apex:repeat> @@ -682,22 +712,51 @@ } console.log(api_id_map); sfdcPage.appendToOnloadQueue(function () { + var layoutSections = JSON.parse('{!layoutSectionsStr}'); + for (let m = 0; m < layoutSections.length; m++) { + let layoutSection = layoutSections[m].layoutFields; + for (let n = 0; n < layoutSection.length; n++) { + let layoutField = layoutSection[n]; + if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) { + let e = document.querySelector("[data-id='"+layoutField.fieldAPI+"']"); + e.disabled = !(layoutField.editableField); + if (!(layoutField.editableField)) { + if (e.getAttribute("multiple") && e.getAttribute("multiple") == 'multiple') { + e.parentNode.classList.add("disabledbutton"); + } + if (e.tagName == 'DIV') { + e.classList.add("disabledbutton"); + } + } + } + } + } //1. Set Last Name label //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '濮撳悕'; //2. Query AWS Data by dataId console.log('Mode for Sobject Page:' + {!isNewMode}); + var EndUserLkid = '000000000000000'; + if(document.querySelector("[data-id='EndUser__c']")){ + EndUserLkid = document.getElementById(document.querySelector("[data-id='EndUser__c']").id + '_lkid').value; + } if (!{!isNewMode}) { blockme(); - QuerySobjectFromAWS(); + if(EndUserLkid!='000000000000000'){ + QuerySobjectFromAWS(EndUserLkid); + }else{ + QuerySobjectFromAWS(); + } + } //Replace Vlookup Field replaceSearchContactLookup(); //3. Set Readonly Attribute - document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton"); - document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); + // document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton"); + // document.querySelectorAll("[data-id='OwnerId']")[1].classList.add("disabledbutton"); - + document.getElementById('topButtonRow').style = ''; + document.getElementById('bottomButtonRow').style = ''; }); </script> <div class="pbBottomButtons"> @@ -706,7 +765,7 @@ <tr> <td class="pbTitle"> <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" /> </td> - <td class="pbButtonb" id="bottomButtonRow"> + <td class="pbButtonb" id="bottomButtonRow" style="pointer-events: none; opacity: 0.4;"> <input class="btn" type="Button" value="{!$Label.Save}" onclick="saveSobjectProcess()" /> <input class="btn" type="Button" value="{!$Label.SaveAndNew}" onclick="saveSobjectProcess()" /> <apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" /> -- Gitblit v1.9.1