public without sharing class eSignFormAttachmentController {
|
|
//存放所有的附件
|
public List<AccessoryData> acccData { get; set; }
|
//存放所有的附件的状态
|
public eSignForm__c eSignForm { get; set; }
|
//区分医院经销商标识符
|
public String identifier { get; set; }
|
public String identifier2 { get; set; }
|
//附件表的parentId
|
public String parentId;
|
public eSignFormAttachmentController() {
|
parentId = System.currentPageReference().getParameters().get('parentId');
|
//parentId = 'a421000000367mz';
|
acccData = new List<AccessoryData>();
|
System.debug('tiaoshiListjiheparentId==='+parentId);
|
}
|
public void init() {
|
getAccessory();
|
String soql = 'SELECT agencyAutoSignUpStatus__c,id,HPSignUpStatus__c,Group_purchase_PCL__c,OCM_man_province_cus__c,agencySignUpDate__c,Sales_Root_Formula__c,HPSignUpDate__c from eSignForm__c where id = :parentId ';
|
List<eSignForm__c> eSignFormData = Database.query(soql);
|
if(eSignFormData!=null){
|
eSignForm = eSignFormData[0];
|
}
|
System.debug('eSignForm==='+eSignForm);
|
}
|
|
public void getAccessory(){
|
String soql = 'SELECT Name,id,parentId,ContentType from Attachment where parentId = :parentId order by createddate desc';
|
List<Attachment> acc = Database.query(soql);
|
Map<String,String> identifierMap = new Map<String,String>();
|
if(acc != null && acc.size() > 0){
|
for(Integer i = 0;i<acc.size();i++){
|
if(acc[i].Name.substring(0,1)=='A'){
|
acc[i].ContentType = '经销商';
|
identifierMap.put(acc[i].ContentType,acc[i].ContentType);
|
}else if(acc[i].Name.substring(0,1)=='H'){
|
acc[i].ContentType = '医院';
|
identifierMap.put(acc[i].ContentType,acc[i].ContentType);
|
}else{
|
acc[i].ContentType = '';
|
}
|
acccData.add(new AccessoryData(acc[i]));
|
}
|
if(identifierMap.containsKey('经销商') && !identifierMap.containsKey('医院')){
|
identifier='经销商';
|
}else if(identifierMap.containsKey('医院') && !identifierMap.containsKey('经销商') ){
|
identifier2='医院';
|
}else if(identifierMap.containsKey('医院') && identifierMap.containsKey('经销商')){
|
identifier='经销商';
|
identifier2='医院';
|
}
|
}
|
System.debug('tiaoshiListjihe==='+acccData);
|
}
|
|
/**
|
* 为了方便前端table获取值
|
*/
|
class AccessoryData {
|
public Attachment accessory { get; set; }
|
public Boolean canEdit { get; private set; }
|
public Boolean hasError { get; private set; }
|
public Boolean hasFieldError { get; private set; }
|
public Integer lineNo { get; private set; }
|
public String changeFlg { get; set; }
|
public String reasonFlg { get; set; }
|
//复选框id值
|
public String chk { get;set; }
|
|
public AccessoryData(Attachment record) {
|
accessory = record;
|
canEdit = true;
|
hasError = false;
|
hasFieldError = false;
|
lineNo = 0;
|
changeFlg = '0';
|
reasonFlg = '0';
|
chk = 'chk'+lineNo;
|
}
|
}
|
}
|