first commit
This commit is contained in:
247
WebRoot/JS/commonFileUpload.js
Normal file
247
WebRoot/JS/commonFileUpload.js
Normal file
@ -0,0 +1,247 @@
|
||||
/**
|
||||
* 文件上传界面及保存公共方法,与带有审核流程的业务关联
|
||||
*/
|
||||
var previewConfigs = new Array();
|
||||
|
||||
/**上传文件页面
|
||||
* masterId 业务数据id
|
||||
* tbName 保存的数据库名称
|
||||
* nameSpace 保存到tomcat下的文件名称
|
||||
*/
|
||||
//上传文件
|
||||
var fileinput_process = function () {
|
||||
$.post(ext.contextPath + '/base/fileInputForProcess.do', {
|
||||
masterId: masterId_process,
|
||||
tbName: tbName_process,
|
||||
nameSpace: nameSpace_process
|
||||
}, function (data) {
|
||||
$("#fileInputDiv").html(data);
|
||||
openModal('fileInputModal');
|
||||
});
|
||||
};
|
||||
var fileinput_processMore = function (typeId) {
|
||||
$.post(ext.contextPath + '/base/fileInputForProcessmore.do', {
|
||||
typeId: typeId,
|
||||
masterId: masterId_process,
|
||||
tbName: tbName_process,
|
||||
nameSpace: nameSpace_process
|
||||
}, function (data) {
|
||||
$("#fileInputDiv").html(data);
|
||||
openModal('fileInputModal');
|
||||
});
|
||||
};
|
||||
var fileinput_processMore1 = function (typeId) {
|
||||
$.post(ext.contextPath + '/base/fileInputForProcessmore1.do', {
|
||||
typeId: typeId,
|
||||
masterId: masterId_process,
|
||||
tbName: tbName_process,
|
||||
nameSpace: nameSpace_process
|
||||
}, function (data) {
|
||||
$("#fileInputDiv").html(data);
|
||||
openModal('fileInputModal');
|
||||
});
|
||||
};
|
||||
//下载文件
|
||||
var fileDownload_process = function (id) {
|
||||
window.open(ext.contextPath + "/base/downloadFile.do?key=" + id + "&tbName=" + tbName_process);
|
||||
};
|
||||
//删除文件
|
||||
var delFileFun_process = function (id) {
|
||||
swal({
|
||||
text: "您确定要删除此记录?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
className: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
className: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function (willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/document/dodeleteFile.do', {
|
||||
id: id,
|
||||
tbName: tbName_process
|
||||
}, function (data) {
|
||||
if (data == 1) {
|
||||
console.info(data)
|
||||
document.getElementById('fileArea').innerHTML = "";
|
||||
getFileList_process();
|
||||
} else {
|
||||
showAlert('d', '删除失败');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
//名称定义不可修改
|
||||
var getFileList_process = function () {
|
||||
$.post(ext.contextPath + '/base/getInputFileList.do', {
|
||||
masterId: masterId_process,
|
||||
tbName: tbName_process
|
||||
}, function (data) {
|
||||
// $("#fileArea").empty();
|
||||
if (data.length > 0) {
|
||||
//$("#fileArea").show();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var filename = data[i].filename;
|
||||
var fileId = data[i].id;
|
||||
var addElement = '';
|
||||
if (status == 'delete') {
|
||||
addElement = '<div class="form-group form-inline">' +
|
||||
'<label class="col-sm-2 control-label"></label>' +
|
||||
'<div class="col-sm-6">' +
|
||||
'<a style="cursor:pointer" id = "' + fileId + '" onclick="fileDownload_process(\'' + fileId + '\')">' + filename + '</a>' +
|
||||
'</div>' +
|
||||
'<div class="col-sm-2">' +
|
||||
'<a style="cursor:pointer" onclick="delFileFun_process(\'' + fileId + '\')">删除</a>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
} else if (status == 'view') {
|
||||
addElement = '<div class="form-group form-inline">' +
|
||||
'<label class="col-sm-2 control-label"></label>' +
|
||||
'<div class="col-sm-6">' +
|
||||
'<a style="cursor:pointer" id = "' + fileId + '" onclick="fileDownload_process(\'' + fileId + '\')">' + filename + '</a>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
}
|
||||
|
||||
var s;
|
||||
var s = fileId;
|
||||
// 在字符处进行分解。
|
||||
var ss = s.split("-");
|
||||
document.getElementById('fileArea').innerHTML = ''
|
||||
if (ss.length > 1) {
|
||||
var filetypeid = ss[1];
|
||||
// console.info(filetypeid+"ss"+ss[1]+"filetypeid");
|
||||
if ($("#" + fileId).length == 0) {
|
||||
$("#" + filetypeid).append(
|
||||
addElement
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// console.info($("#" + fileId).length);
|
||||
if ($("#" + fileId).length == 0) {
|
||||
$("#fileArea").append(
|
||||
addElement
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//else{
|
||||
//$("#fileArea").hide();
|
||||
// }
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
|
||||
//名称定义不可修改
|
||||
var getFileList_process_minio = function (masterId, tbName, bucketName, status) {
|
||||
$.post(ext.contextPath + '/base/getInputFileList_minio.do', {
|
||||
masterId: masterId,
|
||||
tbName: tbName,
|
||||
bucketName: bucketName
|
||||
}, function (data) {
|
||||
if (data.length > 0) {
|
||||
$("#fileArea").show();
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var filename = data[i].filename;
|
||||
var fileId = data[i].id;
|
||||
var addElement = '';
|
||||
if (status == 'delete') {
|
||||
addElement = '<div class="form-group form-inline">' +
|
||||
'<label class="col-sm-2 control-label"></label>' +
|
||||
'<div class="col-sm-6">' +
|
||||
'<a style="cursor:pointer" id = "' + fileId + '" onclick="fileDownload_process(\'' + fileId + '\')">' + filename + '</a>' +
|
||||
'</div>' +
|
||||
'<div class="col-sm-2">' +
|
||||
'<a style="cursor:pointer" onclick="delFileFun_process(\'' + fileId + '\')">删除</a>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
} else if (status == 'view') {
|
||||
addElement = '<div class="form-group form-inline">' +
|
||||
'<label class="col-sm-2 control-label"></label>' +
|
||||
'<div class="col-sm-6">' +
|
||||
'<a style="cursor:pointer" id = "' + fileId + '" onclick="fileDownload_process(\'' + fileId + '\')">' + filename + '</a>' +
|
||||
'</div>' +
|
||||
'</div>'
|
||||
}
|
||||
|
||||
var s;
|
||||
var s = fileId;
|
||||
// 在字符处进行分解。
|
||||
var ss = s.split("-");
|
||||
console.info(ss);
|
||||
if (ss.length > 1) {
|
||||
var filetypeid = ss[1];
|
||||
if ($("#" + fileId).length == 0) {
|
||||
$("#" + filetypeid).append(
|
||||
addElement
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.info($("#" + fileId).length);
|
||||
if ($("#" + fileId).length == 0) {
|
||||
$("#fileArea").append(
|
||||
addElement
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//else{
|
||||
//$("#fileArea").hide();
|
||||
// }
|
||||
}, 'json');
|
||||
};
|
||||
|
||||
/**
|
||||
* 图片预览 -- minio
|
||||
* @param masterId
|
||||
* @param tbName
|
||||
* @param bucketName
|
||||
* @param status
|
||||
*/
|
||||
|
||||
/*
|
||||
var getFileList_picture_minio = function (masterId, tbName, bucketName, status, divId) {
|
||||
$.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;
|
||||
if(status == 'view'){
|
||||
previewConfig['showRemove'] = false;//不显示移除按钮
|
||||
}else{
|
||||
previewConfig['showRemove'] = true;//不显示移除按钮
|
||||
}
|
||||
previewConfigs.push(previewConfig);
|
||||
}
|
||||
showFileInput(divId);
|
||||
} else {
|
||||
$('#'+divId).hide();
|
||||
}
|
||||
}, 'json');
|
||||
};*/
|
||||
Reference in New Issue
Block a user