buli
2022-05-09 0953b3b5fcf19c627c6479a6b86648df653c40db
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<apex:page id="Page" Controller="SearchMemberPageController" sidebar="false" showHeader="false" action="{!init}">
    <apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
    <apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
    <apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
    <apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
    <apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
    <apex:includeScript value="{! URLFOR($Resource.AWSService, 'AWSService.js') }" />
    <style type="text/css">
        td{line-height: 32px;}
        [aws-api] {
            position: relative;
        }
        [aws-api] .decrypt{
            position: absolute;
            top: 50%;left: 0;
            display: none;
            text-align: left;
            /* padding-left: 5px; */
        }
        /* [aws-api]:hover .decrypt{display: block;width: 100px} */
    </style>
    <script>
        AWSService.sfSessionId = '{!GETSESSIONID()}';
        var staticResource = JSON.parse('{!staticResource}');
 
        var aws_data = {};
 
        //zhj 2022-04-22 PIPL start
        //js    hover 
        function jsHover(){
            var encrypts = document.getElementsByClassName('encrypt');
            for(var i = 0;i<encrypts.length;i++){
                encrypts[i].onmouseover = (function close(j) {
                    return function () {
                        //显示Name
                        encrypts[j].children[1].children[0].innerText = encrypts[j].children[1].children[1].innerText
                        //显示Email
                        encrypts[j].children[2].children[0].innerText = encrypts[j].children[2].children[1].innerText
                    }
                })(i);
            }
        }
        //zhj 2022-04-22 PIPL end
 
        function Decrypt(r,dataIds,callback){
            if (!(dataIds && dataIds.length)) {
                if(callback)callback();
                return;
            }
 
            let Foo = function(){
                for (const id of dataIds) {
                    if (aws_data.hasOwnProperty(id)) {
                        let d = aws_data[id];
                        let $e =j$("[aws-id='"+d.dataId+ "']");
                        $e.each((i,e)=>{
                            j$(e).find(".decrypt").html(d[j$(e).attr("aws-api")]);
                        })
                        
                    }
                }
                if(callback)callback();
                jsHover();
            }
            let ids = [];
            for (const id of dataIds) {
                if (!aws_data.hasOwnProperty(id)) {
                    ids.push(id);
                }
            }
            if (ids.length > 0) {
                
                AWSService.search(r.searchUrl,JSON.stringify({
                    "dataIds":ids
                }),function(data){
                    
                    if(data.object && data.object.length > 0){
                        
                        for(let d of data.object){
                            if(d.dataId){
                                aws_data[d.dataId] = d;
                            }
                        }
                        Foo();
                    }else{
                        if(callback)callback();
                    }
                },r.token);
            }else{
                Foo();
            }
        }
 
        function DecryptAll(callback){
            let dataIds = [];
            j$('[aws-id][aws-obj="Contact"]').each((i,e)=>{
                let v = j$(e).attr('aws-id');
                if (v) {
                    dataIds.push(v);
                }
            });
            Decrypt(staticResource,dataIds,callback);
        }
 
        j$(function(){
            //DecryptAll();
            
        })
 
        function doSearchJS(){
            blockme();
            var searchByName = j$(escapeVfId("searchByName")).value();
            var searchByAccount = j$(escapeVfId("searchByAccount")).value();
            var searchByAWSDataIds = j$(escapeVfId("searchByAWSDataIds")).value();
            var memberType = j$(escapeVfId('Page:allData:memberType')).value();
            if (memberType == "Contact" && searchByName) {
                AWSService.search(staticResource.searchUrl,JSON.stringify({
                    contactName:searchByName
                }),function(data){
                    if (data && data.object && data.object.length) {
                        let ids = data.object.map(m=>m.dataId);
                        DoSearch(searchByName,searchByAccount,ids.join(','));
                    }else{
                        unblockUI();
                    }
                    
                },staticResource.token);
            }else{
                DoSearch(searchByName,searchByAccount,[]);
            }
 
            
        }
        function saveJS(){
            blockme();
            save();
        }
        //读取数据,调用父页面刷新方法
        function refreshPage(){
            var isError = j$(escapeVfId("isError")).value();
            if(isError == "true"){     
                return;
            }
            var lineNum = j$(escapeVfId("lineNum")).value();
            var memberId = j$(escapeVfId("memberId")).value();
            var memberName = aws_data[j$(escapeVfId("aws_data_id")).value()].lastName;
            var memberEmail = aws_data[j$(escapeVfId("aws_data_id")).value()].email;
            window.opener.refreshPage(lineNum,memberId,memberName,memberEmail); 
            window.close();
        }
        function closeJS(){
            /*window.parent.opener=null;
            window.parent.open('', '_self', ''); 
            setTimeout('window.parent.close()', 10000);*/
        }
        function hiddenObj(){
            var memberType = j$(escapeVfId('Page:allData:memberType')).value();
            if(memberType == "User"){
                j$(escapeVfId("accountLable")).attr("style","display:none");
                j$(escapeVfId("dataAccount")).attr("style","display:none");
            }
            if(memberType == "Contact"){
                j$(escapeVfId("accountLable")).attr("style","display:block");
                j$(escapeVfId("dataAccount")).attr("style","display:block");
            }
        }
 
 
 
    </script>
     <div style="width: 100%;height: 100%;">
         <apex:outputPanel id="message1">
            <apex:messages styleClass="editListError"/>
        </apex:outputPanel>
         <apex:form id="allData">
             <apex:actionFunction action="{!SearchMember}" name="DoSearch" reRender="result" oncomplete="DecryptAll(unblockUI);">
                 <apex:param assignTo="{!searchByName}" name="searchByName" value=""></apex:param>
                 <apex:param assignTo="{!searchByAccount}" name="searchByAccount" value=""></apex:param>
                 <apex:param assignTo="{!searchByAWSDataIds}" name="searchByAWSDataIds" value=""></apex:param>
             </apex:actionFunction>
             <apex:actionFunction action="{!save}" name="save" reRender="allData,message1" oncomplete="DecryptAll(()=>{unblockUI();refreshPage();closeJS();});">
             </apex:actionFunction>
             <input type="hidden" id="isError" value="{!isError}" />
             <input type="hidden" id="lineNum" value="{!lineNum}" />
             <input type="hidden" id="memberId" value="{!memberId}" />
             <input type="hidden" id="memberName" value="{!memberName}" />
             <input type="hidden" id="memberEmail" value="{!memberEmail}" />
             <input type="hidden" id="aws_data_id" value="{!aws_data_id}" />
                 
                 <table style="width: 100%;">
                     <colgroup>
                         <col style="width: 20%" />
                         <col style="width: 40%" />
                         <col style="width: 40%" />
                     </colgroup>
                     <tr>
                         <th colspan="3">
                             <apex:selectList onchange="hiddenObj()" id="memberType" value="{!memberType}" size="1">
                                 <!-- <apex:selectOptions value="{!items}"></apex:selectOptions> -->
                                 <apex:selectOption itemLabel="外部用户联系人" itemValue="Contact"></apex:selectOption>
                                 <apex:selectOption itemLabel="奥林巴斯内部用户" itemValue="User"></apex:selectOption>
                             </apex:selectList>
                        </th>
                    </tr>
                    <tr>
                         <th style="text-align:center;"><apex:commandButton value="Search" onclick="doSearchJS();return false;" />&nbsp;&nbsp;<apex:commandButton value="Save" onclick="saveJS();return false;"/></th>
 
                         <th id="nameLable" style="text-align:center;"><input id="searchByAWSDataIds"  type="hidden" value="{!searchByAWSDataIds}" /> Name:<input id="searchByName"  type="text" value="{!searchByName}" /></th>
 
                        <th style="text-align:center;"><div id="accountLable">Account:<input id="searchByAccount"  type="text" value="{!searchByAccount}" /></div></th>
                         
                     </tr>     
                 </table>
                 <apex:outputPanel id="result">
                     <table>
                         <colgroup>
                             <col style="width: 10%" />
                             <col style="width: 20%" />
                             <col style="width: 30%" />
                             <col style="width: 40%" />
                         </colgroup>
                         <tr>
                             <th style="text-align:center;">
                                 RESULT
                             </th>
                             <th colspan="2">
                             </th>
                         </tr>
                         <tr>
                             <th></th>
                             <th>NAME</th>
                              <th>EMAIL</th>
                              <th>ACCOUNT</th>
                              <!-- <apex:outputPanel layout="none" rendered="{!IF(memberType == 'Contact', true, false)}">
                                 <th>ACCOUNT</th>
                              </apex:outputPanel>
                              <apex:outputPanel layout="none" rendered="{!IF(memberType == 'User', true, false)}">
                                 <th></th>
                              </apex:outputPanel> -->
                         </tr>
                         <apex:repeat value="{!lineList}" var="line">
                             <tr class="encrypt">
                                 <td style="text-align:right;">
                                     <apex:inputCheckbox id="checkbox" value="{!line.check}" />
                                 </td>
                                 <td aws-obj="Contact" aws-api="lastName" aws-id="{!line.aws_data_id}">
                                    <!-- 20220222 PI改造 by Bright  start -->
                                    <span>{!line.name}</span>
                                    <span class="decrypt"></span>
                                    <!-- 20220222 PI改造 by Bright  end -->
                                </td>
                                 <td aws-obj="Contact" aws-api="email" aws-id="{!line.aws_data_id}">
                                    <!-- 20220222 PI改造 by Bright  start -->
                                    <span>{!line.email}</span>
                                    <span class="decrypt"></span>
                                    <!-- 20220222 PI改造 by Bright  end -->
                                </td>
                                 <td><apex:outputText value="{!line.account}"></apex:outputText></td>
                             </tr>
                         </apex:repeat>
                     </table>
                 </apex:outputPanel>
         </apex:form>
     </div>
</apex:page>