From 248433c920f935ffcaee52b240f0c162decc1564 Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期一, 09 五月 2022 15:16:45 +0800
Subject: [PATCH] NFMUtilUpdate

---
 force-app/main/default/pages/NewAndEditLoanerApplication.page |   57 +++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/force-app/main/default/pages/NewAndEditLoanerApplication.page b/force-app/main/default/pages/NewAndEditLoanerApplication.page
index 5881c4d..1d9a080 100644
--- a/force-app/main/default/pages/NewAndEditLoanerApplication.page
+++ b/force-app/main/default/pages/NewAndEditLoanerApplication.page
@@ -1,10 +1,3 @@
-<!--
-  @description       : 
-  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
-  @group             : 
-  @last modified on  : 03-03-2022
-  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
--->
 <apex:page standardController="loaner_application__c" extensions="NewAndEditLoanerApplicationController" id="page">
   <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
     <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
@@ -70,7 +63,7 @@
                 
                 //payloadJson.AWS_Data_Id__c = r.object[0].dataId;
                 payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
-                if (isNewMode) {
+                if (isNewMode || {!isCloneMode}) {
                     payloadJson.AWS_Data_Id__c = r.object[0].dataId;
                 } else {
                     payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
@@ -137,7 +130,7 @@
         var VLookUpFields = {! VLookUpFieldsJson};
         function ProcessPI(sobjJson, payloadForNewPI) {
             blockme();
-            if ({!isNewMode}) {
+            if ({!isNewMode}  || {!isCloneMode}) {
               NewPIToAWS(sobjJson, payloadForNewPI)
             }else {
               UpdatePIToAWS(sobjJson, payloadForNewPI)
@@ -373,10 +366,10 @@
         <div class="ptBody">
             <div class="content">
                 <img src="/img/s.gif" alt="{! SobjectLabel}" class="pageTitleIcon" title="{! SobjectLabel}" />
-                <h1 class="pageType">{! SobjectLabel}<apex:outputText rendered="{!isNewMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode)}">{!$Label.Edit}</apex:outputText>
+                <h1 class="pageType">{! SobjectLabel}<apex:outputText rendered="{!isNewMode || isCloneMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode || isCloneMode)}">{!$Label.Edit}</apex:outputText>
                     <span class="titleSeparatingColon">:</span>
                 </h1>
-                <h2 class="pageDescription"> <apex:outputText rendered="{!isNewMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode)}">{!$Label.Edit}</apex:outputText>{! SobjectLabel}</h2>
+                <h2 class="pageDescription"> <apex:outputText rendered="{!isNewMode || isCloneMode}">{!$Label.New}</apex:outputText><apex:outputText rendered="{!not(isNewMode || isCloneMode)}">{!$Label.Edit}</apex:outputText>{! SobjectLabel}</h2>
                 <div class="blank">&nbsp;</div>
             </div>
             <div class="links">
@@ -398,9 +391,9 @@
                         <tr>
                             <td class="pbTitle">
                                 <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>
+                                <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}" />
@@ -422,8 +415,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="{!loaner_application__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
-                                        required="{!layoutField.isRequired}" />
+                        <!-- <apex:inputField styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!loaner_application__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
+                                        required="{!layoutField.isRequired}" /> -->
+                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!loaner_application__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}"
+                            required="{!layoutField.isRequired}" />
+                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!loaner_application__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI!='RecordTypeId'}"
+                            required="{!layoutField.isRequired}" />
+                        <apex:outputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!loaner_application__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}"
+                        />
                         <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
                         </apex:pageblocksectionitem>
                     </apex:repeat>
@@ -440,6 +439,25 @@
                 }
                 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 
@@ -449,8 +467,11 @@
                         QuerySobjectFromAWS();
                     }
                     //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">
@@ -459,7 +480,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}" />

--
Gitblit v1.9.1