From e6068da47c1bef5517c9e5fdc8c726766867ad4e Mon Sep 17 00:00:00 2001
From: buli <137736985@qq.com>
Date: 星期五, 14 七月 2023 15:10:02 +0800
Subject: [PATCH] Merge branch 'master' into LEXUpgrade2023-Deloitte

---
 force-app/main/default/pages/NewAndEditReport.page |  321 +++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 235 insertions(+), 86 deletions(-)

diff --git a/force-app/main/default/pages/NewAndEditReport.page b/force-app/main/default/pages/NewAndEditReport.page
index 42ed130..e7e9c6e 100644
--- a/force-app/main/default/pages/NewAndEditReport.page
+++ b/force-app/main/default/pages/NewAndEditReport.page
@@ -1,9 +1,15 @@
-<apex:page standardController="Report__c" extensions="NewAndEditReportController" id="page">
-    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
-    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
-    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
-    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
-    <script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
+<apex:page
+    standardController="Report__c"
+    extensions="NewAndEditReportController"
+    id="page"
+>
+    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}" />
+    <apex:includeScript
+        value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"
+    />
+    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}" />
+    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}" />
+    <apex:includeScript value="{!URLFOR($Resource.connection20)}" />
 
     <style>
         .disabledbutton {
@@ -13,16 +19,21 @@
     </style>
 
     <script>
+        sforce.connection.sessionId = '{!GETSESSIONID()}';
         AWSService.sfSessionId = '{!GETSESSIONID()}';
         var staticResources = JSON.parse('{!staticResource}');
+         //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+         var staticResourcesV2 = JSON.parse('{!staticResourceV2}');
+        //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
         var staticResourcesContact = JSON.parse('{!staticResourceContact}');
         var redirectMode = 'Save';//1. Save 2. SaveAndNew
         var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}');
         var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}');
-        var VLookUpFields = new Set(['Hospital_Reference__c', 'Department_Class_Ref__c', 'Daily_Report__c', 'OwnerId','Hospital_Department__c',
-        'Competition_Company_Name__c','Report_OPDPlan__c','Loaner_request_no1__c','Practitioner1__c','Practitioner2__c','Practitioner3__c','Practitioner4__c',
-        'Practitioner5__c','Opportunity1__c',
-        'Opportunity2__c','Product01__c','Product1__c','Product2__c','Product3__c','Product4__c','Product5__c','Order_No__c','Person_In_Charge__c']);
+        // var VLookUpFields = new Set(['Hospital_Reference__c','Consum_Apply__c','Department_Class_Ref__c', 'Daily_Report__c', 'OwnerId','Hospital_Department__c',
+        // 'Competition_Company_Name__c','Report_OPDPlan__c','Loaner_request_no1__c','Practitioner1__c','Practitioner2__c','Practitioner3__c','Practitioner4__c',
+        // 'Practitioner5__c','Opportunity1__c','Responsible_Person__c',
+        // 'Opportunity2__c','Product01__c','Product1__c','Product2__c','Product3__c','Product4__c','Product5__c','Order_No__c','Person_In_Charge__c','CIC_Number__c']);
+        var VLookUpFields = {! VLookUpFieldsJson};
         var closeField = '';
         // var myCkeditor = null;
         // try {
@@ -31,17 +42,30 @@
         //     console.log('娌℃湁CKEDITOR')
         // }
 
+        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 alertErrorMessage(errorMsg) {
-            let errorMsgNode = document.getElementById("page:form:j_id5:msgContent");
+            let errorMsgNode = document.getElementById("page:form:pageBlock:msgContent");
             errorMsg = '閿欒锛氭棤鏁堟暟鎹��'+'\n' + errorMsg;
             errorMsgNode.innerText = errorMsg;
             errorMsgNode.className = 'pbError';
             unblockUI();
+            EditButton(false);
         }
         function hiddenErrorMsgNode() {
-            let errorMsgNode = document.getElementById("page:form:j_id5:msgContent");
+            let errorMsgNode = document.getElementById("page:form:pageBlock:msgContent");
             errorMsgNode.innerText = '';
             errorMsgNode.className = '';
         }
@@ -50,7 +74,7 @@
             let t = jQuery("label[for$='textAreaDelegate_"+api_name+"']").parent().next().find("textarea")[0];
             if(t && t.id){
                 return CKEDITOR.instances[t.id]
-                
+
             }
             return null;
         }
