高章伟
2022-02-18 8b5f4c6c281cfa548f92de52c8021e37aa81901e
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
public with sharing class AttachmentPreviewController {
    /*目前仅供签收单使用 开发简档给119、  2S6 、2S7 、系统管理员*/
 
    //附件的parentId
    public String parentId { get; private set; }
    //所有附件
    public list<Attachment> attachMentList { get; private set; }
    //构造bean类 用于判断是否显示 电子签收单的附件类型
    public AttachmentInfo attachmentInfo  {get;set;}
    //判断标识 用于判断是否显示 电子签收单的附件类型 电子签收单默认true
    public Boolean isShow {get;set;}
   
    //初始化方法
     public void init() {
        //获取页面参数
          this.parentId = ApexPages.currentPage().getParameters().get('parentId');
         try {
            //判断url是否有id
            if (String.isNotBlank(this.parentId)) {
                //初始化的状态默认就是true
                this.isShow=true;
             this.attachMentList = [SELECT id,parentId,Name,ContentType 
                                                        from Attachment where parentId = :parentId 
                                                        order by createddate desc];
            //如果有非电子签收命名规则的附件 则isShow置成false 页面不显示该列
                for(Attachment attachment:attachMentList){
                    //attachment.Name.substring(0,1);
                    if(attachment.Name.substring(0,1)=='A'){
                        attachment.ContentType='经销商';
 
                    }
                else if(attachment.Name.substring(0,1)=='H'){
                    attachment.ContentType='医院';
                }
                else if(attachment.Name.substring(0,2)!='H-' && attachment.Name.substring(0,2)!='A-'){
                    this.isShow=false;
                }
                }
            //构造方法
            attachmentInfo = new AttachmentInfo(attachMentList, isShow); 
        }
           System.debug('attachmentInfo:'+attachmentInfo);
           System.debug('attachMentList:'+attachMentList);
        } catch (Exception ex) {
            ApexPages.addMessages(ex);
        }
}
   
    public class AttachmentInfo {
        public list<Attachment> attachMentList { get;set; }
        public Boolean isShow      {get; set;}
 
        public AttachmentInfo(list<Attachment> attachMentList, Boolean isShow  ) {
            this.attachMentList = attachMentList;
            this.isShow = isShow;
        }
        
        
    }
 //    public AttachmentPreviewController() {
 
    // }
}