|  |  | 
 |  |  |     <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:includeScript value="{!URLFOR($Resource.connection20)}"/> | 
 |  |  |     <style> | 
 |  |  |         .disabledbutton { | 
 |  |  |             pointer-events: none; | 
 |  |  | 
 |  |  |     <script> | 
 |  |  |         //Initial Required Information | 
 |  |  |         var staticResources = JSON.parse('{!staticResource}'); | 
 |  |  |         //zhj MEBG新方案改造 2022-11-29 start | 
 |  |  |         var staticResourcesV2 = JSON.parse('{!staticResourceV2}'); | 
 |  |  |         var isEdit = JSON.parse('{!isEdit}'); | 
 |  |  |         var phoneNumber = ''; | 
 |  |  |         var directShippmentAddress = ''; | 
 |  |  |         //zhj MEBG新方案改造 2022-11-29 end | 
 |  |  |         var staticResourcesContact = JSON.parse('{!staticResourceContact}'); | 
 |  |  |         var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}'); | 
 |  |  |         var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}'); | 
 |  |  | 
 |  |  |         //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; | 
 |  |  |             // document.querySelector("[data-id='Phone_number__c']").value = data.object.phoneNumber; | 
 |  |  |             // document.querySelector("[data-id='direct_shippment_address__c']").value = data.object.directShippmentAddress; | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 start | 
 |  |  |             if(document.querySelector("[data-id='Phone_number__c']")){ | 
 |  |  |                 document.querySelector("[data-id='Phone_number__c']").value = data.object.phoneNumber; | 
 |  |  |                 phoneNumber = data.object.phoneNumber == null ? '': data.object.phoneNumber; | 
 |  |  |             } | 
 |  |  |                  | 
 |  |  |             if(document.querySelector("[data-id='direct_shippment_address__c']")){ | 
 |  |  |                 document.querySelector("[data-id='direct_shippment_address__c']").value = data.object.directShippmentAddress; | 
 |  |  |                 directShippmentAddress = data.object.directShippmentAddress == null ? '' : data.object.directShippmentAddress; | 
 |  |  |             } | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 end | 
 |  |  |             unblockUI(); | 
 |  |  |             enableButtonStatus();//Add by Li Jun 20220418 | 
 |  |  |         }; | 
 |  |  | 
 |  |  |             console.log('payloadJson=' + JSON.stringify(payloadJson)); | 
 |  |  |             payloadJson.Phone_number__c = r.object[0].phoneNumber; | 
 |  |  |             payloadJson.direct_shippment_address__c = r.object[0].directShippmentAddress; | 
 |  |  |             payloadJson.Phone_Number_Encrypt__c = r.object[0].phoneNumberEncrypt; | 
 |  |  |             payloadJson.Direct_Shippment_Address_Encrypt__c = r.object[0].directShippmentAddressEncrypt; | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 start | 
 |  |  |             // payloadJson.Phone_Number_Encrypt__c = r.object[0].phoneNumberEncrypt; | 
 |  |  |             // payloadJson.Direct_Shippment_Address_Encrypt__c = r.object[0].directShippmentAddressEncrypt; | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 end | 
 |  |  |             payloadJson.AWS_Data_Id__c = '{!AWSDataId}'; | 
 |  |  |             if('{!rtTypeId}'){ | 
 |  |  |                 payloadJson.RecordTypeId = '{!rtTypeId}';//Add by Li Jun for Record Type Issue 20220419 | 
 |  |  |             } | 
 |  |  |             | 
 |  |  |             if (isNewMode || {!isCloneMode}) { | 
 |  |  |                 payloadJson.AWS_Data_Id__c = r.object[0].dataId; | 
 |  |  |                 delete payloadJson.OwnerId; | 
 |  |  |             } else { | 
 |  |  |                 payloadJson.AWS_Data_Id__c = '{!AWSDataId}'; | 
 |  |  |             } | 
 |  |  |             debugger | 
 |  |  |             if('{!rtTypeId}'){ | 
 |  |  |                 payloadJson.RecordTypeId = '{!rtTypeId}';//Add by zhj for Record Type Issue 20220421 | 
 |  |  |             } | 
 |  |  |             return payloadJson; | 
 |  |  |         } | 
 |  |  |         //Add Button status start 20220418 | 
 |  |  | 
 |  |  |         disableButtonStatus(); | 
 |  |  |         //Add Button status end 20220418  | 
 |  |  |         // New Or Edit | 
 |  |  |  | 
 |  |  |         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 ProcessPI(rentalApplyJson, payloadForNewPI) { | 
 |  |  |             blockme(); | 
 |  |  |             if ({!isNewMode} || {!isCloneMode}) { | 
 |  |  | 
 |  |  |             let obj = JSON.parse(payloadForNewPI); | 
 |  |  |             obj[0].dataId = '{!AWSDataId}'; | 
 |  |  |             let payloadForNewPIJson = JSON.stringify(obj); | 
 |  |  |             AWSService.update(staticResources.updateUrl, rentalApplyJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack); | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 start | 
 |  |  |             //AWSService.update(staticResources.updateUrl, rentalApplyJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack); | 
 |  |  |             AWSService.update(staticResourcesV2.updateUrl, rentalApplyJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResourcesV2.transactionUrl, false, insertOrUpdateBack, redirectCallBack); | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 end | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //Insert Sensitive Information to AWS | 
 |  |  |         function NewPIToAWS(rentalApplyJson, payloadForNewPI) { | 
 |  |  |             let controllerSaveMethod = '{!$RemoteAction.RentalApplyController.saveRentalApply}'; | 
 |  |  |             AWSService.insert(staticResources.newUrl, rentalApplyJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack); | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 start | 
 |  |  |             //AWSService.insert(staticResources.newUrl, rentalApplyJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack); | 
 |  |  |             debugger | 
 |  |  |             console.log('staticResourcesV2.newUrl = ' + staticResourcesV2.newUrl); | 
 |  |  |             AWSService.insert(staticResourcesV2.newUrl, rentalApplyJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResourcesV2.transactionUrl, true, insertOrUpdateBack, redirectCallBack); | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 end | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //Check Required Fields | 
 |  |  |         function checkRequiredFieldMsg(formData) { | 
 |  |  |             let blankRequiredFields = ''; | 
 |  |  |             for (i = 0; i < requiredFieldAPIList.length; i++) { | 
 |  |  |                 if (formData[requiredFieldAPIList[i]]) { | 
 |  |  |                 if (formData[requiredFieldAPIList[i]] && !VLookUpFields.has(requiredFieldAPIList[i])) { | 
 |  |  |                     continue; | 
 |  |  |                 }else if(VLookUpFields.has(requiredFieldAPIList[i]) && formData[requiredFieldAPIList[i]] != '000000000000000'){ | 
 |  |  |                     continue; | 
 |  |  |                 } else { | 
 |  |  |                     if (blankRequiredFields == '') { | 
 |  |  | 
 |  |  |  | 
 |  |  |         //Base Process | 
 |  |  |         function saveRentalApplyProcess(saveMode) { | 
 |  |  |             EditButton(true); | 
 |  |  |             redirectMode = saveMode; | 
 |  |  |             console.log('redirectMode' + redirectMode); | 
 |  |  |             hiddenErrorMsgNode(); | 
 |  |  | 
 |  |  |             //3. Prepare the payload for New PI API To AWS - To Do | 
 |  |  |             let payloadForNewPI = getPIPayload(rentalApplyJson); | 
 |  |  |  | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 start | 
 |  |  |             debugger | 
 |  |  |             if(isEdit == true && (rentalApplyJson.Phone_number__c != phoneNumber || rentalApplyJson.direct_shippment_address__c != directShippmentAddress)){ | 
 |  |  |                 alertErrorMessage('申请单批准后,不能编辑备品借用信息'); | 
 |  |  |                 return | 
 |  |  |             } | 
 |  |  |             //zhj MEBG新方案改造 2022-11-29 end | 
 |  |  |  | 
 |  |  |             //4. rentalApply to AWS  | 
 |  |  |             ProcessPI(rentalApplyJson, payloadForNewPI); | 
 |  |  |         } | 
 |  |  | 
 |  |  |             errorMsgNode.innerText = errorMsg; | 
 |  |  |             errorMsgNode.className = 'pbError'; | 
 |  |  |             unblockUI(); | 
 |  |  |             EditButton(false); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //Hide Error Message | 
 |  |  | 
 |  |  |                 </apex:pageBlockSection> | 
 |  |  |             </apex:repeat> | 
 |  |  |             <script> | 
 |  |  |                 blockme(); //zhj 2022-12-28 improve | 
 |  |  |                var init_nodes = document.getElementsByClassName("PIBackApi"); | 
 |  |  |                 var api_id_map={}; | 
 |  |  |                 for(let ei in init_nodes){ | 
 |  |  | 
 |  |  |                     console.log(onlyReadFields); | 
 |  |  |                     for(let i=0;i<onlyReadFields.length;i++){ | 
 |  |  |                         if(document.querySelector('[data-id='+onlyReadFields[i]+']')){ | 
 |  |  |                            document.querySelector('[data-id='+onlyReadFields[i]+']').parentNode.remove(); | 
 |  |  |                             document.querySelector('[data-id='+onlyReadFields[i]+']').parentNode.remove(); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                      | 
 |  |  |                     //2. Query AWS Data by dataId  | 
 |  |  |                     console.log('Mode for rentalApply Page:' + {!isNewMode}); | 
 |  |  |                     if (!{!isNewMode}) { | 
 |  |  |                         blockme(); | 
 |  |  |                         QueryRentalApplyFromAWS(); | 
 |  |  |                     }else{ | 
 |  |  |                         enableButtonStatus();//Add by Li Jun 20220418 | 
 |  |  | 
 |  |  |                             } | 
 |  |  |                         }) | 
 |  |  |                     }); | 
 |  |  |  | 
 |  |  |                     unblockUI(); | 
 |  |  |                                          | 
 |  |  |  | 
 |  |  |  |