importExcel.jsp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 if(result == "-3"){
  29. top.$.ligerDialog.open({ title:"系统中没有定义计量单位准项",height: 200, target : errorDiv , width: 400, slide: false, buttons: [ { text: '确定', onclick: function (item, dialog) { dialog.hidden(); } } ] });
  30. }else if(result == "-4"){
  31. top.$.ligerDialog.open({ title:"系统中计量单位标准项重复",height: 200, target : errorDiv , width: 400, slide: false, buttons: [ { text: '确定', onclick: function (item, dialog) { dialog.hidden(); } } ] });
  32. }else{
  33. top.$.ligerDialog.success('成功导入'+result+'条数据!');
  34. }
  35. <c:if test="${fn:length(infoList) gt 0}">
  36. showInfoDiv();
  37. </c:if>
  38. </c:if>
  39. });
  40. function importExcel(operner){
  41. var rs = $.validate({name:"files",model:[{type:"require",msg:"Excel文件不能为空!"}]});
  42. if(!rs)return;
  43. var mess = "确定要导入吗?";
  44. top.$.ligerDialog.confirm(mess, function (yes){
  45. if(yes){
  46. top.importWaitDlg = top.$.ligerDialog.waitting('正在导入中,请稍候...');
  47. $("#excelForm").submit();
  48. }}
  49. );
  50. }
  51. function showErrorDiv(){
  52. top.$.ligerDialog.open({ title:"数据验证不通过",height: 200, target : errorDiv , width: 400, slide: false, buttons: [ { text: '确定', onclick: function (item, dialog) { dialog.hidden(); } } ] });
  53. }
  54. function showInfoDiv(){
  55. top.$.ligerDialog.open({ title:"数据导入成功",height: 200, target : infoDiv , width: 400, slide: false, buttons: [ { text: '确定', onclick: function (item, dialog) { dialog.hidden(); } } ] });
  56. }
  57. </script>
  58. </HEAD>
  59. <BODY>
  60. <%@ include file="/include/message.jsp"%>
  61. <div class="l-content">
  62. <FORM method='POST' name="excelForm" id="excelForm" action="initStockAction.do?task=excelImport&subTask=import&type=${type }" enctype="multipart/form-data">
  63. <div class="forum-container">
  64. <center>
  65. <Table border="0" cellspacing="1" cellpadding="0" class="l-table-edit line">
  66. <tr>
  67. <td width="25%"><b>Excel文件</b><FONT COLOR="red">*</FONT>:</td>
  68. <td width="55%"><input type="file" name="files" id="files" /></td>
  69. <%--<td class="l-table-edit-td"><input type="button" onclick="submitExcelForm('supplier')" class="l-button" value="导入" /></td> --%>
  70. <td ><a href="${pageContext.request.contextPath}/yw/erp/import/moban/${type }.xls" >下载模版</a> </td>
  71. </tr>
  72. </TABLE>
  73. </center>
  74. </div>
  75. </FORM>
  76. </div>
  77. <div id="errorDiv" style="display: none;">
  78. <div style="color: red;margin:10px 0 10px 0 ">总共有${fn:length(errList)}条数据有问题,请修复后重新导入:</div>
  79. <c:forEach items="${errList}" var="err">
  80. <div style="color: red;">${err}</div>
  81. </c:forEach>
  82. </div>
  83. <div id="infoDiv" style="display: none;">
  84. <c:forEach items="${infoList}" var="info">
  85. <div style="color: green;">${info}</div>
  86. </c:forEach>
  87. </div>
  88. </BODY>
  89. </HTML>