importExcel.jsp 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <%@ include file="/include/head.jsp"%>
  2. <%@ page contentType="text/html;charset=GBK"%>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  4. <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <HEAD>
  7. <TITLE>Excel导入</TITLE>
  8. <link href="main.css" rel="stylesheet" type="text/css"></link>
  9. <link href="./liger/lib/ligerUI/skins/${sessionScope.css}/css/ligerui-all.css"
  10. rel="stylesheet" type="text/css"></link>
  11. <script type="text/javascript" src="/shares/js/jquery-1.3.2.min.js"></script>
  12. <script src="${pageContext.request.contextPath}/liger/lib/ligerUI/js/ligerui.all.js"
  13. type="text/javascript"></script>
  14. <script type="text/javascript" src="/shares/js/common.js"></script>
  15. <script type="text/javascript" src="/shares/js/constant.js"></script>
  16. <script type="text/javascript">
  17. $(function(){
  18. if(top.importWaitDlg)top.importWaitDlg.close();
  19. <c:if test="${result ne null}">
  20. var result = "${result}";
  21. if(result == "-1"){
  22. top.$.ligerDialog.error('导入失败:Excel文件中没有数据!');
  23. }else if(result == "-2"){
  24. showErrorDiv();
  25. //top.$.ligerDialog.error('数据验证不通过,请查询模板格式是否正确!');
  26. }else if(result == "0"){
  27. top.$.ligerDialog.success('操作成功!');
  28. }else{
  29. top.$.ligerDialog.success('成功导入'+result+'条数据!');
  30. }
  31. <c:if test="${fn:length(infoList) gt 0}">
  32. showInfoDiv();
  33. </c:if>
  34. </c:if>
  35. });
  36. function importExcel(operner){
  37. var rs = $.validate({name:"files",model:[{type:"require",msg:"Excel文件不能为空!"}]});
  38. if(!rs)return;
  39. var mess = "确定要导入吗?";
  40. top.$.ligerDialog.confirm(mess, function (yes){
  41. if(yes){
  42. top.importWaitDlg = top.$.ligerDialog.waitting('正在导入中,请稍候...');
  43. $("#excelForm").submit();
  44. }}
  45. );
  46. }
  47. function showErrorDiv(){
  48. top.$.ligerDialog.open({ title:"数据验证不通过",height: 200, target : errorDiv , width: 400, slide: false, buttons: [ { text: '确定', onclick: function (item, dialog) { dialog.hidden(); } } ] });
  49. }
  50. function showInfoDiv(){
  51. top.$.ligerDialog.open({ title:"数据导入成功",height: 200, target : infoDiv , width: 400, slide: false, buttons: [ { text: '确定', onclick: function (item, dialog) { dialog.hidden(); } } ] });
  52. }
  53. </script>
  54. </HEAD>
  55. <BODY>
  56. <%@ include file="/include/message.jsp"%>
  57. <div class="l-content">
  58. <FORM method='POST' name="excelForm" id="excelForm" action="mtInitStockAction.do?task=excelImport&subTask=import&type=${type }" enctype="multipart/form-data">
  59. <div class="forum-container">
  60. <center>
  61. <Table border="0" cellspacing="1" cellpadding="0" class="l-table-edit line">
  62. <tr>
  63. <td width="25%"><b>Excel文件</b><FONT COLOR="red">*</FONT>:</td>
  64. <td width="55%"><input type="file" name="files" id="files" /></td>
  65. <%--<td class="l-table-edit-td"><input type="button" onclick="submitExcelForm('supplier')" class="l-button" value="导入" /></td> --%>
  66. <td ><a href="${pageContext.request.contextPath}/yw/erp/import/moban/${type }.xls" >下载模版</a> </td>
  67. </tr>
  68. </TABLE>
  69. </center>
  70. </div>
  71. </FORM>
  72. </div>
  73. <div id="errorDiv" style="display: none;">
  74. <div style="color: red;margin:10px 0 10px 0 ">总共有${fn:length(errList)}条数据有问题,请修复后重新导入:</div>
  75. <c:forEach items="${errList}" var="err">
  76. <div style="color: red;">${err}</div>
  77. </c:forEach>
  78. </div>
  79. <div id="infoDiv" style="display: none;">
  80. <c:forEach items="${infoList}" var="info">
  81. <div style="color: green;">${info}</div>
  82. </c:forEach>
  83. </div>
  84. </BODY>
  85. </HTML>