@@ -61,12 +85,25 @@
             let result = {}
             result.RecordTypeId = '{!rtTypeId}';
             for (let index = 0; index < nodelist.length; index++) {
-                if (VLookUpFields.has(nodelist[index].getAttribute("data-id"))) {
+                let tag_name = nodelist[index].tagName.toLowerCase();
+                if(tag_name == 'div'){
+                    console.log(nodelist[index])
+                }
+                if (VLookUpFields.indexOf(nodelist[index].getAttribute("data-id")) >= 0) {
                     console.log(nodelist[index].id.indexOf('lkwgt'));
                     if (nodelist[index].id.indexOf('lkwgt') == -1) {
                         let vlookUpNodeId = nodelist[index].id + '_lkid';
-                        let vlookUpNodeValue = document.getElementById(vlookUpNodeId).value;
-                        result[nodelist[index].getAttribute("data-id")] = vlookUpNodeValue;
+                        if (tag_name == 'div') {
+                            vlookUpNodeId = nodelist[index].id.substring(0,nodelist[index].id.length-4) + '_lkid';
+                        }
+                        let vlookUpNodeValue = document.getElementById(vlookUpNodeId);
+                        let v = '';
+                        if(vlookUpNodeValue){
+                            v = vlookUpNodeValue.value;
+                        }else{
+                            v = nodelist[index].value;
+                        }
+                        result[nodelist[index].getAttribute("data-id")] = v;
                     }
                 } else if (nodelist[index].type == 'checkbox') {
                     result[nodelist[index].getAttribute("data-id")] = nodelist[index].checked;
@@ -166,7 +203,7 @@
             // if(document.querySelector("[aria-describedby = 'cke_38']")){
             //     result.VOC_follow_up_result__c = document.querySelector("[aria-describedby = 'cke_38']").contentWindow.document.getElementsByTagName('body')[0].innerHTML
             // }
-            // //瀵瑰簲缁撴灉绗竴娆� 	VOC_follow_up_result1__c cke_71
+            // //瀵瑰簲缁撴灉绗竴娆�    VOC_follow_up_result1__c cke_71
             // if(document.querySelector("[aria-describedby = 'cke_71']")){
             //     result.VOC_follow_up_result1__c = document.querySelector("[aria-describedby = 'cke_71']").contentWindow.document.getElementsByTagName('body')[0].innerHTML
             // }
@@ -183,7 +220,7 @@
         function validateFieldValueFormate() {
             //VOC_Informer_Contact__c,Caller_phone_c__c
             let error_msg = '';
-            // let textEmail = "[data-id='	Follow_staff_email__c']";
+            // let textEmail = "[data-id='  Follow_staff_email__c']";
             // let textPhone1 = "[data-id='VOC_Informer_Contact__c']";
             // let textPhone2 = "[data-id='Caller_phone_c__c']";
             // //Email
@@ -196,7 +233,7 @@
             // if(phone1 && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone1.value)){
             //     error_msg += ';淇℃伅鎻愪緵浜鸿仈绯绘柟寮忥紙鐢佃瘽锛夊彿鐮侀敊璇�';
             // }
-            
+
             // let phone2 = document.querySelector(textPhone2);
             // if(phone2 && !/^1[3|5|8|7][0-9]\d{4,8}$/.test(phone2.value)){
             //     error_msg += ';鑱旂郴鐢佃瘽鍙风爜閿欒';
@@ -221,7 +258,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 == ''){
@@ -229,7 +268,7 @@
                     }else{
                         blankRequiredFields =blankRequiredFields+',' + fieldAPIToLabelMap[requiredFieldAPIList[i]];
                     }
-                    
+
                 }
             }
             return blankRequiredFields;
@@ -255,10 +294,10 @@
             if (!tag_name) {
                 return false;
             }
-            return ['input','select','textarea'].indexOf(tag_name.toLowerCase())>-1;
+            return ['input','select','textarea','div'].indexOf(tag_name.toLowerCase())>-1;
         }
-    	
-    	function IsFormElement(e){
+
+        function IsFormElement(e){
             return IsFormTag(e.tagName);
         }
 
@@ -285,7 +324,7 @@
             return JSON.stringify(reportPayloadList);
         }
 
