Ver código fonte

导入按钮问题处理

user5 3 anos atrás
pai
commit
b0e6d595a5

+ 70 - 0
src/main/webapp/WEB-INF/tags/table/importExcelA.tag

@@ -0,0 +1,70 @@
+<%@ tag language="java" pageEncoding="UTF-8"%>
+<%@ include file="/webpage/include/taglib.jsp"%>
+<%@ attribute name="url" type="java.lang.String" required="true"%>
+<%-- 使用方法: 1.将本tag写在查询的form之前;2.传入controller的url --%>
+<a id="btnImport" class="nav-btn nav-btn-import" data-toggle="tooltip" data-placement="left" title="导入"><i class="fa fa-folder-open-o"></i> 导入</a>
+<div id="importBox" class="hide">
+	<form id="importForm2" action="${url}" method="post" enctype="multipart/form-data" onsubmit="loading('正在导入,请稍等...');">
+		<br/>
+		<input id="uploadFile" name="file" type="file" style="width:330px"/>导入文件不能超过5M,仅允许导入“xls”或“xlsx”格式文件!<br/>  
+
+	</form>
+</div>
+<script type="text/javascript">
+	$(document).ready(function() {
+		$("#btnImport").click(function(){
+			top.layer.open({
+				type: 1,
+				area: [500, 300],
+				title:"导入数据",
+				content:$("#importBox").html() ,
+				btn: ['下载模板','确定', '关闭'],
+				btn1: function(index, layero){
+					window.location.href='${url}/template';
+				},
+				btn2: function(index, layero){
+					/*$('#importForm2').ajaxSubmit({
+                        dataType: "json",
+                        success: function (result) {
+                            console.log(result);
+                            if(result.code == 0){
+                                genRow(result.data);
+                            }else {
+                                top.layer.msg("导入文件异常:"+result.message);
+                            }
+                        },
+                        error: function () {
+                            top.layer.msg("导入文件失败!");
+                        }
+                    });*/
+
+					var formData = new FormData();
+					formData.append("file",top.$("#uploadFile")[0].files[0]);
+					$.ajax({
+						type: 'post',
+						url: "${url}",
+						data: formData,
+						dataType: "json",
+						cache: false,
+						processData: false,
+						contentType: false,
+					}).success(function (result) {
+						if(result.code == 0){
+							genRow(result.data);
+						}else {
+							top.layer.msg("导入文件异常:"+result.message);
+						}
+					}).error(function () {
+						top.layer.msg("导入文件失败!");
+					});
+					top.layer.close(index);
+				},
+				btn3: function(index){
+					top.layer.close(index);
+				}
+			});
+		});
+
+	});
+
+</script>

+ 1 - 1
src/main/webapp/webpage/modules/projectMaterialStorage/projectMaterialStorageForm.jsp

@@ -120,7 +120,7 @@
 			<div class="form-group-label"><h2>材料处理</h2></div>
 			<div class="layui-item nav-btns">
 				<a class="nav-btn nav-btn-add" onclick="addRow1('#workInvoiceProjectRelationList', workInvoiceProjectRelationListRowIdx, workInvoiceProjectRelationListTpl);workInvoiceProjectRelationListRowIdx = workInvoiceProjectRelationListRowIdx + 1;" title="新增"><i class="fa fa-plus"></i>&nbsp;新增</a>
-				<table:importExcelCost url="${ctx}/project/projectMaterialStorage/import"></table:importExcelCost><!-- 导入按钮 -->
+				<table:importExcelA url="${ctx}/project/projectMaterialStorage/import"></table:importExcelA><!-- 导入按钮 -->
 			</div>
 			<div class="layui-table-body layui-item layui-col-xs12 form-table-container"  style="padding:0px">
 				<table id="contentTables" class="table table-bordered table-condensed can-edit no-bottom-margin details">