buli
2022-04-06 2d4a8d2dcad5a17127d2c73c48ddc4b67ec79448
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
<apex:page standardController="Event" tabStyle="Event" extensions="SimpleEventRegisterController" id="page" sidebar="true" action="{!init}">
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:stylesheet value="{!URLFOR($Resource.jquerysuggestcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquerysuggestjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.connection20)}"/>
<apex:includeScript value="{!URLFOR($Resource.apex20)}"/>
<!-- Add By Li Jun for PIPL 20220225 -->
<apex:includeScript value="{!URLFOR($Resource.AWSService, 'AWSService.js') }" />
<script src="../../soap/ajax/53.0/connection.js" type="text/javascript"></script>
<!-- Add By Li Jun for PIPL 20220225 -->
<script>
  var ros = '{!$User.State_Hospital__c}';
  var act = '病院';
  var hospitalString = '病院';
  var agentString = '販売店';
  var innerEventString = '社内活動';
  var outerEventString = '社外イベント';
  var optionsHP = {minchars:3, minwords:2, resultsClass:'visitorplace_results'};
  var options = {minchars:3, resultsClass:'visitorplace_results'};
  
  sforce.connection.sessionId = '{!$Api.Session_ID}';
  
  function setSuggestHospital() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:hospital")).unbind();
        j$( escapeVfId( "page:form:all:visitSettings:hospital")).suggest( '/apex/Xin_SearchVisitorPlace?r=' + encodeURI(ros), optionsHP);
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity2() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity3() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity4() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestOpportunity5() {
    try {
        j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).unbind();
        if (act == hospitalString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
        } else if (act == agentString) {
            j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).suggest( '/apex/Xin_SearchOpportunity?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:agentId').value), {});
        }
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestContract() {
      try {
        j$( escapeVfId( "page:form:all:visitSettings:contract")).unbind();
        j$( escapeVfId( "page:form:all:visitSettings:contract")).suggest( '/apex/Xin_SearchMaintenanceContract?r=' + encodeURI( document.getElementById( 'page:form:all:visitSettings:hospitalId').value), {});
    }
    catch (e) {
        alert( e);
    }
  }
  function setSuggestTraining() {
    j$( escapeVfId( "page:form:all:visitSettings:training")).unbind();
    j$( escapeVfId( "page:form:all:visitSettings:training")).suggest( '/apex/Xin_SearchVisitorPlace_Training?r=' + encodeURI(ros), options);
  }
  function setSuggestCampaign() {
    j$( escapeVfId( "page:form:all:visitSettings:campaign")).unbind();
    j$( escapeVfId( "page:form:all:visitSettings:campaign")).suggest( '/apex/Xin_SearchVisitorPlace_Campaign?r=' + encodeURI(ros), options);
  }
  function setSuggestAgent() {
    var today = new Date();
    var targetDate = today.getFullYear() + '/' + (today.getMonth()+1) + '/' + today.getDate();
    j$( escapeVfId( "page:form:all:visitSettings:agent")).unbind();
    j$( escapeVfId( "page:form:all:visitSettings:agent")).suggest( '/apex/Xin_SearchVisitorPlace_Sales?r=' + encodeURI(ros) + '&d=' + targetDate, optionsHP);
  }
  function resetChild_delay(htmlId) {
    setTimeout(function() {resetChild(htmlId)}, 200);
  }
  function resetChild(htmlId) {
      if (resetValue(htmlId)) {
      } else {
          // 新しい値を設定した
          j$( escapeVfId( "page:form:all:visitSettings:opportunity")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunityId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunityHidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunityHiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contract")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contractId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contractHidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:contractHiddenId")).val("");
          
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity2HiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity3HiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity4HiddenId")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5Id")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5Hidden")).val("");
          j$( escapeVfId( "page:form:all:visitSettings:opportunity5HiddenId")).val("");
      }
  }
 
  function changeVisitToGateway() {
    var select = document.getElementById( 'page:form:all:visitSettings:activity');
    act = document.getElementById( 'page:form:all:visitSettings:activity').options.item( select.selectedIndex).value;
    if ( act == hospitalString) {
        callHospital();
    }
    else if ( act == agentString) {
        callAgent();
    }
    else if ( act == innerEventString) {
        callTraining();
    }
    else if ( act == outerEventString) {
        callCampaign();
    }
    else {
        callNone();
    }
  }
  
  function clearVisitorId(id){
    document.getElementById('page:form:all:visitSettings:' + id).value = '';
  }
  
  function checkLocation(){
    var str = 'page:form:all:visitSettings:hospital';
    var aName = j$(escapeVfId(str)).value();
    if(aName == ''){
        // 訪問場所を設定してください。
        alert('{!$Label.Error_Message16}');
        return false;
    }
    
    var strVP = 'page:form:all:visitSettings:hospitalId';
    var vl = j$(escapeVfId(strVP)).value();
    if(vl.length == 0){
        // 訪問場所が存在しません。
        alert('{!$Label.Error_Message15}');
        return false;
    }
    
    var match = sforce.apex.execute("Add_Report","checkAccountMatch",{name:aName,id:vl});
    if(match == "NG"){
        // 訪問場所IDマッチしていない
        alert('{!$Label.Error_Message15}');
        return false;
    }
    return true;
  }
  
  function searchVisitor2(val){
    if (!checkLocation()) {
        return;
    }
 
    var str = 'page:form:all:visitSettings:hospital';
    var strId = 'page:form:all:visitSettings:hospitalId';
    var aName = j$(escapeVfId(str)).value();
    var aId = j$(escapeVfId(strId)).value();
 
    var vp = aId;
    
    //j$(escapeVfId('Page:mainForm:idDayEdit:idActivities:' + index + ':idVisitorPlaceHidden')).val(aName);
    //j$(escapeVfId('Page:mainForm:idDayEdit:idActivities:' + index + ':idVisitorPlaceHiddenId')).val(aId);
    
    var strId1 = 'page:form:all:visitSettings:visitor1';
    var strHid1 = 'page:form:all:visitSettings:visitor1Id';
    var strVa1 = j$(escapeVfId('page:form:all:visitSettings:visitor1Id')).value()
    var strId2 = 'page:form:all:visitSettings:visitor2';
    var strHid2 = 'page:form:all:visitSettings:visitor2Id';
    var strVa2 = j$(escapeVfId('page:form:all:visitSettings:visitor2Id')).value();
    var strId3 = 'page:form:all:visitSettings:visitor3';
    var strHid3 = 'page:form:all:visitSettings:visitor3Id';
    var strVa3 = j$(escapeVfId('page:form:all:visitSettings:visitor3Id')).value();
    var strId4 = 'page:form:all:visitSettings:visitor4';
    var strHid4 = 'page:form:all:visitSettings:visitor4Id';
    var strVa4 = j$(escapeVfId('page:form:all:visitSettings:visitor4Id')).value();
    var strId5 = 'page:form:all:visitSettings:visitor5';
    var strHid5 = 'page:form:all:visitSettings:visitor5Id';
    var strVa5 = j$(escapeVfId('page:form:all:visitSettings:visitor5Id')).value();
    
    var urlStr = '/apex/SearchVisitor?id1=' + strId1 + '&hId1=' + strHid1 + '&idVa1=' + strVa1 + '&id2=' + strId2 + '&hId2=' + strHid2 + '&idVa2=' + strVa2 + '&id3=' + strId3 + '&hId3=' + strHid3 + '&idVa3=' + strVa3 + '&id4=' + strId4 + '&hId4=' + strHid4 + '&idVa4=' + strVa4 + '&id5=' + strId5 + '&hId5=' + strHid5 + '&idVa5=' + strVa5 + '&val=' + val + '&vp=' + vp;
    var w = window.open(urlStr,'SearchVisitor','menubar=no,height=720,width=986');
    w.focus();
  }
  
  function showModal() {
    //blockme();
    //showModalJs();
  }
 
  // 日报访问场所不允许修改 zh
  window.onload = function disabledActivityType(){
    if ({!isDisable}) {
      document.getElementById('page:form:all:visitSettings:activity').disabled = true; 
    }
    //20210609 mzy WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 start 
    disablePurpose();
    //20210609 mzy WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 end
    //20210511 zh  WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 start
    if({!allDisable}){
        // alert({!allDisable});
    //   j$('input').attr('disabled','disabled');
    //   j$('select').attr('disabled','disabled');
        for(var j=0;j<document.forms['page:form'].elements.length;j++) {
            setButtonDisable(document.forms['page:form'].elements[j],true);
        }
    }
    //20210511 zh  WLIG-BX3DQ5 【委托】Outlook日历和SFDC日历同步 end
  }
  function disablePurpose(){
    var vfeventId = '{!id}';
    if(vfeventId || {!isDisActivityCategory}){
        document.getElementById('page:form:all:visitSettings:activity').disabled = true;  
    }
    if( {!isDisActivityPurposeFSE} ){
       document.getElementById('page:form:all:visitSettings:purposeFSE').disabled = true;  
       //2021-09-30   mzy  锁住活动区分FSE  start
       document.getElementById('page:form:all:visitSettings:purposeTypeFSE').disabled = true;  
       //2021-09-30   mzy  锁住活动区分FSE   end
    }
    if( {!isDisActivityPurposeEscFSE} ){
       document.getElementById('page:form:all:visitSettings:purposeEscFSE').disabled = true;  
    }    
    //2021-08-10  mzy  update  SWAG-C5R6GW   询价任务新增字段  start
    if({!isOppSelect}){
      document.getElementById('page:form:all:visitSettings:opportunity').disabled = true;
      document.getElementById('page:form:all:visitSettings:opportunity2').disabled = true;
    }
    //2021-08-10  mzy  update  SWAG-C5R6GW   询价任务新增字段  end
  }
 
  //Add By Li Jun 20220225 for PIPL Start
  AWSService.sfSessionId = '{!GETSESSIONID()}';
    var staticResources = JSON.parse('{!staticResource}');
    var contactAWSIds = JSON.parse('{!contactAWSIds}');
    console.log('contactAWSIds:'+JSON.stringify(contactAWSIds));
    var sfIdToContactInfo = {};
    function preparePayloadForSearchContact(){
        let searchPayload = new Object();
        searchPayload.dataIds = contactAWSIds;
        searchPayload.contactName = '';
        return JSON.stringify(searchPayload);
    }
    function searchContactAll(){
        let data = preparePayloadForSearchContact();
        let searchCallBack = function searchCallBack(result){
            let contacts = result.object;
            if(contacts == null){
                return;
            }
            for(var i=0;i<contacts.length;i++){
                let temp = {}
                temp.lastName = contacts[i].lastName?contacts[i].lastName:'';                       
                if(contacts[i].sfRecordId){
                    sfIdToContactInfo[contacts[i].sfRecordId] = temp;
                }                    
            }
            console.log('AWS Result:'+JSON.stringify(sfIdToContactInfo));
            let v1Id = j$(escapeVfId('page:form:all:visitSettings:visitor1Id')).value();
            if(sfIdToContactInfo.hasOwnProperty(v1Id)){
                document.getElementById("page:form:all:visitSettings:visitor1").value = sfIdToContactInfo[v1Id].lastName;
            }  
            let v2Id = j$(escapeVfId('page:form:all:visitSettings:visitor2Id')).value();
            if(sfIdToContactInfo.hasOwnProperty(v2Id)){
                document.getElementById("page:form:all:visitSettings:visitor2").value = sfIdToContactInfo[v2Id].lastName;
            }                        
        };
        AWSService.search(staticResources.searchUrl,data,searchCallBack,staticResources.token);
    }
    //Add By Li Jun 20220225 for PIPL End 
