Li Jun
2022-03-20 db4e75dabb6c61be6c3a09e9f11707f6018c2ef2
force-app/main/default/pages/NewRentalApply.page
@@ -2,7 +2,7 @@
  @description       : 
  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
  @group             : 
  @last modified on  : 03-11-2022
  @last modified on  : 03-18-2022
  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
-->
<apex:page standardController="Rental_Apply__c" extensions="RentalApplyController" id="page">
@@ -251,22 +251,20 @@
            return template.content.firstChild;
        }
        function queryContactName() {
            // let sfId = document.getElementById(document.querySelector("[data-id='Loaner_medical_Staff__c']").id + '_lkid').value;
            function queryContactName() {
            let sfId = document.getElementById(document.querySelector("[data-id='Account__c']").id + '_lkid').value;
            let contactsInfo = JSON.parse('{!contactsInfo}');
            let dataId = contactsInfo[sfId];
            let url = staticResourcesContact.queryUrl + '?dataId=' + dataId;
            fetch(url, {
                method: 'GET',
                headers: {
                    'Content-Type': 'application/json',
                    'pi-token': staticResources.token
                }
            }).then((data) => {
                return data.json();
            }).then((result) => {
            let dataId = '';
            if ('{!contactsInfo}' != '') {
                let contactsInfo = JSON.parse('{!contactsInfo}');
                dataId = contactsInfo[sfId];
            } else if ('{!AWSDataId}' != '') {
                dataId = '{!AWSDataId}';
            }
            let queryBackContactName = function queryBackContactName(result){
                document.querySelector("[data-id='Loaner_medical_Staff__c']").value = result.object.lastName;
            })
            };
            AWSService.query(staticResourcesContact.queryUrl, dataId, queryBackContactName, staticResourcesContact.token);
        }
        }
        //自定义lookup查询
        function searchContact(contactNodeId){
@@ -363,6 +361,16 @@
            <script>
                //Append Page
                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) {
                                document.querySelector("[data-id='"+layoutField.fieldAPI+"']").disabled = !(layoutField.editableField);
                            }
                        }
                    }
                    //2. Query AWS Data by dataId 
                    console.log('Mode for rentalApply Page:' + {!isNewMode});
                    if (!{!isNewMode}) {
@@ -372,6 +380,37 @@
                    //Replace Vlookup Field
                    replaceSearchContactLookup();
                    document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton");
                    jQuery(".lookupInput").each(function(i,e){
                        let je =jQuery(e).find('input');
                        je.attr("readonly","");
                        je.css("background","unset");
                        let dataid = je.attr('data-id');
                        if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return;
                        jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">');
                    })
                    jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){
                        this.className = "closeIconOn";
                    });
                    jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){
                        this.className = "closeIcon"
                    });
                    jQuery(".lookupInput").on("click","img[generate]",function(e){
                        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');
                            if(hidden){
                                hidden.value = '';
                            }
                        }
                    });
                });
            </script>
            <div class="pbBottomButtons">