excel_upload.jsp
4.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
Created by IntelliJ IDEA.
User: lenovo
Date: 2019/3/15
Time: 16:24
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="<%=basePath %>resource/css/base.css" rel="stylesheet">
<link href="<%=basePath %>resource/css/basic_info.css" rel="stylesheet">
<link rel="stylesheet" href="<%=basePath %>resource/easyui/uimaker/easyui.css">
<link href="<%=basePath %>resource/css/form.css" rel="stylesheet">
<link rel="stylesheet" href="<%=basePath %>resource/css/form.css">
<script type="text/javascript" src="<%=basePath %>resource/easyui/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/validate/validate-extends.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/js/tools.js"></script>
<!-- validate 验证中英文 -->
<script type="text/javascript" src="<%=basePath %>resource/validate/jquery.validate-${pageContext.response.locale}.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/validate/ajaxfileupload.js"></script>
<script type="text/javascript" src="<%=basePath %>resource/validate/jquery.form.js"></script>
</head>
<body>
<div class="container">
<div class="content">
<form class="from-control" id="form">
<div></div>
<div>
<table class="kv-table">
<tbody>
<div>
<tr class="kv-content" >
<%--<td style="background-color: #EBEDF4; color: black;" class="kv-label" colspan="6"><spring:message code="manifest.excel"/></td>--%>
<td style="background-color: #EBEDF4; color: black;" class="kv-label" colspan="1">
<input type="file" id = "file" name = "file" required="required">
</td>
<td style="background-color: #EBEDF4; color: black;" class="kv-label" colspan="4">
<button type="button" class="layui-btn layui-btn-sm layui-icon layui-icon-user" id="subbtn" onclick="submitFrom()">
<i class="fa fa-trash hidden" aria-hidden="true"></i>导入
</button>
</td>
</tr>
</div>
</tbody>
</table>
</div>
</form>
</div>
</div>
<script type="text/javascript">
function submitFrom() {
var excelPath = $("#file").val();
if(excelPath == null || excelPath == ''){
alert("请选择要上传的Excel文件");
return;
}else{
var fileExtend = excelPath.substring(excelPath.lastIndexOf('.')).toLowerCase();
if(fileExtend == '.xls' || fileExtend == '.xlsx'){
$("#form").ajaxSubmit({
url:"<%=basePath %>manifest/excelUpload",
cache:false,
type:'POST',
dataType:'json',
success: function(data) {
if(data.status == 200){
alert("导入成功");
window.parent.location.reload();
var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
parent.layer.close(index);
}else if (data.status == 201){
alert(data.msg);
}else if(data.status == 202){
alert(data.msg);
}else if (data.status == 300){
alert(data.msg);
}else if (data.status == 301){
alert(data.msg);
}else {
alert(data.msg);
}
}
});
} else {
alert("文件格式需为'.xls'格式");
return;
}
}
}
</script>
</body>
</html>