Li Jun
2022-05-09 639b0139b5713badf37e67b4fe7b9d3b3a592163
force-app/main/default/pages/NewAndEditAgencyContact.page
@@ -1,9 +1,15 @@
<apex:page standardController="Agency_Contact__c" extensions="NewAndEditAgencyContactController" id="page">
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <style>
        .disabledbutton {
            pointer-events: none;
            opacity: 0.4;
        }
    </style>
    <script>
        
        var config = {};
@@ -67,6 +73,9 @@
                } else {
                    payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
                }
                if('{!rtTypeId}'){
                    payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421
                }
                return payloadJson;
            },
            queryBack:function (data) {
@@ -123,7 +132,7 @@
        }
    
        var staticResources = JSON.parse('{!staticResource}');
       var staticResourceAWSContact = JSON.parse('{!staticResourceAWSContact}');
        var staticResourceAWSContact = JSON.parse('{!staticResourceAWSContact}');
    
        var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}');
        var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}');
@@ -132,7 +141,7 @@
        function ProcessPI(sobjJson, payloadForNewPI) {
            blockme();
            if ({!isNewMode} || {!isCloneMode}) {
               NewPIToAWS(sobjJson, payloadForNewPI)
                NewPIToAWS(sobjJson, payloadForNewPI)
            }else {
                UpdatePIToAWS(sobjJson, payloadForNewPI)
            }
@@ -154,14 +163,26 @@
            return '';
        }
        function EditButton(isDisabled){
            var topele = document.getElementById('topButtonRow');
            var bottomele = document.getElementById('bottomButtonRow');
            if (isDisabled) {
                topele.classList.add("disabledbutton");
                bottomele.classList.add("disabledbutton");
            }else {
                topele.classList.remove("disabledbutton");
                bottomele.classList.remove("disabledbutton");
            }
        }
        function IsFormTag(tag_name){
            if (!tag_name) {
                return false;
            }
            return ['input','select','textarea'].indexOf(tag_name.toLowerCase())>-1;
        }
       function IsFormElement(e){
        function IsFormElement(e){
            return IsFormTag(e.tagName);
        }
@@ -298,7 +319,9 @@
        function checkRequiredFieldMsg(formData) {
            let blankRequiredFields = '';
            for(i = 0;i<requiredFieldAPIList.length;i++){
                if(formData[requiredFieldAPIList[i]]){
                if(formData[requiredFieldAPIList[i]] && (VLookUpFields.indexOf(requiredFieldAPIList[i]) == -1)){
                    continue;
                }else if((VLookUpFields.indexOf(requiredFieldAPIList[i]) != -1) && formData[requiredFieldAPIList[i]] != '000000000000000'){
                    continue;
                }else{
                    if(blankRequiredFields == ''){
@@ -312,6 +335,7 @@
            return blankRequiredFields;
        }
        function saveSobjectProcess(save_and_new) {
            EditButton(true);
            if(save_and_new){
                config.SaveAndNew = true;
            }
@@ -349,8 +373,10 @@
        function alertErrorMessage(errorMsg) {
            let errorMsgNode = document.getElementById("page:form:block:msgContent");
            errorMsg = '错误:无效数据。' + '\n' + errorMsg;
            errorMsgNode.innerText = errorMsg;
            errorMsgNode.className = 'pbError';
            EditButton(false);
        }
        function hiddenErrorMsgNode() {
            let errorMsgNode = document.getElementById("page:form:block:msgContent");
@@ -422,7 +448,7 @@
            let dataId = contactsInfo[sfId];
            
            if(dataId){
               AWSService.query(staticResourceAWSContact.queryUrl,dataId,function(result){
                AWSService.query(staticResourceAWSContact.queryUrl,dataId,function(result){
                    if(result.object){
                        document.querySelector("[data-id='Contact__c']").value = result.object.lastName;
                    }
@@ -464,7 +490,7 @@
                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
                                <h2 class="mainTitle">{! SobjectLabel}<apex:outputText rendered="{!isNewMode || isCloneMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode || isCloneMode)}">{!$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}" />
@@ -486,8 +512,10 @@
                    <!--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="{!Agency_Contact__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
                        <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Agency_Contact__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&layoutField.fieldAPI!='RecordTypeId'}"
                            required="{!layoutField.isRequired}" />
                        <apex:outputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Agency_Contact__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&layoutField.fieldAPI=='RecordTypeId'}"
                        />
                        <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
                        </apex:pageblocksectionitem>
                    </apex:repeat>
@@ -495,7 +523,7 @@
                </apex:pageBlockSection>
            </apex:repeat>
            <script>
               var init_nodes = document.getElementsByClassName("PIBackApi");
                var init_nodes = document.getElementsByClassName("PIBackApi");
                var api_id_map={};
                for(let ei in init_nodes){
                    let e = init_nodes[ei];
@@ -508,7 +536,7 @@
                }
                console.log(api_id_map);
                sfdcPage.appendToOnloadQueue(function () {
               jQuery('option').each(function(i,e){
                    jQuery('option').each(function(i,e){
                        if(e.value == '_\x01_'){
                            e.value = '';
                        }
@@ -538,6 +566,8 @@
                    }
                    jQuery('a[data-id="OwnerId"]').remove();
                    document.getElementById('topButtonRow').style = '';
                    document.getElementById('bottomButtonRow').style = '';
                    /*
                    jQuery(".lookupInput").each(function(i,e){
                        let je =jQuery(e).find('input');
@@ -606,7 +636,7 @@
                        <tr>
                            <td class="pbTitle">
                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />&nbsp;</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}" />