-        
+
 
         //5.鏂板缓鎴栫紪杈�
         function ProcessPI(reportJson, payloadForNewPI) {
@@ -300,7 +339,10 @@
         //鏂板缓
         function NewPIToAWS(reportJson, payloadForNewPI) {
             let controllerSaveMethod = '{!$RemoteAction.NewAndEditReportController.saveReport}';
-            AWSService.insert(staticResources.newUrl, reportJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack);
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+            //AWSService.insert(staticResources.newUrl, reportJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, {!isNewMode}, insertOrUpdateBack, redirectCallBack);
+            AWSService.insert(staticResourcesV2.newUrl, reportJson, payloadForNewPI, controllerSaveMethod, staticResourcesV2.token, staticResourcesV2.transactionUrl, {!isNewMode}, insertOrUpdateBack, redirectCallBack);
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
         }
 
         //缂栬緫
@@ -309,7 +351,10 @@
             let obj = JSON.parse(payloadForNewPI);
             obj[0].dataId = '{!AWSDataId}';
             let payloadForNewPIJson = JSON.stringify(obj);
-            AWSService.update(staticResources.updateUrl, reportJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack,redirectCallBack);
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+            //AWSService.update(staticResources.updateUrl, reportJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack,redirectCallBack);
+            AWSService.update(staticResourcesV2.updateUrl, reportJson, payloadForNewPIJson, controllerSaveMethod, staticResourcesV2.token, staticResources.transactionUrl, false, insertOrUpdateBack,redirectCallBack);
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
         }
 
         //鏌ヨ
@@ -343,7 +388,7 @@
         function replaceSearchContactLookup() {
             if (!{!isNewMode}) {
                 queryContactName();
-            }           
+            }
             if(document.querySelector("[data-id='Practitioner1__c']") != null){
                 let contactHtmlString = '<img src="/img/s.gif" onclick="searchContact(\'page:form:contactId\',\'Practitioner1__c\')" alt="Reference Document Number Lookup" class="lookupIcon"  title="Reference Document Number Lookup (New Window)"/>';
                 let lookUpNode = htmlToElement(contactHtmlString);
@@ -387,8 +432,8 @@
                 parentNode.replaceChild(lookUpNode, document.querySelector("[data-id='Person_In_Charge__c']").parentNode.children[2]);
             }
         }
