| | |
| | | <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; |
| | |
| | | var staticResourceContact = JSON.parse('{!staticResourceContact}'); |
| | | var staticResourceAddress = JSON.parse('{!staticResourceAddress}'); |
| | | var staticResources = JSON.parse('{!staticResource}'); |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | var staticResourcesV2 = JSON.parse('{!staticResourceV2}'); |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | var requiredFieldAPIList = JSON.parse('{!requiredFieldAPIListStr}'); |
| | | var fieldAPIToLabelMap = JSON.parse('{!fieldAPIToLabelMapStr}'); |
| | | var VLookUpFields = new Set(['Delivered_Product__c','Hospital__c','Department_Class__c','Account__c','Dealer__c','Incharge_Staff_Contact__c','Maintenance_Contract__c','VM_Maintenance_Contract__c','Repair_Quotation_Id__c','RepairSubOrder__c','On_Call_ID__c','QIS_ID__c','InsReport__c','NFM108_Receipt__c','Rental_Apply_Equipment_Set_Detail__c']); |
| | | var userVLookUpFields = ['Incharge_Staff__c','Repair_Authenticator__c','OCSM_RC_CordingUser__c','OSH_Affirmant__c','OSHRAConfirmUser__c']; |
| | | //var VLookUpFields = new Set(['Source_QIS__c', 'AC_PAED__c', 'RC_PAED__c', 'Delivered_Product__c','Maintenance_Contract_Asset_Estimate__c','Asset__c','TransferApplyDetail__c','Hospital__c','Department_Class__c','Account__c','Dealer__c','Incharge_Staff_Contact__c','Maintenance_Contract__c','Repair_Alternative_ProductList_c__c','VM_Maintenance_Contract__c','Repair_Quotation_Id__c','RepairSubOrder__c','On_Call_ID__c','QIS_ID__c','InsReport__c','NFM108_Receipt__c','Rental_Apply_Equipment_Set_Detail__c']); |
| | | var VLookUpFields = {! VLookUpFieldsJson}; |
| | | var userVLookUpFields = ['Incharge_Staff__c','Repair_Authenticator__c','OCSM_RC_CordingUser__c','OSH_Affirmant__c','OSHRAConfirmUser__c', 'Repair_Determine_result_ConfirmationUser__c', 'ZongjianApprovalManager__c', 'BuchangApprovalManager__c', 'JingliApprovalManager__c', 'Repair_complete_asset_final_check_staff__c', '']; |
| | | var redirectMode = 'Save'; |
| | | |
| | | //Redirect Required Parameter |
| | |
| | | payloadJson.address_ZipCode__c = r.object[0].addressZipCode; |
| | | payloadJson.Detailed_Address__c = r.object[0].detailedAddress; |
| | | payloadJson.RepairApplicant__c = r.object[0].repairApplicant; |
| | | payloadJson.Address_Contacts_Encrypt__c = r.object[0].addressContactsEncrypt; |
| | | payloadJson.Address_Contacts_Name_Encrypt__c = r.object[0].addressContactsNameEncrypt; |
| | | payloadJson.Address_Telephone_Encrypt__c = r.object[0].addressTelephoneEncrypt; |
| | | payloadJson.Address_ZipCode_Encrypt__c = r.object[0].addressZipCodeEncrypt; |
| | | payloadJson.Detailed_Address_Encrypt__c = r.object[0].detailedAddressEncrypt; |
| | | payloadJson.Repair_Applicant_Encrypt__c = r.object[0].repairApplicantEncrypt; |
| | | // payloadJson.Address_Contacts_Encrypt__c = r.object[0].addressContactsEncrypt; |
| | | // payloadJson.Address_Contacts_Name_Encrypt__c = r.object[0].addressContactsNameEncrypt; |
| | | // payloadJson.Address_Telephone_Encrypt__c = r.object[0].addressTelephoneEncrypt; |
| | | // payloadJson.Address_ZipCode_Encrypt__c = r.object[0].addressZipCodeEncrypt; |
| | | // payloadJson.Detailed_Address_Encrypt__c = r.object[0].detailedAddressEncrypt; |
| | | // payloadJson.Repair_Applicant_Encrypt__c = r.object[0].repairApplicantEncrypt; |
| | | payloadJson.AWS_Data_Id__c = '{!AWSDataId}'; |
| | | if (isNewMode) { |
| | | payloadJson.AWS_Data_Id__c = r.object[0].dataId; |
| | |
| | | let nodelist = document.querySelectorAll("[data-id]"); |
| | | let result = {} |
| | | 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'; |
| | | if(document.getElementById(vlookUpNodeId)!=null){ |
| | | 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; |
| | |
| | | console.log(JSON.stringify(result)); |
| | | return result; |
| | | } |
| | | |
| | | 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"); |
| | | } |
| | | } |
| | | //Query from AWS |
| | | 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']").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; |
| | | if(document.querySelector("[data-id='address_Contacts__c']")) |
| | | document.querySelector("[data-id='address_Contacts__c']").value = data.object.addressContacts; |
| | | if(document.querySelector("[data-id='address_Contacts_Name__c']")) |
| | | document.querySelector("[data-id='address_Contacts_Name__c']").value = data.object.addressContactsName; |
| | | if(document.querySelector("[data-id='address_Telephone__c']")) |
| | | document.querySelector("[data-id='address_Telephone__c']").value = data.object.addressTelephone; |
| | | if(document.querySelector("[data-id='address_ZipCode__c']")) |
| | | document.querySelector("[data-id='address_ZipCode__c']").value = data.object.addressZipCode; |
| | | if(document.querySelector("[data-id='Detailed_Address__c']")) |
| | | document.querySelector("[data-id='Detailed_Address__c']").value = data.object.detailedAddress; |
| | | if(document.querySelector("[data-id='RepairApplicant__c']")) |
| | | document.querySelector("[data-id='RepairApplicant__c']").value = 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']").value = data.object.lastName; |
| | | if(document.querySelector("[data-id='address_Contacts__c']")) |
| | | document.querySelector("[data-id='address_Contacts__c']").value = data.object.lastName; |
| | | }; |
| | | var queryBackDecrypt = function queryBack(data) { |
| | | document.querySelector("[data-id='Detailed_Address__c']").value = data.object.detailedAddress; |
| | | document.querySelector("[data-id='address_ZipCode__c']").value = data.object.zipCode; |
| | | document.querySelector("[data-id='address_Telephone__c']").value = data.object.telephone; |
| | | if(document.querySelector("[data-id='Detailed_Address__c']")) |
| | | document.querySelector("[data-id='Detailed_Address__c']").value = data.object.detailedAddress; |
| | | if(document.querySelector("[data-id='address_ZipCode__c']")) |
| | | document.querySelector("[data-id='address_ZipCode__c']").value = data.object.zipCode; |
| | | if(document.querySelector("[data-id='address_Telephone__c']")) |
| | | document.querySelector("[data-id='address_Telephone__c']").value = data.object.telephone; |
| | | AWSService.query(staticResourceContact.queryUrl, '{!ContactAWSDataId}', queryBackContact, staticResourceContact.token); |
| | | } |
| | | |
| | |
| | | let obj = JSON.parse(payloadForNewPI); |
| | | obj[0].dataId = '{!AWSDataId}'; |
| | | let payloadForNewPIJson = JSON.stringify(obj); |
| | | AWSService.update(staticResources.updateUrl, repairJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack); |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | //AWSService.update(staticResources.updateUrl, repairJson, payloadForNewPIJson, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack); |
| | | AWSService.update(staticResourcesV2.updateUrl, repairJson, payloadForNewPIJson, controllerSaveMethod, staticResourcesV2.token, staticResources.transactionUrl, false, insertOrUpdateBack, redirectCallBack); |
| | | //zhj MEBG新方案改造 2022-11-29 end |
| | | } |
| | | |
| | | //Insert Sensitive Information to AWS |
| | | function NewPIToAWS(repairJson, payloadForNewPI) { |
| | | let controllerSaveMethod = '{!$RemoteAction.NewRepairController.saveRepair}'; |
| | | AWSService.insert(staticResources.newUrl, repairJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack); |
| | | //zhj MEBG新方案改造 2022-11-29 start |
| | | //AWSService.insert(staticResources.newUrl, repairJson, payloadForNewPI, controllerSaveMethod, staticResources.token, staticResources.transactionUrl, true, insertOrUpdateBack, redirectCallBack); |
| | | AWSService.insert(staticResourcesV2.newUrl, repairJson, payloadForNewPI, controllerSaveMethod, staticResourcesV2.token, staticResources.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.indexOf(requiredFieldAPIList[i]) == -1)) { |
| | | continue; |
| | | }else if((VLookUpFields.indexOf(requiredFieldAPIList[i]) != -1) && formData[requiredFieldAPIList[i]] != '000000000000000'){ |
| | | continue; |
| | | } else { |
| | | if (blankRequiredFields == '') { |
| | |
| | | |
| | | //Base Process |
| | | function saveRepairProcess(saveMode) { |
| | | EditButton(true); |
| | | redirectMode = saveMode; |
| | | console.log('redirectMode' + redirectMode); |
| | | hiddenErrorMsgNode(); |
| | |
| | | errorMsgNode.innerText = errorMsg; |
| | | errorMsgNode.className = 'pbError'; |
| | | unblockUI(); |
| | | EditButton(false); |
| | | } |
| | | |
| | | //Hide Error Message |
| | |
| | | |
| | | //如果从报修子单过来,需要解密报修人 |
| | | if('{!RepairSubOrderAWSDataId}' != ''){ |
| | | EditButton(true);//add by Li Jun 20220428 By Li Jun |
| | | blockme();//add by Li Jun 20220428 By Li Jun |
| | | var staticResourceRepairSubOrder = JSON.parse('{!staticResourceRepairSubOrder}'); |
| | | let queryBackRepairSubOrder = function queryBackRepairSubOrder(data) { |
| | | document.querySelector("[data-id='RepairApplicant__c']").value = data.object.repairApplicantName; |
| | | if(document.querySelector("[data-id='RepairApplicant__c']")) |
| | | document.querySelector("[data-id='RepairApplicant__c']").value = data.object.repairApplicantName; |
| | | unblockUI();//add by Li Jun 20220428 By Li Jun |
| | | EditButton(false);//add by Li Jun 20220428 By Li Jun |
| | | }; |
| | | debugger; |
| | | AWSService.query(staticResourceRepairSubOrder.queryUrl, '{!RepairSubOrderAWSDataId}', queryBackRepairSubOrder, staticResourceRepairSubOrder.token); |
| | | } |
| | | |