| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368 |
- <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
- <%@ include file="/jsp/framework/head.jsp"%>
- <%@ taglib uri="/WEB-INF/hnisi.tld" prefix="hnisi" %>
- <%@ page import="cn.sinobest.framework.util.DTOUtil"%>
- <%@ page import="cn.sinobest.framework.util.Util"%>
- <%
- String ywlsh=DTOUtil.getValue("ywlsh");
- String where ="1=2";
- if(!Util.isEmpty(ywlsh)){
- where="BAE007='"+ywlsh+"'";
- }
- %>
- <style>
- .fu_list {
- width:600px;
- background:#ebebeb;
- font-size:12px;
- }
- .fu_list td {
- padding:5px;
- line-height:20px;
- background-color:#fff;
- }
- .fu_list table {
- width:100%;
- border:1px solid #ebebeb;
- }
- .fu_list thead td {
- background-color:#f4f4f4;
- }
- .fu_list b {
- font-size:14px;
- }
- /*取消点击时的虚线框*/
- a.files, a.files input {
- outline:none;/*ff*/
- hide-focus:expression(this.hideFocus=true);/*ie*/
- }
- </style>
- <form id="uploadForm" method="post" action="${ctx}/CommUpload.do" ENCTYPE="multipart/form-data" >
- <table border="0" cellspacing="1" class="datatable">
- <tr>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt">添加文件</td>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt"><a href="javascript:void(0);" class="files" id="idFile"></a></td>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt"> </td>
- </td>
- </tr>
- <tr>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt " >
- 文件描述
- </td>
- <td width="3%" rowspan="1" colspan="1" class="tdinput " >
- <input title="" type="text" class="textbox" maxlength="50" name="MEMO" value="" vldStr="文件描述=l(1-200)" />
- </td>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt " >
-
- </td>
- </tr>
- <tr>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt"> </td>
- <td width="3%" rowspan="1" colspan="1" class=" " ><table border="0" cellspacing="0">
- <p align="center">
- <tbody id="idFileList">
- </tbody>
- </p>
- </table></td>
- <td width="3%" rowspan="1" colspan="1" class="tdprompt"> </td>
- </tr>
- </table>
- <%--指定FW_IMPEXP_EXCEL的配置ID --%>
- <input type="hidden" name="configId" value="" />
- <%--CommonSave需要的参数--%>
- <input type="hidden" name="_rtnURL" value="${ctx}/framework/web/uploadyx.do?ywlsh=<%=ywlsh %>" />
- <input type="hidden" name="_redirect" value="false">
- <input type="hidden" name="_commDo" value="fileService.saveFileInfo" />
- <input type="hidden" name="_uploadFile" value="true" />
- <input type="hidden" name="ywlsh" value="<%=ywlsh %>" />
- </form>
- <p align="center">
- <input type="button" value="开始上传" id="idBtnupload" disabled="disabled" />
-
- <input type="button" value="全部取消" id="idBtndel" disabled="disabled" />
- </p>
- <p>
- <hnisi:glt id="fw_wf_yxzllist" whereCls="<%=where %>" height="100"/>
- </p>
- <%--文件下载服务方法 --%>
- <form name="downloadform" action="${ctx}/downFile.do">
- <%--调用service(SysLogService)类的download()的方法生成文件并下载--%>
- <%--service名字 --%>
- <input type="hidden" name="serviceId" value="yxzlFileService">
- <%--方法名 --%>
- <input type="hidden" name="method" value="exportFile">
- <%--传进去的路径名,文件名 --%>
- <input type="hidden" name="FILENAME" value="">
- <input type="hidden" name="FILEPATH" value="">
- <input type="hidden" name="FTPIP" value="">
- <input type="hidden" name="YWLSH" value="">
- </form>
- <p align="center">
- <input type="button" id="btnClose" value="关闭" onclick="doClose1()"/>
- </p>
- <script type="text/javascript">
- var ywlsh="<%=ywlsh%>";
- var isIE = (document.all) ? true : false;
- var Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- }
- }
- }
- var Extend = function(destination, source) {
- for (var property in source) {
- destination[property] = source[property];
- }
- }
- var Bind = function(object, fun) {
- return function() {
- return fun.apply(object, arguments);
- }
- }
- var Each = function(list, fun){
- for (var i = 0, len = list.length; i < len; i++) { fun(list[i], i); }
- };
- //文件上传类
- var FileUpload = Class.create();
- FileUpload.prototype = {
- //表单对象,文件控件存放空间
- initialize: function(form, folder, options) {
-
- this.Form = document.getElementById(form);//表单
- this.Folder = document.getElementById(folder);//文件控件存放空间
- this.Files = [];//文件集合
-
- this.SetOptions(options);
-
- this.FileName = this.options.FileName;
- this._FrameName = this.options.FrameName;
- this.Limit = this.options.Limit;
- this.Distinct = !!this.options.Distinct;
- this.ExtIn = this.options.ExtIn;
- this.ExtOut = this.options.ExtOut;
-
- this.onIniFile = this.options.onIniFile;
- this.onEmpty = this.options.onEmpty;
- this.onNotExtIn = this.options.onNotExtIn;
- this.onExtOut = this.options.onExtOut;
- this.onLimite = this.options.onLimite;
- this.onSame = this.options.onSame;
- this.onFail = this.options.onFail;
- this.onIni = this.options.onIni;
- this.Form.method = "post";
- //注意ie的form没有enctype属性,要用encoding
- this.Form.encoding = "multipart/form-data";
- //整理一次
- this.Ini();
- },
- //设置默认属性
- SetOptions: function(options) {
- this.options = {//默认值
- FileName: "filename",//文件上传控件的name,配合后台使用
- FrameName: "",//iframe的name,要自定义iframe的话这里设置name
- onIniFile: function(){},//整理文件时执行(其中参数是file对象)
- onEmpty: function(){},//文件空值时执行
- Limit: 10,//文件数限制,0为不限制
- onLimite: function(){},//超过文件数限制时执行
- Distinct: true,//是否不允许相同文件
- onSame: function(){},//有相同文件时执行
- ExtIn: ["gif","jpg","rar","zip","iso","swf","xls","doc"],//允许后缀名
- onNotExtIn: function(){},//不是允许后缀名时执行
- ExtOut: [],//禁止后缀名,当设置了ExtIn则ExtOut无效
- onExtOut: function(){},//是禁止后缀名时执行
- onFail: function(){},//文件不通过检测时执行(其中参数是file对象)
- onIni: function(){}//重置时执行
- };
- Extend(this.options, options || {});
- },
- //整理空间
- Ini: function() {
- //整理文件集合
- this.Files = [];
- //整理文件空间,把有值的file放入文件集合
- Each(this.Folder.getElementsByTagName("input"), Bind(this, function(o){
- if(o.type == "file"){ o.value && this.Files.push(o); this.onIniFile(o); }
- }))
- //插入一个新的file
- var file = document.createElement("input");
- file.name = this.FileName;
- file.type = "file";
- file.onchange = Bind(this, function(){ this.Check(file); this.Ini(); });
- file.className="textbox";
- this.Folder.appendChild(file);
- //执行附加程序
- this.onIni();
- },
- //检测file对象
- Check: function(file) {
- var bCheck = true;
- var filePath=file.value;
- var i=filePath.lastIndexOf('\\');
- var filename=filePath.substr(i+1);
-
- if(CFW.oValid.fnIsNull(filename)){
- this.onFail(file);
- return;
- }else if(this.Limit && this.Files.length >= this.Limit){
- this.onLimite();
- this.onFail(file);
- return;
- } else if(!!this.Distinct) {
- Each(this.Files, function(o){
- var tempfilePath=o.value;
- var j=tempfilePath.lastIndexOf('\\');
- var tempfileName=tempfilePath.substr(j+1);
- if(o.value == file.value || tempfileName==filename){
- bCheck = false;
- }
- })
- if(!bCheck){
- this.onSame();
- this.onFail(file);
- return;
- }
-
- }
- new Service().appendQuery({
- configId : 'FW_CONFIG.FW_YXZLINFO_CONF_CNT',
- parameters : {
- FILENAME:filename,
- BAE007:ywlsh
- },
- transform : null
- }).sentAjax(function(data) {
- if(!CFW.oValid.fnIsNull(data[0]) && data[0]>0){
- if(!confirm( '此文件已存在,是否覆盖?')){
- fu.Delete(file);
- }
- }
- });
- },
- //删除指定file
- Delete: function(file) {
- //移除指定file
- this.Folder.removeChild(file); this.Ini();
- },
- //删除全部file
- Clear: function() {
- //清空文件空间
- Each(this.Files, Bind(this, function(o){ this.Folder.removeChild(o); })); this.Ini();
- }
- }
- var fu = new FileUpload("uploadForm", "idFile", {
- onIniFile: function(file){ file.value ? file.style.display = "none" : this.Folder.removeChild(file); },
- onEmpty: function(){ alert("请选择一个文件"); },
- onLimite: function(){ alert("超过上传限制"); },
- onSame: function(){ alert("已经有相同文件"); },
- onNotExtIn: function(){ alert("只允许上传" + this.ExtIn.join(",") + "文件"); },
- onFail: function(file){ this.Folder.removeChild(file); },
- onIni: function(){
- //显示文件列表
- var arrRows = [];
- if(this.Files.length){
- var oThis = this;
- Each(this.Files, function(o){
-
- var a = document.createElement("a");
- a.innerHTML = "取消";
- a.href = "javascript:void(0);";
- a.onclick = function(){ oThis.Delete(o); return false; };
- arrRows.push([o.value, a]);
- });
- } else { arrRows.push(["<p align='center'><font color='gray'>没有添加文件</font></p>", ""]); }
- AddList(arrRows);
- //设置按钮
- document.getElementById("idBtnupload").disabled = document.getElementById("idBtndel").disabled = this.Files.length <= 0;
- }
- });
- document.getElementById("idBtnupload").onclick = function(){
- //显示文件列表
- var arrRows = [];
- var filenames='';
- Each(fu.Files, function(o){
- var i=o.value.lastIndexOf('\\');
- var filename=o.value.substr(i+1);
- filenames+="'"+filename+"',";
- arrRows.push([o.value, " "]);
- });
- AddList(arrRows);
- if(CFW.oValid.fnIsNull(filenames)){
- CFW.oWin.fnAlert('没有需要上传的文件!');
- return;
- }
- fu.Form.submit();
- }
- //用来添加文件列表的函数
- function AddList(rows){
- //根据数组来添加列表
- var FileList = document.getElementById("idFileList"), oFragment = document.createDocumentFragment();
- //用文档碎片保存列表
- Each(rows, function(cells){
- var row = document.createElement("tr");
- Each(cells, function(o){
- var cell = document.createElement("td");
- if(typeof o == "string"){ cell.innerHTML = o; }else{ cell.appendChild(o); }
- row.appendChild(cell);
- });
- oFragment.appendChild(row);
- })
- //ie的table不支持innerHTML所以这样清空table
- while(FileList.hasChildNodes()){ FileList.removeChild(FileList.firstChild); }
- FileList.appendChild(oFragment);
- }
- document.getElementById("idBtndel").onclick = function(){ fu.Clear(); }
-
- function _down(bae007,filename,filepath,ftpserver){
- //把文件绝对路径+名字传给downloadform表单
- document.downloadform.YWLSH.value=bae007;
- document.downloadform.FILENAME.value=filename;
- document.downloadform.FILEPATH.value=filepath;
- document.downloadform.FTPIP.value=ftpserver;
- downloadform.submit();
- }
- function doClose1(){
- if(!CFW.oValid.fnIsNull(ywlsh)){
- var obj=window.opener.document.getElementById('fw_wf_yxzllist');
- if(obj!=null){//判断父窗口是否含有多记录表
- var whereCls="BAE007='"+ywlsh+"'";
- window.opener.CFW.oGlt.fnGetData('fw_wf_yxzllist',whereCls);
- }
- }
- window.close();
- }
- function _delete(bae007,filename,filepath,ftpserver){
- var params = {BAE007:bae007,FILENAME:filename,FILEPATH:filepath,FTPIP:ftpserver};
-
- new Service({
- serviceId:'yxzlDeleteService',
- method:'deleteYXFile',
- parameters:params
- }).sentAjax(function(data){
- var whereCls="BAE007='"+bae007+"'";
- CFW.oGlt.fnGetData('fw_wf_yxzllist',whereCls);
- alert('操作成功!');
-
- },function(msg){
- alert(msg);
- });
- }
- </script>
- </body>
- </html>
|