buli
2022-04-26 5835379ec30b1667c4e522db9d294c9b7bb8633a
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
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
<apex:page id="Page" standardController="Mail_Merge__c" extensions="SendEmailController" sidebar="false" showHeader="false" action="{!init}" title="SendEmail">
 
<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') }" />
 
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no"/>
    <style type="text/css"> 
        .tableCss{
            width: 100%;
            border: 0;
        }
        .errorMessage{
            font-size: 15px;
            color:#FF0000;
        }
        .title{
            height: 30px;
            background-color: #DFE6F0;
        }
        .title font{
            font-size:15px;
            color:#607799;
        }
    </style>
    <script>
        let isBlocking = false;
        function b(){
            if (!isBlocking) {
                isBlocking = true;
                blockme();
            }
        }
 
        function ub(){
            if (isBlocking) {
                isBlocking = false;
                unblockUI();
            }
        }
 
        function formSubmit(){
            testFile();
        }
        function openPDF(){
            //var typeId = "{!mail.RECORD__c}";
            var baseUrl = j$(escapeVfId("baseUrl")).value();
            window.open(baseUrl + '/apex/QuotesPDF?id={!mail.RECORD__c}');
        }
        function openSearchMemberPage(lineNum){
            var baseUrl = j$(escapeVfId("baseUrl")).value();
            //var repairId = j$(escapeVfId("repairId")).value();
            window.open(baseUrl + '/apex/SearchMemberPage?lineNum='+lineNum,'pselect', 'width=600,height=450,scrollbars=yes,toolbar=no,status=no,directories=no,menubar=no,resizable=1', true);
        }
        function refreshPage(lineNum,memberId,memberName,memberEmail){
            /*var memberNameId = "memberName"+lineNum;
            var memberEmailId = "memberEmail"+lineNum;
            j$(escapeVfId(memberNameId)).attr("value",memberName);
            j$(escapeVfId(memberEmailId)).attr("value",memberEmail);*/
            // addMemberData(lineNum,memberId,memberName,memberEmail);
            j$("#memberBody tr[line-id='"+lineNum+"'] input.emailAddress").val(memberEmail);
            j$("#memberBody tr[line-id='"+lineNum+"'] input.name").val(memberName);
        }
        function statusChabge(linenumNum,type){
            var toId = "Page:messageForm:lineDataList:"+linenumNum+":"+"to";
            var ccId = "Page:messageForm:lineDataList:"+linenumNum+":"+"cc";
            var bccId = "Page:messageForm:lineDataList:"+linenumNum+":"+"bcc";
            var toValue = j$(escapeVfId(toId)).value();
            var ccValue = j$(escapeVfId(ccId)).value();
            var bccValue = j$(escapeVfId(bccId)).value();
            j$(escapeVfId(toId)).attr("checked",false);
            j$(escapeVfId(ccId)).attr("checked",false);
            j$(escapeVfId(bccId)).attr("checked",false);
            //这个if判断,保证三个收件人类型有一个时选中的,不可以三个都为不勾选
            //if(toValue == ""&&ccValue==""&&bccValue==""){
                if(type == "to"){
                    j$(escapeVfId(toId)).attr("checked",true);
                }
                if(type == "cc"){
                    j$(escapeVfId(ccId)).attr("checked",true);
                }
                if(type == "bcc"){
                    j$(escapeVfId(bccId)).attr("checked",true);
                }
            //}
            //下边三个if,三个勾选框互斥,只能勾选一个
            /*if(type == "to"){
                j$(escapeVfId(ccId)).attr("checked",false);
                j$(escapeVfId(bccId)).attr("checked",false);
            }
            if(type == "cc"){
                j$(escapeVfId(toId)).attr("checked",false);
                j$(escapeVfId(bccId)).attr("checked",false);
            }
            if(type == "bcc"){
                j$(escapeVfId(toId)).attr("checked",false);
                j$(escapeVfId(ccId)).attr("checked",false);
            }*/
        }
 
        //dialog 弹窗 start 
        var popupBox;
            popupBox = new SimpleDialog("SpeedDialogId", false);  // 不可拖动
            popupBox.createDialog();        
        function openFile(){
            // alert('111111111');
            // uploadFileS();
            document.getElementById("file_input").value = '';
            popupBox.setTitle("请选择要上传的图片!");
            popupBox.importContentNode(document.getElementById("Page:messageForm:popupBox"));
            popupBox.show(document.getElementById("Page:messageForm:popupBox"));
            document.getElementById("Page:messageForm:popupBox").style.display = 'block';
           
 
        }
        //dialog 弹窗 end 
        
        //上传图片
        function saveAttachment(){
                var maxFileSize = 4350000;      //Base64 编码以后最大的文件字节数
                var attachmentBody;                //附件内容
                var attachmentName;                //附件名称
                var attachmentType;                //附件名称
                var attachmentSize;                //附件大小
                var parentId = j$(escapeVfId("parentId")).value();
                // 获取上传图片的数量
                var size = document.getElementById("file_input").files.length;
                if (size > 0) {
                var nameList = [];
                var typeList = [];
                var bodyList = [];
                for(var i = 0;i < size;i++){
                    var fbody = document.getElementById("file_input").files[i];
                    attachmentName = fbody.name;
                    if(fbody.size <= maxFileSize) {
                        attachmentType = fbody.type;
                        nameList.push(attachmentName);
                        typeList.push(attachmentType);
                        var fileReader = new FileReader();
                        fileReader.readAsBinaryString(fbody);
                        fileReader.onload = function(e) {
                            bodyList.push(window.btoa(this.result));
                        }
                        fileReader.onerror = function(e) {
                            alert("上传失败,请重新尝试");
                        }
                        fileReader.onabort = function(e) {
                            alert("上传失败,请重新尝试");
                        }
                    } else {
                        alert("Base64 编码最大允许4.3M文件,"+attachmentName + '过大无法上传');
                    }
 
 
                }
                if (nameList.length > 0) {
                        //使用RemoteAction上传附件
                        Visualforce.remoting.Manager.invokeAction(
                        '{!$RemoteAction.SendEmailController.AddAttachment}',
                        nameList,
                        typeList,
                        bodyList,
                        parentId,
                        function(result,event) {
                            
                            if(result == '文件上传成功'){
                            alert(result); 
                            RefreshPage();
                            } else if (result == null){
                            result = '文件上传失败,请重新上传';
                            alert(result); 
                            RefreshPage();
                            } else {
                            alert(result); 
                            }
                            
                        });
 
                }
                
                }
                
                
        }
 
        // PI改造 By Bright 20220329
        AWSService.sfSessionId = '{!GETSESSIONID()}';
        var staticResourceMail = JSON.parse('{!staticResourceMail}');
        var staticResourceMailMerge = JSON.parse('{!staticResourceMailMerge}');
        var staticResourceDocument = JSON.parse('{!staticResourceDocument}');
        var isQuotesPdf = false;
 
        function alertErrorMessage(errorMsg) {
            console.log(errorMsg);
        }
 
        function uploadFileToAWS(data, size, fileName, callback) {
            
            console.log("body=" + JSON.stringify({ 'file': data, "size": size, 'fileName': fileName }));
            AWSService.post(staticResourceDocument.newUrl, JSON.stringify({ 
                'file': data, 
                "size": size, 
                'fileName': fileName })
                , function(result){
                    console.log("result" + JSON.stringify(result));
                    
                    if (result.success) {
                        let key = result.object;
                        confirmTrans(result.txId,1,function(){
                            if (callback) {
                                callback(key);
                            }
                        })
                        //SendEmail();
                        console.log('key' + key);
                    } else {
                        alertErrorMessage('上传失败请稍后再试!');
                    }
            }, staticResourceDocument.token);
        
        }
 
        function SendEmailCallBack(){
            console.log('SendEmailCallBack');
        }
 
        function confirmTrans(transId, isSuccess,callback) {
              
            AWSService.post(staticResourceDocument.updateUrl, JSON.stringify({
                "txId":transId,
                "sfRecordId":"",
                "isSuccess":isSuccess
            }), function(data){
                console.log("confirmTrans-" + JSON.stringify(data));
                if (callback) {
                    callback()
                }
            }, staticResourceDocument.token);
        
        }
 
        function uploadFile() {
            var maxFileSize = 4350000;
            let files = document.getElementById("file_input").files
            // 获取上传图片的数量
            
            if (files.length == 0) {
                alert('至少选择一个附件');
                return;
            }
            
            let attachList=[];
            let complete_flags = new Array(files.length + 1).join(0).split('').map(function () { return false });
            let AllComplete = function(){
                for (let index = 0; index < complete_flags.length; index++){
                    if(!complete_flags[index]){
                        return;
                    }
                }
                
                ub();
            }
            for(var i = 0;i < files.length;i++){
                var fbody = files[i];
                let j = i;
                if(fbody.size <= maxFileSize) {
                    
                } else {
                    alert("Base64 编码最大允许4.3M文件,"+fbody.name + '过大无法上传');
                    return;
                }
            }
 
            popupBox.hide();
            b();
            for(var i = 0;i < files.length;i++){
                var fbody = files[i];
                let j = i;
                var fileReader = new FileReader();
                fileReader.fbody = fbody;
                fileReader.readAsDataURL(fbody);
                fileReader.onload = function(e) {
                    let reader = this;
                    attachList.push({
                        name:reader.fbody.name,
                        type:reader.fbody.type,
                        body:reader.result,
                        size:reader.fbody.size
                    })
                    // 
                    console.log('onload '+ j);
                    // ReadComplete();
                    uploadFileToAWS(reader.result, reader.fbody.size, reader.fbody.name,function(key){
                        complete_flags[j] = true;
                        AppendAttachmentHtml(reader.fbody.name,key,reader.fbody.size);
                        AllComplete();
                    });
 
                    
                }
                fileReader.onerror = function(e) {
                    ub();
                    alert("上传失败,请重新尝试");
                }
                fileReader.onabort = function(e) {
                    ub();
                    alert("上传失败,请重新尝试");
                }
            }
            
            console.log('end');
            
        }
 
        let AfterCallBack = null;
        function AddQuotesPdf(callback){
            if (isQuotesPdf) {
                alert('已添加报价单,无需重复添加');
                return;
            }
            b();
            AfterCallBack = callback;
            j$("#pdf").attr("src",'/apex/QuotesPDF?id={!typeid}&addFile=AddQuotesPdfCallBack');
        }
 
        function AddQuotesPdfCallBack(uri){
            let bodys = uri.split(',');
            let body = bodys[bodys.length-1]
            let size = window.atob(body).length;
            let name = '报价单.pdf';
            uploadFileToAWS(uri, size, name,function(key){
                ub();
                AppendAttachmentHtml(name,key,size);
                isQuotesPdf = true;
                if (AfterCallBack) {
                    AfterCallBack();
                }
            });
        }
 
        function SendEmailJs(){
 
            let tos = jQuery("#memberBody :checked[target='to']");
            if(tos.length<1){
                alert("至少填写一个收件人");
                return;
            }
 
            let error_email_e = null;
            j$("#memberBody .emailAddress").each(function(i,e){
                if (!/^[\w-]{1,99}@[\da-zA-Z]{1,99}\.[a-zA-Z]+$/.test(e.value)) {
                    error_email_e = e;
                    return false;
                }
                return true;
            })
 
            if (error_email_e) {
                if(error_email_e.value){
                    alert('邮箱地址格式不对:'+error_email_e.value);
                }else{
                    alert('邮箱地址必填');
                }
                
                j$(error_email_e).focus();
                j$(error_email_e).select();
                return;
            }
 
            let subject = j$(".SUBJECT__c").val();
            if (!subject) {
                alert("SUBJECT必填");
                return;
            }
 
            
            let message = j$(".MESSAGE__c").val();
            if (!message) {
                alert("MESSAGE必填");
                return;
            }
 
            let Foo = function(target){
                let targets = jQuery("#memberBody :checked[target='"+target+"']");
                let emails = [];
                let names = [];
                targets.each(function(i,e){
                    let v = j$(e).closest("tr").find(".name").val();
                    names.push(v?v:'-');
                    emails.push(j$(e).closest("tr").find(".emailAddress").val());
                });
                return {
                    emails:emails,
                    names:names
                }
            }
            
 
            let to = Foo('to');
            let cc = Foo('cc');
            let bcc = Foo('bcc');
 
            
            let payload = {
                "bcc": bcc.emails.join(';'),
                "bccName": bcc.names.join(';'),
                "cc": cc.emails.join(';'),
                "ccName": cc.names.join(';'),
                "from": j$(".FROM__c").html(),
                "fromName": "",
                "message": message,
                "recipient": to.emails.join(';'),
                "recordId": "{!typeid}",
                "recordType": "{!type}",
                "subjectCopy": subject+'~{!name}',
                "toName": to.names.join(';')
            };
            b();
 
            
 
            let Send = function(){
                let fileMap = {}
                j$("a.attach_link").each(function(i,e){
                    fileMap[j$(e).attr("data-key")] = j$(e).attr("data-name");
                });
                payload.fileMap = fileMap;
                AWSService.post(staticResourceMail.newUrl,JSON.stringify(payload),function(data){
                    console.log(data);
                    ub();
                    if (data && data.success) {
                        alert('发送成功')
                        if ('{!typeid}') {
                            window.location.href = '/{!typeid}?type=mail';
                        }else{
                            window.location.href = '/'+data.object;
                        }
                    }else{
                        alert('发送失败,原因:'+(data && data.message ? data.message :'未知错误'));
                    }
                },staticResourceMail.token);
            }
 
            // 如果没添加报价单,自动添加
            if ('{!type}' == 'Quotes' && !isQuotesPdf) {
                AddQuotesPdf(Send);
            }else{
                Send();
            }
            
        }
 
        function AppendAttachmentHtml(name,key,size){
           let html =  '<tr style="text-align:center; vertical-align: middle;">'
                         + '<td><a class="attach_link" target="_blank" data-key="'+key+'" data-name="'+name+'" href="'+staticResourceDocument.queryUrl+key+'">'+name+'</a></td>'
                            +'<td>'+new Date().toLocaleString()+'</td>'
                            +'<td>'+size+'</td>'
                            +'<td><input type="button" class="btn delete_attachment" value="delete" /></td>'
                        +'</tr>';
            j$("table.attach_preview").append(html);
        }
 
        function AddMemberJs(){
            let line_id = new Date().getTime()+''+Math.floor(Math.random()*1000);
            let html =  '<tr line-id="'+line_id+'" style="text-align:center;">'
                            +'<td><input id="memberName2" type="hidden" value=""><input class="emailAddress" type="text" value=""/></td>'
                                +'<td><input class="name" type="text" value=""/></td>'
                                +'<td><input line-id="'+line_id+'" target="to" type="checkbox" checked="checked"/></td>'
                                +'<td><input line-id="'+line_id+'" target="cc" type="checkbox"/></td>'
                                +' <td><input line-id="'+line_id+'" target="bcc" type="checkbox"/></td>'
                                +' <td><input line-id="'+line_id+'" class="btn delete" value="delete" type="button"/></td>'
                                +' <td><input type="button" value="Search" onclick="openSearchMemberPage('+line_id +');" class="btn search"/></td>'
                        +' </tr>';
            j$("#memberBody").append(html);
        }
        
        j$(function(){
            j$("table.attach_preview").on("click",".delete_attachment",function(){
                j$(this).closest("tr").remove();
            })
 
            j$("#memberBody").on("click",":checkbox",function(){
                let b = j$(this).prop("checked");
                console.log(b);
                j$(":checkbox[line-id='"+j$(this).attr("line-id")+"']").prop("checked",false);
                j$(this).prop("checked",b);
            })
 
            j$("#memberBody").on("click","input.delete",function(){
                j$("tr[line-id='"+j$(this).attr("line-id")+"']").remove();
            })
            
            if ('{!AWSDataId}') {
                b();
                AWSService.query(staticResourceMailMerge.queryUrl,'{!AWSDataId}',function(data){
                    ub();
                    if (data && data.object) {
                        let allMembers = data.object.allMember.split(';');
                        let allMemberNames = data.object.allMemberName.split(';');
                        j$("#memberBody .emailAddress").each(function(i,e){
                            j$(e).val(allMembers[i]);
                        })
 
                        j$("#memberBody .name").each(function(i,e){
                            j$(e).val(allMemberNames[i]=='-'?'':allMemberNames[i]);
                        })
                    }
 
                },staticResourceMailMerge.token);
            }
        })
    </script>
    <div style="width : 100%;">
    <div style="width : 70%; margin: auto;">
        <apex:form id="messageForm">
            <input type="hidden" id="baseUrl" value="{!baseUrl}"/>
            <input type="hidden" id="parentId" value="{!Id}"/>
            <input type="hidden" id="isOnClick" value="{!isOnClick}"/>
            <apex:actionFunction name="addMemberData" action="{!addMemberData}" reRender="messageForm">
                <apex:param name="lineNum" assignTo="{!lineNum}" value="" />
                <apex:param name="memberId" assignTo="{!memberId}" value="" />
                <apex:param name="memberName" assignTo="{!memberName}" value="" />
                <apex:param name="memberEmail" assignTo="{!memberEmail}" value="" />
            </apex:actionFunction>
            <!-- 图片批量上传 保存Email -->
             <apex:actionFunction name="uploadFileS" action="{!uploadFileS}" reRender="messageForm" oncomplete="openFile();"/>
             <!-- 图片批量上传 刷新页面 -->
              <apex:actionFunction name="RefreshPage"  action="{!RefreshPage}" reRender="messageForm"/>
            <apex:actionFunction name="deleteFile" reRender="fileForm">
                <!-- <apex:param name="lineNum" assignTo="{!lineNum}" value="" /> -->
            </apex:actionFunction>
 
            <apex:actionFunction name="SendEmail" action="{!SendEmail}"  oncomplete="SendEmailCallBack();" reRender="messageForm" >
                <apex:param name="handleType" assignTo="{!handleType}" value="send" />
            </apex:actionFunction>
 
            <div style="width: 100%">
                <div class="errorMessage" style="margin-left: 39%">
                    <span id="errorMessage">{!errorMessage}</span>
                </div>
            </div>
 
            <div style="width: 100%;">
                <table class="tableCss">
                    <tr class="title">
                        <th colspan="2"><font>Recipients</font></th>
                    </tr>
                    <tr>
                        <th style="width: 20%;text-align:center;">FROM:</th>
                        <td><apex:outputText styleClass="FROM__c" value="{!mail.FROM__c}" style="width: 40%"/></td>
                    </tr>
                </table>
            </div>
            <div style="width: 50%;margin-left: 20%;">
                <!-- style="border:1px solid #000000;" -->
                <table class="tableCss">
                    <thead>
                        <tr>
                            <th style="width: 25%;text-align:center;">email</th>
                            <th style="width: 10%;text-align:center;">name</th>
                            <th style="width: 5%;text-align:center;">TO</th>
                            <th style="width: 5%;text-align:center;">CC</th>
                            <th style="width: 5%;text-align:center;">BCC</th>
                            <th style="width: 5%;text-align:center;"></th>
                        </tr>
                    </thead>
                    <tbody id="memberBody">
                        <apex:repeat id="lineDataList" value="{!memberLineDatas}" var="lineData">
                            <tr line-id="{!lineData.lineNum}" style="text-align:center;">
                                <td>
                                <input type="hidden" id="memberName{!lineData.lineNum}" value="{!lineData.name}" />
                                <apex:inputText styleClass="emailAddress" value="{!lineData.emailAddress}" /></td>
                                <td><apex:inputText styleClass="name" value="{!lineData.name}" /></td>
                                <td><apex:inputCheckbox html-line-id="{!lineData.lineNum}" html-target="to"  id="to" value="{!lineData.to}"/></td>
                                <td><apex:inputCheckbox html-line-id="{!lineData.lineNum}" html-target="cc"  id="cc" value="{!lineData.cc}"/></td>
                                <td><apex:inputCheckbox html-line-id="{!lineData.lineNum}" html-target="bcc"  id="bcc" value="{!lineData.bcc}"/></td>
                                <td><input line-id="{!lineData.lineNum}" class="btn delete" value="delete" type="button"/></td>
                                <!-- <td><apex:commandButton onclick="b();" action="{!deLine}" reRender="messageForm" value="delete"  oncomplete="ub();" disabled="{!isOnClick}">
                                    <apex:param name="lineNum" assignTo="{!lineNum}" value="{!lineData.lineNum}" />
                                </apex:commandButton></td> -->
                                <td>
                                    <apex:commandButton onclick="openSearchMemberPage({!lineData.lineNum});" value="Search" disabled="{!isOnClick}">
                                        
                                    </apex:commandButton>
                                </td>
                            </tr>
                        </apex:repeat>
                    </tbody>
                    <thead>
                        <tr style="text-align:center;">
                            <!-- <td><apex:commandButton id="addLine" onclick="b();" action="{!addLine}" reRender="messageForm" value="ADD Member" oncomplete="ub();" disabled="{!isOnClick}"></apex:commandButton></td> -->
                            <td><apex:commandButton id="addLine" onclick="AddMemberJs();" value="ADD Member" oncomplete=""></apex:commandButton></td>
                        </tr>
                    </thead>
                </table>
            </div>
            <div style="width: 100%">
                <table class="tableCss">    
                    <tr class="title">
                        <th colspan="2"><font>Message</font></th>
                    </tr>
                    <tr>
                        <th style="width: 20%;text-align:center;">Date Time:</th>
                        <td><apex:inputField value="{!mail.DATE__c}" style="width: 40%"/></td>
                    </tr>
                    <!-- <tr>
                        <th style="width: 20%;text-align:center;">RECORD:</th>
                        <td><apex:inputField value="{!mail.RECORD__c}" style="width: 40%"/></td>
                    </tr>
                    <tr>
                        <th style="width: 20%;text-align:center;">RECORD TYPE:</th>
                        <td><apex:inputField value="{!mail.RECORD_TYPE__c}" style="width: 40%"/></td>
                    </tr> -->
                    <tr>
                        <th style="text-align:center;width: 20%;">SUBJECT:</th>
                        <td><apex:inputField styleClass="SUBJECT__c" value="{!mail.SUBJECT__c}" style="width: 40%"/></td>
                    </tr>
                    <tr>
                        <th style="text-align:center;width: 20%;">MESSAGE:</th>
                        <td><apex:inputField styleClass="MESSAGE__c" style="height: 200px;width: 60%" value="{!mail.MESSAGE__c}"/></td>
                    </tr>
                </table>
            </div>
        <!-- </apex:form>
        <apex:form id="fileForm"> -->
            <div style="width: 100%">
                <table class="tableCss">
                    <tr class="title">
                        <th colspan="2"><font>Attachments</font></th>
                    </tr>
 
                    <tr>
                        <td>
                            <!-- <apex:commandButton value="Upload Attachment" action="{!uploadFile}" disabled="{!isOnClick}">
                            </apex:commandButton> -->
                             <apex:panelGroup >
                                 <apex:commandButton onclick="openFile();return false;" value="图片批量上传" disabled="{!isOnClick}"/>
                            </apex:panelGroup>
                        </td>
                    </tr>
                </table>
            </div>
            <apex:outputPanel rendered="{!IF(openType == 'View', true, false)}" style="margin-left: 5px;"> 
                <!-- border:1px solid #000000; -->
                <table class="tableCss" style="width: 80%"> 
                    <tr style="text-align:center;">
                        <th style="text-align:center;width: 33%;">File Name</th>
                        <th style="text-align:center;width: 33%;">Upload Time</th>
                        <!-- <th style="text-align:center;width: 33%;">File Size</th> -->
                    </tr>
                    <apex:repeat id="attachmentList" value="{!newAttachmentList}" var="item">
                        <tr style="text-align:center; vertical-align: middle;">
                            <!-- <td><input value="{!item.Name}" readonly="readonly" style="border:none;"/></td> -->
                            <td><apex:outputLink value="/{!item.Id}">{!item.FileName__c}</apex:outputLink></td>
                            <td><apex:inputField value="{!item.CreatedDate}"/></td>
                            <!-- <td><apex:inputField value="{item.BodyLength}"/></td> -->
                            <td id="{!item.Id}">
                                <a target="_blank" href="{!item.ViewLink__c}">查看</a>
                            </td>
                        </tr>
                    </apex:repeat>
                </table>
            </apex:outputPanel>
            <!-- 20220222 PI改造 by Bright start -->
            <apex:outputPanel rendered="{!IF(openType == 'View', false, true)}" style="margin-left: 5px;"> 
                <!-- border:1px solid #000000; -->
                <table class="tableCss attach_preview" style="width: 80%"> 
                    <tr style="text-align:center;">
                        <th style="text-align:center;width: 33%;">File Name</th>
                        <th style="text-align:center;width: 33%;">Upload Time</th>
                        <th style="text-align:center;width: 33%;">File Size</th>
                    </tr>
                    
                </table>
            </apex:outputPanel>
            <!-- 20220222 PI改造 by Bright end -->
 
            <div style="width: 30%;height: 5%;margin-left: 30%;margin-top: middle;">
                 <apex:outputPanel rendered="{!IF(type == 'Quotes', true, false)}">
                    <apex:commandButton id="open" value="查看报价单" onclick="openPDF();return false;" style="width: 49%;height: 5%" />
                    <apex:commandButton id="addPDf" value="添加报价单" onclick="AddQuotesPdf();return false;"  oncomplete="" reRender="messageForm" style="width: 49%;height: 5%" disabled="{!isOnClick}"/>
                </apex:outputPanel>
                <apex:commandButton id="test" value="Send   Mail" onclick="SendEmailJs();return false;" style="width: 99%;height: 5%" disabled="{!isOnClick}"/>
                <!-- <apex:commandButton id="test" action="{!SendEmail}" value="Send   Mail" onclick="b();"  oncomplete="ub();" reRender="messageForm" style="width: 99%;height: 5%" disabled="{!isOnClick}">
                    <apex:param name="handleType" assignTo="{!handleType}" value="send" />
                </apex:commandButton> -->
            </div>
            <apex:outputPanel id="popupBox" layout="block" style="display:none">
 
                <input type="file" id="file_input" name="attFile" multiple="true"/><br/>
                <center>
                    <apex:commandButton value="确认" onclick="uploadFile(); return false;" style="width: 20%; margin: 20px 10px 0px 10px" />
                    <apex:commandButton value="取消" onclick="popupBox.hide();" style="width: 20%; margin: 20px 10px 0px 10px" />
                </center>
            </apex:outputPanel> 
        </apex:form>
        <iframe src="" id="pdf" style="position: absolute;left: 100%;" />
    </div>
    </div>
</apex:page>