110 lines
4.9 KiB
Plaintext
110 lines
4.9 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8"%>
|
||
<script type="text/javascript">
|
||
|
||
|
||
var filelist = new Array();
|
||
//初始化fileinput控件(第一次初始化)
|
||
function initFileInput(ctrlName, uploadUrl) {
|
||
var control = $('#' + ctrlName);
|
||
control.fileinput({
|
||
language: 'zh', //设置语言
|
||
uploadUrl: uploadUrl, //上传的地址
|
||
uploadAsync:true,
|
||
allowedFileExtensions : ['xls','xlsx'],//接收的文件后缀
|
||
showUpload: false, //是否显示上传按钮
|
||
showRemove:false,
|
||
showCaption: false,//是否显示标题
|
||
showClose:false,//右上角关闭按钮
|
||
browseClass: "btn btn-primary", //按钮样式
|
||
maxFileCount: 10, //表示允许同时上传的最大文件个数
|
||
enctype: 'multipart/form-data',
|
||
validateInitialCount:true,
|
||
previewFileIcon: "<i class='fa fa-file'></i>",
|
||
preferIconicPreview: true,//是否强制相关文件展示icon
|
||
initialPreviewAsData: true,
|
||
previewFileIconSettings: {
|
||
'doc': '<i class="fa fa-file-word-o" style="color:#3c8dbc;margin-left:-100px"></i>',
|
||
'docx': '<i class="fa fa-file-word-o" style="color:#3c8dbc;margin-left:-100px"></i>',
|
||
'xls': '<i class="fa fa-file-excel-o" style="color:#00a65a ;margin-left:-100px"></i>',
|
||
|
||
'xlsx': '<i class="fa fa-file-excel-o" style="color:#00a65a ;margin-left:-100px"></i>',
|
||
'pptx': '<i class="fa fa-file-powerpoint-o" style="color:#f39c12;margin-left:-100px "></i>',
|
||
'ppt': '<i class="fa fa-file-powerpoint-o" style="color:#f39c12;margin-left:-100px "></i>',
|
||
//'jpg': '<i class="fa fa-file-image-o" style="color:#00a65a "></i>',
|
||
'pdf': '<i class="fa fa-file-pdf-o" style="color:#dd4b39 ;margin-left:-100px"></i>',
|
||
'zip': '<i class="fa fa-file-zip-o" ></i>',
|
||
},
|
||
|
||
uploadExtraData:function (previewId, index) { //传参
|
||
var data = {
|
||
"masterId": '${masterId}', //此处自定义传参
|
||
"tbName": '${tbName}',
|
||
"nameSpace": '${nameSpace}'
|
||
};
|
||
return data;
|
||
},
|
||
layoutTemplates:{
|
||
actionDelete:''
|
||
},
|
||
});
|
||
control.on("filebatchselected", function (event, data, previewId, index) {
|
||
$(this).fileinput("upload");
|
||
});
|
||
//导入文件上传完成之后的事件
|
||
control.on("fileuploaded", function (event, data, previewId, index) {
|
||
if(data.response.suc) {
|
||
/* console.info(data.response);
|
||
var id = data.response.msg; //文件上传成功返回的文件名,可返回自定义文件名
|
||
filelist.push({ id: id, KeyID: previewId }) */
|
||
// getFileList();
|
||
$("#initialPreviewTable").bootstrapTable('refresh');
|
||
}
|
||
});
|
||
/* control.on('filepredelete', function(event, key, jqXHR, data) {
|
||
console.log("filelist",filelist);
|
||
console.log("id",key);
|
||
for (var i = 0; i < filelist.length; i++) {
|
||
if (filelist[i].KeyID== key) {
|
||
$.post(ext.contextPath + "/maintenance/deleteProblemFile.do", {key:filelist[i].id,tbName:'${tbName}'}, function(data) {
|
||
console.log("resp",data);
|
||
if (data.suc == true) {
|
||
}else if(data.suc == false){
|
||
showAlert('d','删除失败');
|
||
}else{
|
||
showAlert('d',data);
|
||
}
|
||
},'json');
|
||
}
|
||
}
|
||
}); */
|
||
}
|
||
$(function() {
|
||
initFileInput("filelist",ext.contextPath+ "/achievement/acceptanceModel/inputFile.do");
|
||
})
|
||
</script>
|
||
<div class="modal fade" id="fileInputModal">
|
||
<div class="modal-dialog">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">上传</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<!-- 新增界面formid强制为subForm -->
|
||
<form class="form-horizontal" id="fileInputModalForm" style="padding:10px">
|
||
<%-- <input type="hidden" class="form-control" id ="masterId" name ="masterId" value="${masterId}"> --%>
|
||
<div class="form-group" >
|
||
<input type="file" name="filelist" id="filelist" multiple class="file-loading" />
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div>
|