1.4.2.2.1. 前端

<script type="text/javascript">
<!--
……
//附件上传后回调方法
function testCallBack(fileid){1
  //处理文件逻辑的action
  location.href="/t1/fileController.do?fileid="+fileid;  2
}
//-->
</script>
……
        <div class="comp" comp="type:'fileupload',callMethod:'testCallBack'"> 3
        <input type="button" onclick="insertAttachment()" value="上传附件">  4

1

增加回调方法,回调时会传入文件的id,需要把该id传入到目标action中。

2

在此方法中请求处理文件的action,若属性firstSave为ture,则fileid为包含Attachment 的js ArrayList。

Attachment属性如下:
this.id = id;
    this.reference = reference;
    this.subReference = subReference;
    this.category = category;
    this.type = type;
    this.filename = filename;
    this.mimeType = mimeType;
    this.createDate = createDate;
    this.size = size;
    this.fileUrl = fileUrl;
    this.description = description || "";
    this.needClone = needClone;
      this.extension = extension;
    this.icon = icon;
    this.isCanTransform = isCanTransform == 'true' ? true : false; 
    this.onlineView = onlineView == null ? true : onlineView;
    this.extReference = ""; 
    this.extSubReference = ""; 
    this.showArea="";

3

声明文件上传标记。注意comp属性值为:"type:'fileupload'"

4

如果一页只有一个上传组件调用insertAttachment()显示上传界面, 如果有多个上传组件需要调用insertAttachmentPoi(attachmentTrId属性的值)方法,该方法需要和attachmentTrId属性配合使用。 支持属性:

属性 说明 实例
type 指当前为上传文件组件,值为固定值 type:'fileupload
callMethod 回调方法名。注意!方法名必须用引号括起来作为字符串。 callMethod:'testCallBack'
attsdata 指原有的附件,如:协同保存待发—新建,需要把原有的附件显示 attsdata='${ attachmentsJSON}'
applicationCategory 应用分类,统一在ApplicationCategoryEnum定义 applicationCategory:'1'
canDeleteOriginalAtts 指能否删除原有的附件,如转发协同不能删除原有附件 canDeleteOriginalAtts:false
originalAttsNeedClone 是否需要复制原有附件,常用在模板调用 originalAttsNeedClone:false
extensions 允许上传的文件类型,用文件会后缀表示,多个类型用逗号分隔(,) extensions:'txt,jpg'
maxSize 上传文件的大小限制,单位为字节 maxSize:10240000
isEncrypt 对上传的文件是否加密,true为加密;false为不加密 isEncrypt:false
quantity 最多上传文件个数,不使用该参数事默认是5 quantity:1
firstSave 是否先保存附件表信息,ture为先保存,false或者无该属性为后保存。 并且为ture时,回调方法得到的参数值为包含Attachment 的js 数组,否则为逗号(,)分隔的文件ID字符串。 这种情况下后端应该调用附件更新接口,目的是关联业务数据域附件数据。 firstSave:true
attachmentTrId 一页支持多个附件上传组件,和insertAttachmentPoi('poi77')方法配合使用 在方法中传入该属性的值。 attachmentTrId:poi77
showReplaceOrAppend 是否显示“追加”、“覆盖”radio。即,在上传页面中会提供如下元素, 业务模块根据下面元素确定相关逻辑。 <input type="radio" id="skip" name="repeat" value="0" checked="checked"> <input type="radio" id="cover" name="repeat" value="1"> showReplaceOrAppend:true