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.

1396 lines
62 KiB

3 weeks ago
  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. <style>
  8. .formTitle {
  9. text-align: right;
  10. width: 10%;
  11. }
  12. .formActions {
  13. text-align: left;
  14. width: 15%;
  15. }
  16. .project-list table tr td {
  17. padding: 5px;
  18. }
  19. .th_classAdd {
  20. text-align: center !important;
  21. }
  22. .th_classMar {
  23. padding: 10px;
  24. vertical-align: inherit;
  25. }
  26. .ui-jqgrid .ui-jqgrid-view {
  27. height: 300px;
  28. }
  29. .ui-jqgrid .ui-jqgrid-bdiv {
  30. height: 266px !important;
  31. }
  32. .bootstrap-select:not([class*="col-"]):not([class*="form-control"]):not(.input-group-btn) {
  33. width: 100%;
  34. }
  35. .lr-layout-center {
  36. padding: 0 5px;
  37. }
  38. .th_classMar {
  39. padding: 0;
  40. }
  41. .lr-layout-tool {
  42. height: 50px;
  43. }
  44. .lr-layout-center .lr-layout-wrap.lr-layout-wrap-notitle {
  45. padding-top: 50px;
  46. }
  47. .wrapper .nav-tabs {
  48. padding: 0;
  49. }
  50. .webuploader-pick {
  51. padding: 7px 15px;
  52. }
  53. .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
  54. padding: 3px;
  55. }
  56. .form .formTitle {
  57. padding-right: 8px;
  58. }
  59. .form-control, .single-line {
  60. padding: 3px;
  61. }
  62. .ibox-title {
  63. height: 20px;
  64. line-height: 20px;
  65. padding: 0;
  66. padding-left: 15px;
  67. }
  68. .table {
  69. margin-bottom: 0;
  70. }
  71. .bootstrap-select > .dropdown-toggle {
  72. height: 22px;
  73. padding: 2px 6px;
  74. }
  75. .bootstrap-select > .dropdown-toggle.bs-placeholder, .bootstrap-select > .dropdown-toggle.bs-placeholder:hover, .bootstrap-select > .dropdown-toggle.bs-placeholder:focus, .bootstrap-select > .dropdown-toggle.bs-placeholder:active {
  76. height: 22px;
  77. padding: 2px 6px;
  78. }
  79. .form-control, .single-line {
  80. padding: 3px;
  81. height: 22px;
  82. padding: 0 3px;
  83. }
  84. /* 不良原因可选样式 */
  85. .bad-reason-optional {
  86. color: #666;
  87. font-style: italic;
  88. }
  89. /* 空值时的占位符样式 */
  90. .empty-bad-reason {
  91. color: #999;
  92. }
  93. </style>
  94. <script>
  95. debugger;
  96. // 添加全局变量跟踪最后编辑的单元格
  97. var lastrow = null;
  98. var lastcell = null;
  99. var lastrow1 = null;
  100. var lastcell1 = null;
  101. var InvCode = decodeURI($.request("InvCode"));
  102. var JYID = decodeURI($.request("JYID"));
  103. var SampleQuantity = $.request("SampleQuantity");
  104. var WaiveQuantity = decodeURI($.request("WaiveQuantity"));
  105. var AllNumber = $.request("AllNumber");
  106. var YLOTQTY = $.request("YLOTQTY");
  107. var NLOTQTY = $.request("NLOTQTY");
  108. var BCCode = $.request("BCCode");
  109. var BRCode = $.request("BRCode");
  110. var EATTRIBUTE5 = $.request("EATTRIBUTE5");
  111. var EATTRIBUTE6 = $.request("EATTRIBUTE6");
  112. var EATTRIBUTE7 = $.request("EATTRIBUTE7");
  113. var ResultINp = decodeURI($.request("Result"));
  114. var Type = decodeURI($.request("Type"));
  115. var LotNo = decodeURI($.request("LotNo"));
  116. var _Clos = new Array();
  117. var _Clos1 = new Array();
  118. var _ColCaption = new Array();
  119. var _ColFiledName = new Array();
  120. var _LW = new Array();
  121. var AfterLW = new Array();
  122. var SumNum = 1;
  123. var SJKSumNum = 0;
  124. var cj = 0;//记录抽检数量
  125. $(function () {
  126. debugger;
  127. $.ajax({
  128. url: "/DHAY/IQCQuality/GetRulesDetail?LotNo=" + LotNo,
  129. dataType: "json",
  130. async: false,
  131. success: function (data) {
  132. $("#txt_Lot").val(data.rows[0].LotNo);
  133. $("#txt_LotQty").val(data.rows[0].Quantity);
  134. $("#txt_RulesType").val("抽检");
  135. $("#txt_RulesCode").val(data.rows[0].RulesCode);
  136. $("#txt_InvCode").val(data.rows[0].InvCode);
  137. $("#txt_InvName").val(data.rows[0].InvName);
  138. $("#txt_InvStd").val(data.rows[0].InvStd);
  139. if (JYID == "null") {
  140. $("#txt_badCount").val(0);
  141. $("#txt_specialPicks").val(0);
  142. $("#txt_filtering").val(0);
  143. $("#txt_specialNumber").val(data.rows[0].EATTRIBUTE3);
  144. } else {
  145. $("#txt_badCount").val(data.rows[0].UnqualifiedQuantity);
  146. $("#txt_specialPicks").val(data.rows[0].EATTRIBUTE4);
  147. $("#txt_filtering").val(data.rows[0].EATTRIBUTE2);
  148. $("#txt_specialNumber").val(data.rows[0].EATTRIBUTE3);
  149. $("#txt_manhours").val(EATTRIBUTE5);
  150. $("#txt_rejections").val(EATTRIBUTE6);
  151. $("#txt_otherNumber").val(EATTRIBUTE7);
  152. $("#txt_result").val(data.rows[0].Result);
  153. }
  154. }
  155. });
  156. Getcol();
  157. Getcol1();
  158. gridList();
  159. gridList1();
  160. });
  161. // 统一计算表头结论
  162. function calcHeaderResult() {
  163. var gridListOKCount = 0;
  164. var gridList1OKCount = 0;
  165. var rowIds_Item = $("#gridList").getDataIDs();
  166. var rowIds_Item1 = $("#gridList1").getDataIDs();
  167. for (var k = 0; k < rowIds_Item.length; k++) {
  168. var data = $("#gridList").getRowData(rowIds_Item[k]);
  169. if (data.Result === "OK" || data.Result === "合格") {
  170. gridListOKCount++;
  171. }
  172. }
  173. for (var j = 0; j < rowIds_Item1.length; j++) {
  174. var data = $("#gridList1").getRowData(rowIds_Item1[j]);
  175. if (data.Result === "OK" || data.Result === "合格") {
  176. gridList1OKCount++;
  177. }
  178. }
  179. if (rowIds_Item.length === gridListOKCount &&
  180. rowIds_Item1.length === gridList1OKCount) {
  181. $("#txt_result").val("OK");
  182. } else {
  183. $("#txt_result").val("NG");
  184. }
  185. }
  186. function gridList() {
  187. debugger;
  188. var $gridPanel = $("#gridPanel");
  189. var $gridList = $("#gridList");
  190. // 步骤1:深度缓存所有行数据(兼容所有版本)
  191. var cachedData = [];
  192. if ($gridList.length > 0) {
  193. try {
  194. var rowIds = $gridList.getDataIDs(); // 尝试获取行ID(兼容多数版本)
  195. for (var i = 0; i < rowIds.length; i++) {
  196. var rowId = rowIds[i];
  197. var rowData = {};
  198. // 遍历所有列,手动获取单元格值(避免依赖jqGrid内置方法)
  199. var colModel = $gridList.jqGrid('getGridParam', 'colModel') || _Clos;
  200. for (var j = 0; j < colModel.length; j++) {
  201. var colName = colModel[j].name;
  202. if (colName && colName !== 'rn' && colName !== 'cb') { // 排除内置列
  203. try {
  204. rowData[colName] = $gridList.jqGrid('getCell', rowId, colName);
  205. } catch (e) {
  206. // 若getCell也报错,改用DOM获取单元格值(终极兜底)
  207. var cellElem = $gridList.find("#" + rowId + "_" + colName);
  208. rowData[colName] = cellElem.text() || cellElem.val() || "";
  209. }
  210. }
  211. }
  212. rowData._rowId = rowId; // 保留行ID
  213. cachedData.push(rowData);
  214. }
  215. } catch (e) {
  216. console.log("缓存数据时兼容旧版jqGrid:", e);
  217. }
  218. }
  219. // 步骤2:暴力清空表格DOM(无需依赖jqGrid内置方法)
  220. $gridPanel.empty(); // 清空容器所有内容
  221. $gridPanel.html('<table id="gridList"></table>'); // 重建表格DOM
  222. $gridList = $("#gridList"); // 重新获取表格对象
  223. // 步骤3:重新初始化表格(原有配置不变)
  224. $gridList.dataGrid({
  225. url: "/DHAY/IQCQuality/GetInventoryInspectionNew?InvCode=" + InvCode + "&" + Math.random() + "&SampleQuantity=" + SampleQuantity + "&ResultINp=" + ResultINp + "&JYID=" + JYID + "&LotNo=" + LotNo + "&AllNumber=" + AllNumber,
  226. height: $(window).height() - 400,
  227. width: 300,
  228. cellEdit: true,
  229. colModel: _Clos,
  230. cellsubmit: "clientArray", // 数据保存在客户端,关键!
  231. sortname: 'GroupCode',
  232. sortorder: "asc",
  233. viewrecords: true,
  234. rowNum: 200,
  235. afterEditCell: function (rowid, cellname, value, iRow, iCol) {
  236. lastrow = rowid;
  237. lastcell = iCol;
  238. },
  239. loadComplete: function () {
  240. debugger;
  241. $('.ui-jqgrid-bdiv').scrollTop(0);
  242. // 步骤4:强制回填缓存数据(核心:覆盖新加载的空数据)
  243. if (cachedData.length > 0) {
  244. var newRowIds = $gridList.getDataIDs();
  245. for (var i = 0; i < newRowIds.length && i < cachedData.length; i++) {
  246. var rowId = newRowIds[i];
  247. var oldData = cachedData[i];
  248. // 遍历所有缓存的字段,逐列回填
  249. for (var key in oldData) {
  250. if (oldData.hasOwnProperty(key) && key !== '_rowId') {
  251. try {
  252. // 优先用jqGrid方法设置值
  253. $gridList.jqGrid('setCell', rowId, key, oldData[key]);
  254. } catch (e) {
  255. // 终极兜底:直接修改DOM元素值
  256. var cellElem = $gridList.find("#" + rowId + "_" + key);
  257. if (cellElem.is("input")) {
  258. cellElem.val(oldData[key]); // 编辑状态的单元格
  259. } else {
  260. cellElem.text(oldData[key]); // 普通单元格
  261. }
  262. }
  263. }
  264. }
  265. }
  266. }
  267. if (_LW.length > 0) {
  268. for (var i = 0; i < _LW.length; i++) {
  269. try {
  270. $gridList.jqGrid("setCell", _LW[i].ID, _LW[i].FiledNamekey, _LW[i].FiledNamevalue);
  271. } catch (e) {
  272. var cellElem = $gridList.find("#" + _LW[i].ID + "_" + _LW[i].FiledNamekey);
  273. cellElem.text(_LW[i].FiledNamevalue);
  274. }
  275. }
  276. }
  277. reSetActualValueColor();
  278. calcHeaderResult();
  279. },
  280. afterSaveCell: function (rowid, cellname, value) {
  281. debugger;
  282. var obj_Item = $("#gridList");
  283. var rowIds_Item = obj_Item.getDataIDs();
  284. var obj_Item1 = $("#gridList1");
  285. var rowIds_Item1 = obj_Item1.getDataIDs();
  286. if (rowIds_Item.length > 0) {
  287. for (var i = 0; i < rowIds_Item.length; i++) {
  288. var RowData_Item1 = obj_Item.getRowData(rowIds_Item[i]);
  289. if (RowData_Item1.ID == rowid && cellname != "UnqualifiedQuantity" && cellname != "SamplingQuantity") {
  290. var SetValueMax = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "SetValueMax"));
  291. var SetValueMin = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "SetValueMin"));
  292. for (var j = 0; j < _ColFiledName.length; j++) {
  293. var result = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, _ColFiledName[j]));
  294. if (result >= SetValueMin && result <= SetValueMax) {
  295. $("#gridList").jqGrid('setCell', RowData_Item1.ID, _ColFiledName[j], '', { color: 'black' });
  296. } else {
  297. $("#gridList").jqGrid('setCell', RowData_Item1.ID, _ColFiledName[j], '', { color: 'red' });
  298. }
  299. }
  300. }
  301. if (RowData_Item1.ID == rowid && cellname == "UnqualifiedQuantity") {
  302. var SimpaleQuantity = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "SamplingQuantity"));
  303. var AcceptableValue = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "EATTRIBUTE1"));
  304. var result = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "UnqualifiedQuantity"));
  305. RowData_Item1.UnqualifiedQuantity = result;
  306. if (SimpaleQuantity != 0 && result > SimpaleQuantity) {
  307. $.modalMsg("不良数不能大于抽检数量", "warning");
  308. $gridList.jqGrid("setCell", RowData_Item1.ID, "UnqualifiedQuantity", " ");
  309. return;
  310. }
  311. if (SimpaleQuantity == 0) {
  312. if (result == 1) {
  313. $gridList.jqGrid("setCell", RowData_Item1.ID, "Result", "OK");
  314. }
  315. else {
  316. $gridList.jqGrid("setCell", RowData_Item1.ID, "Result", "NG");
  317. }
  318. }
  319. else {
  320. if (result > AcceptableValue) {
  321. $gridList.jqGrid("setCell", RowData_Item1.ID, "Result", "NG");
  322. }
  323. else {
  324. $gridList.jqGrid("setCell", RowData_Item1.ID, "Result", "OK");
  325. }
  326. }
  327. var gridListOKCount = 0;
  328. var gridList1OKCount = 0;
  329. for (var k = 0; k < rowIds_Item.length; k++) {
  330. var gridListData = obj_Item.getRowData(rowIds_Item[k]);
  331. if (gridListData.Result == "OK") {
  332. gridListOKCount++;
  333. }
  334. }
  335. for (var j = 0; j < rowIds_Item1.length; j++) {
  336. var gridList1Data = obj_Item1.getRowData(rowIds_Item1[j]);
  337. if (gridList1Data.Result == "OK") {
  338. gridList1OKCount++;
  339. }
  340. }
  341. if (gridListOKCount == rowIds_Item.length && gridList1OKCount == rowIds_Item1.length) {
  342. $("#txt_result").val("OK");
  343. }
  344. else {
  345. $("#txt_result").val("NG");
  346. }
  347. }
  348. var cjMin = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "SamplingQuantity"));
  349. if (cjMin > cj) {
  350. cj = cjMin;
  351. }
  352. }
  353. }
  354. },
  355. shrinkToFit: false,
  356. ondblClickRow: function (rowid, iRow, iCol, e) {
  357. debugger;
  358. var colModel = $("#gridList").jqGrid("getGridParam", "colModel");
  359. var cellname = colModel[iCol].name;
  360. if (cellname !== "BadReason") {
  361. return; // 如果双击的不是 "BadReason" 列,则直接返回
  362. }
  363. $.modalOpen({
  364. id: "InvCodeSelect",
  365. title: "选择不良原因(可选)",
  366. url: "/DHAY/ICSRCVIQCs/GetBadReasonCode?InvCode=" + InvCode,
  367. width: "50%",
  368. height: "50%",
  369. callBack: function (iframeId) {
  370. var obj = top.frames[iframeId].submitForm();
  371. if (obj) {
  372. debugger;
  373. // 设置单元格值
  374. $("#gridList").jqGrid('setCell', rowid, 'BadReason', obj.BadReasonDesc);
  375. // 强制保存该单元格
  376. try {
  377. // 方法1:使用 saveCell
  378. $("#gridList").jqGrid("saveCell", rowid, iCol);
  379. // 方法2:直接更新行数据
  380. var rowData = $("#gridList").jqGrid('getRowData', rowid);
  381. rowData.BadReason = obj.BadReasonDesc;
  382. $("#gridList").jqGrid('setRowData', rowid, rowData);
  383. // 方法3:触发编辑和保存(更可靠)
  384. $("#gridList").jqGrid('editRow', rowid, true);
  385. $("#gridList").jqGrid('saveRow', rowid);
  386. console.log("不良原因已设置并保存:", obj.BadReasonDesc);
  387. } catch (e) {
  388. console.error("保存单元格时出错:", e);
  389. }
  390. top.frames[iframeId].Close();
  391. }
  392. }
  393. });
  394. }
  395. });
  396. $("#gridList").jqGrid('setFrozenColumns');
  397. }
  398. function gridList1() {
  399. debugger;
  400. document.getElementById("gridPanel1").innerHTML = '<table id="gridList1"></table> ';
  401. var $gridList1 = $("#gridList1");
  402. $gridList1.dataGrid({
  403. url: "/DHAY/IQCQuality/GetInventoryInspectionNew1?InvCode=" + InvCode + "&" + Math.random() + "&SampleQuantity=" + SampleQuantity + "&ResultINp=" + ResultINp + "&JYID=" + JYID + "&LotNo=" + LotNo + "&AllNumber=" + AllNumber,
  404. height: $(window).height() - 400,
  405. width: 300,
  406. cellEdit: true,
  407. colModel: _Clos1,
  408. cellsubmit: "clientArray",
  409. sortname: 'GroupCode',
  410. sortorder: "asc",
  411. viewrecords: true,
  412. rowNum: 200,
  413. afterEditCell: function (rowid, cellname, value, iRow, iCol) {
  414. lastrow1 = rowid;
  415. lastcell1 = iCol;
  416. },
  417. afterSaveCell: function (rowid, cellname, value) {
  418. debugger;
  419. var obj_Item = $("#gridList");
  420. var rowIds_Item = obj_Item.getDataIDs();
  421. var obj_Item1 = $("#gridList1");
  422. var rowIds_Item1 = obj_Item1.getDataIDs();
  423. if (rowIds_Item1.length > 0) {
  424. for (var i = 0; i < rowIds_Item1.length; i++) {
  425. var RowData_Item1 = obj_Item1.getRowData(rowIds_Item1[i]);
  426. if (RowData_Item1.ID == rowid && cellname == "UnqualifiedQuantity") {
  427. var SimpaleQuantity = Number($("#gridList1").jqGrid("getCell", RowData_Item1.ID, "SamplingQuantity"));
  428. var AcceptableValue = Number($("#gridList1").jqGrid("getCell", RowData_Item1.ID, "EATTRIBUTE1"));
  429. var result = Number($("#gridList1").jqGrid("getCell", RowData_Item1.ID, "UnqualifiedQuantity"));
  430. if (SimpaleQuantity != 0 && result > SimpaleQuantity) {
  431. $.modalMsg("不良数不能大于抽检数量", "warning");
  432. $gridList1.jqGrid("setCell", RowData_Item1.ID, "UnqualifiedQuantity", " ");
  433. return;
  434. }
  435. if (SimpaleQuantity == 0) {
  436. if (result == 1) {
  437. $gridList1.jqGrid("setCell", RowData_Item1.ID, "Result", "OK");
  438. }
  439. else {
  440. $gridList1.jqGrid("setCell", RowData_Item1.ID, "Result", "NG");
  441. }
  442. }
  443. else {
  444. if (result > AcceptableValue) {
  445. $gridList1.jqGrid("setCell", RowData_Item1.ID, "Result", "NG");
  446. }
  447. else {
  448. $gridList1.jqGrid("setCell", RowData_Item1.ID, "Result", "OK");
  449. }
  450. }
  451. var gridListOKCount = 0;
  452. var gridList1OKCount = 0;
  453. for (var k = 0; k < rowIds_Item.length; k++) {
  454. var gridListData = obj_Item.getRowData(rowIds_Item[k]);
  455. if (gridListData.Result == "OK") {
  456. gridListOKCount++;
  457. }
  458. }
  459. for (var j = 0; j < rowIds_Item1.length; j++) {
  460. var gridList1Data = obj_Item1.getRowData(rowIds_Item1[j]);
  461. if (gridList1Data.Result == "OK") {
  462. gridList1OKCount++;
  463. }
  464. }
  465. if (gridListOKCount == rowIds_Item.length && gridList1OKCount == rowIds_Item1.length) {
  466. $("#txt_result").val("OK");
  467. }
  468. else {
  469. $("#txt_result").val("NG");
  470. }
  471. var cjMin = Number($("#gridList1").jqGrid("getCell", RowData_Item1.ID, "SamplingQuantity"));
  472. if (cjMin > cj) {
  473. cj = cjMin;
  474. }
  475. }
  476. }
  477. }
  478. },
  479. shrinkToFit: false,
  480. ondblClickRow: function (rowid, iRow, iCol, e) {
  481. debugger;
  482. var colModel = $("#gridList1").jqGrid("getGridParam", "colModel");
  483. var cellname = colModel[iCol].name;
  484. if (cellname !== "BadReason") {
  485. return; // 如果双击的不是 "BadReason" 列,则直接返回
  486. }
  487. $.modalOpen({
  488. id: "InvCodeSelect",
  489. title: "选择不良原因(可选)",
  490. url: "/DHAY/ICSRCVIQCs/GetBadReasonCode?InvCode=" + InvCode,
  491. width: "50%",
  492. height: "50%",
  493. callBack: function (iframeId) {
  494. var obj = top.frames[iframeId].submitForm();
  495. if (obj) {
  496. debugger;
  497. // 设置单元格值
  498. $("#gridList1").jqGrid('setCell', rowid, 'BadReason', obj.BadReasonDesc);
  499. // 强制保存该单元格
  500. try {
  501. // 方法1:使用 saveCell
  502. $("#gridList1").jqGrid("saveCell", rowid, iCol);
  503. // 方法2:直接更新行数据
  504. var rowData = $("#gridList1").jqGrid('getRowData', rowid);
  505. rowData.BadReason = obj.BadReasonDesc;
  506. $("#gridList1").jqGrid('setRowData', rowid, rowData);
  507. // 方法3:触发编辑和保存(更可靠)
  508. $("#gridList1").jqGrid('editRow', rowid, true);
  509. $("#gridList1").jqGrid('saveRow', rowid);
  510. console.log("不良原因已设置并保存:", obj.BadReasonDesc);
  511. } catch (e) {
  512. console.error("保存单元格时出错:", e);
  513. }
  514. top.frames[iframeId].Close();
  515. }
  516. }
  517. });
  518. }
  519. });
  520. $("#gridList1").jqGrid('setFrozenColumns');
  521. }
  522. function submitForm() {
  523. debugger;
  524. // 先强制保存所有编辑中的单元格
  525. try {
  526. if (lastrow !== null && lastcell !== null) {
  527. $("#gridList").jqGrid("saveCell", lastrow, lastcell);
  528. }
  529. if (lastrow1 !== null && lastcell1 !== null) {
  530. $("#gridList1").jqGrid("saveCell", lastrow1, lastcell1);
  531. }
  532. } catch (e) {
  533. console.log("保存单元格时出错:", e);
  534. }
  535. // 确保获取最新的表格数据
  536. $("#gridList").trigger("reloadGrid", { fromServer: false });
  537. $("#gridList1").trigger("reloadGrid", { fromServer: false });
  538. var ICSMTDOC = [];
  539. var obj_Item1 = $("#gridList");
  540. var Result = '';
  541. var samplingQuantity = 0;
  542. var rowIds_Item1 = obj_Item1.getDataIDs();
  543. var obj_Item2 = $("#gridList1");
  544. var rowIds_Item2 = obj_Item2.getDataIDs();
  545. var SpecialPicks = Number($("#txt_specialPicks").val()) || 0;
  546. var BadCount = Number($("#txt_badCount").val()) || 0;
  547. var Filtering = Number($("#txt_filtering").val()) || 0;
  548. var SpecialNumber = $("#txt_specialNumber").val();
  549. var LotResult = "1";
  550. LotResult = $("#txt_result").val() == "Ok" ? "1" : "0";
  551. var Manhours = $("#txt_manhours").val();
  552. var Rejections = Number($("#txt_rejections").val()) || 0;
  553. var OtherNumber = $("#txt_otherNumber").val();
  554. YLOTQTY = AllNumber - BadCount;
  555. NLOTQTY = BadCount;
  556. WaiveQuantity = SpecialPicks - 0 + (Filtering - 0);
  557. if (Manhours == 0 || Manhours == "") {
  558. $.modalMsg("工时必须填写!", "warning");
  559. return;
  560. }
  561. // 调试:打印表格数据
  562. console.log("=== 开始收集数据 ===");
  563. if (rowIds_Item1.length > 0) {
  564. for (var i = 0; i < rowIds_Item1.length; i++) {
  565. var LWFiledName = new Array();
  566. var RowData_Item1 = obj_Item1.getRowData(rowIds_Item1[i]);
  567. var curRowData = $("#gridList").jqGrid('getRowData', RowData_Item1.ID);
  568. if (samplingQuantity < (RowData_Item1.SamplingQuantity - 0)) {
  569. samplingQuantity = RowData_Item1.SamplingQuantity - 0;
  570. }
  571. if (RowData_Item1.Result == "") {
  572. $.modalMsg("定量检验区第" + (i + 1) + "行检验结论为空,必须所有行都有检验结论才能保存检验结果!", "warning");
  573. return;
  574. }
  575. var chkValue = false;
  576. for (var j = 0; j < _ColCaption.length; j++) {
  577. var aaa = _ColCaption[j];
  578. var bbb = _ColFiledName[j];
  579. if (curRowData[bbb] != "") {
  580. chkValue = true;
  581. }
  582. var objFiledName = {
  583. FiledNamevalue: curRowData[bbb],
  584. FiledNamekey: aaa
  585. }
  586. LWFiledName.push(objFiledName);
  587. }
  588. if (chkValue == false) {
  589. $.modalMsg("定量检验区第" + (i + 1) + "行未填写实测值,每一行至少填写一个实测值!", "warning");
  590. return;
  591. }
  592. // 处理结果值
  593. if (RowData_Item1.Result == "OK" || RowData_Item1.Result == "合格") {
  594. Result = '1';
  595. } else {
  596. Result = '0';
  597. }
  598. // 确保获取到正确的数据
  599. var badReasonValue = RowData_Item1.BadReason || "";
  600. var samplingQty = RowData_Item1.SamplingQuantity || 0;
  601. var unqualifiedQty = RowData_Item1.UnqualifiedQuantity || 0;
  602. console.log("定量检验区第" + (i + 1) + "行数据:");
  603. console.log("- BadReason:", badReasonValue);
  604. console.log("- SamplingQuantity:", samplingQty);
  605. console.log("- UnqualifiedQuantity:", unqualifiedQty);
  606. var obj = {
  607. ID: RowData_Item1.ID,
  608. InspectionID: JYID,
  609. GroupCode: RowData_Item1.GroupCode,
  610. GroupName: RowData_Item1.GroupName,
  611. ListCode: RowData_Item1.ListCode,
  612. ListName: RowData_Item1.ListName,
  613. Unit: RowData_Item1.Unit,
  614. SetValueMax: RowData_Item1.SetValueMax,
  615. SetValueMin: RowData_Item1.SetValueMin,
  616. SetValue: unqualifiedQty,
  617. Result: Result,
  618. NUM: RowData_Item1.NUM,
  619. LWFiledName: LWFiledName,
  620. BadReason: badReasonValue, // 确保这个字段存在
  621. SamplingQuantity: samplingQty,
  622. Memo: RowData_Item1.EATTRIBUTE30 || ""
  623. };
  624. ICSMTDOC.push(obj);
  625. console.log("推送的数据对象:", obj);
  626. }
  627. }
  628. if (rowIds_Item2.length > 0) {
  629. for (var i = 0; i < rowIds_Item2.length; i++) {
  630. var RowData_Item2 = obj_Item2.getRowData(rowIds_Item2[i]);
  631. var curRowData = $("#gridList1").jqGrid('getRowData', RowData_Item2.ID)
  632. if (samplingQuantity < (RowData_Item2.SamplingQuantity - 0)) {
  633. samplingQuantity = RowData_Item2.SamplingQuantity - 0;
  634. }
  635. if (RowData_Item2.Result == "") {
  636. $.modalMsg("定性检验区第" + (i + 1) + "行检验结论为空,必须所有行都有检验结论才能保存检验结果!", "warning");
  637. return;
  638. }
  639. // 处理结果值
  640. if (RowData_Item2.Result == "OK" || RowData_Item2.Result == "合格") {
  641. Result = '1';
  642. } else {
  643. Result = '0';
  644. }
  645. // 确保获取到正确的数据
  646. var badReasonValue = RowData_Item2.BadReason || "";
  647. var samplingQty = RowData_Item2.SamplingQuantity || 0;
  648. var unqualifiedQty = RowData_Item2.UnqualifiedQuantity || 0;
  649. console.log("定性检验区第" + (i + 1) + "行数据:");
  650. console.log("- BadReason:", badReasonValue);
  651. console.log("- SamplingQuantity:", samplingQty);
  652. console.log("- UnqualifiedQuantity:", unqualifiedQty);
  653. var obj = {
  654. ID: RowData_Item2.ID,
  655. InspectionID: JYID,
  656. GroupCode: RowData_Item2.GroupCode,
  657. GroupName: RowData_Item2.GroupName,
  658. ListCode: RowData_Item2.ListCode,
  659. ListName: RowData_Item2.ListName,
  660. Unit: RowData_Item2.Unit,
  661. SetValueMax: "0",
  662. SetValueMin: "0",
  663. SetValue: unqualifiedQty,
  664. Result: Result,
  665. NUM: RowData_Item2.NUM,
  666. LWFiledName: new Array(),
  667. BadReason: badReasonValue, // 确保这个字段存在
  668. SamplingQuantity: samplingQty,
  669. Memo: RowData_Item2.EATTRIBUTE30 || ""
  670. };
  671. ICSMTDOC.push(obj);
  672. console.log("推送的数据对象:", obj);
  673. }
  674. }
  675. SampleQuantity = samplingQuantity;
  676. // 在提交前输出完整数据用于调试
  677. console.log("准备提交的完整数据:", JSON.stringify(ICSMTDOC, null, 2));
  678. if (ResultINp != "") {
  679. debugger;
  680. $.modalConfirm("确定修改吗?", function (r) {
  681. if (r) {
  682. $.submitForm({
  683. url: "/DHAY/IQCQuality/UpdateICSInspectionDetailNew?InvCode=" + InvCode + "&JYID=" + JYID + "&AllNumber=" + AllNumber + "&YLOTQTY=" + YLOTQTY + "&NLOTQTY=" + NLOTQTY + "&WaiveQuantity=" + WaiveQuantity + "&Filtering=" + Filtering + "&SpecialNumber=" + SpecialNumber + "&ResultINp=" + ResultINp + "&SpecialPicks=" + SpecialPicks + "&LotResult=" + LotResult + "&Manhours=" + Manhours + "&Rejections=" + Rejections + "&OtherNumber=" + OtherNumber,
  684. param: { ICSMTDOC: JSON.stringify(ICSMTDOC), Lot: $("#txt_Lot").val(), InvCode: $("#txt_InvCode").val(), Type: Type, CJQty: SampleQuantity },
  685. success: function () {
  686. $.currentWindow().$("#gridList").trigger("reloadGrid");
  687. }
  688. })
  689. }
  690. });
  691. } else {
  692. debugger;
  693. $.modalConfirm("确定保存吗?", function (r) {
  694. if (r) {
  695. $.submitForm({
  696. url: "/DHAY/IQCQuality/SaveICSInspectionDetailNew?InvCode=" + InvCode + "&JYID=" + JYID + "&AllNumber=" + AllNumber + "&YLOTQTY=" + YLOTQTY + "&NLOTQTY=" + NLOTQTY + "&WaiveQuantity=" + WaiveQuantity + "&Filtering=" + Filtering + "&SpecialNumber=" + SpecialNumber + "&" + Math.random() + "&ResultINp=" + ResultINp + "&SpecialPicks=" + SpecialPicks + "&LotResult=" + LotResult + "&Manhours=" + Manhours + "&Rejections=" + Rejections + "&OtherNumber=" + OtherNumber,
  697. param: { ICSMTDOC: JSON.stringify(ICSMTDOC), Lot: $("#txt_Lot").val(), InvCode: $("#txt_InvCode").val(), Type: Type, CJQty: SampleQuantity },
  698. success: function () {
  699. $.currentWindow().$("#gridList").trigger("reloadGrid");
  700. }
  701. })
  702. }
  703. });
  704. }
  705. }
  706. function Getcol() {
  707. _ColCaption = new Array();
  708. _ColFiledName = new Array();
  709. $.ajax({
  710. url: "/DHAY/ICSRCVIQCs/SelectSORRFQColumnName?InvCode=" + InvCode + "&JYID=" + JYID + "&" + "&LotNo=" + LotNo + "&" + Math.random(),
  711. dataType: "json",
  712. async: false,
  713. success: function (data) {
  714. var cols = new Array();
  715. var collast = { label: "主键", name: "ID", hidden: true, key: true };
  716. cols.push(collast);
  717. var collast = { label: "抽检值必填", name: "EATTRIBUTE2", hidden: true };
  718. cols.push(collast);
  719. var collast = { label: '检验ID', name: 'InspectionID', hidden: true };
  720. cols.push(collast);
  721. var collast = { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' };
  722. cols.push(collast);
  723. var collast = { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' };
  724. cols.push(collast);
  725. var collast = { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' };
  726. cols.push(collast);
  727. var collast = { label: "检验项目名称", name: "ListName", width: 100, align: 'left' };
  728. cols.push(collast);
  729. var collast = { label: "单位", name: "Unit", width: 100, align: 'left' };
  730. cols.push(collast);
  731. var collast = { label: "检验标准", name: "InspectStander", width: 100, align: 'left', editable: false };
  732. cols.push(collast);
  733. var collast = { label: "检验仪器", name: "EATTRIBUTE7", width: 100, align: 'left', editable: false };
  734. cols.push(collast);
  735. var collast = { label: '标准上限', name: 'SetValueMax', width: 80, align: 'left' };
  736. cols.push(collast);
  737. var collast = { label: '标准下限', name: 'SetValueMin', width: 80, align: 'left' };
  738. cols.push(collast);
  739. if (data.length > 0 && data[0].ColCaption != null) {
  740. debugger;
  741. DateList = data;
  742. if (SJKSumNum == 0) {
  743. SJKSumNum = data.length;
  744. }
  745. for (var i = 0; i < data.length; i++) {
  746. var ColCaption = data[i].ColCaption;
  747. var ColFiledName = data[i].ColFiledName;
  748. var obj = new Array();
  749. obj = {
  750. label: ColCaption,
  751. name: ColFiledName,
  752. width: 150,
  753. align: "center",
  754. sortable: false,
  755. editable: true,
  756. editrules: { number: true }
  757. }
  758. cols.push(obj);
  759. _ColCaption.push(ColCaption);
  760. _ColFiledName.push(ColFiledName);
  761. }
  762. };
  763. if (data.length == 0) {
  764. for (var i = 1; i < SumNum; i++) {
  765. debugger;
  766. var ColCaption = "实际值" + i;
  767. var ColFiledName = "绑定" + i;
  768. var obj = new Array();
  769. obj = {
  770. label: ColCaption,
  771. name: ColFiledName,
  772. width: 80,
  773. align: "center",
  774. sortable: false,
  775. editable: true,
  776. editrules: { number: true }
  777. }
  778. cols.push(obj);
  779. _ColCaption.push(ColCaption);
  780. _ColFiledName.push(ColFiledName);
  781. }
  782. }
  783. if (data.length > 0) {
  784. for (var i = data.length + 1; i <= SJKSumNum; i++) {
  785. debugger;
  786. var ColCaption = "实际值" + i;
  787. var ColFiledName = "绑定" + i;
  788. var obj = new Array();
  789. obj = {
  790. label: ColCaption,
  791. name: ColFiledName,
  792. width: 80,
  793. align: "center",
  794. sortable: false,
  795. editable: true,
  796. editrules: { number: true }
  797. }
  798. cols.push(obj);
  799. _ColCaption.push(ColCaption);
  800. _ColFiledName.push(ColFiledName);
  801. }
  802. }
  803. var collast = { label: '抽检数量', name: 'SamplingQuantity', width: 80, align: 'left' };
  804. cols.push(collast);
  805. var collast = { label: "允许不良数", name: "EATTRIBUTE1", width: 100, align: 'left' };
  806. cols.push(collast);
  807. var collast = { label: '不良数', name: 'UnqualifiedQuantity', width: 150, align: 'left', editable: true, editrules: { number: true } };
  808. cols.push(collast);
  809. var collast = { label: '结论', name: 'Result', width: 150, align: 'left', editable: false };
  810. cols.push(collast);
  811. var collast = {
  812. label: '不良原因',
  813. name: 'BadReason',
  814. width: 120,
  815. align: 'left',
  816. editable: true, // 允许编辑
  817. editrules: { required: false }, // 设为非必填
  818. editoptions: {
  819. placeholder: "可选填"
  820. }
  821. };
  822. cols.push(collast);
  823. var collast = { label: '备注', name: 'EATTRIBUTE30', width: 120, align: 'left', editable: true };
  824. cols.push(collast);
  825. _Clos = cols;
  826. }
  827. });
  828. }
  829. function Getcol1() {
  830. var cols = new Array();
  831. var collast = { label: "主键", name: "ID", hidden: true, key: true };
  832. cols.push(collast);
  833. var collast = { label: "抽检值必填", name: "EATTRIBUTE2", hidden: true };
  834. cols.push(collast);
  835. var collast = { label: '检验ID', name: 'InspectionID', hidden: true };
  836. cols.push(collast);
  837. var collast = { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' };
  838. cols.push(collast);
  839. var collast = { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' };
  840. cols.push(collast);
  841. var collast = { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' };
  842. cols.push(collast);
  843. var collast = { label: "检验项目名称", name: "ListName", width: 100, align: 'left' };
  844. cols.push(collast);
  845. var collast = { label: "单位", name: "Unit", width: 100, align: 'left' };
  846. cols.push(collast);
  847. var collast = { label: "检验标准", name: "InspectStander", width: 100, align: 'left', editable: false };
  848. cols.push(collast);
  849. var collast = { label: "检验仪器", name: "EATTRIBUTE7", width: 100, align: 'left', editable: false };
  850. cols.push(collast);
  851. var collast = { label: '抽检数量', name: 'SamplingQuantity', width: 80, align: 'left' };
  852. cols.push(collast);
  853. var collast = { label: "允许不良数", name: "EATTRIBUTE1", width: 100, align: 'left' };
  854. cols.push(collast);
  855. var collast = { label: '不良数', name: 'UnqualifiedQuantity', width: 150, align: 'left', editable: true, editrules: { number: true } };
  856. cols.push(collast);
  857. var collast = { label: '结论', name: 'Result', width: 150, align: 'left', editable: false };
  858. cols.push(collast);
  859. var collast = {
  860. label: '不良原因',
  861. name: 'BadReason',
  862. width: 120,
  863. align: 'left',
  864. editable: true, // 允许编辑
  865. editrules: { required: false }, // 设为非必填
  866. editoptions: {
  867. placeholder: "可选填"
  868. }
  869. };
  870. cols.push(collast);
  871. var collast = { label: '备注', name: 'EATTRIBUTE30', width: 120, align: 'left', editable: true };
  872. cols.push(collast);
  873. _Clos1 = cols;
  874. }
  875. function AddRows_ColorFastness() {
  876. debugger;
  877. _LW = new Array();
  878. AfterLW = new Array();
  879. var $gridList = $("#gridList");
  880. // 提前缓存_LW数据(兼容旧版)
  881. if ($gridList.length > 0) {
  882. try {
  883. var rowIds = $gridList.getDataIDs();
  884. for (var i = 0; i < rowIds.length; i++) {
  885. var rowData = {};
  886. if (_ColCaption.length > 0) {
  887. for (var j = 0; j < _ColCaption.length; j++) {
  888. var filedKey = _ColFiledName[j];
  889. try {
  890. var filedValue = $gridList.jqGrid('getCell', rowIds[i], filedKey);
  891. } catch (e) {
  892. var cellElem = $gridList.find("#" + rowIds[i] + "_" + filedKey);
  893. var filedValue = cellElem.text() || cellElem.val() || "";
  894. }
  895. _LW.push({
  896. ID: rowIds[i],
  897. FiledNamekey: filedKey,
  898. FiledNamevalue: filedValue
  899. });
  900. }
  901. }
  902. }
  903. } catch (e) {
  904. console.log("新增时缓存数据:", e);
  905. }
  906. }
  907. SumNum = SumNum + 1;
  908. SJKSumNum = SJKSumNum + 1;
  909. Getcol();
  910. gridList();
  911. }
  912. function DelRows_ColorFastness() {
  913. _ColCaption = new Array();
  914. _ColFiledName = new Array();
  915. $.ajax({
  916. url: "/DHAY/ICSRCVIQCs/deleteSelectSORRFQColumnName?InvCode=" + InvCode + "&JYID=" + JYID + "&" + "&LotNo=" + LotNo + "&" + Math.random(),
  917. dataType: "json",
  918. async: false,
  919. success: function (data) {
  920. var cols = new Array();
  921. var collast = { label: "主键", name: "ID", hidden: true, key: true };
  922. cols.push(collast);
  923. var collast = { label: "抽检值必填", name: "EATTRIBUTE2", hidden: true };
  924. cols.push(collast);
  925. var collast = { label: '检验ID', name: 'InspectionID', hidden: true };
  926. cols.push(collast);
  927. var collast = { label: "检验项目组代码", name: "GroupCode", width: 100, align: 'left' };
  928. cols.push(collast);
  929. var collast = { label: "检验项目组名称", name: "GroupName", width: 100, align: 'left' };
  930. cols.push(collast);
  931. var collast = { label: "检验项目代码", name: "ListCode", width: 100, align: 'left' };
  932. cols.push(collast);
  933. var collast = { label: "检验项目名称", name: "ListName", width: 100, align: 'left' };
  934. cols.push(collast);
  935. var collast = { label: "单位", name: "Unit", width: 100, align: 'left' };
  936. cols.push(collast);
  937. var collast = { label: "检验标准", name: "InspectStander", width: 100, align: 'left', editable: false };
  938. cols.push(collast);
  939. var collast = { label: "检验仪器", name: "EATTRIBUTE7", width: 100, align: 'left', editable: false };
  940. cols.push(collast);
  941. var collast = { label: '标准上限', name: 'SetValueMax', width: 80, align: 'left' };
  942. cols.push(collast);
  943. var collast = { label: '标准下限', name: 'SetValueMin', width: 80, align: 'left' };
  944. cols.push(collast);
  945. if (data.length > 0 && data[0].ColCaption != null) {
  946. debugger;
  947. DateList = data;
  948. if (SJKSumNum == 0) {
  949. SJKSumNum = data.length;
  950. }
  951. for (var i = 0; i < data.length; i++) {
  952. var ColCaption = data[i].ColCaption;
  953. var ColFiledName = data[i].ColFiledName;
  954. var obj = new Array();
  955. obj = {
  956. label: ColCaption,
  957. name: ColFiledName,
  958. width: 150,
  959. align: "center",
  960. sortable: false,
  961. editable: true,
  962. editrules: { number: true }
  963. }
  964. cols.push(obj);
  965. _ColCaption.push(ColCaption);
  966. _ColFiledName.push(ColFiledName);
  967. }
  968. };
  969. if (data.length == 0) {
  970. for (var i = 1; i < SumNum; i++) {
  971. debugger;
  972. var ColCaption = "实际值" + i;
  973. var ColFiledName = "绑定" + i;
  974. var obj = new Array();
  975. obj = {
  976. label: ColCaption,
  977. name: ColFiledName,
  978. width: 80,
  979. align: "center",
  980. sortable: false,
  981. editable: true,
  982. editrules: { number: true }
  983. }
  984. cols.push(obj);
  985. _ColCaption.push(ColCaption);
  986. _ColFiledName.push(ColFiledName);
  987. }
  988. }
  989. if (data.length > 0) {
  990. for (var i = data.length + 1; i <= SJKSumNum; i++) {
  991. debugger;
  992. var ColCaption = "实际值" + i;
  993. var ColFiledName = "绑定" + i;
  994. var obj = new Array();
  995. obj = {
  996. label: ColCaption,
  997. name: ColFiledName,
  998. width: 80,
  999. align: "center",
  1000. sortable: false,
  1001. editable: true,
  1002. editrules: { number: true }
  1003. }
  1004. cols.push(obj);
  1005. _ColCaption.push(ColCaption);
  1006. _ColFiledName.push(ColFiledName);
  1007. }
  1008. }
  1009. var collast = { label: '抽检数量', name: 'SamplingQuantity', width: 80, align: 'left' };
  1010. cols.push(collast);
  1011. var collast = { label: "允许不良数", name: "EATTRIBUTE1", width: 100, align: 'left' };
  1012. cols.push(collast);
  1013. var collast = { label: '不良数', name: 'UnqualifiedQuantity', width: 150, align: 'left', editable: true, editrules: { number: true } };
  1014. cols.push(collast);
  1015. var collast = { label: '结论', name: 'Result', width: 150, align: 'left', editable: false };
  1016. cols.push(collast);
  1017. var collast = {
  1018. label: '不良原因',
  1019. name: 'BadReason',
  1020. width: 120,
  1021. align: 'left',
  1022. editable: true, // 允许编辑
  1023. editrules: { required: false }, // 设为非必填
  1024. editoptions: {
  1025. placeholder: "可选填"
  1026. }
  1027. };
  1028. cols.push(collast);
  1029. var collast = { label: '备注', name: 'EATTRIBUTE30', width: 120, align: 'left', editable: true };
  1030. cols.push(collast);
  1031. _Clos = cols;
  1032. }
  1033. });
  1034. _LW = new Array();
  1035. AfterLW = new Array();
  1036. var $gridList = $("#gridList");
  1037. if ($gridList.length > 0) {
  1038. try {
  1039. var rowIds = $gridList.getDataIDs();
  1040. for (var i = 0; i < rowIds.length; i++) {
  1041. if (_ColCaption.length > 0) {
  1042. for (var j = 0; j < _ColCaption.length; j++) {
  1043. var filedKey = _ColFiledName[j];
  1044. try {
  1045. var filedValue = $gridList.jqGrid('getCell', rowIds[i], filedKey);
  1046. } catch (e) {
  1047. var cellElem = $gridList.find("#" + rowIds[i] + "_" + filedKey);
  1048. var filedValue = cellElem.text() || cellElem.val() || "";
  1049. }
  1050. _LW.push({
  1051. ID: rowIds[i],
  1052. FiledNamekey: filedKey,
  1053. FiledNamevalue: filedValue
  1054. });
  1055. }
  1056. }
  1057. }
  1058. } catch (e) {
  1059. console.log("删除时缓存数据:", e);
  1060. }
  1061. }
  1062. if (SumNum > 1) SumNum = SumNum - 1;
  1063. if (SJKSumNum > 1) SJKSumNum = SJKSumNum - 1;
  1064. Getcol();
  1065. gridList();
  1066. }
  1067. //导入
  1068. function btn_Introduction() {
  1069. debugger;
  1070. $("#FileUp").click();
  1071. }
  1072. function btn_UPload() {
  1073. $("#FileUp").click();
  1074. }
  1075. function btnUpLoad(up) {
  1076. var form = new FormData(document.getElementById("form1"));
  1077. var lot = "";
  1078. if (JYID == "" || JYID == "null") {
  1079. lot = LotNo;
  1080. }
  1081. else {
  1082. lot = JYID;
  1083. }
  1084. debugger;
  1085. $.ajax({
  1086. url: "/DHAY/ICSRCVIQCs/UploadFile?LotNo=" + lot + "&" + Math.random(),
  1087. type: "post",
  1088. data: form,
  1089. contentType: false,
  1090. processData: false,
  1091. success: function (data) {
  1092. debugger;
  1093. if (data == "导入成功" || data == true) {
  1094. Getcol();
  1095. gridList();
  1096. alert("导入成功");
  1097. }
  1098. else {
  1099. alert(data);
  1100. }
  1101. },
  1102. error: function (aa) {
  1103. alert("导入失败:" + aa);
  1104. }
  1105. });
  1106. }
  1107. // 公共方法:重新判断所有实际值是否超上下限,并设置对应文字颜色
  1108. function reSetActualValueColor() {
  1109. debugger;
  1110. var obj_Item = $("#gridList");
  1111. var rowIds_Item = obj_Item.getDataIDs();
  1112. if (rowIds_Item.length > 0) {
  1113. for (var i = 0; i < rowIds_Item.length; i++) {
  1114. var RowData_Item1 = obj_Item.getRowData(rowIds_Item[i]);
  1115. var SetValueMax = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "SetValueMax"));
  1116. var SetValueMin = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, "SetValueMin"));
  1117. for (var j = 0; j < _ColFiledName.length; j++) {
  1118. var result = Number($("#gridList").jqGrid("getCell", RowData_Item1.ID, _ColFiledName[j]));
  1119. if (isNaN(result)) {
  1120. continue;
  1121. }
  1122. if (result >= SetValueMin && result <= SetValueMax) {
  1123. $("#gridList").jqGrid('setCell', RowData_Item1.ID, _ColFiledName[j], '', { color: 'black' });
  1124. } else {
  1125. $("#gridList").jqGrid('setCell', RowData_Item1.ID, _ColFiledName[j], '', { color: 'red' });
  1126. }
  1127. }
  1128. }
  1129. }
  1130. }
  1131. // 调试函数:查看当前表格数据
  1132. function debugData() {
  1133. debugger;
  1134. var obj_Item1 = $("#gridList");
  1135. var rowIds_Item1 = obj_Item1.getDataIDs();
  1136. var obj_Item2 = $("#gridList1");
  1137. var rowIds_Item2 = obj_Item2.getDataIDs();
  1138. console.log("=== 定量检验区数据 ===");
  1139. for (var i = 0; i < rowIds_Item1.length; i++) {
  1140. var rowData = obj_Item1.getRowData(rowIds_Item1[i]);
  1141. console.log("行" + (i + 1) + ":", rowData);
  1142. console.log("不良原因值:", rowData.BadReason);
  1143. console.log("数据类型:", typeof rowData.BadReason);
  1144. }
  1145. console.log("=== 定性检验区数据 ===");
  1146. for (var i = 0; i < rowIds_Item2.length; i++) {
  1147. var rowData = obj_Item2.getRowData(rowIds_Item2[i]);
  1148. console.log("行" + (i + 1) + ":", rowData);
  1149. console.log("不良原因值:", rowData.BadReason);
  1150. console.log("数据类型:", typeof rowData.BadReason);
  1151. }
  1152. $.modalAlert("数据已输出到控制台,请按F12查看", "info");
  1153. }
  1154. </script>
  1155. <form id="form1">
  1156. <div class="topPanel" style="height:15px">
  1157. <div class="toolbar">
  1158. <div class="btn-group">
  1159. <input id="FileUp" name="FileUp" type="file" style="display:none;" accept=".csv, application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" onchange="btnUpLoad(this)" />
  1160. <a id="NF-Introduction" authorize="yes" class="btn btn-primary dropdown-text" onclick="btn_UPload()">导入</a>
  1161. <!-- 添加调试按钮 -->
  1162. <a class="btn btn-warning dropdown-text" onclick="debugData()">调试数据</a>
  1163. </div>
  1164. </div>
  1165. </div>
  1166. <div style="padding-top: 20px; margin-right: 20px;">
  1167. <div class="ibox-title">
  1168. 主表
  1169. </div>
  1170. <table class="form">
  1171. <tr>
  1172. <td style="text-align:right;"><label class="lglabel" for="txt_InvCode">条码批次</label>:</td>
  1173. <td>
  1174. <div class="input-group">
  1175. <input id="txt_Lot" type="text" class="form-control" style="width: 100px;" readonly="readonly">
  1176. </div>
  1177. </td>
  1178. <td style="width:20px"></td>
  1179. <td style="text-align:right;"><label class="lglabel" for="txt_RulesCode">条码数量</label>:</td>
  1180. <td>
  1181. <div class="input-group">
  1182. <input id="txt_LotQty" type="text" class="form-control" style="width: 100px;" readonly="readonly">
  1183. </div>
  1184. </td>
  1185. <td style="width:20px"></td>
  1186. <td style="text-align:right;"><label class="lglabel" for="txt_RulesName">检验属性</label>:</td>
  1187. <td colspan="3">
  1188. <div class="input-group">
  1189. <input id="txt_RulesType" type="text" class="form-control" style="width: 100px;" readonly="readonly">
  1190. </div>
  1191. </td>
  1192. </tr>
  1193. <tr></tr>
  1194. <tr>
  1195. <td style="text-align:right;"><label class="lglabel" for="txt_InvCode">存货代码</label>:</td>
  1196. <td>
  1197. <div class="input-group">
  1198. <input id="txt_InvCode" type="text" class="form-control" style="width: 100px;" readonly="readonly">
  1199. </div>
  1200. </td>
  1201. <td style="width:20px"></td>
  1202. <td style="text-align:right;"><label class="lglabel" for="txt_RulesCode">存货名称</label>:</td>
  1203. <td>
  1204. <div class="input-group">
  1205. <input id="txt_InvName" type="text" class="form-control" style="width: 100px;" readonly="readonly">
  1206. </div>
  1207. </td>
  1208. <td style="width:20px"></td>
  1209. <td style="text-align:right;"><label class="lglabel" for="txt_RulesName">规格型号</label>:</td>
  1210. <td colspan="3">
  1211. <div class="input-group">
  1212. <input id="txt_InvStd" type="text" class="form-control" style="width: 100px;" readonly="readonly">
  1213. </div>
  1214. </td>
  1215. </tr>
  1216. <tr></tr>
  1217. <tr>
  1218. <td style="text-align:right;"><label class="lglabel" for="txt_badCount">总不良数</label>:</td>
  1219. <td>
  1220. <div class="input-group">
  1221. <input id="txt_badCount" type="text" class="form-control" style="width: 100px;" oninput="value=value.replace(/[^\d]/g,'')">
  1222. </div>
  1223. </td>
  1224. <td style="width:20px"></td>
  1225. <td style="text-align:right;"><label class="lglabel" for="txt_specialPicks">特采数量</label>:</td>
  1226. <td>
  1227. <div class="input-group">
  1228. <input id="txt_specialPicks" type="text" class="form-control" value="0" style="width: 100px;" oninput="value=value.replace(/[^\d]/g,'')">
  1229. </div>
  1230. </td>
  1231. <td style="width:20px"></td>
  1232. <td style="text-align:right;"><label class="lglabel" for="txt_filtering">上线筛选数量</label>:</td>
  1233. <td>
  1234. <div class="input-group">
  1235. <input id="txt_filtering" type="text" class="form-control" style="width: 100px;" oninput="value=value.replace(/[^\d]/g,'')">
  1236. </div>
  1237. </td>
  1238. <td style="text-align:right;"><label class="lglabel" for="txt_specialNumber">特采单号</label>:</td>
  1239. <td>
  1240. <div class="input-group">
  1241. <input id="txt_specialNumber" type="text" class="form-control" style="width: 100px;">
  1242. </div>
  1243. </td>
  1244. </tr>
  1245. <tr>
  1246. <td style="text-align:right;"><label class="lglabel" for="txt_result">检测结果</label>:</td>
  1247. <td>
  1248. <div class="input-group">
  1249. <input id="txt_result" type="text" class="form-control" style="width: 100px;" value="OK" oninput="value=value.replace(/[^\d]/g,'')" readonly="readonly">
  1250. </div>
  1251. </td>
  1252. <td style="width:20px"></td>
  1253. <td style="text-align:right;"><span style="color:red">*</span><label class="lglabel" for="txt_manhours">工时</label>:</td>
  1254. <td>
  1255. <div class="input-group">
  1256. <input id="txt_manhours" type="text" class="form-control required" value="0" style="width: 100px;" oninput="value=value.replace(/[^\d.]/g,'').replace(/\.{2,}/g,'.').replace(/^\./g,'').replace(/(\.\d*)\./g,'$1')">
  1257. </div>
  1258. </td>
  1259. <td style="width:20px"></td>
  1260. <td style="text-align:right;"><label class="lglabel" for="txt_rejections">拒收数量</label>:</td>
  1261. <td>
  1262. <div class="input-group">
  1263. <input id="txt_rejections" type="text" class="form-control" value="0" style="width: 100px;" oninput="value=value.replace(/[^\d]/g,'')">
  1264. </div>
  1265. </td>
  1266. <td style="text-align:right;"><label class="lglabel" for="txt_otherNumber">其它数量</label>:</td>
  1267. <td>
  1268. <div class="input-group">
  1269. <input id="txt_otherNumber" type="text" class="form-control" value="0" style="width: 100px;">
  1270. </div>
  1271. </td>
  1272. </tr>
  1273. </table>
  1274. </div>
  1275. </form>
  1276. <div class="ibox-title">
  1277. 定量检验区:
  1278. </div>
  1279. <div class="gridPanel2">
  1280. <div id="gridPager">
  1281. <label class="radio-inline">
  1282. <a style="margin-left:3px;" class="btn btn-next" onclick="AddRows_ColorFastness(); return false;"><i class="fa fa-plus" style="margin-right:5px"></i>新增</a>
  1283. </label>
  1284. <label class="radio-inline">
  1285. <a style="margin-left:3px;" class="btn btn-next" onclick="DelRows_ColorFastness(); return false;"><i class="fa fa-minus" style="margin-right:5px"></i>删除</a>
  1286. </label>
  1287. </div>
  1288. <div class="gridPanel" id="gridPanel">
  1289. <table id="gridList"></table>
  1290. </div>
  1291. </div>
  1292. <div class="ibox-title" style="height: 30px;">
  1293. 定性检验区:
  1294. </div>
  1295. <div class="gridPanel1">
  1296. <div class="gridPanel1" id="gridPanel1">
  1297. <table id="gridList1"></table>
  1298. </div>
  1299. </div>