var uploader;var $msglist;var filelist;var errorfile;var errorcount;var handlecount;var successcount;var allMaxSize=500;$(function(){initUpLoader()});function onSelectFile(){$msglist.html("");var a=uploader.getFiles();if(a.length>0){uploader.removeFile(a[0].id)}uploader.reset();$("#bntStartUpload").linkbutton({text:"开始上传"});$("#bntStartUpload").linkbutton({disabled:false});$("#bntShowDataList").linkbutton({disabled:true});$("#bntStartAccept").linkbutton({disabled:true});$(".webuploader-element-invisible").trigger("click");$(".msg-box-upload").show();$(".msg-box-upload").css({padding:10});onResetAcceptFormatDesignPage()}function onStartUpload(){var a=uploader.getFiles();if(a.length==0){$("#bntStartUpload").linkbutton({disabled:true});$(".msg-box-upload").hide();return openMessageDlg("请选择一个文件进行上传!")}$("#ctlBtn").trigger("click")}function checkErrorFile(){var c=base_path+"com/webuploader/download.do?filename="+errorfile;var b=window.open(c)}function initUpLoader(){$("#uploadMsgProgress").hide();$(".msg-box-upload").hide();$("#bntStartUpload").linkbutton({disabled:true});$("#bntShowDataList").linkbutton({disabled:true});$("#bntStartAccept").linkbutton({disabled:true});$msglist=$("#msglist");var c=$("#ctlBtn");var d="pending";var a={};var b;if(jsonFormatDesign.code.indexOf("I_RDRIMPORTDATA")>-1||jsonFormatDesign.code.indexOf("I_HLDIMPORTEXCELDATA")>-1||jsonFormatDesign.code.indexOf("I_BIBIMPORTEXCELDATA")>-1||jsonFormatDesign.code.indexOf("I_ORDERMENUBIBIMPORTEXCELDATA")>-1||jsonFormatDesign.code.indexOf("I_ORDERXLSBIBIMPORTEXCELDATA")>-1){b="uploadExcel.do";a={title:"excel",extensions:"xls,xlsx",mimeTypes:"application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}}else{if(jsonFormatDesign.code.indexOf("I_BIBIMPORTDATA")>-1){b="uploadMarc.do";a={}}else{if(jsonFormatDesign.code.indexOf("I_CIRIMPORTDATA")>-1||jsonFormatDesign.code.indexOf("E_BIBLABEL")>-1||jsonFormatDesign.code.indexOf("I_CIRDATABACTH")>-1){b="uploadFile.do";a={title:"txt",extensions:"txt"}}else{if(jsonFormatDesign.code.indexOf("I_BIBDATABATCHRECORD")>-1||jsonFormatDesign.code.indexOf("I_HLDIMPORTDATA")>-1){b="uploadFileSplit.do";a={}}}}}uploader=WebUploader.create({pick:"#picker",swf:BASE_URL+"/Uploader.swf",server:base_path+"com/webuploader/"+b,accept:a,auto:true,disableGlobalDnd:true,fileNumLimit:1,fileSizeLimit:allMaxSize*1024*1024,});uploader.on("fileQueued",function(e){$msglist.append('

'+e.name+'

('+WebUploader.formatSize(e.size)+")等待上传...
")});uploader.on("uploadProgress",function(f,e){$percent=$("#uploadMsgProgress");$percent.css({width:e*100+"%"});$percent.html("已上传["+e*100+"%]");$("#uploadMsgProgress").show()});uploader.on("uploadSuccess",function(f,e){$("#"+f.id+"show").find("div.state").text("("+WebUploader.formatSize(f.size)+")已上传");$("#bntStartUpload").linkbutton({text:"已上传"});$("#bntStartUpload").linkbutton({disabled:true});$("#bntShowDataList").linkbutton({disabled:false});$("#bntStartAccept").linkbutton({disabled:false});$(".acceptTextTip").hide();uploadSuccessHandler(f,e)});uploader.on("uploadError",function(e){$("#"+e.id+"show").find("div.state").text("("+WebUploader.formatSize(e.size)+")上传出错");$("#bntStartUpload").linkbutton({text:"上传出错"})});uploader.on("uploadComplete",function(e){$("#uploadMsgProgress").fadeOut()});uploader.on("error",function(e){if(e=="F_DUPLICATE"){openMessageDlg("请不要重复选择文件!")}else{if(e=="Q_EXCEED_SIZE_LIMIT"){openMessageDlg("所选附件总大小不可超过"+allMaxSize+"M哦!
换个小点的文件吧!")}}});c.on("click",function(){if(d==="uploading"){uploader.stop()}else{uploader.upload()}})};