From bfca7a84bec815da594f1d12558535ed06d2490b Mon Sep 17 00:00:00 2001
From: 沙世明 <shashiming@prec-tech.com>
Date: 星期二, 13 九月 2022 09:57:32 +0800
Subject: [PATCH] 本地提交备份

---
 force-app/main/default/pages/NewConsumApply.page |   90 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 68 insertions(+), 22 deletions(-)

diff --git a/force-app/main/default/pages/NewConsumApply.page b/force-app/main/default/pages/NewConsumApply.page
index 588c175..caa93fc 100644
--- a/force-app/main/default/pages/NewConsumApply.page
+++ b/force-app/main/default/pages/NewConsumApply.page
@@ -10,7 +10,7 @@
     <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
     <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:includeScript value="{!URLFOR($Resource.connection20)}"/>
     <style>
         .disabledbutton {
             pointer-events: none;
@@ -23,9 +23,23 @@
         var staticResourcesContact = JSON.parse('{!staticResourceContact}');
         var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}');
         var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}');
-        var VLookUpFields = new Set(['Loaner_medical_Staff__c', 'Hospital__c', 'Strategic_dept__c', 'Account__c', 'QIS_number__c', 'OPDPlan__c', 'Campaign__c', 'Rental_Apply__c', 'Shipment_address__c', 'Dealer__c', 'Old_Consum_Apply__c', 'DeliverySlip__c', 'OwnerId', 'OPD__c']);
-        var userVLookUpFields = ['Person_In_Charge__c', 'applyUser__c', 'CC_EmailUser__c', 'Assign_Person__c', 'Consum_Assistant__c', 'Consum_Assistant2__c', 'Consum_Assistant3__c', 'SalesManager__c', 'ZongjianApprovalManager__c', 'BuchangApprovalManagerSales__c', 'TongkuoZongjian__c'];
+        //var VLookUpFields = new Set(['Loaner_medical_Staff__c', 'Hospital__c', 'Strategic_dept__c', 'Account__c', 'QIS_number__c', 'OPDPlan__c', 'Campaign__c', 'Rental_Apply__c', 'Shipment_address__c', 'Dealer__c', 'Old_Consum_Apply__c', 'DeliverySlip__c', 'OwnerId', 'OPD__c']);
+        var VLookUpFields = {! VLookUpFieldsJson};
+        // var userVLookUpFields = ['Person_In_Charge__c', 'applyUser__c', 'CC_EmailUser__c', 'Assign_Person__c', 'Consum_Assistant__c', 'Consum_Assistant2__c', 'Consum_Assistant3__c', 'SalesManager__c', 'ZongjianApprovalManager__c', 'BuchangApprovalManagerSales__c', 'TongkuoZongjian__c'];
         var redirectMode = 'Save';
+
+        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");
+            }
+        }
 
         //Redirect Required Parameter
         var redirectCallBack = function redirectCallBack(sfId,errorMessage) {
@@ -44,8 +58,10 @@
         //Query Required Parameter
         var queryBack = function queryBack(data) {
             console.log('data = ' + data);
-            document.querySelector("[data-id='Phone_number__c']").value = data.object.phoneNumber;
-            document.querySelector("[data-id='direct_shippment_address__c']").value = data.object.directShippmentAddress;
+            if(document.querySelector("[data-id='Phone_number__c']"))
+                document.querySelector("[data-id='Phone_number__c']").value = data.object.phoneNumber;
+            if(document.querySelector("[data-id='direct_shippment_address__c']"))
+                document.querySelector("[data-id='direct_shippment_address__c']").value = data.object.directShippmentAddress;
             unblockUI();
         };
 
@@ -62,8 +78,12 @@
             payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
             if (isNewMode || {!isCloneMode}) {
                 payloadJson.AWS_Data_Id__c = r.object[0].dataId;
+                delete payloadJson.OwnerId;
             } else {
                 payloadJson.AWS_Data_Id__c = '{!AWSDataId}';
+            }
+            if('{!rtTypeId}'){
+                payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421
             }
             return payloadJson;
         }
@@ -127,12 +147,25 @@
                 result.HP_received_sign_rich__c = document.querySelector("[aria-describedby = 'cke_34']").contentWindow.document.getElementsByTagName('body')[0].innerHTML
             } 
             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;
@@ -151,15 +184,15 @@
                     index++;
                 }
             }
