From 02ddc35714cbd1688b7cb057f770f1410de79dab Mon Sep 17 00:00:00 2001 From: buli <137736985@qq.com> Date: 星期五, 11 三月 2022 12:19:33 +0800 Subject: [PATCH] PIPL Updated Code 20220311 --- force-app/main/default/pages/OFSInsReportLayout.page | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 163 insertions(+), 6 deletions(-) diff --git a/force-app/main/default/pages/OFSInsReportLayout.page b/force-app/main/default/pages/OFSInsReportLayout.page index ba81af1..5167cdd 100644 --- a/force-app/main/default/pages/OFSInsReportLayout.page +++ b/force-app/main/default/pages/OFSInsReportLayout.page @@ -8,6 +8,7 @@ <apex:includeScript value="{!URLFOR($Resource.connection20)}"/> <apex:includeScript value="{!URLFOR($Resource.apex20)}"/> <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/> + <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" /> <style type="text/css"> table#AssetTable select { width: 98%; @@ -127,6 +128,147 @@ } //add by rentx 20210809 鍏ㄩ�夊姛鑳� end + + +AWSService.sfSessionId = '{!GETSESSIONID()}'; +var staticResource = JSON.parse('{!staticResource}'); +var aws_data = {}; +var txid = null; +function Encrypt(callback){ + blockme(); + //callback();return; + //<input type="hidden" value="{!ir.Id}" id="IrId"/> + + //<input type="hidden" value="{!ir.Responsible_Person_Encrypted__c}" id="Responsible_Person_Encrypted__c"/> + //<input type="hidden" value="{!ir.phone_Encrypted__c}" id="phone_Encrypted__c"/> + let e_id = document.getElementById("IrId"); + let url = staticResource.newUrl; + + aws_data = { + "phone":j$("[field-api='phone__c']").val(), + "responsiblePerson":j$("[field-api='Responsible_Person__c']").val(), + }; + + if(e_id && e_id.value){ + url = staticResource.updateUrl; + aws_data.dataId = document.getElementById("Page:Form:Block:AWS_Data_Id__c").value; + } + + + + AWSService.post(url, JSON.stringify([aws_data]), function(data){ + + if (!(data && data.object && data.object.length)) { + console.log('AWSService.post failed'); + return; + } + let aws_data1 = data.object[0]; + txid = data.txId; + + document.getElementById("Page:Form:Block:AWS_Data_Id__c").value = aws_data1.dataId; + j$("[field-api='phone__c']").val(aws_data1.phone); + document.getElementById("Page:Form:Block:phone_Encrypted__c").value = aws_data1.phoneEncrypt; + j$("[field-api='Responsible_Person__c']").val(aws_data1.responsiblePerson); + document.getElementById("Page:Form:Block:Responsible_Person_Encrypted__c").value = aws_data1.responsiblePersonEncrypt; + + if (callback) { + callback(); + } + }, staticResource.token); +} + +function saveBtnJs(){ + Encrypt(saveBtn); +} +function submitJs(){ + Encrypt(submit); +} +function showPDFJs(){ + Encrypt(showPDF); +} + +function afterSaveBtnJs(){ + Trans(); +} + +function afterSubmitJs(){ + Trans(); +} + +function afterShowPDFJs(){ + Trans(function(){ + if (!HasError()) { + window.location.href = '/apex/InsReportPDFOuter?id=' + document.getElementById("IrId").value; + } + + }); +} + +function HasError(){ + + // if (IsAddmessage) { + // return true; + // } + let e = document.getElementById("Page:Form:MessageP"); + if (!e) { + return false; + } + + let divs = j$(e).find("div.message"); + for (let i = 0; i < divs.length; i++) { + for (let j = 0; j < divs[i].classList.length; j++) { + for(let cls of divs[i].classList){ + if (cls.indexOf('error')>-1) { + return true; + } + } + + } + + } + + + return false; +} + +function Decrypt(data){ + + j$("[field-api='phone__c']").val(data.phone); + j$("[field-api='Responsible_Person__c']").val(data.responsiblePerson); + + +} + +function Trans(callback){ + let payload = { + "txId":txid, + "sfRecordId":document.getElementById("IrId").value, + "isSuccess":(txid && !HasError()) ? 1 : 0 + }; + AWSService.post(staticResource.transactionUrl, JSON.stringify(payload), function(result){ + Decrypt(aws_data); + if(callback)callback(); + unblockUI(); + }, staticResource.token); +} + +function Query(){ + let ele = document.getElementById("Page:Form:Block:AWS_Data_Id__c"); + if (ele && ele.value) { + blockme(); + AWSService.query(staticResource.queryUrl, ele.value, function(data){ + if (data && data.object) { + Decrypt(data.object); + } + unblockUI(); + }, staticResource.token); + } +} + +j$(function(){ + Query(); +}) + </script> <title>{!ir.Name}</title> </head> @@ -138,6 +280,9 @@ // 淇濆瓨寰屻�佹柊瑕忋伄鍫卞憡鏇窱D銈掑彇寰� tmpinsid = '{!ir.Id}'; tmpinsn = '{!JSENCODE(ir.Name)}'; + //var IsAddmessage = {IsAddmessage}; + var isPDF = {!isPDF}; + </script> <apex:actionFunction name="searchfunc" action="{!searchBtn}" rerender="Form,Block,UnCheckSection" onComplete="unblockUI();"></apex:actionFunction> @@ -149,9 +294,14 @@ <apex:actionFunction name="saveByRepair" action="{!saveBtn}" rerender="Form" onComplete="unblockUI();openRepair();"/> +<apex:actionFunction name="saveBtn" action="{!saveBtn}" rerender="Form" onComplete="afterSaveBtnJs();"/> +<apex:actionFunction name="submit" action="{!submit}" rerender="Form" onComplete="afterSubmitJs();"/> +<apex:actionFunction name="showPDF" action="{!showPDF}" rerender="Form" onComplete="afterShowPDFJs();"/> + <apex:outputPanel id="MessageP"> <apex:pageMessages /> </apex:outputPanel> + <div><apex:pageBlock mode="maindetail" Id="Block" rendered="{!initFlag}"> <div style="position: relative;top:0;width:100%;"> @@ -162,10 +312,10 @@ <apex:outputLabel value="{!$ObjectType.Inspection_Report__c.fields.Name_Manual__c.Label}" for="Name_Manual"/>锛� <apex:inputField value="{!ir.Name}" id="Ir_Name" html-disabled="disabled" style="border-width:0px;font-size:18px;font-weight:bold;padding-right:20px;-webkit-text-fill-color:black;"/> </td> - <td style="text-align: center;padding-right: 100px;"><apex:commandButton style="width:80px;" value="淇濆瓨" action="{!saveBtn}" onclick="blockme();" rerender="Form" onComplete="unblockUI();"/></td> - <td style="text-align: center;padding-right: 100px;"><apex:commandButton value="鎻愪氦" action="{!submit}" onclick="blockme();" style="width:80px" rerender="Form" id="submitButton" onComplete="unblockUI();"/></td> + <td style="text-align: center;padding-right: 100px;"><input class="btn" type="Button" style="width:80px;" value="淇濆瓨" action="" onclick="saveBtnJs();" rerender="Form" onComplete="unblockUI();"/></td> + <td style="text-align: center;padding-right: 100px;"><input class="btn" type="Button" value="鎻愪氦" action="" onclick="submitJs();" style="width:80px" rerender="Form" id="submitButton" onComplete="unblockUI();"/></td> <td style="text-align: center;padding-right: 100px;"><apex:commandButton style="width:80px;" value="鍏抽棴绐楀彛" onclick="location.href='/apex/OFSWindowClose';return false;" id="closeButton"/></td> - <td style="text-align: center;"><apex:commandButton style="width:80px;" value="PDF" action="{!showPDF}" onclick="blockme();" rerender="Form" onComplete="unblockUI();"/></td> + <td style="text-align: center;"><input class="btn" type="Button" style="width:80px;" value="PDF" action="" onclick="showPDFJs();" rerender="Form" onComplete="unblockUI();"/></td> </tr> </table> <apex:pageBlockSection title="{!sectionList[0].title}" columns="{!sectionList[0].column}" showHeader="{!sectionList[0].showHeader}" rendered="{!sectionList.size>0}"> @@ -207,11 +357,18 @@ </div> <div style="position: relative;top:0;height:700px;overflow:hidden;overflow-y:auto;-webkit-overflow-scrolling: touch;"> <input type="hidden" value="{!ir.Id}" id="IrId"/> + <apex:inputHidden value="{!ir.Responsible_Person_Encrypted__c}" id="Responsible_Person_Encrypted__c"/> + <apex:inputHidden value="{!ir.phone_Encrypted__c}" id="phone_Encrypted__c"/> + <apex:inputHidden value="{!ir.AWS_Data_Id__c}" id="AWS_Data_Id__c"/> + + + + <apex:repeat value="{!sectionList}" var="section" id="SectionList"> <apex:pageBlockSection title="{!section.title}" columns="{!section.column}" showHeader="{!section.showHeader}" rendered="{!!section.isTop}"> <apex:repeat value="{!section.sectionItemList}" var="sectionItem" id="SectionItemList"> <apex:outputField value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&&NOT(sectionItem.isInput)}"/> - <apex:inputField style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&§ionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/> + <apex:inputField html-field-api="{!sectionItem.api}" style="width:{!sectionItem.width};height:{!sectionItem.height};" value="{!ir[sectionItem.api]}" rendered="{!NOT(sectionItem.isDummy)&&NOT(sectionItem.isCustomize)&§ionItem.isInput}" required="{!sectionItem.isRequired}" html-tabindex="{!sectionItem.index}"/> <apex:pageblockSectionItem rendered="{!NOT(sectionItem.isDummy)&&(sectionItem.isCustomize)&&Not(isNull(sectionItem.customizeLable))}"> <apex:outputLabel value="{!sectionItem.customizeLable}"/> <apex:outputPanel layout="none"> @@ -222,7 +379,7 @@ </apex:outputPanel> <apex:outputPanel layout="none" rendered="{!NOT(api == 'Hospital__c' && ir.Id != '')}"> <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/> -<apex:inputField value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/> +<apex:inputField html-field-api="{!api}" value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/> <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}"> <apex:outputField value="{!ir[api]}"/> </apex:outputPanel> @@ -234,7 +391,7 @@ <apex:outputPanel layout="none"> <apex:repeat value="{!sectionItem.apiList}" var="api"> <apex:outputLabel style="font-weight: bold; padding-right: 5px;" value="{!sectionItem.apiLabelMap[api]}"/> -<apex:inputField value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/> +<apex:inputField html-field-api="api" value="{!ir[api]}" style="{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && (sectionItem.isInput || sectionItem.apiInputMap[api])}" required="{!sectionItem.apiRequireMap[api]}" html-tabindex="{!sectionItem.index}"/> <apex:outputPanel style="display:inline-block;{!sectionItem.apiStyleMap[api]}" rendered="{!NOT(api=='') && NOT((sectionItem.isInput || sectionItem.apiInputMap[api]))}"> <apex:outputField value="{!ir[api]}"/> </apex:outputPanel> -- Gitblit v1.9.1