Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/document/equipmentFileAdd.jsp

124 lines
5.6 KiB
Plaintext
Raw Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" pageEncoding="UTF-8"%>
<script type="text/javascript">
var filelist = new Array();
var control;
//初始化fileinput控件第一次初始化
function initFileInput(ctrlName, uploadUrl) {
control = $('#' + ctrlName);
control.fileinput({
language: 'zh', //设置语言
uploadUrl: uploadUrl, //上传的地址
uploadAsync:true,
allowedFileExtensions : ['jpg', 'png','gif','pdf','doc','xls','docx','ppt','pptx','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 = {
"tbName": '${tbName}',//此处自定义传参
"nameSpace": '${nameSpace}',
"equipmentIds":'${equipmentId}',
"masterId": '${masterId}'
};
return data;
},
//设置缩略图上的按钮,为空不显示,默认显示
layoutTemplates:{
actionDelete:'',
actionUpload:''
},
});
/* control.on("filebatchselected", function (event, data, previewId, index) {
$(this).fileinput("upload");
}); */
//导入文件上传完成之后的事件
control.on("fileuploaded", function (event, data, previewId, index) {
if(data.response.suc) {
closeModal('fileInputModal');
$("#fileTable").bootstrapTable('refresh');
}
});
}
$(function() {
initFileInput("filelist",ext.contextPath+ "/document/inputFile.do");
//提示
$("#uploadAlert").popover({
trigger:'manual',
placement : 'bottom', //placement of the popover. also can use top, bottom, left or right
title : '<div style="text-align:center; color:red; font-size:14px;">温馨提示</div>', //this is the top title bar of the popover. add some basic css
html: 'true', //needed to show html of course
content : '<div id="popOverBox">设备中上传的资料,只能在技术档案菜单的全局搜索中查看,请您知悉!</div>', //this is the content of the html box. add the image here or anything you want really.
animation: false
}).on("mouseenter", function () {
var _this = this;
$(this).popover("show");
$(this).siblings(".popover").on("mouseleave", function () {
$(_this).popover('hide');
});
}).on("mouseleave", function () {
var _this = this;
setTimeout(function () {
if (!$(".popover:hover").length) {
$(_this).popover("hide")
}
}, 100);
});
})
//导入上传文件的数据
function uploadFun(){
if($("#filelist").val() == null || $("#filelist").val()==""){
showAlert('d','上传的文件不能为空!','alertFileDiv');
}else{
control.fileinput("upload");
}
}
</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">&times;</span></button>
<h4 class="modal-title">上传 &nbsp;&nbsp;<i id="uploadAlert" class="icon fa fa-warning"></i></h4>
</div>
<div class="modal-body">
<!-- 新增界面formid强制为subForm -->
<form class="form-horizontal" id="fileInputModalForm" style="padding:10px">
<div id="alertFileDiv"></div>
<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>
<button type="button" class="btn btn-primary" onclick="uploadFun()" id="btn_upload"><i class="glyphicon glyphicon-upload"></i>上传</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>