|  |  |  | 
|---|
|  |  |  | @description       : | 
|---|
|  |  |  | @author            : ChangeMeIn@UserSettingsUnder.SFDoc | 
|---|
|  |  |  | @group             : | 
|---|
|  |  |  | @last modified on  : 03-17-2022 | 
|---|
|  |  |  | @last modified on  : 03-23-2022 | 
|---|
|  |  |  | @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc | 
|---|
|  |  |  | --> | 
|---|
|  |  |  | <apex:page standardController="Repair__c" extensions="NewRepairController" id="page"> | 
|---|
|  |  |  | 
|---|
|  |  |  | </style> | 
|---|
|  |  |  | <script> | 
|---|
|  |  |  | //Initial Required Information | 
|---|
|  |  |  | var staticResourceContact = JSON.parse('{!staticResourceContact}'); | 
|---|
|  |  |  | var staticResourceAddress = JSON.parse('{!staticResourceAddress}'); | 
|---|
|  |  |  | var staticResources = JSON.parse('{!staticResource}'); | 
|---|
|  |  |  | 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='address_Contacts__c']").value = data.object.addressContacts; | 
|---|
|  |  |  | document.querySelector("[data-id='address_Contacts_Name__c']").value = data.object.addressContactsName; | 
|---|
|  |  |  | document.querySelector("[data-id='address_Telephone__c']").value = data.object.addressTelephone; | 
|---|
|  |  |  | document.querySelector("[data-id='address_ZipCode__c']").value = data.object.addressZipCode; | 
|---|
|  |  |  | document.querySelector("[data-id='Detailed_Address__c']").value = data.object.detailedAddress; | 
|---|
|  |  |  | document.querySelector("[data-id='RepairApplicant__c']").value = data.object.repairApplicant; | 
|---|
|  |  |  | unblockUI(); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | // var queryBack = function queryBack(data) { | 
|---|
|  |  |  | //     console.log('data = ' + data); | 
|---|
|  |  |  | //     document.querySelector("[data-id='address_Contacts__c']").value = data.object.addressContacts; | 
|---|
|  |  |  | //     document.querySelector("[data-id='address_Contacts_Name__c']").value = data.object.addressContactsName; | 
|---|
|  |  |  | //     document.querySelector("[data-id='address_Telephone__c']").value = data.object.addressTelephone; | 
|---|
|  |  |  | //     document.querySelector("[data-id='address_ZipCode__c']").value = data.object.addressZipCode; | 
|---|
|  |  |  | //     document.querySelector("[data-id='Detailed_Address__c']").value = data.object.detailedAddress; | 
|---|
|  |  |  | //     document.querySelector("[data-id='RepairApplicant__c']").value = data.object.repairApplicant; | 
|---|
|  |  |  | //     unblockUI(); | 
|---|
|  |  |  | // }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //Check If Insert Or Update | 
|---|
|  |  |  | var insertOrUpdateBack = function insertOrUpdateBack(payloadJson, result, isNewMode) { | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(document.getElementById(vlookUpNodeId)!=null){ | 
|---|
|  |  |  | let vlookUpNodeValue = document.getElementById(vlookUpNodeId).value; | 
|---|
|  |  |  | result[nodelist[index].getAttribute("data-id")] = vlookUpNodeValue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (nodelist[index].type == 'checkbox') { | 
|---|
|  |  |  | result[nodelist[index].getAttribute("data-id")] = nodelist[index].checked; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (let i = 0; i < userVLookUpFields.length; i++) { | 
|---|
|  |  |  | let userVlookUpNodeValue = document.querySelector("[data-id='" + userVLookUpFields[i] + "']").children[1].value; | 
|---|
|  |  |  | console.log('userVlookUpNodeValue:'+userVlookUpNodeValue); | 
|---|
|  |  |  | if(userVlookUpNodeValue!='000000000000000'){ | 
|---|
|  |  |  | result[userVLookUpFields[i]] = userVlookUpNodeValue; | 
|---|
|  |  |  | if(document.querySelector("[data-id='" + userVLookUpFields[i] + "']")!=null){ | 
|---|
|  |  |  | // let userVlookUpNodeValue = document.querySelector("[data-id='" + userVLookUpFields[i] + "']").children[1].value; | 
|---|
|  |  |  | let userVlookUpNodeValue = jQuery('[data-id="Incharge_Staff__c"] .lookupInput input').val() | 
|---|
|  |  |  | console.log('userVlookUpNodeValue:'+userVlookUpNodeValue); | 
|---|
|  |  |  | if(userVlookUpNodeValue!='000000000000000'){ | 
|---|
|  |  |  | result[userVLookUpFields[i]] = userVlookUpNodeValue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | result.work_location_select__c = document.querySelector("[id='page:form:j_id30:j_id34:1:j_id35:j_id36:18:j_id37']").value; | 
|---|
|  |  |  | result.work_location_select__c = document.querySelector("[id='page:form:block:j_id34:1:j_id35:j_id36:18:j_id37']").value; | 
|---|
|  |  |  | // result.ProblemDescription__c = document.querySelector("[aria-describedby = 'cke_34']").contentWindow.document.getElementsByTagName('body')[0].innerHTML | 
|---|
|  |  |  | /* | 
|---|
|  |  |  | if(result.engineerSendDate__c){ | 
|---|
|  |  |  | result.engineerSendDate__c = result.engineerSendDate__c.replace(/\//g, '-')+':00'; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | console.log(JSON.stringify(result)); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | function QueryRepairFromAWS() { | 
|---|
|  |  |  | AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | var queryBack = function queryBack(data) { | 
|---|
|  |  |  | console.log(data); | 
|---|
|  |  |  | document.querySelector("[data-id='address_Contacts__c']").innerHTML = data.object.addressContacts; | 
|---|
|  |  |  | document.querySelector("[data-id='address_Contacts_Name__c']").innerHTML = data.object.addressContactsName; | 
|---|
|  |  |  | document.querySelector("[data-id='address_Telephone__c']").innerHTML = data.object.addressTelephone; | 
|---|
|  |  |  | document.querySelector("[data-id='address_ZipCode__c']").innerHTML = data.object.addressZipCode; | 
|---|
|  |  |  | document.querySelector("[data-id='Detailed_Address__c']").innerHTML = data.object.detailedAddress; | 
|---|
|  |  |  | document.querySelector("[data-id='RepairApplicant__c']").innerHTML = data.object.repairApplicant; | 
|---|
|  |  |  | AWSService.query(staticResourceAddress.queryUrl, '{!DecryptAWSDataId}', queryBackDecrypt, staticResourceAddress.token); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | var queryBackContact = function queryBack(data) { | 
|---|
|  |  |  | console.log(data); | 
|---|
|  |  |  | document.querySelector("[data-id='address_Contacts__c']").innerHTML = data.object.lastName; | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | var queryBackDecrypt = function queryBack(data) { | 
|---|
|  |  |  | document.querySelector("[data-id='Detailed_Address__c']").innerHTML = data.object.detailedAddress; | 
|---|
|  |  |  | document.querySelector("[data-id='address_ZipCode__c']").innerHTML = data.object.zipCode; | 
|---|
|  |  |  | document.querySelector("[data-id='address_Telephone__c']").innerHTML = data.object.telephone; | 
|---|
|  |  |  | AWSService.query(staticResourceContact.queryUrl, '{!ContactAWSDataId}', queryBackContact, staticResourceContact.token); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //Update Sensitive Information to AWS | 
|---|
|  |  |  | function UpdatePIToAWS(repairJson, payloadForNewPI) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //Alert Error Message | 
|---|
|  |  |  | function alertErrorMessage(errorMsg) { | 
|---|
|  |  |  | let errorMsgNode = document.getElementById("page:form:msgContent"); | 
|---|
|  |  |  | let errorMsgNode = document.getElementById("page:form:block:msgContent"); | 
|---|
|  |  |  | errorMsg = '错误:无效数据。' + '\n' + errorMsg; | 
|---|
|  |  |  | errorMsgNode.innerText = errorMsg; | 
|---|
|  |  |  | errorMsgNode.className = 'pbError'; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //Hide Error Message | 
|---|
|  |  |  | function hiddenErrorMsgNode() { | 
|---|
|  |  |  | let errorMsgNode = document.getElementById("page:form:msgContent"); | 
|---|
|  |  |  | let errorMsgNode = document.getElementById("page:form:block:msgContent"); | 
|---|
|  |  |  | errorMsgNode.innerText = ''; | 
|---|
|  |  |  | errorMsgNode.className = ''; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | <div class="ptBreadcrumb"></div> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <apex:form id="form"> | 
|---|
|  |  |  | <!-- Error Msg--> | 
|---|
|  |  |  | <apex:outputPanel id="errorMsg"> | 
|---|
|  |  |  | <apex:pageMessages id="msgContent" escape="false" /> | 
|---|
|  |  |  | </apex:outputPanel> | 
|---|
|  |  |  | <apex:pageblock > | 
|---|
|  |  |  | <apex:pageblock id="block"> | 
|---|
|  |  |  | <div class="pbHeader"> | 
|---|
|  |  |  | <table cellspacing="0" cellpadding="0" border="0"> | 
|---|
|  |  |  | <tbody> | 
|---|
|  |  |  | 
|---|
|  |  |  | </tbody> | 
|---|
|  |  |  | </table> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <!-- Error Msg--> | 
|---|
|  |  |  | <div style="text-align: center;"> | 
|---|
|  |  |  | <apex:outputPanel id="errorMsg"> | 
|---|
|  |  |  | <apex:pageMessages id="msgContent" escape="false" /> | 
|---|
|  |  |  | </apex:outputPanel> | 
|---|
|  |  |  | </div> | 
|---|
|  |  |  | <!-- Iterate the layoutSections, which is a list of sections --> | 
|---|
|  |  |  | <apex:repeat value="{!layoutSections}" var="layoutSection"> | 
|---|
|  |  |  | <apex:pageBlockSection title="{!layoutSection.name}" 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-data-id="{!layoutField.fieldAPI}" value="{!Repair__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" | 
|---|
|  |  |  | <apex:inputField styleClass="PIBackApi PIBackApi_{!layoutField.fieldAPI}" html-data-id="{!layoutField.fieldAPI}" value="{!Repair__c[layoutField.fieldAPI]}" rendered="{!not(layoutField.isPlaceHOlder)}" | 
|---|
|  |  |  | required="{!layoutField.isRequired}" /> | 
|---|
|  |  |  | <apex:pageblocksectionitem rendered="{!layoutField.isPlaceHolder}"> | 
|---|
|  |  |  | </apex:pageblocksectionitem> | 
|---|
|  |  |  | 
|---|
|  |  |  | }; | 
|---|
|  |  |  | document.querySelector("[data-id='OwnerId']").classList.add("disabledbutton"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | jQuery(".lookupInput").each(function(i,e){ | 
|---|
|  |  |  | let je =jQuery(e).find('input'); | 
|---|
|  |  |  | je.attr("readonly",""); | 
|---|
|  |  |  | je.css("background","unset"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let previous_value = {}; | 
|---|
|  |  |  | jQuery(".lookupInput input").each(function(i,e){ | 
|---|
|  |  |  | let je =jQuery(e); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | let dataid = je.attr('data-id'); | 
|---|
|  |  |  | if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return; | 
|---|
|  |  |  | jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){ | 
|---|
|  |  |  | this.className = "closeIconOn"; | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){ | 
|---|
|  |  |  | this.className = "closeIcon" | 
|---|
|  |  |  | }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | jQuery(".lookupInput").on("click","img[generate]",function(e){ | 
|---|
|  |  |  | let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id"); | 
|---|
|  |  |  | let input = document.getElementById(id); | 
|---|
|  |  |  | if(input){ | 
|---|
|  |  |  | input.value = ''; | 
|---|
|  |  |  | let hidden = document.getElementById(id+'_lkid'); | 
|---|
|  |  |  | if(hidden){ | 
|---|
|  |  |  | hidden.value = ''; | 
|---|
|  |  |  | if(['Incharge_Staff_Contact__c'].indexOf(dataid) < 0) return; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | jQuery(e).focus(function(){ | 
|---|
|  |  |  | previous_value[this.id] = this.value; | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | jQuery(e).change(function(){ | 
|---|
|  |  |  | if (previous_value[this.id] != jQuery(this).val()) { | 
|---|
|  |  |  | document.getElementById(this.id+'_lkid').value = ''; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // jQuery(".lookupInput").each(function(i,e){ | 
|---|
|  |  |  | //     let je =jQuery(e).find('input'); | 
|---|
|  |  |  | //     je.attr("readonly",""); | 
|---|
|  |  |  | //     je.css("background","unset"); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //     let dataid = je.attr('data-id'); | 
|---|
|  |  |  | //     if(['Hospital_Name__c','Department_Class__c','OwnerId'].indexOf(dataid) > -1) return; | 
|---|
|  |  |  | //     jQuery(e).children(":last-child").before('<img class="closeIcon" data-id="'+dataid+'" generate="" alt="Clear" src="/s.gif" style="display: inline-block;">'); | 
|---|
|  |  |  | // }) | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // jQuery(".lookupInput").on("mouseenter","img[generate]",function(e){ | 
|---|
|  |  |  | //     this.className = "closeIconOn"; | 
|---|
|  |  |  | // }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // jQuery(".lookupInput").on("mouseleave","img[generate]",function(e){ | 
|---|
|  |  |  | //     this.className = "closeIcon" | 
|---|
|  |  |  | // }); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // jQuery(".lookupInput").on("click","img[generate]",function(e){ | 
|---|
|  |  |  | //     let id = jQuery("input[data-id='"+jQuery(this).attr("data-id")+ "']").attr("id"); | 
|---|
|  |  |  | //     let input = document.getElementById(id); | 
|---|
|  |  |  | //     if(input){ | 
|---|
|  |  |  | //         input.value = ''; | 
|---|
|  |  |  | //         let hidden = document.getElementById(id+'_lkid'); | 
|---|
|  |  |  | //         if(hidden){ | 
|---|
|  |  |  | //             hidden.value = ''; | 
|---|
|  |  |  | //         } | 
|---|
|  |  |  | //     } | 
|---|
|  |  |  | // }); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | </script> | 
|---|
|  |  |  | <div class="pbBottomButtons"> | 
|---|