buli
2022-05-13 08a21f49f2eaf9cfc19ceb67b196cc36ba689305
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!--
  @description       : 
  @author            : ChangeMeIn@UserSettingsUnder.SFDoc
  @group             : 
  @last modified on  : 02-22-2022
  @last modified by  : ChangeMeIn@UserSettingsUnder.SFDoc
-->
<apex:page standardController="Contact" extensions="NewAndEditContactController" id="page">
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }"/>
    <apex:form id="form">
        <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="{!layoutEncryptedAPIList}" var="encryptedAPI">
                    <apex:outputField html-data-id="{!encryptedAPI}" title="{!ApiPrefix}{!encryptedAPI}" value="{!Contact[encryptedAPI]}" />
                </apex:repeat> -->
                <apex:outputField html-data-id="{!encryptedAPIList[0]}" title="{!ApiPrefix}{!encryptedAPIList[0]}" value="{!Contact[encryptedAPIList[0]]}" />
                <br/>
                <!-- Title -->
                <apex:outputField html-data-id="{!encryptedAPIList[1]}" title="{!ApiPrefix}{!encryptedAPIList[1]}" value="{!Contact[encryptedAPIList[1]]}" />
                <apex:outputField html-data-id="{!encryptedAPIList[2]}" title="{!ApiPrefix}{!encryptedAPIList[2]}" value="{!Contact[encryptedAPIList[2]]}" />
                &nbsp;
                <apex:outputField value="{!Contact.Title_IsChanged__c}" />
                <!-- Mobile Phone -->
                <apex:outputField html-data-id="{!encryptedAPIList[3]}" title="{!ApiPrefix}{!encryptedAPIList[3]}" value="{!Contact[encryptedAPIList[3]]}" />
                <apex:outputField html-data-id="{!encryptedAPIList[4]}" title="{!ApiPrefix}{!encryptedAPIList[4]}" value="{!Contact[encryptedAPIList[4]]}" />
                &nbsp;
                <apex:outputField value="{!Contact.MobilePhone_IsChanged__c}" />
                 <!-- Phone -->
                 <apex:outputField html-data-id="{!encryptedAPIList[5]}" title="{!ApiPrefix}{!encryptedAPIList[5]}" value="{!Contact[encryptedAPIList[5]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[6]}" title="{!ApiPrefix}{!encryptedAPIList[6]}" value="{!Contact[encryptedAPIList[6]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Phone_IsChanged__c}" />
                 <!-- Fax -->
                 <apex:outputField html-data-id="{!encryptedAPIList[7]}" title="{!ApiPrefix}{!encryptedAPIList[7]}" value="{!Contact[encryptedAPIList[7]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[8]}" title="{!ApiPrefix}{!encryptedAPIList[8]}" value="{!Contact[encryptedAPIList[8]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Fax_IsChanged__c}" />
                 <!-- OtherPhone -->
                 <apex:outputField html-data-id="{!encryptedAPIList[9]}" title="{!ApiPrefix}{!encryptedAPIList[9]}" value="{!Contact[encryptedAPIList[9]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[10]}" title="{!ApiPrefix}{!encryptedAPIList[10]}" value="{!Contact[encryptedAPIList[10]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.OtherPhone_IsChanged__c}" />
                 <!-- Email -->
                 <apex:outputField html-data-id="{!encryptedAPIList[11]}" title="{!ApiPrefix}{!encryptedAPIList[11]}" value="{!Contact[encryptedAPIList[11]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[12]}" title="{!ApiPrefix}{!encryptedAPIList[12]}" value="{!Contact[encryptedAPIList[12]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Email_IsChanged__c}" />
                 <!-- Postcode -->
                 <apex:outputField html-data-id="{!encryptedAPIList[13]}" title="{!ApiPrefix}{!encryptedAPIList[13]}" value="{!Contact[encryptedAPIList[13]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[14]}" title="{!ApiPrefix}{!encryptedAPIList[14]}" value="{!Contact[encryptedAPIList[14]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Postcode_IsChanged__c}" />
                 <!-- Address1 -->
                 <apex:outputField html-data-id="{!encryptedAPIList[15]}" title="{!ApiPrefix}{!encryptedAPIList[15]}" value="{!Contact[encryptedAPIList[15]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[16]}" title="{!ApiPrefix}{!encryptedAPIList[16]}" value="{!Contact[encryptedAPIList[16]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Address1_IsChanged__c}" />
                 <!-- Address2 -->
                 <apex:outputField html-data-id="{!encryptedAPIList[17]}" title="{!ApiPrefix}{!encryptedAPIList[17]}" value="{!Contact[encryptedAPIList[17]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[18]}" title="{!ApiPrefix}{!encryptedAPIList[18]}" value="{!Contact[encryptedAPIList[18]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Address2_IsChanged__c}" />
                 <!-- Address3__c -->
                 <apex:outputField html-data-id="{!encryptedAPIList[19]}" title="{!ApiPrefix}{!encryptedAPIList[19]}" value="{!Contact[encryptedAPIList[19]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[20]}" title="{!ApiPrefix}{!encryptedAPIList[20]}" value="{!Contact[encryptedAPIList[20]]}" />
                 &nbsp;
                 <apex:outputField value="{!Contact.Address3_IsChanged__c}" />
                 <!-- ContactEnglishName -->
                 <apex:outputField html-data-id="{!encryptedAPIList[21]}" title="{!ApiPrefix}{!encryptedAPIList[21]}" value="{!Contact[encryptedAPIList[21]]}" />
                 <apex:outputField html-data-id="{!encryptedAPIList[22]}" title="{!ApiPrefix}{!encryptedAPIList[22]}" value="{!Contact[encryptedAPIList[22]]}" />
            </apex:pageBlockSection>
            <script>
                var config = {
                    SobjectName : "{!SobjectName}",
                    ApiPrefix:"{!ApiPrefix}",
                    AWSToSobjectMap:{!AWSToSobjectMapJson},
                    AWSToSobjectNonEncryptedMap:{!AWSToSobjectNonEncryptedMapJson},
                    AWSToSobjectEncryptedMap:{!AWSToSobjectEncryptedMapJson}
                };
                var staticResources = JSON.parse('{!staticResource}');
                function QuerySobjectFromAWS() {
                    AWSService.query(staticResources.queryUrl, '{!AWSDataId}', queryBack, staticResources.token);
                }
                var queryBack = function queryBack(data) {
                    if(!data.object){
                        console.log('data.object is ' + data.object);
                        return;
                    }
 
                    for(let f in config.AWSToSobjectNonEncryptedMap){
                        let t = "[title='"+config.ApiPrefix+config.AWSToSobjectNonEncryptedMap[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');
                        }
                        
                    }
                    // 当不能自动正确替换加密数据时需要在此处添加js,硬编码处理
                    // document.querySelector("[data-id='LastName']").value = data.object.lastName;
                };
                sfdcPage.appendToOnloadQueue(function () {
                    console.log('sfdcPage.appendToOnloadQueue')
                    // document.querySelector("[data-id='LastName']").parentNode.parentNode.parentNode.children[0].innerText = '姓名'
                    QuerySobjectFromAWS();
                });
            </script>
        </apex:pageblock>
    </apex:form>
</apex:page>