</script>
<style>
    .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>
<div class="bPageTitle">
  <div class="ptBody">
    <div class="content">
      <img src="/s.gif" alt="主页"  class="pageTitleIcon" title="主页"/>
      <h1 class="pageType">日历<span  class="titleSeparatingColon">:</span></h1>
      <h2 class="pageDescription"> 新建事件</h2>
      <div class="blank">&nbsp;</div>
    </div>
  </div>
</div>
 
<apex:pageMessages showDetail="false" id="msgs"/>
 
<apex:form id="form">
 
<apex:actionFunction name="callHospital" action="{!visitToHospital}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callAgent" action="{!visitToAgent}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callTraining" action="{!visitToTraining}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callCampaign" action="{!visitToCampaign}" immediate="true" rerender="visitSettings"/>
<apex:actionFunction name="callNone" action="{!visitToNone}" immediate="true" rerender="visitSettings"/>
 
 
<apex:pageBlock title="事件编辑" mode="edit" id="all">
 
    <apex:pageblockSection title="日历详细信息" columns="2" collapsible="false" id="visitSettings">
 
        <apex:inputfield value="{!targetEvent.StartDateTime}" required="true" id="startDateTime" />
        <!--<apex:inputfield value="{!targetEvent.DurationInMinutes}" label="持续时间(分钟)" required="true" id="durationMinutes"/>-->
        <!--2021-07-22  mzy  事件页面优化--将持续时间换成结束时间 start -->
        <apex:inputfield value="{!targetEvent.EndDateTime}"   required="true" id="endDateTime"/>
        <!--2021-07-22  mzy  事件页面优化--将持续时间换成结束时间 end-->
        <apex:pageblockSectionItem />
        <apex:pageblockSectionItem />
        <!--2.1 拜访区分-->
        <apex:inputfield value="{!targetEvent.Activity_Type2__c}" onchange="changeVisitToGateway();" id="activity" required="true" />
        <!--2.2 拜访目的(FSE)/ 拜访目的(FSE外)-->
        <!-- <apex:inputfield value="{!targetEVent.Main_Visit_Location__c}" rendered="{!isHospital}" /> -->
        <apex:inputfield value="{!targetEvent.Activity_PurposeFSE__c}" required="true" rendered="{!IF(LoginUser.Job_Category__c == '销售服务', 'true', 'false')}"  id="purposeFSE" />
        <apex:inputfield value="{!targetEvent.Activity_PurposeEscFSE__c}" required="true" rendered="{!IF(LoginUser.Job_Category__c != '销售服务', 'true', 'false')}" id="purposeEscFSE" /> 
        <!--3.1 空-->
        <apex:pageblockSectionItem />
        <!--3.2 活动区分FSE/活动区分FSE外-->
         <!-- 20121-09-30 mzy 点检改善 end-->
         <apex:inputfield id="purposeTypeFSE" value="{!targetEvent.Purpose_TypeFSE__c}"  rendered="{!IF(LoginUser.Job_Category__c == '销售服务', 'true', 'false')}"  />
         <!-- 20121-09-30 mzy 点检改善 end-->
        <apex:inputfield value="{!targetEvent.Purpose_TypeEscFSE__c}" rendered="{!IF(LoginUser.Job_Category__c != '销售服务', 'true', 'false')}" />
        <!-- 10101104 zh SFDC-BUF6KM OPD被动任务是战略科室时,显示不能更改的战略科室和可更改的普通科室 start -->
        <apex:inputText label="战略科室" value="{!DepartmentName}" rendered="{!isShowDepartment}" disabled="true" style="width:97%"/>
        <apex:pageblockSectionItem rendered="{!isShowDepartment}" />
        <!-- 10101104 zh SFDC-BUF6KM OPD被动任务是战略科室时,显示不能更改的战略科室和可更改的普通科室 end -->
        <!--4.1-2整个横区域  科室/市场活动/公司工作/经销商-->
        <apex:inputText label="科室" value="{!targetEvent.Location}" rendered="{!isHospital}" id="hospital" onfocus="setSuggestHospital()" onchange="resetChild_delay('page:form:all:visitSettings:hospital');" style="width:97%" disabled="{!isDisableDepart}"/>
 
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isHospital}" id="hospitalId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isHospital}" id="hospitalHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isHospital}" id="hospitalHiddenId"/> 
        <apex:inputText label="经销商" value="{!targetEvent.Location}" rendered="{!isAgent}" id="agent" onfocus="setSuggestAgent()" onchange="resetValue('page:form:all:visitSettings:agent');" style="width:97%" disabled="{!IF(targetEvent.Location !='',true,false)}"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isAgent}" id="agentId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isAgent}" id="agentHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isAgent}" id="agentHiddenId"/>
        <apex:inputText label="公司工作" value="{!targetEvent.Location}" rendered="{!isTraining}" id="training" onfocus="setSuggestTraining()" onchange="resetValue('page:form:all:visitSettings:training');" style="width:97%" disabled="{!IF(targetEvent.Location !='',true,false)}"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isTraining}" id="trainingId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isTraining}" id="trainingHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isTraining}" id="trainingHiddenId"/>
        <apex:inputText label="市场活动" value="{!targetEvent.Location}" rendered="{!isCampaign}" id="campaign" onfocus="setSuggestCampaign()" onchange="resetValue('page:form:all:visitSettings:campaign');" style="width:97%" disabled="{!IF(targetEvent.Location !='',true,false)}"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isCampaign}" id="campaignId"/>
        <apex:inputHidden value="{!targetEvent.Location}" rendered="{!isCampaign}" id="campaignHidden"/>
        <apex:inputHidden value="{!targetEvent.whatid__c}" rendered="{!isCampaign}" id="campaignHiddenId"/>
        
        <!--5.1 主题-->
        <apex:pageblockSectionItem rendered="{!isHospital}">
            <apex:outputLabel value="主题" for="mId"/>
            <apex:outputPanel layout="block">
                <apex:outputPanel layout="block"/>
                <apex:inputText value="{!targetEvent.Subject}" style="width:97%"  required="false" size="50"/>
            </apex:outputPanel>
        </apex:pageblockSectionItem>
        <!--5.2 OPD计划-->
        <!-- <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="True" id="opportunity5111" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');"/>
        <apex:pageblockSectionItem /> -->
        <!-- 20200922 zh SWAG-BS6BYA 样式调整 start -->
 
        <!-- 访问对象1 -->
              <!-- <apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/> -->
              <!-- Add by Li Jun for PIPL 20220303 Start -->
              <apex:inputText label="访问对象" value="{!idVisitor1PI}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/>
              <!-- Add by Li Jun for PIPL 20220303 End -->
              <apex:pageblockSectionItem />
        <!-- 访问对象2 -->
              <!-- <apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/> -->
               <!-- Add by Li Jun for PIPL 20220303 Start -->
              <apex:inputText label=" " value="{!idVisitor2PI}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/>
              <!-- Add by Li Jun for PIPL 20220303 End -->
              <script>
                    console.log('Load AWS Data');
                    searchContactAll();
              </script>
              <apex:pageblockSectionItem rendered="{!isAgent}"/>
              <!-- <apex:pageblockSectionItem /> -->
        <!-- 询价1 -->
              <apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/>
              <apex:pageblockSectionItem />
        <!-- 询价2 -->
              <apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>
              <apex:pageblockSectionItem />
        <!-- 无询价申请理由 -->
              <apex:inputField label="{!$ObjectType.Event.fields.noOpp_Reason__c.label}" value="{!targetEvent.noOpp_Reason__c}" rendered="{!isHospital || isAgent}" id="noOppReason" />
              <!-- <apex:pageblockSectionItem /> -->
        <!--5.2 OPD计划-->
            <!--2021-12-23  mzy  备品任务 stat  只有用户拜访时可以勾选 OPD计划-->            
            <!-- 10101104 zh SFDC-BUF6KM OPD被动任务 start -->
              <!-- <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="True" id="opportunity5111" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');" /> -->
              <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="{!!isOpdDisable && isHospital}" id="opportunity5111" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');" />
              <apex:inputField label="{!$ObjectType.Event.fields.OPDPlan_Flag__c.label}" value="{!targetEvent.OPDPlan_Flag__c}" rendered="{!isOpdDisable && isHospital}" html-disabled="true" />
            <!-- 10101104 zh SFDC-BUF6KM OPD被动任务 end -->
            <!--2021-12-23  mzy  备品任务 end   只有用户拜访时可以勾选 OPD计划-->
              <!-- <apex:pageblockSectionItem /> -->
        <!-- 涉及的维修合同 -->
              <apex:pageblockSectionItem rendered="{!IF(isShowService,false,true)}"/>
              <apex:inputText label="{!$Label.Involved}{!$Label.Service_Agreement}" value="{!targetEvent.Related_Service1__c}" rendered="{!isShowService && isHospital}" id="contract" onFocus="setSuggestContract();" onchange="resetValue('page:form:all:visitSettings:contract');" disabled="{!isDisService}"/>
              <!-- <apex:pageblockSectionItem rendered="{!isAgent}"/>
                <apex:inputField label="{!$Label.Involved}{!$Label.Service_Agreement}" value="{!targetEvent.Related_Service1__c}" rendered="{!isHospital}" id="contract" onFocus="setSuggestContract();" onchange="resetValue('page:form:all:visitSettings:contract');"/> -->
        <!-- 20200922 zh SWAG-BS6BYA 样式调整 end -->
        <!-- 20200901 ljh add start  -->
        <!-- 计划出借的备品 -->
        <!--5.2 计划出借的备品-->
        <!-- 20200907 zh 计划出借备品 start -->
        <apex:outputPanel layout="block" style="overflow:auto; height:185px;" rendered="{!isHospital || isCampaign}" >
            <table style="margin-left: 15%;">
                <tr>
                    <td align="right"><b>计划出借的备品</b></td>
                    <td width="40px"></td>
                    <td><b>出借套数</b></td>
                </tr>
                <apex:repeat value="{!prods}" var="prod" id="planProducts">
                    <tr>
                        <td align="right"> {!prod.Name} </td>
                        <th width="10px"></th>
                        <td> 
                            <apex:inputText style="width: 60px;" id="rentalQuantity" value="{!planProducts[prod.Name]}" disabled="{!isDisPlanProd}"/> 
                        </td>
                    </tr>
                </apex:repeat>
            </table>
        </apex:outputPanel>
 
        <!-- <apex:inputfield value="{!targetEvent.PlanLendProduct__c}" rendered="{!isHospital || isCampaign}"/>
        <apex:pageblockSectionItem rendered="{!not(isHospital || isCampaign)}"/> -->
        <!--6.1 空-->
        <apex:pageblockSectionItem />
        <!-- 6.2 出借套数展示 -->
        <!-- <apex:inputfield value="{!targetEvent.LendNum__c}" rendered="{!isHospital || isCampaign}"/>
        <apex:pageblockSectionItem rendered="{!not(isHospital || isCampaign)}"/> -->
        <!-- 20200907 zh 计划出借备品 end -->
 
        <!-- Visitor 1-5 -->
        <!-- 20200901 ljh 样式调整02 start-->
        <!-- 访问对象1 -->
              <!-- <apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem /> -->
        <!-- 访问对象2 -->
              <!-- <apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem rendered="{!isAgent}"/> -->
              <!-- <apex:pageblockSectionItem /> -->
        <!-- 询价1 -->
              <!-- <apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/>
              <apex:pageblockSectionItem /> -->
        <!-- 询价2 -->
              <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>
              <apex:pageblockSectionItem /> -->
        <!-- 无询价申请理由 -->
              <!-- <apex:inputField label="{!$ObjectType.Event.fields.noOpp_Reason__c.label}" value="{!targetEvent.noOpp_Reason__c}" rendered="{!isHospital || isAgent}" id="noOppReason" /> -->
        <!-- 20200901 ljh 样式调整02 end-->
        <!-- 20200901 ljh 样式调整02原来 start-->
        <!-- Visitor 1-5 -->
        <!-- 访问对象1 -->
              <!--<apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>-->
        <!-- 询价1 -->
              <!--<apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/>-->
 
        <!-- 访问对象2 -->
              <!--<apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>-->
        <!-- 询价2 -->
              <!--<apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>-->
 
        <!-- 访问对象3 -->
             <!-- <apex:inputText label=" " value="{!targetEvent.Visitor3__c}" rendered="{!isHospital}" id="visitor3" onchange="clearVisitorId('visitor3Id');" onClick="searchVisitor2(value);"/>
        <apex:pageblockSectionItem rendered="{!isAgent}"/>-->
 
        <!-- 询价3 -->
              <!--<apex:inputField label=" " value="{!targetEvent.Related_Opportunity3__c}" rendered="{!isHospital || isAgent}" id="opportunity3" onFocus="setSuggestOpportunity3();" onchange="resetValue('page:form:all:visitSettings:opportunity3');"/>
              <apex:pageblockSectionItem rendered="{!isAgent}"/>
 
              <apex:inputText label=" " value="{!targetEvent.Visitor4__c}" rendered="{!isHospital}" id="visitor4" onchange="clearVisitorId('visitor4Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem rendered="{!isHospital}"/>
              <apex:inputText label=" " value="{!targetEvent.Visitor5__c}" rendered="{!isHospital}" id="visitor5" onchange="clearVisitorId('visitor5Id');" onClick="searchVisitor2(value);"/>
              <apex:pageblockSectionItem rendered="{!isHospital}"/>-->
        <!-- 20200901 ljh 样式调整02原来 end-->
 
        <apex:inputHidden id="visitor1Id" value="{!targetEvent.Visitor1_ID__c}" rendered="{!isHospital}"/>
        <apex:inputHidden id="visitor2Id" value="{!targetEvent.Visitor2_ID__c}" rendered="{!isHospital}"/>
        <!-- <apex:inputHidden id="visitor3Id" value="{!targetEvent.Visitor3_ID__c}" rendered="{!isHospital}"/> -->
        <!-- <apex:inputHidden id="visitor4Id" value="{!targetEvent.Visitor4_ID__c}" rendered="{!isHospital}"/> -->
        <!-- <apex:inputHidden id="visitor5Id" value="{!targetEvent.Visitor5_ID__c}" rendered="{!isHospital}"/> -->
        <!-- <apex:inputText label="访问对象" value="{!targetEvent.Visitor1__c}" rendered="{!isHospital}" id="visitor1" onchange="clearVisitorId('visitor1Id');" onClick="searchVisitor2(value);" style="width:30%"/>
        <apex:inputHidden id="visitor1Id" value="{!targetEvent.Visitor1_ID__c}" rendered="{!isHospital}"/>
        
        <apex:inputText label=" " value="{!targetEvent.Visitor2__c}" rendered="{!isHospital}" id="visitor2" onchange="clearVisitorId('visitor2Id');" onClick="searchVisitor2(value);" style="width:30%"/>
        <apex:inputHidden id="visitor2Id" value="{!targetEvent.Visitor2_ID__c}" rendered="{!isHospital}"/>
        
        <apex:inputText label=" " value="{!targetEvent.Visitor3__c}" rendered="{!isHospital}" id="visitor3" onchange="clearVisitorId('visitor3Id');" onClick="searchVisitor2(value);" style="width:30%"/>
        <apex:inputHidden id="visitor3Id" value="{!targetEvent.Visitor3_ID__c}" rendered="{!isHospital}"/> -->
        
       <!--  <apex:inputText label=" " value="{!targetEvent.Visitor4__c}" rendered="{!isHospital}" id="visitor4" onchange="clearVisitorId('visitor4Id');" onClick="searchVisitor2(value);"/>
        <apex:inputHidden id="visitor4Id" value="{!targetEvent.Visitor4_ID__c}" rendered="{!isHospital}"/>
        
        <apex:inputText label=" " value="{!targetEvent.Visitor5__c}" rendered="{!isHospital}" id="visitor5" onchange="clearVisitorId('visitor5Id');" onClick="searchVisitor2(value);"/>
        <apex:inputHidden id="visitor5Id" value="{!targetEvent.Visitor5_ID__c}" rendered="{!isHospital}"/>
         -->
          
        <!-- <apex:pageblockSectionItem rendered="{!IF(targetEvent.Activity_Type2__c == '病院', false, true)}"> -->
        <!-- <apex:inputfield value="{!targetEvent.Purpose_TypeFSE__c}"  rendered="{!IF(LoginUser.Job_Category__c == '销售服务', 'true', 'false')}"/>
        <apex:inputfield value="{!targetEvent.Purpose_TypeEscFSE__c}" rendered="{!IF(LoginUser.Job_Category__c != '销售服务', 'true', 'false')}"/>
        <apex:pageblockSectionItem /> -->
        
        <!-- <apex:pageblockSectionItem />
        <apex:pageblockSectionItem /> -->
        
        <!-- <apex:inputField label="{!$Label.Involved}{!$Label.Opportunity}" value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunity" onFocus="setSuggestOpportunity();" onchange="resetValue('page:form:all:visitSettings:opportunity');"/> -->
        <!-- <apex:pageblockSectionItem rendered="{!isAgent}"/>
        <apex:inputField label="{!$Label.Involved}{!$Label.Service_Agreement}" value="{!targetEvent.Related_Service1__c}" rendered="{!isHospital}" id="contract" onFocus="setSuggestContract();" onchange="resetValue('page:form:all:visitSettings:contract');"/> -->
        <!-- Opportunity2-5 -->
        <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2" onFocus="setSuggestOpportunity2();" onchange="resetValue('page:form:all:visitSettings:opportunity2');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/>
        <apex:inputField label=" " value="{!targetEvent.Related_Opportunity3__c}" rendered="{!isHospital || isAgent}" id="opportunity3" onFocus="setSuggestOpportunity3();" onchange="resetValue('page:form:all:visitSettings:opportunity3');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/> -->
        <!-- <apex:inputField label=" " value="{!targetEvent.Related_Opportunity4__c}" rendered="{!isHospital || isAgent}" id="opportunity4" onFocus="setSuggestOpportunity4();" onchange="resetValue('page:form:all:visitSettings:opportunity4');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/>
        <apex:inputField label=" " value="{!targetEvent.Related_Opportunity5__c}" rendered="{!isHospital || isAgent}" id="opportunity5" onFocus="setSuggestOpportunity5();" onchange="resetValue('page:form:all:visitSettings:opportunity5');"/>
        <apex:pageblockSectionItem rendered="{!isHospital || isAgent}"/> -->
        
        <apex:inputHidden value="{!targetEvent.Related_Opportunity1_ID__c}" rendered="{!isHospital || isAgent}" id="opportunityId"/>
        <apex:inputHidden value="{!targetEvent.Related_Service1_ID__c}" rendered="{!isHospital}" id="contractId"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity1__c}" rendered="{!isHospital || isAgent}" id="opportunityHidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Service1__c}" rendered="{!isHospital}" id="contractHidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity1_ID__c}" rendered="{!isHospital || isAgent}" id="opportunityHiddenId"/>
        <apex:inputHidden value="{!targetEvent.Related_Service1_ID__c}" rendered="{!isHospital}" id="contractHiddenId"/>
        <!-- Opportunity2-5 -->
        <apex:inputHidden value="{!targetEvent.Related_Opportunity2_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity2Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity2__c}" rendered="{!isHospital || isAgent}" id="opportunity2Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity2_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity2HiddenId"/>
        <!-- <apex:inputHidden value="{!targetEvent.Related_Opportunity3_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity3Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity3__c}" rendered="{!isHospital || isAgent}" id="opportunity3Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity3_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity3HiddenId"/> -->
        <!-- <apex:inputHidden value="{!targetEvent.Related_Opportunity4_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity4Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity4__c}" rendered="{!isHospital || isAgent}" id="opportunity4Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity4_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity4HiddenId"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity5_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity5Id"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity5__c}" rendered="{!isHospital || isAgent}" id="opportunity5Hidden"/>
        <apex:inputHidden value="{!targetEvent.Related_Opportunity5_ID__c}" rendered="{!isHospital || isAgent}" id="opportunity5HiddenId"/> -->
    </apex:pageblockSection>
 
     <apex:pageBlockButtons >
        <apex:commandButton value="保存" rerender="all,msgs" action="{!save}" onclick="blockme();" oncomplete="unblockUI();disablePurpose();" />
        <apex:commandButton value="保存并新建" rerender="all,msgs" action="{!saveAndNew}" onclick="blockme(); disablePurpose();"  oncomplete="unblockUI();"/>
         <apex:commandButton value="取消" action="{!cancel}" onclick="blockme();" oncomplete="unblockUI();"/>
     </apex:pageBlockButtons>
    
</apex:pageBlock>
</apex:form>
 
</apex:page>