From 24fda5246494953a232b37547fb50bde77bd9886 Mon Sep 17 00:00:00 2001
From: Li Jun <buli@deloitte.com.cn>
Date: 星期三, 27 四月 2022 12:03:42 +0800
Subject: [PATCH] PIPLButtonIssueFix

---
 force-app/main/default/pages/NewAndEditQIS.page |   43 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/force-app/main/default/pages/NewAndEditQIS.page b/force-app/main/default/pages/NewAndEditQIS.page
index 5e63772..9180f37 100644
--- a/force-app/main/default/pages/NewAndEditQIS.page
+++ b/force-app/main/default/pages/NewAndEditQIS.page
@@ -68,6 +68,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) {
@@ -135,6 +138,19 @@
                 NewPIToAWS(sobjJson, payloadForNewPI)
             }else {
                 UpdatePIToAWS(sobjJson, payloadForNewPI)
+            }
+        }
+
+        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");
             }
         }
 
@@ -254,9 +270,9 @@
                 } else {
                     result[field_api_name] = ele.value;
                     //鍏抽棴QIS鐞嗙敱涓烘棤鏃�
-                    if(field_api_name == 'Cancel_QIS_Reason__c' && ele.value == '_\x01_'){
-                        result[field_api_name] = '';
-                    }
+                    // if(field_api_name == 'Cancel_QIS_Reason__c' && ele.value == '_\x01_'){
+                    //     result[field_api_name] = '';
+                    // }
                 }
                 
                 // let e1 = document.getElementById(api_id_map[field_api_name]);
@@ -364,6 +380,7 @@
             return blankRequiredFields;
         }
         function saveSobjectProcess(save_and_new) {
+            EditButton(true);
             
             if(save_and_new){
                 config.SaveAndNew = true;
@@ -403,6 +420,7 @@
             let errorMsgNode = document.getElementById("page:form:block:msgContent");
             errorMsgNode.innerText = errorMsg;
             errorMsgNode.className = 'pbError';
+            EditButton(false);
         }
         function hiddenErrorMsgNode() {
             let errorMsgNode = document.getElementById("page:form:block:msgContent");
@@ -441,7 +459,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}" />
@@ -463,8 +481,12 @@
                     
                     <!--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="{!QIS_Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
-                                        required="{!layoutField.isRequired}" />
+                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!QIS_Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}"
+                            required="{!layoutField.isRequired}" />
+                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!QIS_Report__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="{!QIS_Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}"
+                        />
                         <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
                         </apex:pageblocksectionitem>
                     </apex:repeat>
@@ -484,6 +506,11 @@
             }
             console.log(api_id_map);
             sfdcPage.appendToOnloadQueue(function () {
+                jQuery('option').each(function(i,e){
+                	if(e.value == '_\x01_'){
+                		e.value = '';
+                	}
+                })
                 //鍒ゆ柇鏄惁涓哄彧璇婚�夐」
                 var layoutSections = JSON.parse('{!layoutSectionsStr}');
                     for (let m = 0; m < layoutSections.length; m++) {
@@ -524,6 +551,8 @@
                             oi.value = '{!CurrentUserId}'
                         }
                     }
+                document.getElementById('topButtonRow').style = '';
+聽 聽 聽 聽 聽  document.getElementById('bottomButtonRow').style = '';
             });
             </script>
             <div class="pbBottomButtons">
@@ -532,7 +561,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