Li Jun
2022-03-28 f5a94e721ae5a26f817f0df75065b64f1f192eb3
force-app/main/default/pages/NewAndEditASEActivity.page
@@ -2,7 +2,7 @@
  @description       : 
  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
  @group             : 
  @last modified on  : 03-17-2022
  @last modified on  : 03-23-2022
  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
-->
<apex:page standardController="ASEActivity__c" extensions="NewAndEditASEActivityController" id="page">
@@ -26,6 +26,7 @@
            SaveAndNew:false,
            AWSToSobjectMap:{!AWSToSobjectMapJson},
            AWSToSobjectNonEncryptedMap:{!AWSToSobjectNonEncryptedMapJson},
            AWSToSobjectNonEncryptedMapKeySet:{!AWSToSobjectNonEncryptedMapKeySet},
            AWSToSobjectEncryptedMap:{!AWSToSobjectEncryptedMapJson},
            SobjectToAWSModel:function (sobjJson) {
                let leadPayloadList = [];
@@ -117,7 +118,7 @@
                            
                        }
                        else{
                            console.log(f + 'is not in data.object');
                            console.log(f + ' is not in data.object');
                        }
                    }
                }
@@ -141,6 +142,7 @@
        var staticResourcesContact = JSON.parse('{!staticResourceContact}');
        console.log('{!staticResource}');
        var VLookUpFields = {! VLookUpFieldsJson};
        function ProcessPI(sobjJson, payloadForNewPI) {
            blockme();
            if ({!isNewMode}) {
@@ -166,8 +168,15 @@
            return '';
        }
        function IsFormElement(tag_name){
            return ['input','select','textarea'].indexOf(tag_name)>-1;
        function IsFormTag(tag_name){
            if (!tag_name) {
                return false;
            }
            return ['input','select','textarea'].indexOf(tag_name.toLowerCase())>-1;
        }
        function IsFormElement(e){
            return IsFormTag(e.tagName);
        }
        function getPIPayload(sobjJson) {
@@ -188,7 +197,7 @@
            if(phone ){
                if(phone.value){
                    if(!/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone.value)){
                       error_msg += ';电话号码错误';
                        error_msg += ';电话号码错误';
                    }
                }else{
                    if(phone.previousSibling && phone.previousSibling.className.indexOf('requiredBlock')>-1){
@@ -220,11 +229,12 @@
            let nodelist = document.getElementsByClassName(config.ApiPrefix);
            let result = {}
            for (let index = 0; index < nodelist.length; index++) {
                let ele = nodelist[index];
                let field_api_name = GetEleApiName(ele);
            for (let index in api_id_map) {
                let ele = document.getElementById(api_id_map[index]);
                let field_api_name = index;
                let tag_name = ele.tagName.toLowerCase();
                if(!IsFormElement(tag_name)){
                if(!IsFormTag(tag_name)){
                    console.log('tag_name='+tag_name+',field_api_name'+field_api_name+' is not a form element');
                    continue;
                }
@@ -394,10 +404,11 @@
                accountValue = document.getElementById(accountNodeId).value;   
            } 
            console.log('accountValue = ' + accountValue);
            let searchContactKeyWord = document.querySelector("[data-id='ReporterASE__c']").value;
            if(accountValue !='000000000000000'){
                suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue;
                suffixUrl = "?contactId="+contactNodeId+"&accountId="+accountValue+"&searchContactKeyWord=" + searchContactKeyWord;
            }else{
                suffixUrl = "?contactId="+contactNodeId;
                suffixUrl = "?contactId="+contactNodeId+"&searchContactKeyWord=" + searchContactKeyWord;
            }
            let baseUrl = "/apex/SearchContactPage";
            let newSearchContactParam = 'height=600,width=800,left=100,top=100,dialogHide=true,resizable=no,scrollbars=yes,toolbar=no,status=no';
@@ -521,6 +532,20 @@
                </apex:pageBlockSection>
            </apex:repeat>
            <script>
               var init_nodes = document.getElementsByClassName("PIBackApi");
               var api_id_map={};
               for(let ei in init_nodes){
                   let e = init_nodes[ei];
                  if(IsFormElement(e)){
                       if(e.getAttribute("multiple") != 'multiple' || e.style.display == 'none' && e.id.indexOf('selected') < 0){
                           api_id_map[GetEleApiName(e)] = e.id;
                       }
                   }
               }
               console.log(api_id_map);
                sfdcPage.appendToOnloadQueue(function () {
                    var layoutSections = JSON.parse('{!layoutSectionsStr}');
                    for (let m = 0; m < layoutSections.length; m++) {
@@ -528,7 +553,16 @@
                        for (let n = 0; n < layoutSection.length; n++) {
                            let layoutField = layoutSection[n];
                            if (layoutField.fieldAPI != '' && document.querySelector("[data-id='"+layoutField.fieldAPI+"']") != null) {
                                document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField);
                                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");
                                    }
                                }
                            }
                        }
                    }
@@ -544,6 +578,7 @@
                    replaceSearchContactLookup();
                    document.querySelectorAll("[data-id='OwnerId']")[0].classList.add("disabledbutton");
                    jQuery('a[data-id="OwnerId"]').remove();
                    /*
                    jQuery(".lookupInput").each(function(i,e){
                        let je =jQuery(e).find('input');
                        je.attr("readonly","");
@@ -566,13 +601,31 @@
                        let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id");
                        let input = document.getElementById(id);
                        if(input){
                           input.value = '';
                     let hidden = document.getElementById(id+'_lkid');
                            input.value = '';
                            let hidden = document.getElementById(id+'_lkid');
                            if(hidden){
                               hidden.value = '';
                                hidden.value = '';
                            }
                        }
                    });
                    */
                    let previous_value = {};
                    jQuery(".lookupInput input").each(function(i,e){
                        let je =jQuery(e);
                        let dataid = je.attr('data-id');
                        if(['ContactId'].indexOf(dataid) < 0) return;
                        jQuery(e).focus(function(){
                            previous_value[this.id] = this.value;
                        })
                        jQuery(e).change(function(){
                            if (previous_value[this.id] != jQuery(this).val()) {
                                document.getElementById(this.id+'_lkid').value = '';
                            }
                        })
                    })
                });
            </script>
            <div class="pbBottomButtons">