100 lines
3.3 KiB
JavaScript
100 lines
3.3 KiB
JavaScript
|
|
function showFileInput(ctrlName, layoutTemplates) {
|
||
|
|
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: layoutTemplates,
|
||
|
|
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, id, dele) {
|
||
|
|
$.post(ext.contextPath + '/base/getInputFileList_minio.do', {
|
||
|
|
masterId: masterId,
|
||
|
|
tbName: tbName,
|
||
|
|
bucketName: bucketName
|
||
|
|
}, function (data) {
|
||
|
|
if (data.length > 0) {
|
||
|
|
previews = new Array();
|
||
|
|
$('#maintenancefile').show();
|
||
|
|
$('#' + divId).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);
|
||
|
|
}
|
||
|
|
|
||
|
|
let v = {
|
||
|
|
actionUpload: '',
|
||
|
|
}
|
||
|
|
|
||
|
|
if (!dele) {
|
||
|
|
v.actionDelete = ''
|
||
|
|
}
|
||
|
|
|
||
|
|
showFileInput(divId, v);
|
||
|
|
if (divId != 'fileArea' && id != '') {
|
||
|
|
$.post(ext.contextPath + "/workorder/overhaulItemProject/doupdate.do", 'id=' + id + '&annex=' + data.length, function (data) {
|
||
|
|
if (data.res == 1 || data.res == '1') {
|
||
|
|
$("#table_overhaul_item_content").bootstrapTable('refresh');
|
||
|
|
}
|
||
|
|
}, 'json');
|
||
|
|
}
|
||
|
|
|
||
|
|
} else {
|
||
|
|
$('#' + divId).hide();
|
||
|
|
}
|
||
|
|
}, 'json');
|
||
|
|
};
|
||
|
|
|
||
|
|
var fileinput = function (divId, oid) {
|
||
|
|
$.post(ext.contextPath + '/overhaul/fileinputMinio.do', {
|
||
|
|
masterId: masterId,
|
||
|
|
tbName: tbName,
|
||
|
|
nameSpace: nameSpace,
|
||
|
|
divId: divId,
|
||
|
|
id: oid ? oid : ''
|
||
|
|
}, function (data) {
|
||
|
|
$("#fileInputDiv").html(data);
|
||
|
|
openModal('fileInputModal');
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|