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.

254 lines
9.7 KiB

1 month ago
  1. 
  2. @{
  3. ViewBag.Title = "Index";
  4. Layout = "~/Views/Shared/_Index.cshtml";
  5. }
  6. <script>
  7. var STNO = $.request("STNO");
  8. var WorkPoint = $.request("WorkPoint");
  9. var Type = $.request("Type");
  10. $(function () {
  11. if (Type=='1') {
  12. gridList();
  13. } else {
  14. gridList2();
  15. }
  16. })
  17. function gridList() {
  18. document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> <div id="gridPager"></div> ';//重置grid
  19. var $gridList = $("#gridList");
  20. var queryJson = {
  21. }
  22. $gridList.dataGrid({
  23. url: "/SRM/ASNManage/GetGridJsonUpload" + "?" + Math.random() + "&WorkPoint=" + WorkPoint + "&STNO=" + STNO,
  24. postData: { queryJson: JSON.stringify(queryJson) },
  25. height: $(window).height() - 200,
  26. width: $(window).width() - 180,
  27. colModel: [
  28. { label: "主键", name: "ID", hidden: true, key: true },
  29. { label: '物料编码', name: 'InvCode', width: 200, align: 'left' },
  30. { label: '物料名称', name: 'InvName', width: 200, align: 'left' },
  31. { label: '批次', name: 'BatchCode', width: 150, align: 'left' },
  32. { label: '批次数量', name: 'BatchCodeNum', width: 150, align: 'left' },
  33. { label: '供应商编码', name: 'VenCode', width: 150, align: 'left' },
  34. { label: '供应商名称', name: 'VenName', width: 150, align: 'left' },
  35. {
  36. label: '出货报告', name: 'FileName', width: 150, align: 'left',
  37. formatter: function (cellvalue, options, rowObject) {
  38. var html = "";
  39. if (cellvalue != "" && cellvalue != null) {
  40. html = " <a href='../../../File/VendorFile/" + rowObject.VenCode + "/" + STNO + rowObject.InvCode + rowObject.BatchCode + "/" + cellvalue + "' download='" + cellvalue + "' style='color:blue;'>" + cellvalue + "</a>";
  41. }
  42. return html;
  43. }
  44. },
  45. { label: '上传时间', name: 'CerateTime', width: 150, align: 'left' },
  46. ],
  47. shrinkToFit: true,//宽度自适应
  48. gridComplete: function () {
  49. },
  50. pager: "#gridPager",
  51. sortorder: "desc",
  52. sortname: 'CerateTime ',
  53. viewrecords: true,
  54. multiselect: true,
  55. });
  56. $("#warehouse a.btn-default").click(function () {
  57. $("#warehouse a.btn-default").removeClass("active");
  58. $(this).addClass("active");
  59. $('#btn_search').trigger("click");
  60. });
  61. $("#btn_search").click(function () {
  62. var warehouse = $("#warehouse a.active").attr('data-value');
  63. var queryJson = {
  64. }
  65. $gridList.jqGrid('setGridParam', {
  66. postData: { queryJson: JSON.stringify(queryJson) },
  67. page: 1
  68. }).trigger('reloadGrid');
  69. });
  70. }
  71. function gridList2() {
  72. document.getElementById("gridPanel").innerHTML = ' <table id="gridList"></table> <div id="gridPager"></div> ';//重置grid
  73. var $gridList = $("#gridList");
  74. var queryJson = {
  75. }
  76. $gridList.dataGrid({
  77. url: "/SRM/ASNManage/GetGridJsonUpload2" + "?" + Math.random() + "&WorkPoint=" + WorkPoint + "&STNO=" + STNO,
  78. postData: { queryJson: JSON.stringify(queryJson) },
  79. height: $(window).height() - 200,
  80. width: $(window).width() - 180,
  81. colModel: [
  82. { label: "主键", name: "ID", hidden: true, key: true },
  83. { label: '物料编码', name: 'InvCode', width: 200, align: 'left' },
  84. { label: '物料名称', name: 'InvName', width: 200, align: 'left' },
  85. { label: '批次', name: 'BatchCode', width: 150, align: 'left' },
  86. { label: '批次数量', name: 'BatchCodeNum', width: 150, align: 'left' },
  87. { label: '供应商编码', name: 'VenCode', width: 150, align: 'left' },
  88. { label: '供应商名称', name: 'VenName', width: 150, align: 'left' },
  89. {
  90. label: '出货报告', name: 'FileName', width: 150, align: 'left',
  91. formatter: function (cellvalue, options, rowObject) {
  92. var html = "";
  93. if (cellvalue != "" && cellvalue != null) {
  94. html = " <a href='../../../File/VendorFile/" + rowObject.VenCode + "/" + STNO + rowObject.InvCode + rowObject.BatchCode + "/" + cellvalue + "' download='" + cellvalue + "' style='color:blue;'>" + cellvalue + "</a>";
  95. }
  96. return html;
  97. }
  98. },
  99. { label: '上传时间', name: 'CerateTime', width: 150, align: 'left' },
  100. ],
  101. shrinkToFit: true,//宽度自适应
  102. gridComplete: function () {
  103. },
  104. pager: "#gridPager",
  105. sortorder: "desc",
  106. sortname: 'CerateTime ',
  107. viewrecords: true,
  108. multiselect: true,
  109. });
  110. $("#warehouse a.btn-default").click(function () {
  111. $("#warehouse a.btn-default").removeClass("active");
  112. $(this).addClass("active");
  113. $('#btn_search').trigger("click");
  114. });
  115. $("#btn_search").click(function () {
  116. var warehouse = $("#warehouse a.active").attr('data-value');
  117. var queryJson = {
  118. }
  119. $gridList.jqGrid('setGridParam', {
  120. postData: { queryJson: JSON.stringify(queryJson) },
  121. page: 1
  122. }).trigger('reloadGrid');
  123. });
  124. }
  125. function Close() {
  126. $.modalClose();
  127. }
  128. function reloadData() {
  129. }
  130. function UpLoadFiles(STNO) {
  131. $("#FileUp").click();
  132. }
  133. function UpLoadFile(fileinfo) {
  134. debugger;
  135. var InvCode;
  136. var InvName;
  137. var BatchCode;
  138. var VenCode;
  139. var BatchCodeNum;
  140. var innerhtml = '';
  141. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  142. if (ids.length != 1) {
  143. $.modalAlert("请选择一行数据进行上传!");
  144. return;
  145. }
  146. for (var i in ids) {
  147. var rowData = jQuery("#gridList").jqGrid("getRowData", ids[i]);
  148. InvCode = rowData.InvCode;
  149. InvName = rowData.InvName;
  150. BatchCode = rowData.BatchCode;
  151. VenCode = rowData.VenCode;
  152. BatchCodeNum = rowData.BatchCodeNum;
  153. }
  154. var UserCode = '@NFine.Code.OperatorProvider.Provider.GetCurrent().UserCode'
  155. var files = fileinfo.files;
  156. var fileName = "";
  157. for (var i = 0; i < files.length; i++) {
  158. var regex = /\s/;
  159. if (regex.test(files[i].name)) {
  160. $.modalAlert("文件名:<span style='color: red;'>" + files[i].name + "</span>,包含空格,上传失败,请修改后重新上传!", "warning");
  161. var file = document.getElementById('FileUp');
  162. file.value = "";
  163. return false;
  164. }
  165. fileName += "" + files[i].name + ";";
  166. if (fileName != null && fileName != "") {
  167. var data = new FormData();
  168. jQuery.each(jQuery('#FileUp')[0].files, function (i, file) {
  169. data.append('file-' + i, file);
  170. });
  171. $.ajax({
  172. url: "/SRM/ASNManage/UpLoadFile?STNO=" + STNO + "&InvCode=" + InvCode + "&BatchCodeNum=" + BatchCodeNum + "&BatchCode=" + BatchCode + "&VenCode=" + VenCode + "&Type=" + Type + "&" + Math.random(),
  173. type: "post",
  174. data: data,
  175. dataType: "json",
  176. contentType: false,
  177. processData: false,
  178. success: function (data) {
  179. debugger;
  180. if (data.state == "success") {
  181. if (Type == '1') {
  182. gridList();
  183. } else {
  184. gridList2();
  185. }
  186. $.modalMsg(data.message, data.state);
  187. //$("#fileName").val(fileName);
  188. }
  189. else {
  190. $.modalAlert("异常:" + data.message, data.state);
  191. }
  192. }
  193. });
  194. }
  195. }
  196. document.getElementById("FileUp").value = "";
  197. }
  198. </script>
  199. <form id="form1">
  200. <div class="topPanel">
  201. <div class="toolbar">
  202. <div class="btn-group">
  203. <input id='FileUp' type='file' style="display: none" onchange="UpLoadFile(this)" multiple="multiple" />
  204. <a id="btn_FileUp" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="UpLoadFiles(this)"><i class="fa fa-pencil-square-o"></i>上传出货报告</a>
  205. </div>
  206. </div>
  207. @*<div class="search">
  208. <table>
  209. <tr>
  210. <td>
  211. <span class="input-group-btn">
  212. <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
  213. </span>
  214. </td>
  215. </tr>
  216. </table>
  217. </div>*@
  218. </div>
  219. <div class="gridPanel" id="gridPanel">
  220. <table id="gridList"></table>
  221. <div id="gridPager"></div>
  222. </div>
  223. </form>