-            for (let i = 0; i < userVLookUpFields.length; i++) {
-                if(document.querySelector("[data-id='" + userVLookUpFields[i] + "']")!=null){
-                    let userVlookUpNodeValue = document.querySelector("[data-id='" + userVLookUpFields[i] + "']").children[1].value;
-                    console.log('userVlookUpNodeValue:'+userVlookUpNodeValue);
-                    if(userVlookUpNodeValue!='000000000000000'){
-                        result[userVLookUpFields[i]] = userVlookUpNodeValue;
-                    }
-                }
-            }
+            // for (let i = 0; i < userVLookUpFields.length; i++) {
+            //     if(document.querySelector("[data-id='" + userVLookUpFields[i] + "']")!=null){
+            //         let userVlookUpNodeValue = document.querySelector("[data-id='" + userVLookUpFields[i] + "']").children[1].value;
+            //         console.log('userVlookUpNodeValue:'+userVlookUpNodeValue);
+            //         if(userVlookUpNodeValue!='000000000000000'){
+            //             result[userVLookUpFields[i]] = userVlookUpNodeValue;
+            //         }
+            //     }
+            // }
             //鏍煎紡鍖栨椂闂�
             if(result.pickup_time__c){
                 result.pickup_time__c = result.pickup_time__c.replace(/\//g, '-')+':00';
@@ -216,7 +249,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'&&formData[requiredFieldAPIList[i]] != ''){
                     continue;
                 } else {
                     if (blankRequiredFields == '') {
@@ -232,6 +267,8 @@
 
         //Base Process
         function saveConsumApplyProcess(saveMode) {
+            EditButton(true);
+            
             redirectMode = saveMode;
             console.log('redirectMode' + redirectMode);
             hiddenErrorMsgNode();
@@ -265,6 +302,7 @@
             errorMsgNode.innerText = errorMsg;
             errorMsgNode.className = 'pbError';
             unblockUI();
+            EditButton(false);
         }
 
         //Hide Error Message
@@ -298,7 +336,8 @@
             let dataId = contactsInfo[sfId];
             let url = staticResourcesContact.queryUrl + '?dataId=' + dataId;
             let queryBackContactName = function queryBackContactName(result){
-                document.querySelector("[data-id='Loaner_medical_Staff__c']").value = result.object.lastName;
+                if(document.querySelector("[data-id='Loaner_medical_Staff__c']"))
+                    document.querySelector("[data-id='Loaner_medical_Staff__c']").value = result.object.lastName;
                 //document.querySelector("[data-id='LastName']").value = result.object.lastName;
             };
             AWSService.query(staticResourcesContact.queryUrl, dataId, queryBackContactName, staticResourcesContact.token);
@@ -380,7 +419,7 @@
                                 <img src="/img/s.gif" alt="" class="minWidth" title="" width="1" height="1" />
                                 <h2 class="mainTitle">鑰楁潗澶囧搧鐢宠缂栬緫</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="淇濆瓨" onclick="saveConsumApplyProcess('Save')" />
                                 <input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveConsumApplyProcess('SaveAndNew')" />
                                 <apex:commandButton action="{!cancel}" value="鍙栨秷" />
@@ -401,8 +440,12 @@
 
                     <!--Each section has layoutFields, let's iterate them as well-->
                     <apex:repeat value="{!layoutSection.layoutFields}" var="layoutField">
-                        <apex:inputField html-data-id="{!layoutField.fieldAPI}" value="{!Consum_Apply__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}"
+                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Consum_Apply__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&isNewMode}"
                             required="{!layoutField.isRequired}" />
+                        <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Consum_Apply__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="{!Consum_Apply__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)&&not(isNewMode)&&layoutField.fieldAPI=='RecordTypeId'}"
+                       />
                         <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}">
                         </apex:pageblocksectionitem>
                     </apex:repeat>
@@ -455,6 +498,9 @@
                     //Replace Vlookup Field
                     replaceSearchContactLookup();
                     document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton");
+                    
+                    document.getElementById('topButtonRow').style = '';
+聽 聽 聽 聽 聽 聽 聽document.getElementById('bottomButtonRow').style = '';
 
                     let previous_value = {};
                     jQuery(".lookupInput input").each(function(i,e){
@@ -512,7 +558,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="淇濆瓨" onclick="saveConsumApplyProcess('Save')" />
                                 <input class="btn" type="Button" value="淇濆瓨骞舵柊寤�" onclick="saveConsumApplyProcess('SaveAndNew')" />
                                 <apex:commandButton action="{!cancel}" value="鍙栨秷" />

--
Gitblit v1.9.1