fancy公用上传下载
作者:互联网
fancy公用上传下载
将fancy文件夹放在com.samsung.cs.quality.common.ui 下面的 webapp/csqCommon 的下面
fileUpload.vm文件公用上传下载
1.引用插件
javascript <!--2019.1.15--> <link rel="stylesheet" type="text/css" href="/cs/csqCommon/fancy/style.css" /> <script type="text/javascript" src="/cs/csqCommon/fancy/mootools.js"></script> <script type="text/javascript" src="/cs/csqCommon/fancy/source/Fx.ProgressBar.js"></script> <script type="text/javascript" src="/cs/csqCommon/fancy/source/Swiff.Uploader.js"></script> <script type="text/javascript" src="/cs/csqCommon/fancy/source/FancyUpload3.Attach.js"></script>
2.前台删除,新增,初始化的函数<script language="javascript"> <!--2019.4.15--> function removeFiles(id){ var val=document.getElementById("files").value; var v=""; if(val!=''){ var arr=val.split(","); if(arr.length==1){ document.getElementById("files").value=""; }else{ for(var i=0;i<arr.length;i++){ if(arr[i]!=id){ v=v+arr[i]+","; } } if(v!=""){ //alert(v.substring(0,v.length-1)); document.getElementById("files").value=v.substring(0,v.length-1); } } } } function addFiles(id){ var val=document.getElementById("files").value; if(val==''){ val=id; }else{ val=val+","+id; } //alert(val); document.getElementById("files").value=val; } function initFile(apObj, filename, filesize, fileid, resourceId, mimeType){ var file=new FancyUpload3.Attach.File(up,{id:1,size:filesize,name:filename,status:3,validationError:null}); file.render(); file.ui.element.highlight('#e6efc2'); file.ui.element.getElement('.file-progress').destroy(); file.ui.element.getElement('.file-cancel').destroy(); var s=resourceId+"|"+filename+"|"+mimeType+"|"+fileid; new Element('span', {'class': 'file-removed', text: 'remove'}).removeEvents().addEvent('click', function() { file.ui.element.destroy(); removeFiles(s); //alert(s); return false; }).inject(file.ui.size, 'after'); file.ui.element.addEvent('dblclick',function(){ var downUrl = "$contextPath/common/download/"+fileid; window.open(downUrl,"_blank","toolbar=0, status=0, scrollbars=yes, location=0, menubar=0, resizable=1") }); addFiles(s); } </script>
3.html需要引用的宏,也是在fileupload.vm文件
```javascriptmacro (fileUploadSizablePanel $width $height $strID $actionFilePath $inputName $refType $refId $size)
#if ($refId && \(refId != '') #set (\)fileObj = \(services.fileManager.findFileInfosByRef(\)refType, \(refId)) #else #set (\)fileObj = '')
end
标签:val,上传下载,公用,fancy,var,refId 来源: https://www.cnblogs.com/guangxinliu/p/10844739.html