旭捷内部项目管理系统
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.

188 lines
6.2 KiB

10 months ago
  1. var rollList = []
  2. var rolls = []
  3. // 获取扫描卷
  4. function getRollInfo(rollNo) {
  5. let roll = {
  6. "rollno": rollNo,
  7. // "statusDb": "I"
  8. }
  9. $.ajax({
  10. url: "/finishedProduct/crollinfo/infoRollno",
  11. contentType: 'application/json',
  12. type: "POST",
  13. data: JSON.stringify(roll),
  14. dataType: "json",
  15. beforeSend: function (request) {
  16. request.setRequestHeader("token", $.cookie("token"));
  17. },
  18. success: function (data) {
  19. if (data.code == 0) {
  20. rollInfoData = data.cRollinfo;
  21. if (rollInfoData) {
  22. if(rollInfoData.statusDb != 'I'){
  23. layer.alert("该卷的状态为: "+rollInfoData.status);
  24. $("#rollNo").val('');
  25. $("#rollNo").focus();
  26. return;
  27. }
  28. if (rollList.length > 0){
  29. var partBool = rollList.some(item => item.partno === rollInfoData.partno)
  30. if (!partBool){
  31. layer.alert('不同物料的卷不能进行合并');
  32. return
  33. }
  34. }
  35. var rollBool = rollList.some(item => item.rollno === rollInfoData.rollno)
  36. if (rollBool) {
  37. layer.alert('该卷号已存在');
  38. return
  39. }
  40. rollList.push(rollInfoData)
  41. var str = '<tr id = ' + rollInfoData.rollno + '>' +
  42. '<th class="" style="text-align:center;background-color: #ffff;">' +
  43. '<button data-toggle="modal" onclick="removeRoll(\'' + rollInfoData.rollno + '\')" style="padding: 3px 10px;">' +
  44. '删除</button>' +
  45. '<th class="" style="text-align:center;background-color: #ffff;">' +
  46. '<span>' + rollInfoData.rollno + '</span></th>' +
  47. '<th class="" style="text-align:center;background-color: #ffff;">' +
  48. '<span>' + rollInfoData.rollqty + '</span></th>' +
  49. '</tr>';
  50. $("#roll_table").append(str);
  51. $("#rollno1").val('');
  52. $("#rollno1").focus();
  53. } else {
  54. layer.alert('该卷不存在');
  55. }
  56. } else {
  57. layer.alert('该卷不存在');
  58. }
  59. if (data.code == 401) {
  60. layer.alert('用户身份已过期');
  61. window.location.href = "/login"
  62. }
  63. },
  64. error: function (data) {
  65. }
  66. });
  67. }
  68. // 删除扫描内容
  69. function removeRoll(rollNo) {
  70. $table = $("#roll_table tr");
  71. $("tr[id='" + rollNo + "']").remove();
  72. rollList = rollList.filter(item => item.rollno != rollNo)
  73. $("#rollno1").val('');
  74. $("#rollno1").focus();
  75. }
  76. //物料号bind 回车事件
  77. $("#rollno1").bind("keydown", function (event) {
  78. if (event.keyCode == 13) {
  79. var rollNo = $("#rollno1").val();
  80. if (null == rollNo || rollNo == "") {
  81. layer.alert("卷号不能为空!");
  82. return false;
  83. } else {
  84. getRollInfo(rollNo);
  85. $("#rollno1").val('');
  86. $("#rollno1").focus();
  87. return false;
  88. }
  89. }
  90. return true;
  91. });
  92. // 合卷
  93. function joinRoll() {
  94. if (rollList.length < 2) {
  95. layer.alert("卷的数量要大于等2")
  96. return;
  97. }
  98. $.ajax({
  99. url: "/finishedProduct/crollinfo/joinRoll",
  100. contentType: 'application/json',
  101. type: "POST",
  102. data: JSON.stringify(rollList),
  103. dataType: "json",
  104. beforeSend: function (request) {
  105. request.setRequestHeader("token", $.cookie("token"));
  106. },
  107. success: function (data) {
  108. rollList = []
  109. if (data.code == 0) {
  110. $("#roll_join_table").html('');
  111. layer.alert("合卷成功")
  112. $('#rollno1').val('')
  113. $('#rollno1').focus()
  114. $("#roll_table").html('');
  115. rollList = []
  116. roll = data.newRoll
  117. rolls.push(data.newRoll)
  118. var str = '<tr id = ' + data.newRoll.rollno + '>' +
  119. '<th class="" style="text-align:center;background-color: #ffff;">' +
  120. '<span>' + data.newRoll.rollno + '</span></th>' +
  121. '<th class="" style="text-align:center;background-color: #ffff;">' +
  122. '<span>' + data.newRoll.rollqty + '</span></th>' +
  123. '<th class="" style="text-align:center;background-color: #ffff;">' +
  124. '<button onclick="printRoll(\'' + data.newRoll.rollno + '\')" data-toggle="modal" style="padding: 3px 10px;">' +
  125. '打印标签</button></th>' +
  126. '</tr>';
  127. $("#roll_join_table").append(str);
  128. print(data.newRoll)
  129. }
  130. if (data.code == 401) {
  131. layer.alert('用户身份已过期');
  132. window.location.href = "/login"
  133. }
  134. },
  135. error: function (data) {
  136. }
  137. });
  138. }
  139. function printRoll(){
  140. print(roll);
  141. }
  142. // 打印卷标签
  143. function print(val){
  144. var rollPrintList = []
  145. rollPrintList.push(val)
  146. if (rollPrintList.length <= 0) {
  147. return;
  148. }
  149. $.ajax({
  150. url: "/finishedProduct/crollinfo/rollPrint",
  151. contentType: 'application/json',
  152. type: "POST",
  153. data: JSON.stringify(rollPrintList),
  154. dataType: "json",
  155. beforeSend: function (request) {
  156. request.setRequestHeader("token", $.cookie("token"));
  157. },
  158. success: function (data) {
  159. rollList = []
  160. if (data.code == 0) {
  161. layer.alert("打印成功")
  162. rollPrintList = []
  163. }else {
  164. layer.alert(data.msg)
  165. }
  166. if (data.code == 401) {
  167. layer.alert('用户身份已过期');
  168. window.location.href = "/login"
  169. }
  170. },
  171. error: function (data) {
  172. }
  173. });
  174. }