|
|
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
|
|
<c:set var="path" value="${pageContext.request.contextPath}"/>
|
|
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
|
|
<style>
|
|
|
.loading {
|
|
|
width: 160px;
|
|
|
height: 56px;
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
line-height: 56px;
|
|
|
color: #fff;
|
|
|
padding-left: 60px;
|
|
|
font-size: 15px;
|
|
|
background: #000;
|
|
|
opacity: 0.7;
|
|
|
z-index: 9999;
|
|
|
-moz-border-radius: 20px;
|
|
|
-webkit-border-radius: 20px;
|
|
|
border-radius: 20px;
|
|
|
filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
|
|
|
}
|
|
|
</style>
|
|
|
<!--导入加载-->
|
|
|
<div id="loadingModel" class="modal fade" data-keyboard="false"
|
|
|
data-backdrop="static" data-role="dialog"
|
|
|
aria-labelledby="myModalLabel" aria-hidden="true">
|
|
|
<div id="loading" class="loading">加载中。。。</div>
|
|
|
</div>
|
|
|
<script>
|
|
|
//导入按钮
|
|
|
function importBtn(){
|
|
|
$("#myModalLabel1").text('导入');
|
|
|
$('#myModal1').modal('show')
|
|
|
}
|
|
|
|
|
|
//导入excel
|
|
|
//url:导入请求的相对路径,exportFileName:导出出错数据的关键字
|
|
|
function importExcel(url,exportFileName){
|
|
|
var fileDir = $("#upfile").val();
|
|
|
var suffix = fileDir.substr(fileDir.lastIndexOf("."));
|
|
|
if ("" == fileDir) {
|
|
|
toastr.warning("选择需要导入的Excel文件!")
|
|
|
return false;
|
|
|
}
|
|
|
if (".xls" != suffix && ".xlsx" != suffix) {
|
|
|
toastr.warning("文件格式有误!选择Excel格式的文件导入!")
|
|
|
return false;
|
|
|
}
|
|
|
$("#form1").attr('disabled', 'disabled');
|
|
|
var url = path + url;
|
|
|
$('#loadingModel').modal('show');
|
|
|
$("#loading").css("background","url("+path+"/static/img/load.gif) no-repeat 10px 50%");
|
|
|
$('#form1').ajaxSubmit({
|
|
|
type:'POST',
|
|
|
url : url,
|
|
|
dataType : 'text',//服务器返回的数据类型 可选XML ,Json jsonp script html text等
|
|
|
data:{upfile:$("#upfile").val()},
|
|
|
error : function() {
|
|
|
$("#form1").removeAttr('disabled');
|
|
|
toastr.warning("导入excel出错!")
|
|
|
},
|
|
|
success : function(data) {
|
|
|
$('#loadingModel').modal('hide');
|
|
|
if(data == null || data == ''){
|
|
|
toastr.success("全部导入成功!");
|
|
|
setTimeout(function(){
|
|
|
window.location.reload();
|
|
|
},1000)
|
|
|
}else{
|
|
|
if(data.indexOf("@") != -1){
|
|
|
var datas = data.split("@");
|
|
|
var workBookKey = datas[0];
|
|
|
data = datas[1];
|
|
|
Common.confirm({
|
|
|
title: "提示",
|
|
|
message: data,
|
|
|
operate: function (reselt) {
|
|
|
if (reselt) {
|
|
|
var url = path + "/exportWrongExcel?fileName="+exportFileName+"&workBookKey=" + workBookKey;
|
|
|
window.location.href = url;
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
|
toastr.error(data);
|
|
|
}
|
|
|
}
|
|
|
$("#upfile").val("");
|
|
|
$("#form1").removeAttr('disabled');
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
</script>
|