-        var newSearchContactWindow = null;  
-        
+        var newSearchContactWindow = null;
+
         function htmlToElement(html) {
             var template = document.createElement('template');
             html = html.trim(); // Never return a text node of whitespace as the result
@@ -450,8 +495,8 @@
             let accountValue = "";
             if (document.querySelector("[data-id='Hospital_Department__c']")) {
                 let accountNodeId = document.querySelector("[data-id='Hospital_Department__c']").id + '_lkid';
-                accountValue = document.getElementById(accountNodeId).value;   
-            } 
+                accountValue = document.getElementById(accountNodeId).value;
+            }
             console.log(accountValue);
             if(accountValue !='000000000000000'){
                 let baseUrl = "/apex/SearchContactPage";
@@ -512,26 +557,42 @@
             payloadJson.Medical_History__c = result.object[0].medicalHistory;
             payloadJson.sex__c = result.object[0].sex;
 
-            payloadJson.VOC_Informer_Name_Encrypted__c = result.object[0].vocInformerNameEncrypt;
-            payloadJson.Caller_phone_c_Encrypted__c = result.object[0].callerPhoneEncrypt;
-            payloadJson.VOC_Informer_Contact_Encrypted__c = result.object[0].vocInformerContactEncrypt;
-            payloadJson.Person_In_Charge_Text_Encrypted__c = result.object[0].personInChargeTextEncrypt;
-            payloadJson.Professor_sigh_text_Encrypted__c = result.object[0].professorSighTextEncrypt;
-            payloadJson.Staff_Info_Manual_c_Encrypted__c = result.object[0].staffInfoManualEncrypt;
-            payloadJson.Responsible_Person_HP_c_Encrypted__c = result.object[0].responsiblePersonHPEncrypt;
-            payloadJson.Practitioner1_Part_Encrypted__c = result.object[0].practitioner1PartEncrypt;
-            payloadJson.Practitioner2_Part_Encrypted__c = result.object[0].practitioner2PartEncrypt;
-            payloadJson.Practitioner3_Part_Encrypted__c = result.object[0].practitioner3PartEncrypt;
-            payloadJson.Practitioner4_Part_Encrypted__c = result.object[0].practitioner4PartEncrypt;
-            payloadJson.Practitioner5_Part_Encrypted__c = result.object[0].practitioner5PartEncrypt;
-            payloadJson.age_Encrypted__c = result.object[0].ageEncrypt;
-            payloadJson.Medical_History_Encrypted__c = result.object[0].medicalHistoryEncrypt;
-            payloadJson.sex_Encrypted__c = result.object[0].sexEncrypt;
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 start
+            // payloadJson.VOC_Informer_Name_Encrypted__c = result.object[0].vocInformerNameEncrypt;
+            // payloadJson.Caller_phone_c_Encrypted__c = result.object[0].callerPhoneEncrypt;
+            // payloadJson.VOC_Informer_Contact_Encrypted__c = result.object[0].vocInformerContactEncrypt;
+            // payloadJson.Person_In_Charge_Text_Encrypted__c = result.object[0].personInChargeTextEncrypt;
+            // payloadJson.Professor_sigh_text_Encrypted__c = result.object[0].professorSighTextEncrypt;
+            // payloadJson.Staff_Info_Manual_c_Encrypted__c = result.object[0].staffInfoManualEncrypt;
+            // payloadJson.Responsible_Person_HP_c_Encrypted__c = result.object[0].responsiblePersonHPEncrypt;
+            // payloadJson.Practitioner1_Part_Encrypted__c = result.object[0].practitioner1PartEncrypt;
+            // payloadJson.Practitioner2_Part_Encrypted__c = result.object[0].practitioner2PartEncrypt;
+            // payloadJson.Practitioner3_Part_Encrypted__c = result.object[0].practitioner3PartEncrypt;
+            // payloadJson.Practitioner4_Part_Encrypted__c = result.object[0].practitioner4PartEncrypt;
+            // payloadJson.Practitioner5_Part_Encrypted__c = result.object[0].practitioner5PartEncrypt;
+            // payloadJson.age_Encrypted__c = result.object[0].ageEncrypt;
+            // payloadJson.Medical_History_Encrypted__c = result.object[0].medicalHistoryEncrypt;
+            // payloadJson.sex_Encrypted__c = result.object[0].sexEncrypt;
+            //zhj MEBG鏂版柟妗堟敼閫� 2022-11-29 end
+
             if (isNewMode || {!isCloneMode}||!'{!AWSDataId}') {//Add by Li Jun for PIPL 20220413
                 payloadJson.AWS_Data_Id__c = result.object[0].dataId;
                 delete payloadJson.OwnerId;
             } else {
                 payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
+            }
+            if('{!sfRecordIdForEdit}'){
+                payloadJson.Id = '{!sfRecordIdForEdit}';
+            }
+            if('{!rtTypeId}'){
+                payloadJson.RecordTypeId = '{!rtTypeId}';//Add by Li Jun for Record Type Issue 20220421
+            }
+            if('{!isCloneMode}' == 'true'){
+                var reportId = '{!sfRecordIdForEdit}';
+                var r = sforce.connection.query("select Practitioner4__c,Practitioner5__c from Report__c where id='"+reportId+"'")
+                payloadJson.Practitioner4__c = r.getArray("records")[0].Practitioner4__c
+                payloadJson.Practitioner5__c = r.getArray("records")[0].Practitioner5__c
+                payloadJson.Id = null
             }
             return payloadJson;
         }
@@ -551,6 +612,8 @@
 
         //鐐瑰嚮淇濆瓨鎸夐挳
         function saveReportProcess(saveMode) {
+            EditButton(true);
+
             redirectMode = saveMode;
             console.log('redirectMode' + redirectMode);
             hiddenErrorMsgNode();
@@ -573,7 +636,7 @@
             let payloadForNewPI = getPIPayload(reportJson);
             console.log('鍔犲瘑瀛楁锛�'+payloadForNewPI);
 
-            //5. report to AWS 
+            //5. report to AWS
             ProcessPI(reportJson, payloadForNewPI);
         }
     </script>
@@ -581,16 +644,24 @@
     <div class="bPageTitle">
         <div class="ptBody">
             <div class="content">
-                <img src="/img/s.gif" alt="鎶ュ憡涔�" class="pageTitleIcon" title="鎶ュ憡涔�" />
-                <h1 class="pageType">鎶ュ憡涔�
+                <img
+                    src="/img/s.gif"
+                    alt="鎶ュ憡涔�"
+                    class="pageTitleIcon"
+                    title="鎶ュ憡涔�"
+                />
+                <h1 class="pageType">
+                    鎶ュ憡涔�
                     <span class="titleSeparatingColon">:</span>
                 </h1>
-                <h2 class="pageDescription"> 鏂板缓鎶ュ憡涔�</h2>
+                <h2 class="pageDescription">鏂板缓鎶ュ憡涔�</h2>
                 <div class="blank">&nbsp;</div>
             </div>
             <div class="links">
