DESKTOP-0K9VGFE\hp
2022-03-11 6d766b0c8e9b31e7e03ffd344a94c2851aa9beb9
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<apex:page controller="CampaignMemberServiceController" showHeader="false" sidebar="false" id="allPage" action="{!init}" title="参会人员">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<!-- 2022/02/15 张华建 dependency start -->
<apex:includeScript value="{!URLFOR($Resource.AWSService, 'AWSService.js') }" />
<!-- 2022/02/15 张华建 dependency end -->
<style type="text/css">
    .visitorplace_results {
        border: 1px solid gray;
        background-color: white;
        padding: 0;
        margin: 0;
        list-style: none;
        position: absolute;
        z-index: 10000;
        display: none;
        overflow:auto;
        white-space:nowrap;
        width:400px;
        height:250px;
    }
    .visitorplace_results li {
        padding: 2px 5px 2px 0px;
        margin-left : 2px;
        color: #101010;
        text-align: left;
    }
</style>
<script>
//訪問場所インスタント検索
//allPage:allForm:allBlock:records:0:department
sforce.connection.sessionId = '{!$Api.Session_ID}';
 
var Error_Message15 = '医院科室不存在,请重新设定。';
var Error_Message16 = '请设定医院科室。';
 
function setVisitorPlace(index){
    try{
        var str = 'allPage:allForm:allBlock:records:'+ index + ':department';
        var strPage = null;
        var options = {};
 
        var ros = j$(escapeVfId('userState')).value();
 
        strPage = '/apex/CM_SearchDepartmentService?r=' + encodeURI(ros);
        options = {minchars:3, minwords:2, resultsClass:'visitorplace_results'};
 
        jQuery(escapeVfId(str)).unbind();
        if (strPage != null) {
            jQuery(escapeVfId(str)).suggest(strPage,options);
        }
    }catch(e){
        alert(e);
    }
 
    //setVisitorPlaceDisabled();
}
 
function vpClear2_delay(index){
    var vp = 'allPage:allForm:allBlock:records:'+ index + ':department';
    var vpHidden = 'allPage:allForm:allBlock:records:'+ index + ':departmentHidden';
    setTimeout(
        function() {
            if(j$(escapeVfId(vp)).attr("jquerysuggest_skip_flag") == "false") {
                if (j$(escapeVfId(vp)).value() != j$(escapeVfId(vpHidden)).value()) {
                    vpClear2(index);
                }
            }
        },
        200
    );
}
 
function vpClear2(index){
  var vp = 'allPage:allForm:allBlock:records:'+ index + ':department';
  var vpHidden = 'allPage:allForm:allBlock:records:'+ index + ':departmentHidden';
  var vpId = 'allPage:allForm:allBlock:records:'+ index + ':departmentId';
  var vpHiddenId = 'allPage:allForm:allBlock:records:'+ index + ':departmentHiddenId';
  if (j$(escapeVfId(vp)).value() != j$(escapeVfId(vpHidden)).value() || j$(escapeVfId(vpId)).value() != j$(escapeVfId(vpHiddenId)).value()) {
    changeFlg = 'false';
    v1 = 'allPage:allForm:allBlock:records:' + index + ':contact';
 
    if(j$(escapeVfId(v1)).value() != null && j$(escapeVfId(v1)).value() != ''){changeFlg = 'true';}
 
    unblockUI();
    if(changeFlg == 'true'){
        alert('设定参会人员后,不能变更医院科室。');
        vpBefore = j$(escapeVfId('allPage:allForm:allBlock:records:' + index + ':departmentHidden')).value();
        vpIdBefore = j$(escapeVfId('allPage:allForm:allBlock:records:' + index + ':departmentHiddenId')).value();
        j$(escapeVfId('allPage:allForm:allBlock:records:' + index + ':department')).val(vpBefore);
        j$(escapeVfId('allPage:allForm:allBlock:records:' + index + ':departmentId')).val(vpIdBefore);
        document.getElementById('allPage:allForm:allBlock:records:' + index + ':department').blur();
        return;
    }
  }
  resetValue('allPage:allForm:allBlock:records:'+ index + ':department');
}
 
    //関連する引合インスタント検索
    function setRelOppId(index, id, hiddenId){
        try{
            var str = 'allPage:allForm:allBlock:records:'+ index + ':' + id;
            var strPD = 'allPage:allForm:allBlock:records:'+ index + ':department';
            var aNamePD = j$(escapeVfId(strPD)).value();
            if(aNamePD == ''){
                // 訪問場所を設定してください。
                document.getElementById(str).blur();
                alert(Error_Message16);
                return;
            }
 
            var strVP = 'allPage:allForm:allBlock:records:'+ index + ':departmentId';
            var vl = j$(escapeVfId(strVP)).value();
            if(vl.length == 0){
                // 訪問場所が存在しません。
                document.getElementById(str).blur();
                alert(Error_Message15);
                return;
            }
 
            var match = sforce.apex.execute("Add_Report","checkAccountMatch",{name:aNamePD,id:vl});
            if(match == "NG"){
                // 訪問場所IDマッチしていない
                document.getElementById(str).blur();
                alert("无法确定访问场所,请再设定一次访问场所。");
                return;
            }
 
            var strPage = '/apex/CM_SearchOpportunity?r=' + encodeURI(vl);
            jQuery(escapeVfId(str)).unbind();
            jQuery(escapeVfId(str)).suggest(strPage,{});
        }catch(e){
            alert(e);
        }
    }
 
