You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.5 KiB
Plaintext

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@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>