/* uploadifive 1.2.2 copyright (c) 2012 reactive apps, ronnie garcia released under the uploadifive standard license */ ;(function($) { var methods = { init : function(options) { return this.each(function() { // create a reference to the jquery dom object var $this = $(this); $this.data('fileupload', { inputs : {}, // the object that contains all the file inputs inputcount : 0, // the total number of file inputs created fileid : 0, queue : { count : 0, // total number of files in the queue selected : 0, // number of files selected in the last select operation replaced : 0, // number of files replaced in the last select operation errors : 0, // number of files that returned an error in the last select operation queued : 0, // number of files added to the queue in the last select operation cancelled : 0 // total number of files that have been cancelled or removed from the queue }, uploads : { current : 0, // number of files currently being uploaded attempts : 0, // number of file uploads attempted in the last upload operation successful : 0, // number of files successfully uploaded in the last upload operation errors : 0, // number of files returning errors in the last upload operation count : 0 // total number of files uploaded successfully } }); var $data = $this.data('fileupload'); // set the default options var settings = $data.settings = $.extend({ 'auto' : true, // automatically upload a file when it's added to the queue 'buttonclass' : 'uploadbutton', // a class to add to the uploadifive button 'buttontext' : '', // the text that appears on the uploadifive button 'checkscript' : false, // path to the script that checks for existing file names 'dnd' : true, // allow drag and drop into the queue 'droptarget' : false, // selector for the drop target 'fileobjname' : 'filedata', // the name of the file object to use in your server-side script 'filetypeexts' : '*.*', // type of files allowed (image, etc), separate with a pipe character | 'formdata' : {'organcode':'syzh','cid':'123','uploadedid':'uploadedid','alreadyfilediv':'alreadyfilediv'}, // additional data to send to the upload script 'height' : 30, // the height of the button 'itemtemplate' : false, // the html markup for the item in the queue 'method' : 'post', // the method to use when submitting the upload 'multi' : true, // set to true to allow multiple file selections 'overrideevents' : [], // an array of events to override 'queueid' : false, // the id of the file queue 'queuesizelimit' : 10, // the maximum number of files that can be in the queue 'removecompleted' : false, // set to true to remove files that have completed uploading 'simuploadlimit' : 0, // the maximum number of files to upload at once 'truncatelength' : 0, // the length to truncate the file names to 'uploadlimit' : 10, // the maximum number of files you can upload 'uploadscript' : contextrootpath +'/plugins/upload/multifileupload.xhtml', // 服务器端处理该上传请求的程序(servlet, struts2-action) 'width' : 100, // the width of the button 'fileuploadedcount' : 0, //已经上传文件数量 'filecountlimit' : 10, //最多上传文件数量 'filessizelimit' : 1024, //所有文件大小限制, 1024b 'successtimeout' : 30, //表示文件上传完成后等待服务器响应的时间。超过该时间,那么将认为上传成功。 onsearchinit : function(datas){ return true; }, // 当每个文件添加至队列后触发 onselect :function(file){ /* alert( 'id: ' + file.id   + ' - 索引: ' + file.index   + ' - 文件名: ' + file.name   + ' - 文件大小: ' + file.size   + ' - 类型: ' + file.type   + ' - 创建日期: ' + file.creationdate   + ' - 修改日期: ' + file.modificationdate   + ' - 文件状态: ' + file.filestatus);*/ //如果没有附件 显示: “暂无上传附件” $("#uploadedfile_none").remove(); //选中文件事件 settings.fileuploadedcount++;//已上传文件数量+1 //判断数量是否超出限制 //settings.fileuploadedcount==settings.filecountlimit+parseint(1) 为了当同时上传多个附件,但超出附件最大值时,只提示一次“上传文件数量已经超出限制!” 2016-5-16 管琳琳 // if(settings.filecountlimit暂无上传附件!")); }},3000); }, // 每次初始化一个队列时触发, 即浏览文件后, 加入一个队列 oninit : function (instance) { //初始化查询所有附件 $this.fileupload("search",settings.formdata.organcode,settings.formdata.cid,settings.formdata.uploadedid,settings.formdata.alreadyfilediv); }, //上传完成时触发(每个文件触发一次) onuploadsuccess : function(file, data, response) { /*alert( 'id: ' + file.id   + ' - 索引: ' + file.index // 索引时按照上传附件时,弹出的选择文件窗口中对文件排序的顺序(文件名、修改日期、类型、大小)。这里可以做文章,可以按照客户机文件排序方式排序文件   + ' - 文件名: ' + file.name   + ' - 文件大小: ' + file.size   + ' - 类型: ' + file.type   + ' - 创建日期: ' + file.creationdate   + ' - 修改日期: ' + file.modificationdate   + ' - 文件状态: ' + file.filestatus   + ' - 服务器端消息: ' + data   + ' - 是否上传成功: ' + response);*/ var d = new date(file.modificationdate); var lastmodified = d.getfullyear() + '-' + (d.getmonth() + 1) + '-' + d.getdate() + ' ' + d.gethours() + ':' + d.getminutes() + ':' + d.getseconds(); /* 调用ajax修改附件部分信息 */ $.ajax({ type : "post", url : contextrootpath + '/plugins/upload/editfileajax.xhtml', data : {"organcode":settings.formdata.organcode,"cid":settings.formdata.cid,"filename":encodeuri(encodeuri(file.name)),"index":file.index,"lastmodified":lastmodified}, timeout : 60000, success : function(data){ //alert(data); }, error : function(xmlhttprequest, textstatus, error){ /*if(error == "timeout"){ alert("连接超时"); }else{ alert(textstatus); }*/ } }); if(settings.isgraphicmix){ $this.fileupload("searchnew",settings.formdata.organcode,settings.formdata.cid,settings.formdata.uploadedid,settings.formdata.alreadyfilediv,data.logicid); /*var imgmark = $(".imgmark"); for(var i=0;i -1) { settings.filessizelimit = filessizelimitbytes * 1000; } else if (settings.filessizelimit.indexof('mb') > -1) { settings.filessizelimit = filessizelimitbytes * 1000000; } else if (settings.filessizelimit.indexof('gb') > -1) { settings.filessizelimit = filessizelimitbytes * 1000000000; } } else { settings.filessizelimit = settings.filessizelimit * 1024; } // create a template for a file input $data.inputtemplate = $('') .css({ 'font-size' : settings.height + 'px', 'opacity' : 0, 'position' : 'absolute', 'right' : '-3px', 'top' : '-3px', 'z-index' : 999 }); // create a new input $data.createinput = function() { // create a clone of the file input var input = $data.inputtemplate.clone(); // create a unique name for the input item var inputname = input.name = 'input' + $data.inputcount++; // set the multiple attribute if (settings.multi) { input.attr('multiple', true); } // set the accept attribute on the input if (settings.filetypeexts) { var filetype = acceptmime(settings.filetypeexts); input.attr('accept', filetype); } // set the onchange event for the input input.bind('change', function() { $data.queue.selected = 0; $data.queue.replaced = 0; $data.queue.errors = 0; $data.queue.queued = 0; // add a queue item to the queue for each file var limit = this.files.length; $data.queue.selected = limit; // 判断文件数量和文件大小是否超出范围 // trigger the select event if (typeof settings.onselect === 'function') { settings.onselect.call($this, $data.queue); } if (($data.queue.count + limit) > settings.filecountlimit && settings.filecountlimit !== 0) { if ($.inarray('onerror', settings.overrideevents) < 0) { alert('上传文件数量已经超出限制!'); //取消全部正在上传附件进程 $this.fileupload("cancel",file); $data.queuecomplete(); } // trigger the error event if (typeof settings.onerror === 'function') { settings.onerror.call($this, 'queue_limit_exceeded'); } return; } else { for (var n = 0; n < limit; n++) { file = this.files[n]; //判断文件大小是否超出限制 if(settings.filessizelimit settings.queuesizelimit && settings.queuesizelimit !== 0) { // check if the queuesizelimit was reached if ($.inarray('onerror', settings.overrideevents) < 0) { alert('上传文件数量已经超出限制!'); //取消全部正在上传附件进程 $this.fileupload("cancel",file); $data.queuecomplete(); } // trigger the onerror event if (typeof settings.onerror === 'function') { settings.onerror.call($this, 'queue_limit_exceeded'); } } else { // add a queue item for each file for (var n = 0; n < limit; n++) { file = filedata.files[n]; //判断文件大小是否超出限制 if(settings.filessizelimit\ x\
\
\
\
\ '); } else { $data.queueitem = $(settings.itemtemplate); } // add an item to the queue $data.addqueueitem = function(file) { if ($.inarray('onaddqueueitem', settings.overrideevents) < 0) { // check if the filename already exists in the queue if($data.removeexistingfile(file)){ settings.fileuploadedcount--; // 原有附件 // $data.uploads.successful--; $data.uploads.count--; $data.queue.count--; //$data.uploads.current++; //return; } // create a clone of the queue item template file.queueitem = $data.queueitem.clone(); // add an id to the queue item file.queueitem.attr('id', settings.id + '-file-' + $data.fileid++); // bind the close event to the close button file.queueitem.find('.close').bind('click', function() { methods.cancel.call($this, file); return false; }); var filename = file.name; if (filename.length > settings.truncatelength && settings.truncatelength != 0) { filename = filename.substring(0, settings.truncatelength) + '...'; } file.queueitem.find('.filename').html(filename); // add a reference to the file file.queueitem.data('file', file); $data.queueel.append(file.queueitem); } // trigger the addqueueitem event if (typeof settings.onaddqueueitem === 'function') { settings.onaddqueueitem.call($this, file); } // check the filesize if (file.size > settings.filessizelimit && settings.filessizelimit != 0) { $data.error('file_size_limit_exceeded', file); } else { $data.queue.queued++; $data.queue.count++; } } // remove an item from the queue $data.removequeueitem = function(file, instant, delay) { // set the default delay if (!delay) delay = 0; var fadetime = instant ? 0 : 500; if (file.queueitem) { if (file.queueitem.find('.fileinfo').html() != ' - 已完成') { file.queueitem.find('.fileinfo').html(' - cancelled'); } file.queueitem.find('.progress-bar').width(0); file.queueitem.delay(delay).fadeout(fadetime, function() { $(this).remove(); }); delete file.queueitem; $data.queue.count--; } } // count the number of files that need to be uploaded $data.filestoupload = function() { var filestoupload = 0; for (var key in $data.inputs) { input = $data.inputs[key]; limit = input.files.length; for (var n = 0; n < limit; n++) { file = input.files[n]; if (!file.skip && !file.complete) { filestoupload++; } } } return filestoupload; } // check if a file exists $data.checkexists = function(file) { if ($.inarray('oncheck', settings.overrideevents) < 0) { // this request needs to be synchronous $.ajaxsetup({ 'async' : false }); // send the filename to the check script var checkdata = $.extend(settings.formdata, {filename: file.name}); $.post(settings.checkscript, checkdata, function(fileexists) { file.exists = parseint(fileexists); }); if (file.exists) { if (!confirm('a file named ' + file.name + ' already exists in the upload folder.\nwould you like to replace it?')) { // if not replacing the file, cancel the upload methods.cancel.call($this, file); return true; } } } // trigger the check event if (typeof settings.oncheck === 'function') { settings.oncheck.call($this, file, file.exists); } return false; } // upload a single file $data.uploadfile = function(file, uploadall) { if (!file.skip && !file.complete && !file.uploading) { file.uploading = true; $data.uploads.current++; $data.uploads.attempted++; // create a new ajax request xhr = file.xhr = new xmlhttprequest(); // start the upload // use the faster formdata if it exists if (typeof formdata === 'function' || typeof formdata === 'object') { // create a new formdata object var formdata = new formdata(); // add the form data formdata.append(settings.fileobjname, file); // add the rest of the formdata for (i in settings.formdata) { formdata.append(i, settings.formdata[i]); } // open the ajax call xhr.open(settings.method, settings.uploadscript, true); // on progress function xhr.upload.addeventlistener('progress', function(e) { if (e.lengthcomputable) { $data.progress(e, file); } }, false); // on complete function xhr.addeventlistener('load', function(e) { if (this.readystate == 4) { file.uploading = false; if (this.status == 200) { if (file.xhr.responsetext !== 'invalid file type.') { $data.uploadcomplete(e, file, uploadall); } else { $data.error(file.xhr.responsetext, file, uploadall); } } else if (this.status == 404) { $data.error('404_file_not_found', file, uploadall); } else if (this.status == 403) { $data.error('403_forbidden', file, uploadall); } else { $data.error('unknown error', file, uploadall); } } }); // send the form data (multipart/form-data) xhr.send(formdata); } else { // send as binary var reader = new filereader(); reader.onload = function(e) { // set some file builder variables var boundary = '-------------------------' + (new date).gettime(), dashes = '--', eol = '\r\n', binfile = ''; // build an rfc2388 string binfile += dashes + boundary + eol; // generate the headers binfile += 'content-disposition: form-data; name="' + settings.fileobjname + '"'; if (file.name) { binfile += '; filename="' + file.name + '"'; } binfile += eol; binfile += 'content-type: application/octet-stream' + eol + eol; binfile += e.target.result + eol; for (key in settings.formdata) { binfile += dashes + boundary + eol; binfile += 'content-disposition: form-data; name="' + key + '"' + eol + eol; binfile += settings.formdata[key] + eol; } binfile += dashes + boundary + dashes + eol; // on progress function xhr.upload.addeventlistener('progress', function(e) { $data.progress(e, file); }, false); // on complete function xhr.addeventlistener('load', function(e) { file.uploading = false; var status = this.status; if (status == 404) { $data.error('404_file_not_found', file, uploadall); } else { if (file.xhr.responsetext != 'invalid file type.') { $data.uploadcomplete(e, file, uploadall); } else { $data.error(file.xhr.responsetext, file, uploadall); } } }, false); // open the ajax request var url = settings.uploadscript; if (settings.method == 'get') { var params = $(settings.formdata).param(); url += params; } xhr.open(settings.method, settings.uploadscript, true); xhr.setrequestheader("content-type", "multipart/form-data; boundary=" + boundary); // trigger the uploadfile event if (typeof settings.onuploadfile === 'function') { settings.onuploadfile.call($this, file); } // send the file for upload xhr.sendasbinary(binfile); } reader.readasbinarystring(file); } } } // update a file upload's progress $data.progress = function(e, file) { if ($.inarray('onprogress', settings.overrideevents) < 0) { if (e.lengthcomputable) { var percent = math.round((e.loaded / e.total) * 100); } file.queueitem.find('.fileinfo').html(' - ' + percent + '%'); file.queueitem.find('.progress-bar').css('width', percent + '%'); } // trigger the progress event if (typeof settings.onprogress === 'function') { settings.onprogress.call($this, file, e); } } // trigger an error $data.error = function(errortype, file, uploadall) { if ($.inarray('onerror', settings.overrideevents) < 0) { // get the error message switch(errortype) { case '404_file_not_found': errormsg = '404 error'; break; case '403_forbidden': errormsg = '403 forbidden'; break; case 'forbidden_file_type': errormsg = 'forbidden file type'; break; case 'file_size_limit_exceeded': errormsg = 'file too large'; break; default: errormsg = 'unknown error'; break; } // add the error class to the queue item file.queueitem.addclass('error') // output the error in the queue item .find('.fileinfo').html(' - ' + errormsg); // hide the file.queueitem.find('.progress').remove(); } // trigger the error event if (typeof settings.onerror === 'function') { settings.onerror.call($this, errortype, file); } file.skip = true; if (errortype == '404_file_not_found') { $data.uploads.errors++; } else { $data.queue.errors++; } if (uploadall) { methods.upload.call($this, null, true); } } // trigger when a single file upload is complete $data.uploadcomplete = function(e, file, uploadall) { if ($.inarray('onuploadcomplete', settings.overrideevents) < 0) { file.queueitem.find('.progress-bar').css('width', '100%'); file.queueitem.find('.fileinfo').html(' - 已完成'); file.queueitem.find('.progress').slideup(250); file.queueitem.addclass('complete'); } // trigger the complete event if (typeof settings.onuploadcomplete === 'function') { settings.onuploadcomplete.call($this, file, file.xhr.responsetext); } if (settings.removecompleted) { settimeout(function() { methods.cancel.call($this, file); }, 3000); } file.complete = true; $data.uploads.successful++; $data.uploads.count++; $data.uploads.current--; delete file.xhr; if (uploadall) { methods.upload.call($this, null, true); } } // trigger when all the files are done uploading $data.queuecomplete = function() { // trigger the queuecomplete event if (typeof settings.onqueuecomplete === 'function') { settings.onqueuecomplete.call($this, $data.uploads); } } // ---------------------- // initialize uploadifive // ---------------------- // check if html5 is available if (window.file && window.filelist && window.blob && (window.filereader || window.formdata)) { // assign an id to the object settings.id = 'uploadifive-' + $this.attr('id'); // wrap the file input in a div with overflow set to hidden $data.button = $('
' + settings.buttontext + '
'); if (settings.buttonclass) $data.button.addclass(settings.buttonclass); // style the button wrapper $data.button.css({ 'overflow' : 'hidden', 'position' : 'relative' }); // insert the button above the file input $this.before($data.button) // add the file input to the button .appendto($data.button) // modify the styles of the file input .hide(); // create a new input $data.createinput.call($this); // create the queue container if (!settings.queueid) { settings.queueid = settings.id + '-queue'; $data.queueel = $('
'); $data.button.after($data.queueel); } else { $data.queueel = $('#' + settings.queueid); } // add drag and drop functionality if (settings.dnd) { try{ var droptarget = document.getelementbyid(settings.formdata.uploadedid).parentnode; droptarget.addeventlistener('dragleave', function(e) { // 拖出 // stop firefox from opening the dropped file(s) e.preventdefault(); e.stoppropagation(); }, false); droptarget.addeventlistener('dragenter', function(e) { // 拖进(请把文件拖放到这个区域,就可作为附件添加。) // stop firefox from opening the dropped file(s) e.preventdefault(); e.stoppropagation(); $("#" + settings.formdata.uploadedid).parent().addclass(" file_float_main"); var a = document.getelementbyid("attachdrag"); if(a == null){ var file_float_div = $('
请把文件拖放到这个区域,就可作为附件添加。
'); $("#" + settings.formdata.uploadedid).parent().before(file_float_div); file_float_div.width(file_float_div.parent().width()); file_float_div.height(150); var attachdrag = document.getelementbyid("attachdrag"); attachdrag.addeventlistener('dragleave', function(e) { // 拖出 // stop firefox from opening the dropped file(s) e.preventdefault(); e.stoppropagation(); $("#" + settings.formdata.uploadedid).parent().removeclass(" file_float_main"); var a = document.getelementbyid("attachdrag"); if(a != null){ a.style.display = "none"; } }, false); attachdrag.addeventlistener('dragenter', function(e) { // 拖进(请把文件拖放到这个区域,就可作为附件添加。) // stop firefox from opening the dropped file(s) e.preventdefault(); e.stoppropagation(); }, false); attachdrag.addeventlistener('dragover', function(e) { // stop firefox from opening the dropped file(s) e.preventdefault(); e.stoppropagation(); }, false); attachdrag.addeventlistener('drop', $data.drop, false); }else{ a.style.display = ""; } }, false); droptarget.addeventlistener('dragover', function(e) { // stop firefox from opening the dropped file(s) e.preventdefault(); e.stoppropagation(); }, false); droptarget.addeventlistener('drop', $data.drop, false); }catch(e){} // var $droptarget = settings.droptarget ? $(settings.droptarget) : $data.queueel.get(0); // $droptarget.addeventlistener('dragleave', function(e) { // // stop firefox from opening the dropped file(s) // e.preventdefault(); // e.stoppropagation(); // }, false); // $droptarget.addeventlistener('dragenter', function(e) { // // stop firefox from opening the dropped file(s) // e.preventdefault(); // e.stoppropagation(); // }, false); // $droptarget.addeventlistener('dragover', function(e) { // // stop firefox from opening the dropped file(s) // e.preventdefault(); // e.stoppropagation(); // }, false); // $droptarget.addeventlistener('drop', $data.drop, false); } // send as binary workaround for chrome if (!xmlhttprequest.prototype.sendasbinary) { xmlhttprequest.prototype.sendasbinary = function(datastr) { function bytevalue(x) { return x.charcodeat(0) & 0xff; } var ords = array.prototype.map.call(datastr, bytevalue); var ui8a = new uint8array(ords); this.send(ui8a.buffer); } } // trigger the oninit event if (typeof settings.oninit === 'function') { settings.oninit.call($this); } } else { // trigger the fallback event if (typeof settings.onfallback === 'function') { settings.onfallback.call($this); } return false; } }); }, // write some data to the console debug : function() { return this.each(function() { console.log($(this).data('fileupload')); }); }, // clear all the items from the queue clearqueue : function() { this.each(function() { var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; for (var key in $data.inputs) { input = $data.inputs[key]; limit = input.files.length; for (i = 0; i < limit; i++) { file = input.files[i]; methods.cancel.call($this, file); } } // trigger the onclearqueue event if (typeof settings.onclearqueue === 'function') { settings.onclearqueue.call($this, $('#' + $data.settings.queueid)); } }); }, // cancel a file upload in progress or remove a file from the queue cancel : function(file, fast) { this.each(function() { var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; // if user passed a queue item id instead of file... if (typeof file === 'string') { if (!isnan(file)) { fileid = 'uploadifive-' + $(this).attr('id') + '-file-' + file; } file = $('#' + fileid).data('file'); } file.skip = true; $data.filescancelled++; if (file.uploading) { $data.uploads.current--; file.uploading = false; file.xhr.abort(); delete file.xhr; methods.upload.call($this); } if ($.inarray('oncancel', settings.overrideevents) < 0) { $data.removequeueitem(file, fast); } // trigger the cancel event if (typeof settings.oncancel === 'function') { settings.oncancel.call($this, file); } }); }, // upload the files in the queue upload : function(file, keepvars) { this.each(function() { var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; if (file) { $data.uploadfile.call($this, file); } else { // check if the upload limit was reached //alert($data.uploads.count + "count");alert($data.uploads.current + "current");alert(settings.filecountlimit + "filecountlimit"); if (($data.uploads.count + $data.uploads.current) <= settings.filecountlimit || settings.filecountlimit == 0) { if (!keepvars) { $data.uploads.attempted = 0; $data.uploads.successsful = 0; $data.uploads.errors = 0; var filestoupload = $data.filestoupload(); // trigger the onupload event if (typeof settings.onupload === 'function') { settings.onupload.call($this, filestoupload); } } // loop through the files $('#' + settings.queueid).find('.uploadifive-queue-item').not('.error, .complete').each(function() { _file = $(this).data('file'); // check if the simupload limit was reached //alert($data.uploads.count);alert(settings.uploadlimit); if (($data.uploads.current >= settings.simuploadlimit && settings.simuploadlimit !== 0) || ($data.uploads.current >= settings.filecountlimit && settings.filecountlimit !== 0) || ($data.uploads.count > settings.filecountlimit && settings.filecountlimit !== 0)) { return false; } if (settings.checkscript) { // let the loop know that we're already processing this file _file.checking = true; skipfile = $data.checkexists(_file); _file.checking = false; if (!skipfile) { $data.uploadfile(_file, true); } } else { $data.uploadfile(_file, true); } }); if ($('#' + settings.queueid).find('.uploadifive-queue-item').not('.error, .complete').size() == 0) { $data.queuecomplete(); } } else { if ($data.uploads.current == 0) { if ($.inarray('onerror', settings.overrideevents) < 0) { if ($data.uploads.count > 0 && settings.filecountlimit != 0) { alert('上传文件数量已经超出限制!'); $data.uploads.count = settings.filecountlimit; //取消全部正在上传附件进程 $this.fileupload("cancel",file); $data.queuecomplete(); } } // trigger the onerror event if (typeof settings.onerror === 'function') { settings.onerror.call($this, 'upload_limit_exceeded', $data.uploads.count); } } } } }); }, searchnew: function(organcode,cid,uploadedid,alreadyfilediv,logicid){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; //查询已上传 的附件 $.ajax({ type: "post", url: contextrootpath + "/plugins/upload/showfilesnew.xhtml", data: {organcode:organcode,cid:cid,showthumbnail:settings.showthumbnail,thumbnailwidth:settings.thumbnailwidth,thumbnailheigth:settings.thumbnailheigth,isshowhistorylog:settings.isshowhistorylog,isgraphicmix:settings.isgraphicmix,logicid:logicid}, async: false, success: function(datas){ if(datas == ""){ return; } var datas=eval(datas); if(datas.length>=1 && datas[0].error){ // 错误信息 // alert(datas[0].msg); return; } if(settings.onsearchinit.call($this,datas)){ var filecontentlist = ''; //$("#"+uploadedid).empty().prev("div").empty(); settings.fileuploadedcount=0; // 显示附件图标 @author lihui 2016-8-19 var fileshowul=$("#gllfile"+cid); $.each(datas,function(index,data){ if(data == null){ return; } var newwidth = 50; var newheigth = 50; if(settings.thumbnailwidth != null){ newwidth = settings.thumbnailwidth; } if(settings.thumbnailheigth != null){ newheigth = settings.thumbnailheigth; } var j = math.round(data.filelength); var o = "b"; if(data.filelength>1024){ //计算文件大小(kb,mb) begin j = math.round(data.filelength/ 1024); o = "kb"; if (j > 1000) { j = math.round(j / 1000); o = "mb"; } var l = j.tostring().split("."); j = l[0]; if (l.length > 1) { j += "." + l[1].substr(0, 2); } } j += o; //计算文件大小(kb,mb)end //计算文件名称超过10个字符 以...显示 var filename_dowon=data.oldfilename; if(filename_dowon!=null){ if(isincludechinese(filename_dowon)){ // 是汉字的话 if (filename_dowon.length > 4) { filename_dowon = filename_dowon.substr(0, 4) + "..."; } }else{ // 是非汉字的话 if (filename_dowon.length > 6) { filename_dowon = filename_dowon.substr(0, 6) + "..."; } } } // 专门给弹出的div用的 var filename_dowon_div=data.oldfilename; if(filename_dowon_div!=null){ if(isincludechinese(filename_dowon_div)){ // 是汉字的话 if (filename_dowon_div.length > 20) { filename_dowon_div = filename_dowon_div.substr(0, 20) + "..."; } }else{ // 是非汉字的话 if (filename_dowon_div.length > 40) { filename_dowon_div = filename_dowon_div.substr(0, 40) + "..."; } } } //是否图文混合显示 true:是。false:否 if(settings.isgraphicmix){ //图标显示方式 // alert(data.filetype); var fileshowul_li=$("
  • "); fileshowul.prepend(fileshowul_li); var fileshowul_li_div=$("
    "); fileshowul_li.append(fileshowul_li_div); var filehowul_li_input=$("标题" + "" + "内容" + ""); fileshowul_li.append(filehowul_li_input); var fileshowdiv_table = ""; fileshowdiv_table += " "; fileshowdiv_table += "
    "; var imgsrc = contextrootpath+"/saas/plugins/fileupload3/img/ico/"+geticobyfiletype(data.filetype); // 判断图片附件是否显示缩略图 if(settings.showthumbnail && isimage(data.filetype) && data.thumbnail != null && data.thumbnail != ""){ // 生成缩略图 imgsrc = contextrootpath + data.thumbnail; } fileshowdiv_table += " "; fileshowdiv_table += "
    "; var fileshowul_li_div_table=$(fileshowdiv_table); fileshowul_li_div.append(fileshowul_li_div_table); var fileshowul_li_c_div=$("
    "); fileshowul_li_div.append(fileshowul_li_c_div); var fileshowul_li_c_mz=$("
    "+filename_dowon_div+"
    "); fileshowul_li_c_div.append(fileshowul_li_c_mz); var fileshowul_li_c_ank=$("
    "); fileshowul_li_c_div.append(fileshowul_li_c_ank); // 预览 if(isimage(data.filetype)){ // 图片的预览 var fileshowul_li_c_ank_ly=$(""); fileshowul_li_c_ank.append(fileshowul_li_c_ank_ly); } // 删除 if(settings.deleteable==true){ var fileshowul_li_c_ank_sc=$(""); fileshowul_li_c_ank_sc.click(function(){ $this.fileupload("deletefileupdateinput",organcode,data.logicid,data.cid,uploadedid,alreadyfilediv); $data.queuecomplete(); }) fileshowul_li_c_ank.append(fileshowul_li_c_ank_sc); } } }); } //如果没有附件 显示: “暂无上传附件” if($("#"+uploadedid).children().length==0&&$("#"+settings.queueid).children().length==0){ $("#"+uploadedid).append($("暂无上传附件!")); } } }); //#end_ajax }, search: function(organcode,cid,uploadedid,alreadyfilediv){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; if(settings.formdata.filesize != null && settings.formdata.filesize!="" &&settings.fileuploadedcount == "0"){ $("#"+settings.formdata.filesize).val(settings.fileuploadedcount); } //查询已上传 的附件 $.ajax({ type: "post", url: contextrootpath + "/plugins/upload/showfilesajax.xhtml", data: {organcode:organcode,cid:cid,ctype:settings.formdata.ctype,showthumbnail:settings.showthumbnail,thumbnailwidth:settings.thumbnailwidth,thumbnailheigth:settings.thumbnailheigth,isshowhistorylog:settings.isshowhistorylog,isgraphicmix:settings.isgraphicmix,order:settings.formdata.order,sort:settings.formdata.sort}, async: false, success: function(datas){ if(datas == ""){ return; } var datas=eval(datas); if(datas.length>=1 && datas[0].error){ // 错误信息 // alert(datas[0].msg); return; } // 判断是否显示“已上传附件列表” //if(datas.length>=1){ //$("#"+alreadyfilediv).css("display","block"); //}else{ //$("#"+alreadyfilediv).css("display","none"); //} if(settings.onsearchinit.call($this,datas)){ $("#"+uploadedid).empty().prev("div").empty(); settings.fileuploadedcount=0; // 显示附件图标 @author lihui 2016-8-19 var fileshowdiv=$("
    "); var fileshowul=""; if(settings.isgraphicmix){ fileshowul=$("
      "); }else{ fileshowul=$("
        "); } var newwidth = 50; var newheigth = 50; if(settings.thumbnailwidth != null){ newwidth = settings.thumbnailwidth; } if(settings.thumbnailheigth != null){ newheigth = settings.thumbnailheigth; } $.each(datas,function(index,data){ if(data == null){ return; } var j = math.round(data.filelength); var o = "b"; if(data.filelength>1024){ //计算文件大小(kb,mb) begin j = math.round(data.filelength/ 1024); o = "kb"; if (j > 1000) { j = math.round(j / 1000); o = "mb"; } var l = j.tostring().split("."); j = l[0]; if (l.length > 1) { j += "." + l[1].substr(0, 2); } } j += o; //计算文件大小(kb,mb)end // 专门给弹出的div用的 var filename_dowon_div=data.oldfilename; if(filename_dowon_div!=null){ if(isincludechinese(filename_dowon_div)){ // 是汉字的话 if (filename_dowon_div.length > 20) { filename_dowon_div = filename_dowon_div.substr(0, 20) + "..."; } }else{ // 是非汉字的话 if (filename_dowon_div.length > 35) { filename_dowon_div = filename_dowon_div.substr(0, 35) + "..."; } } } filename_dowon_div = filename_dowon_div+"("+j+")"; //是否图文混合显示 true:是。false:否 if(settings.isgraphicmix){ /* 图标显示方式 */ //alert(data.filetype); var fileshowul_li=$("
      • "); fileshowul.append(fileshowul_li); var fileshowul_li_div=$("
        "); fileshowul_li.append(fileshowul_li_div); var filehowul_li_input=$("标题" + "" + "内容" + ""); fileshowul_li.append(filehowul_li_input); var fileshowdiv_table = ""; fileshowdiv_table += " "; //fileshowdiv_table += " "; fileshowdiv_table += "
        "; var imgsrc = contextrootpath+"/saas/plugins/fileupload3/img/ico/"+geticobyfiletype(data.filetype); // 判断图片附件是否显示缩略图 if(settings.showthumbnail && isimage(data.filetype) && data.thumbnail != null && data.thumbnail != ""){ // 生成缩略图 imgsrc = contextrootpath + data.thumbnail; } fileshowdiv_table += " "; fileshowdiv_table += "
        "+filename_dowon+"("+j+")
        "; var fileshowul_li_div_table=$(fileshowdiv_table); fileshowul_li_div.append(fileshowul_li_div_table); var fileshowul_li_c_div=$("
        "); fileshowul_li_div.append(fileshowul_li_c_div); var fileshowul_li_c_mz=$("
        "+filename_dowon_div+"
        "); fileshowul_li_c_div.append(fileshowul_li_c_mz); var fileshowul_li_c_ank=$("
        "); fileshowul_li_c_div.append(fileshowul_li_c_ank); // 预览【目前只支持图片的预览】 if(isimage(data.filetype)){ var fileshowul_li_c_ank_ly=$(""); fileshowul_li_c_ank.append(fileshowul_li_c_ank_ly); } // 删除 if(settings.deleteable==true){ var fileshowul_li_c_ank_sc=$(""); fileshowul_li_c_ank_sc.click(function(){ $this.fileupload("deletefileupdateinput",organcode,data.logicid,data.cid,uploadedid,alreadyfilediv); $data.queuecomplete(); }) fileshowul_li_c_ank.append(fileshowul_li_c_ank_sc); } }else{ //计算文件名称超过10个字符 以...显示 // 显示附件图标 @author lihui 2016-8-19 if(settings.showico){ /* 图标显示方式 */ // alert(data.filetype); var fileshowul_li=$("
      • "); fileshowul.append(fileshowul_li); var fileshowul_li_div=$("
        "); fileshowul_li.append(fileshowul_li_div); var fileshowdiv_table = " "; fileshowdiv_table += " "; //计算文件名称超过10个字符 以...显示 var filename_dowon=data.oldfilename; if(filename_dowon!=null){ if(isincludechinese(filename_dowon)){ // 是汉字的话 if (filename_dowon.length > 8) { filename_dowon = filename_dowon.substr(0, 8) + "..."; } }else{ // 是非汉字的话 if (filename_dowon.length > 12) { filename_dowon = filename_dowon.substr(0, 12) + "..."; } } } // 是否显示名称 if(settings.isshowtitle != undefined){ if(settings.isshowtitle){ fileshowdiv_table += " "; } }else{ fileshowdiv_table += " "; } fileshowdiv_table += "
        "; var imgsrc = contextrootpath+"/saas/plugins/fileupload3/img/ico/"+geticobyfiletype(data.filetype); // 判断图片附件是否显示缩略图 if(settings.showthumbnail && isimage(data.filetype) && data.thumbnail != null && data.thumbnail != ""){ // 生成缩略图 imgsrc = contextrootpath + data.thumbnail; } fileshowdiv_table += " "; fileshowdiv_table += "
        "+filename_dowon+"
        "+filename_dowon+"
        "; var fileshowul_li_div_table=$(fileshowdiv_table); fileshowul_li_div.append(fileshowul_li_div_table); var fileshowul_li_c_div=$("
        "); fileshowul_li_div.append(fileshowul_li_c_div); var fileshowul_li_c_mz=$("
        "+filename_dowon_div+"
        "); fileshowul_li_c_div.append(fileshowul_li_c_mz); var fileshowul_li_c_ank=$("
        "); fileshowul_li_c_div.append(fileshowul_li_c_ank); // 预览 if(isimage(data.filetype)){ // 图片的预览 var fileshowul_li_c_ank_ly=$(""); fileshowul_li_c_ank.append(fileshowul_li_c_ank_ly); }else if(data.isweboffice && isoffice(data.filetype)){ // office的预览 var fileshowul_li_c_ank_ly=$("
        "); var fileshowul_li_c_ank_a=$("预览"); fileshowul_li_c_ank_a.click(function(){ webofficepreview(data.logicid, organcode, settings.previewtype, settings.downloadable, settings.formdata.isencrypt); }) fileshowul_li_c_ank_ly.append(fileshowul_li_c_ank_a); fileshowul_li_c_ank.append(fileshowul_li_c_ank_ly); } // 下载 if(undefined == settings.downloadable || settings.downloadable==true){ var fileshowul_li_c_ank_xz=$(""); fileshowul_li_c_ank_xz.click(function(){ $this.fileupload("downloadfile",organcode,data.logicid,settings.formdata.isencrypt,settings.formdata.issavedownlog); $data.queuecomplete(); }) fileshowul_li_c_ank.append(fileshowul_li_c_ank_xz); } // 删除 if(settings.deleteable==true){ var fileshowul_li_c_ank_sc=$(""); fileshowul_li_c_ank_sc.click(function(){ $this.fileupload("deletefile",organcode,data.logicid,data.cid,uploadedid,alreadyfilediv); $data.queuecomplete(); }) fileshowul_li_c_ank.append(fileshowul_li_c_ank_sc); } // 历史记录 if(settings.isshowhistorylog==true ){ // 记录附件上传历史记录 if(data.logs!=null){ var logs=eval(data.logs); if(logs.length>=1){ var fileshowul_li_c_gd1_2=$("
        "); fileshowul_li_c_ank.append(fileshowul_li_c_gd1_2); var fileshowul_li_c_tck3=$("
        "); fileshowul_li_c_gd1_2.append(fileshowul_li_c_tck3); fileshowul_li_c_gd1_2.append($("历史记录")); $.each(logs,function(logindex,log){ var logfilename_dowon_div=log.oldfilename; if(isincludechinese(logfilename_dowon_div)){ // 是汉字的话 if (logfilename_dowon_div.length > 8) { logfilename_dowon_div = logfilename_dowon_div.substr(0, 8) + "..."; } }else{ // 是非汉字的话 if (logfilename_dowon_div.length > 15) { logfilename_dowon_div = logfilename_dowon_div.substr(0, 15) + "..."; } } fileshowul_li_c_tck3.append($("").click(function(){ $this.fileupload("downloadfile",organcode,log.logicid,settings.formdata.isencrypt,settings.formdata.issavedownlog); $data.queuecomplete(); })); }); } } } // 全文批注 if(settings.docredbtenable==true || settings.docprintbtenable==true || settings.docacceptbtenable==true || settings.doceditbtenable==true || settings.docprotectbtenable==true){ var fileshowul_li_c_gd1=$("
        "); fileshowul_li_c_ank.append(fileshowul_li_c_gd1); var fileshowul_li_c_tck2=$("
        "); fileshowul_li_c_gd1.append(fileshowul_li_c_tck2); fileshowul_li_c_gd1.append($("全文批注")); // 全文批注:修订[有痕迹]按钮 if(settings.docprotectbtenable==true){ var fileshowul_li_c_ann2=$(""); fileshowul_li_c_ann2.click(function(){ webofficedoc(data.logicid, organcode, data.cid, settings.formdata.formlogicid, settings.formdata.isencrypt, "protect"); }) fileshowul_li_c_tck2.append(fileshowul_li_c_ann2); } // 全文批注:修改[无痕迹](排版) if(settings.doceditbtenable==true){ var fileshowul_li_c_ann3=$(""); fileshowul_li_c_ann3.click(function(){ webofficedoc(data.logicid, organcode, data.cid, settings.formdata.formlogicid, settings.formdata.isencrypt, "edit"); }) fileshowul_li_c_tck2.append(fileshowul_li_c_ann3); } // 全文批注:核稿按钮 if(settings.docacceptbtenable==true){ var fileshowul_li_c_ann4=$(""); fileshowul_li_c_ann4.click(function(){ webofficedoc(data.logicid, organcode, data.cid, settings.formdata.formlogicid, settings.formdata.isencrypt, "accept"); }) fileshowul_li_c_tck2.append(fileshowul_li_c_ann4); } // 全文批注:一键套红 if(settings.docredbtenable==true){ var fileshowul_li_c_ann5=$(""); fileshowul_li_c_ann5.click(function(){ webofficedocred(data.logicid, organcode, data.cid, settings.formdata.formlogicid, settings.formdata.isencrypt); }) fileshowul_li_c_tck2.append(fileshowul_li_c_ann5); } // 全文批注:打印按钮 if(settings.docprintbtenable==true){ var fileshowul_li_c_ann6=$(""); fileshowul_li_c_ann6.click(function(){ webofficedoc(data.logicid, organcode, data.cid, settings.formdata.formlogicid, settings.formdata.isencrypt, "print"); }) fileshowul_li_c_tck2.append(fileshowul_li_c_ann6); } // 全文批注:模版编辑 if(settings.doctemplateeditenable==true){ var fileshowul_li_c_ann7=$(""); fileshowul_li_c_ann7.click(function(){ webofficedoc(data.logicid, organcode, data.cid, settings.formdata.formlogicid, settings.formdata.isencrypt, "template"); }) fileshowul_li_c_tck2.append(fileshowul_li_c_ann7); } } }else{ //计算文件名称超过10个字符 以...显示 var filename_dowon=data.oldfilename; if(filename_dowon!=null){ if(isincludechinese(filename_dowon)){ // 是汉字的话 if (filename_dowon.length > 20) { filename_dowon = filename_dowon.substr(0, 20) + "..."; } }else{ // 是非汉字的话 if (filename_dowon.length > 35) { filename_dowon = filename_dowon.substr(0, 35) + "..."; } } } /* 常规显示方式 */ //最外层的div var filecontentdiv=$('
        '); //文件名称 var filecontentfilenamep=$('

        '); var filecontentfilenamea=$(''+filename_dowon+'('+j+')'); filecontentfilenamea.click(function(){ $this.fileupload("downloadfile",organcode,data.logicid,settings.formdata.isencrypt,settings.formdata.issavedownlog); $data.queuecomplete(); }) filecontentfilenamep.append(filecontentfilenamea); filecontentdiv.append(filecontentfilenamep); //删除按钮 if(settings.deleteable==true){ var filecontentdelfilea=$(''); filecontentdelfilea.click(function(){ $this.fileupload("deletefile",organcode,data.logicid,data.cid,uploadedid,alreadyfilediv); $data.queuecomplete(); }) var filecontentdelfilespan=$(' 删除文件 '); filecontentdelfilea.append(filecontentdelfilespan); filecontentdiv.append(filecontentdelfilea); } //进度条 var filecontentprogress=$('

        已完成

        '); filecontentdiv.append(filecontentprogress); $("#"+uploadedid).append(filecontentdiv);//追加到div中 } } //已经上传文件数量++ settings.fileuploadedcount++; }); if(settings.formdata.filesize != null && settings.formdata.filesize!=""){ $("#"+settings.formdata.filesize).val(settings.fileuploadedcount); } if(settings.showico){ // 图标方式 fileshowdiv.append(fileshowul); if(datas.length>3 && ((undefined != settings.delfilebybatch && settings.delfilebybatch) || (undefined != settings.downloadbybatch && settings.downloadbybatch))){ $("body").append($("
        ")); // 添加批量删除按钮 if(undefined != settings.delfilebybatch && settings.delfilebybatch){ fileshowdiv.append($("")); } // 添加打包下载按钮 if(undefined != settings.downloadbybatch && settings.downloadbybatch){ fileshowdiv.append($("")); } } fileshowdiv.append($("
        ")); $("#"+uploadedid).append(fileshowdiv);//追加到div中 }else{ // 列表方式 if(datas.length>3 && ((undefined != settings.delfilebybatch && settings.delfilebybatch) || (undefined != settings.downloadbybatch && settings.downloadbybatch))){ var filecontentdiv=$('
        '); $("body").append($("
        ")); // 添加批量删除按钮 if(undefined != settings.delfilebybatch && settings.delfilebybatch){ filecontentdiv.append($("")); } // 添加打包下载按钮 if(undefined != settings.downloadbybatch && settings.downloadbybatch){ filecontentdiv.append($("")); } $("#"+uploadedid).before(filecontentdiv);//追加到div中 } } } //如果没有附件 显示: “暂无上传附件” if($("#"+uploadedid).children().length==0&&$("#"+settings.queueid).children().length==0){ $("#"+uploadedid).append($("暂无上传附件!")); } } }); //#end_ajax }, //下载附件(租户编码,逻辑id) downloadfile: function(organcode,logicid,isencrypt,issavedownlog){ fileuploadbyico(organcode,logicid,isencrypt,issavedownlog); // 调用页面的方法 try{ ondownloadfilesuccess(); }catch(e){} }, deletefileunprompt: function(organcode,logicid,cid,uploadedid,alreadyfilediv){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; //删除附件(租户编码,附件的逻辑id,关联的对象逻辑id) $.ajax({ type: "post", url: contextrootpath +"/plugins/upload/delfileajax.xhtml", data: "organcode="+organcode+"&logicid="+logicid, success: function(data){ if(data=="true"){ try{ //刷新已经上传的文件列表 settings.fileuploadedcount--; $this.fileupload("buttondisabledfive"); $this.fileupload("search",organcode,cid,uploadedid,alreadyfilediv); }catch(e){} }else{ alert("删除失败!"); } } }); }, deletefileupdateinput: function(organcode,logicid,cid,uploadedid,alreadyfilediv){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; //删除附件(租户编码,附件的逻辑id,关联的对象逻辑id) if(window.confirm('当前操作将直接删除该附件,确定要删除吗?')){ $.ajax({ type: "post", url: contextrootpath +"/plugins/upload/delfileajax.xhtml", data: "organcode="+organcode+"&logicid="+logicid+"&cid="+cid, success: function(data){ if(data=="true"){ if(settings.isgraphicmix){ $("#li"+logicid).remove(); }else{ //刷新已经上传的文件列表 settings.fileuploadedcount--; $this.fileupload("buttondisabledfive"); $this.fileupload("search",organcode,cid,uploadedid,alreadyfilediv); } }else{ alert("删除失败!"); } } }); } }, deletefile: function(organcode,logicid,cid,uploadedid,alreadyfilediv){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; //删除附件(租户编码,附件的逻辑id,关联的对象逻辑id) if(window.confirm('当前操作将直接删除该附件,确定要删除吗?')){ $.ajax({ type: "post", url: contextrootpath +"/plugins/upload/delfileajax.xhtml", data: "organcode="+organcode+"&logicid="+logicid, success: function(data){ if(data=="true"){ //刷新已经上传的文件列表 settings.fileuploadedcount--; $this.fileupload("buttondisabledfive"); $this.fileupload("search",organcode,cid,uploadedid,alreadyfilediv); }else{ alert("删除失败!"); } } }); } }, deletefilenotips: function(organcode,logicid,cid,uploadedid,alreadyfilediv){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; //删除附件(租户编码,附件的逻辑id,关联的对象逻辑id) $.ajax({ type: "post", url: contextrootpath +"/plugins/upload/delfileajax.xhtml", data: "organcode="+organcode+"&logicid="+logicid, success: function(data){ if(data=="true"){ //刷新已经上传的文件列表 // settings.fileuploadedcount--; // $this.fileupload("buttondisabledfive"); // $this.fileupload("search",organcode,cid,uploadedid,alreadyfilediv); }else{ alert("删除失败!"); } } }); }, //判断数量是否超出限制 buttondisabledfive: function(){ var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; //alert("限制:"+settings.filecountlimit+"已经上传:"+settings.fileuploadedcount); // 如果 已经上传文件数量==限制文件数量 按钮设置为只读 /*if(settings.filecountlimit < settings.fileuploadedcount){ //按钮只读 $this.uploadify("disable",true); //取消全部正在上传附件进程 $this.uploadify("cancel"); }else{ //按钮可用 $this.uploadify("disable",false); }*/ }, // destroy an instance of uploadifive destroy : function() { this.each(function() { var $this = $(this), $data = $this.data('fileupload'), settings = $data.settings; // clear the queue methods.clearqueue.call($this); // destroy the queue if it was created if (!settings.queueid) $('#' + settings.queueid).remove(); // remove extra inputs $this.siblings('input').remove(); // show the original file input $this.show() // move the file input out of the button .insertbefore($data.button); // delete the button $data.button.remove(); // trigger the destroy event if (typeof settings.ondestroy === 'function') { settings.ondestroy.call($this); } }); } } $.fn.fileupload = function(method) { if (methods[method]) { return methods[method].apply(this, array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error('在fileupload中没有此 [' + method + '] 方法!'); } } })(jquery); //为了将*.png;*.doc;转换为mime方式的image/png;application/msword function acceptmime(filetypeexts){ var a = filetypeexts.split(';'); var r = ""; for (var n = 0; n < a.length; n++) { var t = "."+a[n].split('.')[1]; var retval = filetypetoacceptmime(t); if(retval!=""){ r += retval+","; } } r = r.substr(0, r.length - 1); return r; } //通过附件类型判断显示什么图标(暂时就这么几个图标,后期可以再加) function geticobyfiletype(filetype){ if(filetype == null){ return filetype; } filetype = filetype.tolowercase(); if(filetype.indexof(".") ==0 ){ filetype = filetype.substr(1, filetype.length); } if(filetype == "xlsx" || filetype == "xls"){ return "xls.png"; }else if(filetype == "docx" || filetype == "doc"){ return "word.png"; }else if(filetype == "pptx" || filetype == "ppt"){ return "ppt.png"; }else if(filetype == "pdf"){ return "pdf.png"; }else if(isimage(filetype)){ return "image.png"; }else if(filetype == "zip" || filetype == "rar" || filetype == "tar.gz"){ return "zip.png"; }else if(filetype == "flv" || filetype == "smi" || filetype == "rm" || filetype == "wmv" || filetype == "avi" || filetype == "mpg" || filetype == "wma" || filetype == "swf" || filetype == "mp4"){ return "video.png"; }else{ return "other.png"; } } //以图片方式显示附件时的下载地址 function fileuploadbyico(organcode,logicid,isencrypt,issavedownlog){ // 在新窗口中打开,避免由于附件不存在而跳入到空白页面 @author lihui 2016-8-19 window.open(contextrootpath + "/plugins/upload/download.xhtml?organcode="+organcode+"&logicid="+logicid+"&isencrypt="+isencrypt+"&issavedownlog="+issavedownlog,"_blank"); } function savegraphicmix(fn){ var filelogicids = $(".filelogicid"); var graphicmixobjs = "["; for(var i=0;i", width:"1100px", height:"900px", close: function () { } }); /*var organcode = "ctsj"; var replacevalue="{\"qjgl.title\":\"11\",\"qjgl.oaqjsy\":\"22\",\"qjgl.oajqlxdh\":\"33\",\"qjgl.oaqjts\":\"44\",\"qjgl.oalsjjr\":\"55\"}"; */ var organcode = $("#organcode").val(); var replacevalue=$("#replacevalue").val(); $("#tagjseventwin").attr("src",contextrootpath+"/plugins/upload/templatepreview.xhtml?organcode="+organcode+"&&replacevalue="+replacevalue); }