regBaseXmImport.jsp
4.03 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
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>项目导入</title>
<meta name="decorator" content="default"/>
<script type="text/javascript">
$(document).ready(function() {
});
var str = "正在导入文件数据,请稍等...";
var seq = 0;
var second=500; //间隔时间1秒钟
function scroll() {
msg = str.substring(0, seq+1);
document.getElementById("word").innerHTML = msg;
seq++;
if (seq >= str.length){ seq = 0;}
}
//若onsubmit事件无法触发,使用绑定按钮点击事件代替
function check() {
var excel_file = $("#excel_file").val();
var issure = "${issure}";
// alert(issure+"1233333");
if ((excel_file == "" || excel_file.length == 0) && (issure == undefined || issure == null || issure =="")) {
alert("请选择文件路径!");
return false;
} else {
//重复执行某个方法
window.setInterval("scroll()",second);
return true;
}
}
function checkDada(){
var fileObj = document.getElementById("excel_file").files[0]; // 获取文件对象
var FileController = "${ctx}/reg/base/regBaseXm/checkfiledata"; // 接收上传文件的后台地址
$.ajax({
url:FileController,
type:"post",
data:form,
processData:false,
contentType:false,
success:function(data){
window.clearInterval(timer);
console.log("over..");
},
error:function(e){
alert("错误!!");
window.clearInterval(timer);
}
});
}
// $("#excel_button").on('click', function() {
// var excel_file = $("#excel_file").val();
// if (excel_file == "" || excel_file.length == 0) {
// alert("请选择文件路径!");
// return false;
// } else {
// return true;
// }
// });
</script>
<style type="text/css">
ol{padding-left:20px}
</style>
</head>
<body>
<form name="Form" action="${ctx}/reg/base/regBaseXm/importFile?issure=${issure}" method="post" enctype="multipart/form-data" onsubmit="return check();">
<br>
<%-- <input class="btn btn-default" id="excel_file" type="file" name="filename" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"/> --%>
<%-- <input id="check_button" class="btn btn-primary" type="button" onclick="checkDada()" value="数据验证"/> --%>
<c:if test="${not empty issure}">
<a href="${ctx}/reg/base/regBaseXm/importSave?issure=${issure}"><input id="excel_button" class="btn btn-primary" type="button" value="确定导入"/></a></c:if>
<c:if test="${empty issure}">
<input class="btn btn-default" id="excel_file" type="file" name="filename" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"/>
<input id="excel_button" class="btn btn-primary" type="submit" value="数据验证并导入"/></c:if>
<a href="${ctx}/reg/base/regBaseXm/download"><input type="button" class="btn btn-primary" value="下载excel模板"/></a>
</form>
<h3 id="word" ></h3><br/>
<c:if test="${not empty issure}">
<br>
<h3 style="color:red;">以下信息需手动确认:</h3>
<ol id="errormsg">
<c:forEach items="${listtem}" var="str" varStatus="status">
<li>${str }</li>
</c:forEach>
</ol>
</c:if>
<h3 id="word" ></h3><br/>
<c:if test="${not empty VIEW}">
<br>
<h5 style="color:red;">错误信息如下:</h5>
<ol id="errormsg">
<c:forEach items="${errorList}" var="str" varStatus="status">
<c:if test="${status.index!=0 }">
<li>${str }</li>
</c:if>
</c:forEach>
</ol>
</c:if>
<c:if test="${not empty msg}">
<h4 style="color:red;">${msg }</h4>
</c:if>
<a href="${ctx}/reg/base/regBaseXm/"><input type="button" class="btn btn-primary" value="返 回"/></a>
</body>
</html>