-                <a href="javascript:openPopupFocusEscapePounds(%27https://help.salesforce.com/apex/htdoor?loc=help&amp;target=leads_edit.htm&amp;section=Leads&amp;language=zh_CN&amp;release=234.18.8&amp;instance=CS117&amp;showSplash=true%27, %27Help%27, 700, 600, %27width=700,height=600,resizable=yes,toolbar=yes,status=no,scrollbars=yes,menubar=yes,directories=no,location=no,dependant=no%27, false, false);"
-                    title="姝ら〉闈㈢殑甯姪 锛堟柊绐楀彛锛�">
+                <a
+                    href="javascript:openPopupFocusEscapePounds(%27https://help.salesforce.com/apex/htdoor?loc=help&amp;target=leads_edit.htm&amp;section=Leads&amp;language=zh_CN&amp;release=234.18.8&amp;instance=CS117&amp;showSplash=true%27, %27Help%27, 700, 600, %27width=700,height=600,resizable=yes,toolbar=yes,status=no,scrollbars=yes,menubar=yes,directories=no,location=no,dependant=no%27, false, false);"
+                    title="姝ら〉闈㈢殑甯姪 锛堟柊绐楀彛锛�"
+                >
                     <span class="helpLink">姝ら〉闈㈢殑甯姪</span>
                     <img src="/img/s.gif" alt="" class="helpIcon" />
                 </a>
@@ -604,44 +675,95 @@
         <!-- <apex:outputPanel id="errorMsg">
             <apex:pageMessages id="msgContent" escape="false" />
         </apex:outputPanel> -->
-        <apex:pageblock >
+        <apex:pageblock id="pageBlock">
             <div class="pbHeader">
                 <table cellspacing="0" cellpadding="0" border="0">
                     <tbody>
                         <tr>
                             <td class="pbTitle">
-                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
+                                <img
+                                    src="/img/s.gif"
+                                    alt=""
+                                    class="minWidth"
+                                    title=""
+                                    width="1"
+                                    height="1"
+                                />
                                 <h2 class="mainTitle">鎶ュ憡涔︾紪杈�</h2>
                             </td>
-                            <td class="pbButton" id="topButtonRow" style="pointer-events: none; opacity: 0.4;">
-                                <input class="btn" type="Button" value="淇濆瓨" onclick="saveReportProcess('Save')" />
-                                <input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveReportProcess('SaveAndNew')" />
-                                <apex:commandButton action="{!cancel}" value="鍙栨秷" />
+                            <td
+                                class="pbButton"
+                                id="topButtonRow"
+                                style="pointer-events: none; opacity: 0.4"
+                            >
+                                <input
+                                    class="btn"
+                                    type="Button"
+                                    value="淇濆瓨"
+                                    onclick="saveReportProcess('Save')"
+                                />
+                                <input
+                                    class="btn"
+                                    type="Button"
+                                    value="淇濆瓨骞舵柊寤�"
+                                    onclick="saveReportProcess('SaveAndNew')"
+                                />
+                                <apex:commandButton
+                                    action="{!cancel}"
+                                    value="鍙栨秷"
+                                />
                             </td>
                         </tr>
                     </tbody>
                 </table>
             </div>
             <!-- Error Msg-->
-            <div style="text-align: center;">
+            <div style="text-align: center">
                 <apex:outputPanel id="errorMsg">
                     <apex:pageMessages id="msgContent" escape="false" />
                 </apex:outputPanel>
-            </div>          
-            <br/>
+            </div>
+            <br />
             <!-- Iterate the layoutSections, which is a list of sections -->
             <apex:repeat value="{!layoutSections}" var="layoutSection">
-                <apex:pageBlockSection title="{!layoutSection.name}" showHeader="{!layoutSection.useHeader}" collapsible="{!layoutSection.allowCollapse}"
-                    columns="{!layoutSection.columns}">
-
+                <apex:pageBlockSection
+                    title="{!layoutSection.name}"
+                    showHeader="{!layoutSection.useHeader}"
+                    collapsible="{!layoutSection.allowCollapse}"
+                    columns="{!layoutSection.columns}"
+                >
                     <!--Each section has layoutFields, let's iterate them as well-->
