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() {
|
|
// }
|
}
|