$.extend({
// 文件下载
download : function(url, data, method) {
if (url && data) {
// 把参数组装成 form的 input
var inputs = '';
$.each(data, function(name, value) {
if(value) {
inputs += '<input type="hidden" name="' + name + '" value="' + value + '" />';
}
});
// request发送请求
$('<form action="' + url + '" method="' + (method || 'post') + '">' + inputs + '</form>').appendTo('body').submit().remove();
}
},
// 预览pdf文件
previewPdfFile: function (fileId){
if (fileId) {
$.closeDialog('#pdfPreviewWindow');
var url = top.location.href.substring(0, top.location.href.lastIndexOf("/"))+"/file/getPDFfile.json?id=" + fileId;
$('<div id="pdfPreviewWindow"></div>').dialog({
title : '文件预览',
content : '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:95%;"></iframe>',
width : 1000,
draggable : true,
height : 700,
top : 70,
onClose : function() {
$.closeDialog('#pdfPreviewWindow');
}
});
} else {
$.messager.alert('提示', '文件不存在');
}
},
// 上传文件
uploader : function(formId, fileName, fileId, buttonId, callBack) {
var _title = document.title;
var uploader = new plupload.Uploader({
runtimes : 'gears,html5,flash,silverlight,browserplus',
browse_button : buttonId,
url : 'file/uploadFile.json',
container : 'container_' + buttonId,
max_file_size : '20mb',
chunk_size : '1mb',
unique_names : true,
filters : [ {title : "PDF files", extensions : "pdf"}],
flash_swf_url : 'ui_component/plupload/plupload.flash.swf',
silverlight_xap_url : 'ui_component/plupload//plupload.silverlight.xap'
});
$('#'+buttonId).mouseenter(function() {
uploader.refresh();
});
uploader.bind('FilesAdded', function(up, files) {
$('#'+formId).find('#'+fileName).val(files[0].name);
document.title = _title;
up.refresh();
$.messager.progress();
});
uploader.bind('QueueChanged', function() {
uploader.start();
});
uploader.bind('Error', function(up, err) {
$.messager.alert('提示', err.message);
document.title = _title;
up.refresh();
$.messager.progress('close');
});
uploader.bind('FileUploaded', function(up, file, response) {
$('#'+formId).find('#'+fileId).val(response.response);
$.messager.progress('close');
if (typeof callBack == "function") {
callBack();
}
});
uploader.init();
return uploader;
},
// 赎回根据文件id获取文件类型
getInvestRedeemFileTypeNameByFileTypeId:function(value) {
var ret = '';
switch (value) {
case "1" : ret = "赎回申请单"; break;
case "2" : ret = "特殊变更申请书"; break;
case "3" : ret = "债权转让文件"; break;
case "4" : ret = "管理费折扣函"; break;
case "5" : ret = "封闭期赎回审批表"; break;
case "6" : ret = "补充协议"; break;
case "7" : ret = "线下付款凭证"; break;
case "8" : ret = "合同"; break;
case "9" : ret = "身份证"; break;
case "B" : ret = "银行卡"; break;
case "P" : ret = "委托扣划授权"; break;
}
return ret;
},
//根据文件类型id获得文件类型名称
getFileTypeNameByFileTypeId:function(value) {
var ret = '';
switch (value) {
case "0" : ret = "身份证"; break;
case "1" : ret = "银行卡"; break;
case "2" : ret = "合同"; break;
case "3" : ret = "变更申请"; break;
case "4" : ret = "委托划扣授权"; break;
case "5" : ret = "管理费折扣函"; break;
case "6" : ret = "付款凭证"; break;
case "7" : ret = "担保协议"; break;
}
return ret;
},
});
// 文件下载
download : function(url, data, method) {
if (url && data) {
// 把参数组装成 form的 input
var inputs = '';
$.each(data, function(name, value) {
if(value) {
inputs += '<input type="hidden" name="' + name + '" value="' + value + '" />';
}
});
// request发送请求
$('<form action="' + url + '" method="' + (method || 'post') + '">' + inputs + '</form>').appendTo('body').submit().remove();
}
},
// 预览pdf文件
previewPdfFile: function (fileId){
if (fileId) {
$.closeDialog('#pdfPreviewWindow');
var url = top.location.href.substring(0, top.location.href.lastIndexOf("/"))+"/file/getPDFfile.json?id=" + fileId;
$('<div id="pdfPreviewWindow"></div>').dialog({
title : '文件预览',
content : '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:95%;"></iframe>',
width : 1000,
draggable : true,
height : 700,
top : 70,
onClose : function() {
$.closeDialog('#pdfPreviewWindow');
}
});
} else {
$.messager.alert('提示', '文件不存在');
}
},
// 上传文件
uploader : function(formId, fileName, fileId, buttonId, callBack) {
var _title = document.title;
var uploader = new plupload.Uploader({
runtimes : 'gears,html5,flash,silverlight,browserplus',
browse_button : buttonId,
url : 'file/uploadFile.json',
container : 'container_' + buttonId,
max_file_size : '20mb',
chunk_size : '1mb',
unique_names : true,
filters : [ {title : "PDF files", extensions : "pdf"}],
flash_swf_url : 'ui_component/plupload/plupload.flash.swf',
silverlight_xap_url : 'ui_component/plupload//plupload.silverlight.xap'
});
$('#'+buttonId).mouseenter(function() {
uploader.refresh();
});
uploader.bind('FilesAdded', function(up, files) {
$('#'+formId).find('#'+fileName).val(files[0].name);
document.title = _title;
up.refresh();
$.messager.progress();
});
uploader.bind('QueueChanged', function() {
uploader.start();
});
uploader.bind('Error', function(up, err) {
$.messager.alert('提示', err.message);
document.title = _title;
up.refresh();
$.messager.progress('close');
});
uploader.bind('FileUploaded', function(up, file, response) {
$('#'+formId).find('#'+fileId).val(response.response);
$.messager.progress('close');
if (typeof callBack == "function") {
callBack();
}
});
uploader.init();
return uploader;
},
// 赎回根据文件id获取文件类型
getInvestRedeemFileTypeNameByFileTypeId:function(value) {
var ret = '';
switch (value) {
case "1" : ret = "赎回申请单"; break;
case "2" : ret = "特殊变更申请书"; break;
case "3" : ret = "债权转让文件"; break;
case "4" : ret = "管理费折扣函"; break;
case "5" : ret = "封闭期赎回审批表"; break;
case "6" : ret = "补充协议"; break;
case "7" : ret = "线下付款凭证"; break;
case "8" : ret = "合同"; break;
case "9" : ret = "身份证"; break;
case "B" : ret = "银行卡"; break;
case "P" : ret = "委托扣划授权"; break;
}
return ret;
},
//根据文件类型id获得文件类型名称
getFileTypeNameByFileTypeId:function(value) {
var ret = '';
switch (value) {
case "0" : ret = "身份证"; break;
case "1" : ret = "银行卡"; break;
case "2" : ret = "合同"; break;
case "3" : ret = "变更申请"; break;
case "4" : ret = "委托划扣授权"; break;
case "5" : ret = "管理费折扣函"; break;
case "6" : ret = "付款凭证"; break;
case "7" : ret = "担保协议"; break;
}
return ret;
},
});