纽威
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.

182 lines
5.0 KiB

3 years ago
3 years ago
3 years ago
3 years ago
  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 #99D3F5;
  25. border-radius: 4px;
  26. color: #fff;
  27. background-color: #1ABC9C;
  28. border-color: #1ABC9C;
  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 class="formValue" colspan="2">
  56. <div class="btn-group" style="width:35px">
  57. <label>年份:</label>
  58. </div>
  59. <div class="btn-group">
  60. <input type="text" name="txt_Year" id="txt_Year" class="form-control" style="width:70px" />
  61. </div>
  62. </td>
  63. <td>
  64. <label id="showFileName"></label>
  65. </td>
  66. </tr>
  67. <tr>
  68. <td class="formValue" style="width:125px">
  69. <div id="u-file-c" class="u-file-btn">
  70. <input type="file" class="u-file-btn-input" name="files" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" style="width:350px" />选择上传文件
  71. </div>
  72. </td>
  73. <td class="formValue">
  74. <a style=" width 79px" class="btn btn-primary dropdown-text" onclick="Upload()"> 导入数据 </a>
  75. </td>
  76. </tr>
  77. <tr>
  78. <td class="formValue">
  79. <label class="radio-inline">
  80. <input type="text" name="UPLoadType" id="UPLoadType" class="form-control" value="NCR数量" style="display:none;visibility:hidden" />
  81. </label>
  82. </td>
  83. </tr>
  84. </table>
  85. </div>
  86. </form>
  87. <script>
  88. $(".u-file-btn").on("change", "input[type='file']", function () {
  89. var filePath = $(this).val();
  90. if (filePath.indexOf("xls") != -1 || filePath.indexOf("xlsx") != -1) {
  91. var arr = filePath.split('\\');
  92. var fileName = arr[arr.length - 1];
  93. document.getElementById("showFileName").innerText = fileName;
  94. } else {
  95. document.getElementById("showFileName").innerText = "";
  96. alert("您未上传文件,或者您上传文件类型有误!");
  97. return false
  98. }
  99. })
  100. $(function () {
  101. var day = new Date();
  102. day.setTime(day.getTime());
  103. var Year = day.getFullYear();
  104. document.getElementById("txt_Year").value = Year;
  105. });
  106. function Upload()
  107. {
  108. var form = new FormData(document.getElementById("form1"));
  109. $.ajax({
  110. url: "/WMS/HomeWork/UploadFile?" + Math.random(),
  111. type: "post",
  112. data: form,
  113. contentType: false,
  114. processData: false,
  115. success: function (data) {
  116. if (data == "true" || data == true) {
  117. //alert("上传成功");
  118. //layer.msg("上传成功");
  119. $.modalAlertNew("WMS00014");
  120. window.setTimeout(function () {
  121. $.modalClose();
  122. }, 2500);
  123. $.currentWindow().$("#gridList").trigger("reloadGrid");
  124. }
  125. else {
  126. //alert("上传失败:" + data);
  127. $.modalAlertNew("WMS00016", data);
  128. }
  129. },
  130. error: function (aa) {
  131. $.modalAlertNew("WMS00016", aa);
  132. }
  133. });
  134. }
  135. </script>