public with sharing class QLMAttachmentPreviewController {
|
// //附件的parentId
|
public String parentId { get; private set; }
|
// //附件的Id
|
public String attachId { get; private set; }
|
//所有附件
|
public list<Attachment> attachMentList { get; private set; }
|
|
//所有超过12Murl
|
public list<Over12MInfo> Over12MInfoList { get; set; }
|
|
|
//构造bean类
|
public AttachmentInfo attachmentInfo {get; set;}
|
|
public String gethtmlvalue() {
|
this.parentId = ApexPages.currentPage().getParameters().get('parentId');
|
this.attachId = ApexPages.currentPage().getParameters().get('Id');
|
System.debug('123456--=--=--=-=--=' + attachId);
|
try {
|
// return [SELECT Id, Body, ParentId FROM Attachment
|
// where Id = :parentId ].body.tostring();
|
String Att = [SELECT Id, Body, ParentId FROM Attachment
|
where Id = :attachId ].body.tostring();
|
System.debug('------123456----' + Att);
|
return Att;
|
} catch (exception e) {
|
return '';
|
}
|
}
|
|
public void init() {
|
//获取页面参数
|
this.parentId = ApexPages.currentPage().getParameters().get('parentId');
|
this.attachId = ApexPages.currentPage().getParameters().get('Id');
|
Over12MInfoList = new List<Over12MInfo>();
|
try {
|
//判断url是否有id
|
if (String.isNotBlank(this.parentId)) {
|
this.attachMentList = [SELECT id, parentId, Name, Body, ContentType
|
from Attachment where parentId = :parentId];
|
|
attachmentInfo = new AttachmentInfo(attachMentList);
|
List<Tender_information__c> QLMattachMentList = [SELECT id, ProjectId__c, InfoType__c,
|
Overstep_12M_infofile__c,
|
File_Surpass_12M__c from Tender_information__c
|
where Id = :parentId];
|
if (QLMattachMentList.size() > 0) {
|
System.debug('QLMattachMentList:' + QLMattachMentList);
|
Integer i = 1;
|
// for (Tender_information__c Over12M : QLMattachMentList) {
|
for (String urlStr : QLMattachMentList[0].Overstep_12M_infofile__c.split(',')) {
|
// this.url = Over12M.Overstep_12M_infofile__c;
|
System.debug('urlStr:' + urlStr);
|
urlStr = urlStr.replaceAll('http://', 'https://');
|
over12MInfo over12MFile = new Over12MInfo('文件' + i, urlStr);
|
Over12MInfoList.add(over12MFile);
|
System.debug('12345678Over12MInfoList:' + Over12MInfoList);
|
i++;
|
}
|
}
|
}
|
} catch (Exception ex) {
|
ApexPages.addMessages(ex);
|
}
|
}
|
|
public class AttachmentInfo {
|
public list<Attachment> attachMentList { get; set; }
|
|
public AttachmentInfo(list<Attachment> attachMentList) {
|
this.attachMentList = attachMentList;
|
for (Attachment tempatt : attachMentList) {
|
tempatt.Name = String.escapeSingleQuotes(tempatt.Name);
|
}
|
}
|
}
|
public class Over12MInfo {
|
public string name { get; set; }
|
public string url { get; set; }
|
public Over12MInfo(string name, string url) {
|
this.name = name;
|
this.url = url;
|
}
|
}
|
}
|