// 20220216 PI改造 by 徐亮 start
var staticResource = JSON.parse('{!staticResource}');
    
    var awsids = [];
    var aws_result={};
 
    jQuery(function(){
        var eles = document.getElementsByClassName("contact");
        for(let e of eles){
            let awsid = e.getAttribute('awsid');
            if(awsid) awsids.push(awsid);
        }
 
        if(awsids.length > 0){
            AWSService.search(staticResource.searchUrl,JSON.stringify({dataIds:awsids}),function(result){
                if(result.status == '0' && result.object && result.object.length > 0){
                    for(let obj of result.object){
                        jQuery("[awsid='"+obj.dataId + "']").val(obj.lastName);
                    }
                }
            },staticResource.token);
        }
    })
 
    
 
    
 
    //jQuery(".contact").attr("awsid");
 
    function encrypt(){
        jQuery(".contact").each(function(i,e){
            if(e.value){
                e.value = '***';
            }
        });
    }
 
    // 20220216 PI改造 by 徐亮 end
 
function saveJs() {
    blockme();
    encrypt() // 20220216 PI改造 by 徐亮
    saveLine();
}
 
 
function addJs() {
    blockme();
    addLine();
}
function closeJs() {
    window.close();
}
function deleteJs(line) {
    blockme();
    deleteLine(line);
}
 
function openSearchContact(line) {
    var vpHiddenId = j$(escapeVfId('allPage:allForm:allBlock:records:'+ (line-1) + ':departmentHiddenId')).value();
    if (vpHiddenId == null || vpHiddenId == '') {
        alert("请先选择医院科室。");
        return false;
    }
    var urlStr = 'apex/CM_SearchContactService?line='+ line + '&acc=' + vpHiddenId;
    var w = window.open(urlStr,'CM_SearchContactService','menubar=no,height=580,width=620');
    w.focus();
}
 
function openCreateLead(line) {
    var username = j$(escapeVfId('allPage:allForm:allBlock:records:'+ (line-1) + ':contact')).value();
    var userid = j$(escapeVfId('allPage:allForm:allBlock:records:'+ (line-1) + ':contactId')).value();
    var contactSDCName = j$(escapeVfId('allPage:allForm:allBlock:records:'+ (line-1) + ':contactSDCName')).value();
    var acc = j$(escapeVfId('allPage:allForm:allBlock:records:'+ (line-1) + ':department')).value();
    var accid = j$(escapeVfId('allPage:allForm:allBlock:records:'+ (line-1) + ':departmentId')).value();
    var campaign = j$(escapeVfId('campaignName')).value();
    var campaignId = j$(escapeVfId('campaignId')).value();
    if (username == null || username == '') {
        alert("请先选择参会人员。");
    } else{
        var urlStr = '/00Q/e?RecordType=01210000000QiRa&ent=Lead&name_lastlea2=' + encodeURI(username) +
                            '&CF00N10000006ps6f=' + encodeURI(username) + '&CF00N10000006ps6f_lkid=' + userid +
                            '&lea3=' + encodeURI(acc) +
                            '&CF00N10000002CvC5=' + encodeURI(acc) + '&CF00N10000002CvC5_lkid=' + accid +
                            '&lea20=' + encodeURI(campaign) + '&lea20_lkid=' + campaignId +
                            '&CF00N10000004oN28=' + encodeURI(campaign) + '&CF00N10000004oN28_lkid=' + campaignId +
                            '&lea5=' + encodeURI('学会/沙龙') + '&CF00N10000006qNtt=' + encodeURI(contactSDCName);
        window.open(urlStr);
    }
}
 
