Exception.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. var acceptClick;
  2. var selectBomInfo;
  3. var calQty;
  4. var BillBomInfo = [];
  5. var keyValue = request('keyValue');
  6. var bootstrap = function ($, learun) {
  7. "use strict";
  8. var classnames = ['yellowCircle'];
  9. var reg = /^(\-|\+)?\d+(\.\d+)?$/;
  10. var regex = /^[1-9]\d*$/;
  11. const StampChildTypes = ["WS34芯股--异常", "WS18--异常", "WS50--异常", "WS09--异常"];
  12. var selectedRow = learun.frameTab.currentIframe().selectedRow;
  13. var page = {
  14. init: function () {
  15. page.bind();
  16. page.initData();
  17. },
  18. bind: function () {
  19. // 设置小圆圈的点击事件
  20. //$('.circle').click(function () {
  21. // $(this).toggleClass('selectedactive');
  22. //});
  23. for (var i = 0; i < StampChildTypes.length; i++) {
  24. let id = i + 1;
  25. $("#StampChildType").append($("<option value='" + id + "'>" + StampChildTypes[i] + "</option>"));
  26. }
  27. $("#StampChildType").on('change', function () {
  28. for (var i = 0; i < StampChildTypes.length; i++) {
  29. let id = i + 1;
  30. if ($(this).val() == id) {
  31. $("#StampChildType" + id).show();
  32. }
  33. else {
  34. $("#StampChildType" + id).hide();
  35. }
  36. }
  37. });
  38. $("#StampChildType").val(1).change();
  39. // 设置小圆圈的点击事件
  40. $('.clickcircle').click(function () {
  41. //for (var i = 0; i < classnames.length; i++) {
  42. // if ($(this).attr('class').indexOf(classnames[i]) >= 0) {
  43. // $(this).removeClass(classnames[i]);
  44. // $(this).addClass('selectedactive');
  45. // }
  46. //}
  47. $(this).toggleClass(classnames[0]);
  48. });
  49. },
  50. initData: function () {
  51. if (!!keyValue) {
  52. learun.httpAsync('GET', top.$.rootUrl + '/FJManager/BillBomSet/GetBillBomsetinfo', { id: keyValue }, function (res) {
  53. if (res.code > 0) {
  54. BillBomInfo = res.data;
  55. $('#form').lrSetFormData(res.data);
  56. $("#StampChildType").val(BillBomInfo.StampChildType).change();
  57. $("#StampChildType" + BillBomInfo.StampChildType).show();
  58. for (var i = 0; i < BillBomInfo.Bomsetinfos.length; i++) {
  59. var item = BillBomInfo.Bomsetinfos[i];
  60. $("#StampChildType" + BillBomInfo.StampChildType).children().each(function () {
  61. var id = $(this).text();
  62. if (item.XYNo == id) {
  63. $(this).removeClass('selectedactive');
  64. $(this).addClass(classnames[item.CategoryId]);
  65. }
  66. });
  67. //$("#allcontainer > div").children().each(function () {
  68. // var id = $(this).text();
  69. // if (item.XYNo == id) {
  70. // $(this).removeClass('selectedactive');
  71. // $(this).addClass(classnames[item.CategoryId]);
  72. // }
  73. //});
  74. }
  75. }
  76. });
  77. }
  78. }
  79. };
  80. // 保存数据
  81. acceptClick = function (callBack) {
  82. if (!$('#form').lrValidform()) {
  83. return false;
  84. }
  85. var postData = $('#form').lrGetFormData();
  86. postData.StampChildType = $("#StampChildType").val();
  87. var setInfos = [];
  88. //$("#allcontainer > div").children().each(function () {
  89. $("#StampChildType" + postData.StampChildType).children().each(function () {
  90. for (var i = 0; i < classnames.length; i++) {
  91. var setinfo = {};
  92. if ($(this).attr('class').indexOf(classnames[i]) >= 0) {
  93. setinfo["XYNo"] = $(this).text();
  94. setinfo["CategoryId"] = i;
  95. setinfo["IsEmpty"] = 0;
  96. setInfos.push(setinfo);
  97. }
  98. }
  99. });
  100. if (!$('#form').lrValidform()) {
  101. return false;
  102. }
  103. if (setInfos.length == 0) {
  104. learun.alert.error('请选择跺型编号。');
  105. return false;
  106. }
  107. postData.ProMaterCode = '';
  108. postData.HWCountQty = 0;
  109. postData.ProCode = '';
  110. postData.BomCode = '';
  111. postData.LayerCountQty = 1;
  112. postData.Category = 3;
  113. postData.StampType = 6;
  114. postData.TpTypeCode = '2';
  115. postData.TotalQty = $("#StampChildType" + postData.StampChildType + " .clickcircle").length;
  116. if (postData.StampChildType == '4') {
  117. postData.TpTypeCode = '1';
  118. }
  119. postData.Bomsetinfos = setInfos;
  120. $.lrSaveForm(top.$.rootUrl + '/FJManager/BillBomSet/SaveExceptionForm?keyValue=' + keyValue, postData, function (res) {
  121. // 保存成功后才回调
  122. if (!!callBack) {
  123. callBack();
  124. }
  125. });
  126. };
  127. page.init();
  128. }