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.

195 lines
8.3 KiB

  1. @{
  2. ViewBag.Title = "Index";
  3. Layout = "~/Views/Shared/_Index.cshtml";
  4. }
  5. <link href="~/Content/js/select2/select2.min.css" rel="stylesheet" />
  6. <script src="~/Content/js/select2/select2.min.js"></script>
  7. <script>
  8. var InvCode = decodeURI($.request("InvCode"));
  9. var JYID = decodeURI($.request("JYID"));
  10. var SampleQuantity = $.request("SampleQuantity");
  11. var ResultINp = decodeURI($.request("Result"));
  12. $(function () {
  13. debugger;
  14. gridList();
  15. })
  16. function gridList() {
  17. debugger;
  18. var $gridList = $("#gridList");
  19. if (ResultINp == "") {
  20. $gridList.dataGrid({
  21. url: "/WMS/ICSRCVIQCs/GetInventoryInspection?InvCode=" + InvCode + "&" + Math.random() + "&SampleQuantity=" + SampleQuantity + "&ResultINp=" + ResultINp,
  22. height: $(window).height() - 50,
  23. width: $(window).height() - 200,
  24. cellEdit: true,
  25. colModel: [
  26. { label: "主键", name: "ID", hidden: true, key: true },
  27. { label: '检验ID', name: 'InspectionID', hidden: true },
  28. { label: "抽样次数", name: "NUM", width: 100, align: 'left' },
  29. { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' },
  30. { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' },
  31. { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' },
  32. { label: "检验项目名称", name: "ListName", width: 100, align: 'left' },
  33. { label: "单位", name: "Unit", width: 100, align: 'left' },
  34. { label: '标准上限', name: 'SetValueMax', width: 80, align: 'left' },
  35. { label: '标准下限', name: 'SetValueMin', width: 80, align: 'left' },
  36. { label: '实际值', name: 'SetValue', width: 150, align: 'left', editable: true, editrules: { number: true } },
  37. { label: '是否合格', name: 'Result', width: 80, align: 'left' },
  38. ],
  39. //pager: "#gridPager",
  40. cellsubmit: "clientArray",
  41. //sortname: 'ListCode',
  42. viewrecords: true,
  43. rowNum: 200,
  44. afterSaveCell: function (rowid, cellname, value) {
  45. debugger;
  46. //总扣分数加其他扣分数
  47. if (cellname === 'SetValue') {
  48. Price = Number(value);
  49. if (Price < 0) {
  50. $.modalAlert("请输入大于0的单价!");
  51. return;
  52. }
  53. SetValueMax = Number($gridList.jqGrid("getCell", rowid, 'SetValueMax'));
  54. SetValueMin = Number($gridList.jqGrid("getCell", rowid, 'SetValueMin'));
  55. SumSetValue = SetValueMax + SetValueMin
  56. if (Price != 0) {
  57. if (Price > SumSetValue) {
  58. $("#gridList").jqGrid('setCell', rowid, "Result", "不合格");
  59. } else {
  60. $("#gridList").jqGrid('setCell', rowid, "Result", "合格");
  61. }
  62. }
  63. }
  64. }
  65. });
  66. } else {
  67. $gridList.dataGrid({
  68. url: "/WMS/ICSRCVIQCs/GetInventoryInspection?InvCode=" + InvCode + "&" + Math.random() + "&SampleQuantity=" + SampleQuantity + "&ResultINp=" + ResultINp,
  69. height: $(window).height() - 50,
  70. width: $(window).height() - 200,
  71. cellEdit: true,
  72. colModel: [
  73. { label: "主键", name: "ID", hidden: true, key: true },
  74. { label: '检验ID', name: 'InspectionID', hidden: true },
  75. { label: "抽样次数", name: "NUM", width: 100, align: 'left' },
  76. { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' },
  77. { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' },
  78. { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' },
  79. { label: "检验项目名称", name: "ListName", width: 100, align: 'left' },
  80. { label: "单位", name: "Unit", width: 100, align: 'left' },
  81. { label: '标准上限', name: 'SetValueMax', width: 80, align: 'left' },
  82. { label: '标准下限', name: 'SetValueMin', width: 80, align: 'left' },
  83. { label: '实际值', name: 'SetValue', width: 150, align: 'left', editable: true, editrules: { number: true } },
  84. { label: '是否合格', name: 'Result', width: 80, align: 'left' },
  85. ],
  86. //pager: "#gridPager",
  87. cellsubmit: "clientArray",
  88. sortname: 'NUM,GroupCode',
  89. sortorder: "asc",
  90. viewrecords: true,
  91. rowNum: 200,
  92. afterSaveCell: function (rowid, cellname, value) {
  93. debugger;
  94. //总扣分数加其他扣分数
  95. if (cellname === 'SetValue') {
  96. Price = Number(value);
  97. if (Price < 0) {
  98. $.modalAlert("请输入大于0的单价!");
  99. return;
  100. }
  101. SetValueMax = Number($gridList.jqGrid("getCell", rowid, 'SetValueMax'));
  102. SetValueMin = Number($gridList.jqGrid("getCell", rowid, 'SetValueMin'));
  103. SumSetValue = SetValueMax + SetValueMin
  104. if (Price != 0) {
  105. if (Price > SumSetValue) {
  106. $("#gridList").jqGrid('setCell', rowid, "Result", "不合格");
  107. } else {
  108. $("#gridList").jqGrid('setCell', rowid, "Result", "合格");
  109. }
  110. }
  111. }
  112. }
  113. });
  114. }
  115. }
  116. function submitForm() {
  117. debugger;
  118. var ICSMTDOC = [];
  119. var obj_Item1 = $("#gridList");
  120. var Result = '';
  121. var rowIds_Item1 = obj_Item1.getDataIDs();
  122. if (rowIds_Item1.length > 0) {
  123. for (var i = 0; i < rowIds_Item1.length; i++) {
  124. var RowData_Item1 = obj_Item1.getRowData(rowIds_Item1[i]);
  125. if (RowData_Item1.SetValue=='') {
  126. $.modalAlertNew("WMS00105");
  127. return;
  128. }
  129. if (RowData_Item1.Result == '') {
  130. $.modalAlertNew("WMS00105");
  131. return;
  132. }
  133. if (RowData_Item1.Result == "合格") {
  134. Result='1';
  135. }else {
  136. Result='0';
  137. }
  138. var obj = {
  139. ID: RowData_Item1.ID,
  140. InspectionID: JYID,
  141. GroupCode: RowData_Item1.GroupCode,
  142. GroupName: RowData_Item1.GroupName,
  143. ListCode: RowData_Item1.ListCode,
  144. ListName: RowData_Item1.ListName,
  145. Unit: RowData_Item1.Unit,
  146. SetValueMax: RowData_Item1.SetValueMax,
  147. SetValueMin: RowData_Item1.SetValueMin,
  148. SetValue: RowData_Item1.SetValue,
  149. Result: Result,
  150. NUM: RowData_Item1.NUM
  151. };
  152. ICSMTDOC.push(obj);
  153. }
  154. }
  155. debugger;
  156. $.modalConfirm("确定保存吗?", function (r) {
  157. if (r) {
  158. $.submitForm({
  159. url: "/WMS/ICSRCVIQCs/SaveICSInspectionDetail?InvCode=" + InvCode + "&" + Math.random() + "&ResultINp=" + ResultINp,
  160. param: { ICSMTDOC: JSON.stringify(ICSMTDOC) },
  161. success: function () {
  162. $.currentWindow().$("#gridList").trigger("reloadGrid");
  163. }
  164. })
  165. }
  166. });
  167. }
  168. </script>
  169. <form id="form1">
  170. <div class="gridPanel">
  171. <table id="gridList"></table>
  172. @*<div id="gridPager"></div>*@
  173. </div>
  174. </form>