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

325 lines
13 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <script>
  6. debugger;
  7. //var Type = $.request("Type");
  8. var ColModelMain = [];
  9. var ColModelSub = [];
  10. var _Clos = new Array();
  11. $(function () {
  12. SetCols();
  13. gridList();
  14. })
  15. function SetCols() {
  16. $.ajax({
  17. url: "/Print/SelectColumnName?" + Math.random(),
  18. dataType: "json",
  19. async: false,
  20. success: function (data) {
  21. var cols = new Array();
  22. var collast = { label: "主键", name: "ID", hidden: true, frozen: true };
  23. cols.push(collast);
  24. var collast = {
  25. label: "类型", name: "DABDOCType", width: 60, align: "left",
  26. formatter: function (cellvalue) {
  27. if (cellvalue == "1") {
  28. return "套件";
  29. } else if (cellvalue == "2") {
  30. return "散件";
  31. }
  32. else { return ""; }
  33. }
  34. };
  35. cols.push(collast);
  36. var collast = { label: '拆卸单号', name: 'Code', width: 120, align: 'left' };
  37. cols.push(collast);
  38. var collast = { label: '数量', name: 'Qty', width: 150, align: 'left' };
  39. cols.push(collast);
  40. var collast = { label: '料品编码', name: 'InvCode', width: 150, align: 'left' };
  41. cols.push(collast);
  42. var collast = { label: '料品名称', name: 'InvName', width: 100, align: 'left' };
  43. cols.push(collast);
  44. var collast = { label: '仓库代码', name: 'WHCode', width: 100, align: 'left' };
  45. cols.push(collast);
  46. var collast = { label: '是否选择', name: 'isInput', width: 150, align: 'left' };
  47. cols.push(collast);
  48. var collast = { label: '是否生成', name: 'isCreate', width: 150, align: 'left' };
  49. cols.push(collast);
  50. if (data != null && data.length > 0) {
  51. DateList = data;
  52. for (var i = 0; i < data.length; i++) {
  53. var ColName = data[i].ColName;
  54. var ColCode = data[i].ColCode;
  55. var obj = new Array();
  56. obj = {
  57. label: ColName,
  58. name: ColCode,
  59. width: 80,
  60. align: "left"
  61. }
  62. cols.push(obj);
  63. }
  64. }
  65. _Clos = cols;
  66. }
  67. });
  68. }
  69. function gridList() {
  70. var $gridList = $("#gridList");
  71. var queryJson = {
  72. DABDOCCode: $("#txt_DABDOCCode").val(),
  73. }
  74. $gridList.dataGrid({
  75. url: "/WMS/ICSDisassemblyDoc/GetGridJson" + "?" + Math.random(),
  76. postData: { queryJson: JSON.stringify(queryJson) },
  77. height: $(window).height() - 200,
  78. width: $(window).width() - 300,
  79. colModel: _Clos,
  80. //colModel: [
  81. // { label: "主键", name: "ID", hidden: true, key: true },
  82. // {
  83. // label: "类型", name: "DABDOCType", width: 60, align: "left",
  84. // formatter: function (cellvalue) {
  85. // if (cellvalue == "1") {
  86. // return "套件";
  87. // } else if (cellvalue == "2") {
  88. // return "散件";
  89. // }
  90. // else { return ""; }
  91. // }
  92. // },
  93. // { label: '拆卸单号', name: 'Code', width: 120, align: 'left' },
  94. // { label: '数量', name: 'Qty', width: 150, align: 'left' },
  95. // { label: '料品编码', name: 'InvCode', width: 150, align: 'left' },
  96. // { label: '料品名称', name: 'InvName', width: 100, align: 'left' },
  97. // { label: '仓库代码', name: 'WHCode', width: 100, align: 'left' },
  98. // { label: '批次', name: 'BatchCode', width: 150, align: 'left' },
  99. // { label: '是否选择', name: 'isInput', width: 150, align: 'left' },
  100. // { label: '是否生成', name: 'isCreate', width: 150, align: 'left' },
  101. //],
  102. width: "100%",
  103. autowidth: true,
  104. gridComplete: function () {
  105. },
  106. pager: "#gridPager",
  107. sortname: 'Code',
  108. sortorder: "desc",
  109. viewrecords: true,
  110. multiselect: true,
  111. beforeSelectRow: function (rowid, e) {
  112. $("#gridList").jqGrid('resetSelection');
  113. return (true);
  114. },
  115. subGrid: true, // (1)开启子表格支持
  116. subGridRowExpanded: function (subgrid_id, rowid) { // (2)子表格容器的id和需要展开子表格的行id,将传入此事件函数
  117. $("#gridList").jqGrid("setSelection", rowid, false);
  118. bindSubGrid(subgrid_id, rowid)
  119. }
  120. });
  121. $("#warehouse a.btn-default").click(function () {
  122. $("#warehouse a.btn-default").removeClass("active");
  123. $(this).addClass("active");
  124. $('#btn_search').trigger("click");
  125. });
  126. $("#btn_search").click(function () {
  127. var warehouse = $("#warehouse a.active").attr('data-value');
  128. var queryJson = {
  129. DABDOCCode: $("#txt_DABDOCCode").val(),
  130. }
  131. $gridList.jqGrid('setGridParam', {
  132. postData: { queryJson: JSON.stringify(queryJson) },
  133. }).trigger('reloadGrid');
  134. });
  135. }
  136. function bindSubGrid(subgrid_id, rowid) {
  137. debugger;
  138. $("#gridList").jqGrid("setSelection", rowid, false);
  139. var subgrid_table_id;
  140. subgrid_table_id = subgrid_id + "_t"; // (3)根据subgrid_id定义对应的子表格的table的id
  141. var subgrid_pager_id;
  142. subgrid_pager_id = subgrid_id + "_pgr" // (4)根据subgrid_id定义对应的子表格的pager的id
  143. // (5)动态添加子报表的table和pager
  144. $("#" + subgrid_id).html("<table id='" + subgrid_table_id + "' class='scroll'></table><div id='" + subgrid_pager_id + "' class='scroll'></div>");
  145. var Code = $("#gridList").jqGrid('getRowData', rowid).Code;
  146. //var Sequence = $("#gridList").jqGrid('getRowData', rowid).Sequence;
  147. // (6)创建jqGrid对象
  148. $("#" + subgrid_table_id).dataGrid({
  149. cellEdit: true,
  150. url: "/WMS/ICSDisassemblyDoc/GetSubGridJson?Code=" + Code + "&" + Math.random(), // (7)子表格数据对应的url,注意传入的contact.id参数
  151. colModel: [
  152. { label: '行号', name: 'Sequence', width: 120, align: 'left' },
  153. {
  154. label: "类型", name: "DABDOCType", width: 60, align: "left",
  155. formatter: function (cellvalue) {
  156. if (cellvalue == "1") {
  157. return "套件";
  158. } else if (cellvalue == "2") {
  159. return "散件";
  160. }
  161. else { return ""; }
  162. }
  163. },
  164. { label: '拆卸单号', name: 'Code', width: 120, align: 'left' },
  165. { label: '数量', name: 'Qty', width: 150, align: 'left' },
  166. { label: '料品编码', name: 'InvCode', width: 150, align: 'left' },
  167. { label: '料品名称', name: 'InvName', width: 100, align: 'left' },
  168. { label: '仓库代码', name: 'WHCode', width: 100, align: 'left' },
  169. { label: '批次', name: 'BatchCode', width: 150, align: 'left' },
  170. { label: '条码', name: 'LotNo', width: 150, align: 'left' },
  171. ],
  172. //colModel: ColModelSub,
  173. shrinkToFit: true,//宽度自适应
  174. multiselect: true,
  175. prmNames: { search: "search" },
  176. viewrecords: true,
  177. height: "100%",
  178. rowNum: 20,
  179. pager: subgrid_pager_id,
  180. });
  181. }
  182. function btnkit() {
  183. debugger;
  184. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  185. if (ids.length == 0) {
  186. $.modalAlert("请选择数据!");
  187. return;
  188. }
  189. for (var i = 0; i < ids.length; i++) {
  190. var rowData = $("#gridList").jqGrid('getRowData', ids[i]);
  191. var Code = rowData.Code;//单据号
  192. var InvCode = rowData.InvCode;//料品编码
  193. var InvName = rowData.InvName;//料品名称
  194. var WHCode = rowData.WHCode;//仓库代码
  195. var BatchCode = rowData.BatchCode;//仓库代码
  196. var Qty = rowData.Qty//数量
  197. var isInput = rowData.isInput//是否选择
  198. if (isInput == "已选") {
  199. $.modalAlert("该套件已选择!");
  200. return;
  201. }
  202. }
  203. $.modalOpen({
  204. id: "ICSDisassemblyDocAdd",
  205. title: "选择套件",
  206. url: "/WMS/ICSDisassemblyDoc/ICSDisassemblyDocAdd?Code=" + Code + "&InvName=" + encodeURI(encodeURI(InvName)) + "&WHCode=" + WHCode + "&BatchCode=" + BatchCode + "&InvCode=" + InvCode + "&Qty=" + Qty + "&" + Math.random(),
  207. width: "1200px",
  208. height: "1150px",
  209. callBack: function (iframeId) {
  210. top.frames[iframeId].submitForm();
  211. }
  212. });
  213. }
  214. //批量生成条码
  215. function btnGenerate() {
  216. debugger;
  217. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  218. if (ids.length == 0) {
  219. $.modalAlert("请选择数据!");
  220. return;
  221. }
  222. for (var i = 0; i < ids.length; i++) {
  223. var rowData = $("#gridList").jqGrid('getRowData', ids[i]);
  224. var Code = rowData.Code;
  225. var isInput = rowData.isInput;
  226. var isCreate = rowData.isCreate;
  227. if (isInput == '未选') {
  228. $.modalAlert("请先选择套件!");
  229. return;
  230. }
  231. if (isCreate == '已生成') {
  232. $.modalAlert("该单据已生成过条码!");
  233. return;
  234. }
  235. }
  236. $.modalConfirm("是否批量生成条码?", function (r) {
  237. if (r) {
  238. $.submitForm({
  239. url: "/WMS/ICSDisassemblyDoc/CreateInventoryLot?Code=" + Code + "&" + Math.random(),
  240. success: function () {
  241. $.currentWindow().$("#gridList").trigger("reloadGrid");
  242. }
  243. })
  244. }
  245. });
  246. }
  247. function btnDeleteLot() {
  248. var ids = $("#gridList").jqGrid('getGridParam', 'selarrrow'); //获取 多行数据
  249. if (ids.length == 0) {
  250. $.modalAlert("请选择数据!");
  251. return;
  252. }
  253. for (var i = 0; i < ids.length; i++) {
  254. var rowData = $("#gridList").jqGrid('getRowData', ids[i]);
  255. var Code = rowData.Code;
  256. }
  257. $.modalConfirm("是否批量删除条码?", function (r) {
  258. if (r) {
  259. $.submitForm({
  260. url: "/WMS/ICSDisassemblyDoc/DeleteInventoryLot?Code=" + Code + "&" + Math.random(),
  261. success: function () {
  262. $.currentWindow().$("#gridList").trigger("reloadGrid");
  263. }
  264. })
  265. }
  266. });
  267. }
  268. </script>
  269. <div class="topPanel" style="height:60px;">
  270. <div class="toolbar">
  271. <div class="btn-group">
  272. <a id="NF-kit" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btnkit()"><i class="fa fa-pencil-square-o"></i>绑定套件</a>
  273. <a id="NF-Generate" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btnGenerate()"><i class="fa fa-pencil-square-o"></i>批量生成条码</a>
  274. <a id="NF-DeleteLot" authorize="yes" style="margin-left:3px;" class="btn btn-primary" onclick="btnDeleteLot()"><i class="fa fa-pencil-square-o"></i>删除条码</a>
  275. <a class="btn btn-primary" onclick="$.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
  276. </div>
  277. <script>$('.toolbar').authorizeButton()</script>
  278. </div>
  279. <div class="search">
  280. <table>
  281. <tr>
  282. <td style="text-align:right;"><label class="lglabel" for="txt_DABDOCCode">单据号</label>:</td>
  283. <td>
  284. <div class="input-group">
  285. <input id="txt_DABDOCCode" type="text" class="form-control" style="width: 100px;">
  286. </div>
  287. </td>
  288. <td>
  289. <span class="input-group-btn">
  290. <button id="btn_search" type="button" class="btn btn-primary"><i class="fa fa-search"></i></button>
  291. </span>
  292. </td>
  293. </tr>
  294. </table>
  295. </div>
  296. </div>
  297. <div class="gridPanel">
  298. <table id="gridList"></table>
  299. <div id="gridPager"></div>
  300. </div>