-                    <apex:repeat value="{!layoutSection.layoutFields}" var="layoutField">
-                        <apex:inputField html-title="{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}"  styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
-                            required="{!layoutField.isRequired}" />
-                        <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
+                    <apex:repeat
+                        value="{!layoutSection.layoutFields}"
+                        var="layoutField"
+                    >
+                        <!-- <apex:inputField html-title="{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}"  styleClass="{!ApiPrefix} {!ApiPrefix}_{!layoutField.fieldAPI}" value="{!Report__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
+                            required="{!layoutField.isRequired}" /> -->
+                        <apex:inputField
+                            styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}"
+                            html-data-id="{!layoutField.fieldAPI}"
+                            value="{!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="{!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="{!Report__c[layoutField.fieldAPI]}"
+                            rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}"
+                        />
+                        <apex:pageblocksectionitem
+                            rendered="{!layoutField.isPlaceHolder}"
+                        >
                         </apex:pageblocksectionitem>
                     </apex:repeat>
-
                 </apex:pageBlockSection>
             </apex:repeat>
             <script>
@@ -653,7 +775,7 @@
                         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);
@@ -681,7 +803,7 @@
 
                     //1. Set Last Name label
                     //document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[2].children[0].innerText = '濮撳悕';
-                    //2. Query AWS Data by dataId 
+                    //2. Query AWS Data by dataId
                     console.log('Mode for Lead Page:' + {!isNewMode});
                     if (!{!isNewMode}) {
                         QueryLeadFromAWS();
@@ -689,19 +811,22 @@
                     //Replace Vlookup Field
                     replaceSearchContactLookup();
                     //3. Set Readonly Attribute
-                    document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton");
+                    if(document.querySelector("[data-id='OwnerId']"))
+                        document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton");
 
                     //濡傛灉鏄疧PD璁″垝杩囨潵鐨�
                     if('{!no1Name}' != '' && '{!no1Id}' != ''){
                         console.log('name = '+'{!no1Name}')
                         console.log('Id = '+'{!no1Id}')
-                        document.querySelector("[data-id='Loaner_request_no1__c']").value = '{!no1Name}'
-                        document.getElementById(document.querySelector("[data-id='Loaner_request_no1__c']").id + '_lkid').value = '{!no1Id}'
+                        if(document.querySelector("[data-id='Loaner_request_no1__c']")){
+                            document.querySelector("[data-id='Loaner_request_no1__c']").value = '{!no1Name}'
+                            document.getElementById(document.querySelector("[data-id='Loaner_request_no1__c']").id + '_lkid').value = '{!no1Id}'
+                        }
                     }
-                    
-					document.getElementById('topButtonRow').style = '';
-聽 聽 聽 聽 聽 聽 聽document.getElementById('bottomButtonRow').style = '';
-                    
+
+                    document.getElementById('topButtonRow').style = '';
+                    document.getElementById('bottomButtonRow').style = '';
+
                     let previous_value = {};
                     jQuery(".lookupInput input").each(function(i,e){
                         let je =jQuery(e);
@@ -756,17 +881,41 @@
                     <tbody>
                         <tr>
                             <td class="pbTitle">
-                                <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />&nbsp;</td>
-                            <td class="pbButtonb" id="bottomButtonRow" style="pointer-events: none; opacity: 0.4;">
-                                <input class="btn" type="Button" value="淇濆瓨" onclick="saveReportProcess('Save')" />
-                                <input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveReportProcess('SaveAndNew')" />
-                                <apex:commandButton action="{!cancel}" value="鍙栨秷" />
+                                <img
+                                    src="/img/s.gif"
+                                    alt=""
+                                    class="minWidth"
+                                    title=""
+                                    width="1"
+                                    height="1"
+                                />&nbsp;
+                            </td>
+                            <td
+                                class="pbButtonb"
+                                id="bottomButtonRow"
+                                style="pointer-events: none; opacity: 0.4"
+                            >
+                                <input
+                                    class="btn"
+                                    type="Button"
+                                    value="淇濆瓨"
+                                    onclick="saveReportProcess('Save')"
+                                />
+                                <input
+                                    class="btn"
+                                    type="Button"
+                                    value="淇濆瓨骞舵柊寤�"
+                                    onclick="saveReportProcess('SaveAndNew')"
+                                />
+                                <apex:commandButton
+                                    action="{!cancel}"
+                                    value="鍙栨秷"
+                                />
                             </td>
                         </tr>
                     </tbody>
                 </table>
             </div>
         </apex:pageblock>
-
     </apex:form>
-</apex:page>
\ No newline at end of file
+</apex:page>

--
Gitblit v1.9.1