</script>
 
    <apex:form id="allForm">
        <apex:actionFunction name="saveLine" action="{!saveLine}" rerender="allForm,allPanel,allBlock,records" oncomplete="checkLine('1');">
        </apex:actionFunction>
        <apex:actionFunction name="addLine" action="{!addLine}" rerender="allForm,allPanel,allBlock,records" oncomplete="checkLine();">
        </apex:actionFunction>
        <apex:actionFunction name="deleteLine" action="{!deleteLine}" rerender="allForm,allPanel,allBlock,records" oncomplete="checkLine();">
            <apex:param name="firstParam" assignTo="{!lineNo}" value="" />
        </apex:actionFunction>
        <apex:actionFunction name="checkLine" action="{!checkLine}" rerender="allForm,allPanel,allBlock,records" oncomplete="unblockUI();">
            <apex:param name="firstParam" assignTo="{!saveflg}" value="" />
        </apex:actionFunction>
        <apex:outputPanel id="allPanel">
            <apex:pageBlock id="allBlock">
                <apex:pageBlockButtons location="top">
                    <apex:commandButton onclick="saveJs();" value="保存" rerender="dummy"/>
                    <apex:commandButton onclick="addJs();" value="添加行" rerender="dummy"/>
                    <apex:commandButton onclick="closeJs();" value="关闭" rerender="dummy"/>
                </apex:pageBlockButtons>
 
                <apex:outputPanel id="message">
                    <apex:pageMessages />
                </apex:outputPanel>
 
                <input type="hidden" id="campaignName" value="{!campaignName}"/>
                <input type="hidden" id="campaignId" value="{!campaignId}"/>
                <input type="hidden" id="hasError" value="{!hasError}"/>
                <input type="hidden" id="userState" value="{!localuser.State_Hospital__c}"/>
 
                <table class="linetable" border="1" style="border-collapse: collapse;width:850px;table-layout:fixed;">
                    <colgroup>
                        <col width="40px"/>
                        <col width="300px"/>
                        <col width="150px"/>
                         <col width="150px"/>
                        <col width="150px"/>
                          
                         <col width="50px"/>
                    </colgroup>
                    <tr style="background-color:#DCDCDC;">
                        <th style="text-align:center">No.</th>
                        <th style="text-align:center">{!$ObjectType.CampaignMember__c.fields.Department__c.label}</th>
                        <th style="text-align:center">{!$ObjectType.CampaignMember__c.fields.Contact__c.label}</th>
                         <th style="text-align:center">{!$ObjectType.CampaignMember__c.fields.State__c.label}</th>
                        <th style="text-align:center">{!$ObjectType.CampaignMember__c.fields.City__c.label}</th>
                         
 
                        <th style="text-align:center">操作</th>
                    </tr>
                </table>
                <div style="width:875px;height:260px;overflow:auto;">
                <table id="linetable" class="linetable" border="1" style="border-collapse: collapse;width:850px;table-layout:fixed;">
                    <colgroup>
                        <col width="40px"/>
                        <col width="300px"/>
                        <col width="150px"/>
                               <col width="150px"/>
                             <col width="150px"/>
 
 
                        <col width="50px"/>
 
                    </colgroup>
                    <apex:repeat value="{!lineInfoList}" var="lineInfo" id="records">
                    <tr>
                        <td align="center">
                            <apex:outputText id="line" value="{!lineInfo.line}"></apex:outputText>
                        </td>
                        <td align="center">
                            <apex:inputField id="department" value="{!lineInfo.cm.Department__c}" onblur="vpClear2_delay({!lineInfo.line - 1});" onfocus="setVisitorPlace({!lineInfo.line - 1});" style="width:95%;"></apex:inputField>
                            <apex:inputHidden id="departmentId" value="{!lineInfo.cm.Department_ID__c}" />
                            <apex:inputHidden id="departmentHidden" value="{!lineInfo.cm.Department__c}" />
                            <apex:inputHidden id="departmentHiddenId" value="{!lineInfo.cm.Department_ID__c}" />
                        </td>
                        <td align="center">
                            <apex:inputField styleClass="contact" html-awsid="{!lineInfo.cm.Contact_ID__r.AWS_Data_Id__c}" id="contact" value="{!lineInfo.cm.Contact__c}" onclick="openSearchContact({!lineInfo.line})" style="width: 95%"></apex:inputField>
                            <apex:inputHidden id="contactId" value="{!lineInfo.cm.Contact_ID__c}"></apex:inputHidden>
                            <apex:inputHidden id="contactSDCName" value="{!lineInfo.cm.Contact_ID__r.Strategic_dept_Class__r.Name}"></apex:inputHidden>
                        </td>
                        <td align="center">
                            <apex:outputText id="State" value="{!lineInfo.cm.State__c}" style="width: 95%"></apex:outputText>
 
                        </td>
                        <td align="center">
                            <apex:outputText id="City" value="{!lineInfo.cm.City__c}" style="width: 95%"></apex:outputText>
                        </td>
                          
                        <td align="center">
                            <input style="width:90%;" type="button" value="删除" onclick="deleteJs({!lineInfo.line})"/>
                        </td>
                    </tr>
                    </apex:repeat>
                </table>
                </div>
            </apex:pageBlock>
        </apex:outputPanel>
    </apex:form>
</apex:page>