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

138 lines
4.6 KiB

10 months ago
  1. //初始化
  2. $(function () {
  3. });
  4. //卷号bind 回车事件
  5. $("#rollNo").bind("keydown", function (event) {
  6. if (event.keyCode == 13) {
  7. var rollNo = $("#rollNo").val();
  8. if (null == rollNo || rollNo == "") {
  9. layer.alert("卷号不能为空!");
  10. } else {
  11. getRollInfo(rollNo);
  12. return false;
  13. }
  14. }
  15. return true;
  16. });
  17. var rollList = []
  18. var rollInfoData = {}
  19. function getRollInfo(rollNo) {
  20. let roll = {
  21. "rollno": rollNo,
  22. // "statusDb": "I"
  23. }
  24. $.ajax({
  25. url: "/finishedProduct/crollinfo/outRollno",
  26. contentType: 'application/json',
  27. type: "POST",
  28. data: JSON.stringify(roll),
  29. dataType: "json",
  30. beforeSend: function (request) {
  31. request.setRequestHeader("token", $.cookie("token"));
  32. },
  33. success: function (data) {
  34. if (data.code == 0) {
  35. rollInfoData = data.cRollinfo;
  36. if (rollInfoData) {
  37. if(rollInfoData.statusDb != 'I'){
  38. layer.alert("该卷的状态为: "+rollInfoData.status);
  39. $("#rollNo").val('');
  40. $("#rollNo").focus();
  41. return;
  42. }
  43. var rollBool = rollList.some(item => item.rollno === rollInfoData.rollno)
  44. if (rollBool) {
  45. layer.alert('该卷号已存在');
  46. $("#rollNo").val('');
  47. $("#rollNo").focus();
  48. return
  49. }
  50. rollList.push(rollInfoData)
  51. var str = '<tr id = ' + rollInfoData.rollno + '>' +
  52. '<th class="" style="text-align:center;background-color: #ffff;">' +
  53. '<button data-toggle="modal" onclick="removeRoll(\'' + rollInfoData.rollno + '\')" style="padding: 3px 10px;">' +
  54. '删除</button>' +
  55. '<th class="" style="text-align:center;background-color: #ffff;">' +
  56. '<span>' + rollInfoData.rollno + '</span></th>' +
  57. '<th class="" style="text-align:center;background-color: #ffff;">' +
  58. '<span>' + rollInfoData.partno + '</span></th>' +
  59. '<th class="" style="text-align:center;background-color: #ffff;">' +
  60. '<span>' + rollInfoData.rollqty + '</span></th>' +
  61. '</tr>';
  62. $("#roll_table").append(str);
  63. $("#rollNo").val('');
  64. $("#rollNo").focus();
  65. } else {
  66. layer.alert('该卷不存在');
  67. $("#rollNo").val('');
  68. $("#rollNo").focus();
  69. }
  70. } else {
  71. layer.alert('该卷不存在');
  72. }
  73. if (data.code == 500) {
  74. layer.alert(data.msg);
  75. }
  76. if (data.code == 401) {
  77. layer.alert('用户身份已过期');
  78. window.location.href = "/login"
  79. }
  80. },
  81. error: function (data) {
  82. }
  83. });
  84. }
  85. // 删除扫描内容
  86. function removeRoll(rollNo) {
  87. $table = $("#roll_table tr");
  88. $("tr[id='" + rollNo + "']").remove();
  89. rollList = rollList.filter(item => item.rollno != rollNo)
  90. $("#rollNo").val('');
  91. $("#rollNo").focus();
  92. }
  93. // 确认其它出库
  94. function otherOutbound() {
  95. if(rollList.length == 0){
  96. layer.alert("请扫描卷在出库")
  97. return
  98. }
  99. rollList.map( item => {
  100. item.status = "已耗用"
  101. item.statusDb = "D"
  102. // todo 是否需要同步
  103. // item.synchronizedflag="Y"
  104. return item;
  105. })
  106. $.ajax({
  107. url: "/finishedProduct/crollinfo/batchRollUpdateStatus",
  108. contentType: 'application/json',
  109. type: "POST",
  110. data: JSON.stringify(rollList),
  111. dataType: "json",
  112. beforeSend: function (request) {
  113. request.setRequestHeader("token", $.cookie("token"));
  114. },
  115. success: function (data) {
  116. if (data.code == 0) {
  117. $("#rollNo").val('');
  118. $("tr[id]").remove();
  119. rollList = []
  120. layer.alert('出库成功');
  121. } else {
  122. layer.alert('出库失败');
  123. }
  124. if (data.code == 401) {
  125. layer.alert('用户身份已过期');
  126. window.location.href = "/login"
  127. }
  128. },
  129. error: function (data) {
  130. }
  131. });
  132. }