You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

162 lines
4.5 KiB

  1. @{
  2. ViewBag.Title = "Form";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <link href="~/Content/css/bootstrap/bootstrap-select.css" rel="stylesheet" />
  6. <link href="~/Content/css/toastr.min.css" rel="stylesheet" />
  7. <script src="~/Content/js/datepicker/WdatePicker.js"></script>
  8. <script src="~/Content/js/bootstrap/bootstrap-select.min.js"></script>
  9. <script src="~/Content/js/toastr.min.js"></script>
  10. <script src="~/Content/js/parseForm.js"></script>
  11. <style>
  12. .u-file-btn {
  13. position: relative;
  14. direction: ltr;
  15. height: 23px;
  16. overflow: hidden;
  17. line-height: 23px;
  18. margin-right: 10px;
  19. padding: 3px 0;
  20. text-align: center;
  21. width: 105px;
  22. color: black;
  23. background: #D0EEFF;
  24. border: 1px solid #1281c1;
  25. border-radius: 4px;
  26. color: #fff;
  27. background-color: #1281c1;
  28. border-color: #1281c1;
  29. }
  30. .u-file-btn-input {
  31. cursor: pointer;
  32. text-align: right;
  33. z-index: 10;
  34. font-size: 118px; /* font-size: 118px 工作正常 */
  35. position: absolute;
  36. top: 0px;
  37. right: 0px;
  38. opacity: 0;
  39. filter: Alpha(opacity:0);
  40. }
  41. </style>
  42. <script type="text/javascript">
  43. toastr.options.positionClass = 'toast-center-center';
  44. </script>
  45. <form id="form1">
  46. <div style="padding-top: 20px; ">
  47. <table class="form" style="text-align:left">
  48. <tr>
  49. <td class="formValue" colspan="2">
  50. <img src="~/Content/img/Excel.png" style="width:22px;height:22px" />
  51. <a href="~/ReportFile/工单条码导入模板.xlsx" style="color:darkblue; ">原条码导入模板 </a>&nbsp;&nbsp;(支持"xls","xlsx"格式)
  52. </td>
  53. </tr>
  54. <tr>
  55. <td>
  56. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  57. <label id="showFileName"></label>
  58. </td>
  59. </tr>
  60. <tr>
  61. <td class="formValue" style="width:125px">
  62. <div id="u-file-c" class="u-file-btn">
  63. <input id="FileUp" type="file" class="u-file-btn-input" name="files" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" style="width:350px" />选择上传文件
  64. </div>
  65. </td>
  66. <td class="formValue">
  67. <a id="NF-ExportCurrentStock" authorize="yes" class="btn btn-primary dropdown-text" onclick="Upload()"><i class="fa fa-download"></i>导入数据</a>
  68. </td>
  69. </tr>
  70. </table>
  71. </div>
  72. </form>
  73. <script>
  74. $(".u-file-btn").on("change", "input[type='file']", function () {
  75. var filePath = $(this).val();
  76. if (filePath.indexOf("xls") != -1 || filePath.indexOf("xlsx") != -1) {
  77. var arr = filePath.split('\\');
  78. var fileName = arr[arr.length - 1];
  79. document.getElementById("showFileName").innerText = fileName;
  80. } else {
  81. document.getElementById("showFileName").innerText = "";
  82. alert("您未上传文件,或者您上传文件类型有误!");
  83. return false
  84. }
  85. })
  86. $(function () {
  87. //var day = new Date();
  88. //day.setTime(day.getTime());
  89. //var Year = day.getFullYear();
  90. //document.getElementById("txt_Year").value = Year;
  91. });
  92. function Upload()
  93. {
  94. var form = new FormData(document.getElementById("form1"));
  95. $.ajax({
  96. url: "/WMS/WMSCreateItemLot/UploadFile?" + Math.random(),
  97. type: "post",
  98. data: form,
  99. contentType: false,
  100. processData: false,
  101. success: function (data) {
  102. if (data == "true" || data == true) {
  103. //alert("上传成功");
  104. //layer.msg("上传成功");
  105. $.modalAlertNew("WMS00014");
  106. window.setTimeout(function () {
  107. $.modalClose();
  108. }, 2500);
  109. $.currentWindow().$("#gridList").trigger("reloadGrid");
  110. }
  111. else {
  112. //alert("上传失败:" + data);
  113. $.modalAlertNew("WMS00016", data);
  114. }
  115. },
  116. error: function (aa) {
  117. $.modalAlertNew("WMS00016", aa);
  118. }
  119. });
  120. document.getElementById("FileUp").value = "";
  121. }
  122. </script>