Li Jun
2022-03-31 3ba0123db48f8bab81ddf0913e1b95280ef545e8
force-app/main/default/pages/ViewReportDecryptInfo.page
@@ -5,34 +5,55 @@
        <apex:pageblock id="pageBlock">
            <apex:pageBlockSection showHeader="false" title="" collapsible="true" columns="2" id="pageBlockSection">
                <!--Each section has layoutFields, let's iterate them as well-->
                <apex:repeat value="{!encryptedAPIList}" var="encryptedAPI">
                    <apex:outputField html-data-id="{!encryptedAPI}" value="{!Report__c[encryptedAPI]}" />
                <apex:repeat value="{!layoutEncryptedAPIList}" var="encryptedAPI">
                    <apex:outputField html-data-id="{!encryptedAPI}" title="{!ApiPrefix}{!encryptedAPI}" value="{!Report__c[encryptedAPI]}" />
                </apex:repeat>
            </apex:pageBlockSection>
            <script>
                var staticResources = JSON.parse('{!staticResource}');
                var AWSToSobjectEncryptedMapJson = JSON.parse('{!AWSToSobjectEncryptedMapJson}');
                var ApiPrefix = '{!ApiPrefix}';
                function QueryLeadFromAWS() {
                    AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token);
                }
                var queryBack = function queryBack(data) {
                    document.querySelector("[data-id='VOC_Informer_Name__c']").innerText=data.object.vocInformerName
                    document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id2:1:j_id3']").innerText=data.object.callerPhone
                    document.querySelector("[data-id='VOC_Informer_Contact__c']").innerText=data.object.vocInformerContact
                    document.querySelector("[data-id='Person_In_Charge_Text__c']").innerText=data.object.personInChargeText
                    document.querySelector("[data-id='Professor_sigh_text__c']").innerText=data.object.professorSighText
                    document.querySelector("[data-id='Staff_Info_Manual_c__c']").innerText=data.object.staffInfoManual
                    document.querySelector("[data-id='Medical_History__c']").innerText = data.object.medicalHistory
                    document.querySelector("[data-id='Responsible_Person_HP_c__c']").innerText=data.object.responsiblePersonHP
                    document.querySelector("[data-id='Practitioner1_Part__c']").innerText=data.object.practitioner1Part
                    document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:8:j_id3').innerText=data.object.practitioner2Part
                    document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:9:j_id3').innerText=data.object.practitioner3Part
                    document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:10:j_id3').innerText=data.object.practitioner4Part
                    document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:11:j_id3').innerText=data.object.practitioner5Part
                    document.querySelector("[data-id='age__c']").innerText=data.object.age
                    document.querySelector("[data-id='sex__c']").innerText=data.object.sex
                    if(!data.object){
                        console.log('data.object is ' + data.object);
                        return;
                    }
                    for(let f in AWSToSobjectEncryptedMapJson){
                        let t = "[title='"+ApiPrefix+AWSToSobjectEncryptedMapJson[f]+"']";
                        let ele = document.querySelector(t);
                        if(ele){
                            ele.title = '';
                            if(data.object.hasOwnProperty(f)){
                                ele.innerHTML = data.object[f];
                            }
                            else{
                                console.log(f + 'is not in data.object');
                            }
                        }else{
                            console.log('selector='+t+' not found');
                        }
                    }
                    // document.querySelector("[data-id='VOC_Informer_Name__c']").innerText=data.object.vocInformerName
                    // document.querySelector("[id='page:form:pageBlock:pageBlockSection:j_id2:1:j_id3']").innerText=data.object.callerPhone
                    // document.querySelector("[data-id='VOC_Informer_Contact__c']").innerText=data.object.vocInformerContact
                    // document.querySelector("[data-id='Person_In_Charge_Text__c']").innerText=data.object.personInChargeText
                    // document.querySelector("[data-id='Professor_sigh_text__c']").innerText=data.object.professorSighText
                    // document.querySelector("[data-id='Staff_Info_Manual_c__c']").innerText=data.object.staffInfoManual
                    // document.querySelector("[data-id='Medical_History__c']").innerText = data.object.medicalHistory
                    // document.querySelector("[data-id='Responsible_Person_HP_c__c']").innerText=data.object.responsiblePersonHP
                    // document.querySelector("[data-id='Practitioner1_Part__c']").innerText=data.object.practitioner1Part
                    // document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:8:j_id3').innerText=data.object.practitioner2Part
                    // document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:9:j_id3').innerText=data.object.practitioner3Part
                    // document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:10:j_id3').innerText=data.object.practitioner4Part
                    // document.getElementById('page:form:pageBlock:pageBlockSection:j_id2:11:j_id3').innerText=data.object.practitioner5Part
                    // document.querySelector("[data-id='age__c']").innerText=data.object.age
                    // document.querySelector("[data-id='sex__c']").innerText=data.object.sex
                };
                sfdcPage.appendToOnloadQueue(function () {
                    console.log('awsDataId = '+'{!AWSDataId}')
                    QueryLeadFromAWS();
                });
            </script>