first commit
This commit is contained in:
167
WebRoot/JS/commonFile.js
Normal file
167
WebRoot/JS/commonFile.js
Normal file
@ -0,0 +1,167 @@
|
||||
function showFileInput_new(ctrlName, previews, previewConfigs) {
|
||||
var control = $('#' + ctrlName);
|
||||
control.fileinput('destroy');
|
||||
control.fileinput({
|
||||
language: 'zh', //设置语言
|
||||
showUpload: false, //是否显示上传按钮
|
||||
allowedFileExtensions: ['jpg', 'png', 'gif', 'pdf', 'doc', 'xls', 'docx', 'ppt', 'pptx', 'xlsx'],
|
||||
showRemove: false,
|
||||
showCaption: false,//是否显示标题
|
||||
showBrowse: false,//选择按钮
|
||||
showClose: false,//右上角关闭按钮
|
||||
dropZoneEnabled: false,//是否显示拖拽区域
|
||||
fileActionSettings: {
|
||||
showDrag: false
|
||||
},
|
||||
browseClass: "btn btn-primary", //按钮样式
|
||||
maxFileCount: 10, //表示允许同时上传的最大文件个数
|
||||
enctype: 'multipart/form-data',
|
||||
validateInitialCount: true,
|
||||
previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
|
||||
initialPreviewAsData: true,
|
||||
initialPreview: previews,
|
||||
initialPreviewConfig: previewConfigs,
|
||||
layoutTemplates: {
|
||||
actionUpload: ''
|
||||
},
|
||||
deleteUrl: ext.contextPath + "/base/deleteInputFile.do",
|
||||
deleteExtraData: function () { //传参
|
||||
var data = {
|
||||
"tbName": tbName
|
||||
};
|
||||
return data;
|
||||
}
|
||||
});
|
||||
$('#kvFileinputModal').on("hidden.bs.modal", function () {
|
||||
$(this).removeData("bs.modal");
|
||||
//modal重复打开会导致前面的滚动条失去作用
|
||||
$('.modal').css("overflow", "auto");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载文件
|
||||
* @param divId div的id
|
||||
*/
|
||||
var getFileListMinio = function (divId) {
|
||||
// $.post(ext.contextPath + '/base/getInputFileList.do', {
|
||||
$.post(ext.contextPath + '/base/getInputFileList_minio.do', {
|
||||
masterId: masterId,
|
||||
tbName: tbName,
|
||||
bucketName: bucketName
|
||||
}, function (data) {
|
||||
if (data.length > 0) {
|
||||
previews = new Array();
|
||||
$('#maintenancefile').show();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var previewConfig = new Object();
|
||||
var path = data[i].abspath;
|
||||
previews.push(path);
|
||||
previewConfig['width'] = '50px';
|
||||
previewConfig['caption'] = data[i].filename;
|
||||
previewConfig['key'] = data[i].id;
|
||||
previewConfigs.push(previewConfig);
|
||||
}
|
||||
showFileInput_new(divId);
|
||||
} else {
|
||||
$('#' + divId).hide();
|
||||
}
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
/**
|
||||
* 加载图片 2个参数
|
||||
* @param divId div的id
|
||||
*/
|
||||
/*var getFileListMinioPic = function (divId, status) {
|
||||
$.post(ext.contextPath + '/base/getInputFileList_minio.do', {
|
||||
masterId: masterId,
|
||||
tbName: tbName,
|
||||
bucketName: bucketName
|
||||
}, function (data) {
|
||||
if (data.length > 0) {
|
||||
previews = new Array();
|
||||
$('#maintenancefile').show();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var previewConfig = new Object();
|
||||
var path = 'data:image/png;base64,' + data[i].streamFile;
|
||||
previews.push(path);
|
||||
previewConfig['width'] = '50px';
|
||||
previewConfig['caption'] = data[i].filename;
|
||||
previewConfig['key'] = data[i].id;
|
||||
if (status == 'view') {
|
||||
previewConfig['showRemove'] = false;//不显示移除按钮
|
||||
} else {
|
||||
previewConfig['showRemove'] = true;//显示移除按钮
|
||||
}
|
||||
previewConfigs.push(previewConfig);
|
||||
}
|
||||
showFileInput_new(divId);
|
||||
} else {
|
||||
$('#' + divId).hide();
|
||||
}
|
||||
}, 'json');
|
||||
};*/
|
||||
|
||||
/**
|
||||
* 加载图片 5个参数
|
||||
* @param divId div的id
|
||||
*/
|
||||
var getFileListMinioPic = function (divId, status, entityId, previews, previewConfigs) {
|
||||
if (entityId == '') {
|
||||
entityId = masterId;
|
||||
}
|
||||
$.post(ext.contextPath + '/base/getInputFileList_minio.do', {
|
||||
masterId: entityId,
|
||||
tbName: tbName,
|
||||
bucketName: bucketName
|
||||
}, function (data) {
|
||||
if (data.length > 0) {
|
||||
previews = new Array();
|
||||
$('#maintenancefile').show();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var previewConfig = new Object();
|
||||
var path = 'data:image/png;base64,' + data[i].streamFile;
|
||||
previews.push(path);
|
||||
previewConfig['width'] = '50px';
|
||||
previewConfig['caption'] = data[i].filename;
|
||||
previewConfig['key'] = data[i].id;
|
||||
if (status == 'view') {
|
||||
previewConfig['showRemove'] = false;//不显示移除按钮
|
||||
} else {
|
||||
previewConfig['showRemove'] = true;//显示移除按钮
|
||||
}
|
||||
previewConfigs.push(previewConfig);
|
||||
}
|
||||
showFileInput_new(divId, previews, previewConfigs);
|
||||
} else {
|
||||
$('#' + divId).hide();
|
||||
}
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
//上传文件
|
||||
var fileinput = function (divId) {
|
||||
$.post(ext.contextPath + '/base/fileinputMinio.do', {
|
||||
masterId: masterId,
|
||||
tbName: tbName,
|
||||
nameSpace: nameSpace,
|
||||
divId: divId
|
||||
}, function (data) {
|
||||
$("#fileInputDiv").html(data);
|
||||
openModal('fileInputModal');
|
||||
});
|
||||
};
|
||||
|
||||
//上传图片
|
||||
var fileinputPic = function (divId) {
|
||||
$.post(ext.contextPath + '/base/fileinputMinioPic.do', {
|
||||
masterId: masterId,
|
||||
tbName: tbName,
|
||||
nameSpace: nameSpace,
|
||||
divId: divId
|
||||
}, function (data) {
|
||||
$("#fileInputDiv").html(data);
|
||||
openModal('fileInputModal');
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user