斯瑞奇mes后端
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.

122 lines
3.7 KiB

3 years ago
  1. var site = $("#current_site").val();
  2. var defectList=[];
  3. //页面初始化
  4. $(function(){
  5. // 初始化光标
  6. $("#seqNo_scan").focus();
  7. });
  8. //为物料号绑定一个失去焦点事件
  9. $("#seqNo_scan").bind("keydown",function(event) {
  10. if (event.keyCode == 13) {
  11. var seqNo = $(this).val().trim();
  12. if(seqNo == null || seqNo == ""){
  13. layer.msg("派工单号不能为空!",{
  14. offset:['20%','30%'],
  15. });
  16. $("#seqNo_scan").val("");
  17. $("#seqNo_scan").focus();
  18. return false;
  19. }
  20. scanSeqNo(seqNo);
  21. }
  22. });
  23. function doScanSeqNo() {
  24. var seqNo = $("#seqNo_scan").val();
  25. if(seqNo == null || seqNo == ""){
  26. layer.msg("派工单号不能为空!",{
  27. offset:['20%','30%'],
  28. });
  29. $("#seqNo_scan").val("");
  30. $("#seqNo_scan").focus();
  31. return false;
  32. }
  33. scanSeqNo(seqNo);
  34. }
  35. function scanSeqNo(seqNo) {
  36. var jsonData = {
  37. site: site,
  38. seqNo: seqNo,
  39. }
  40. $.ajax({
  41. url: "/schedule/scanSeqNo",
  42. contentType: 'application/json',
  43. type: "POST",
  44. data: JSON.stringify(jsonData),//你的formid
  45. dataType: "JSON",
  46. async: false,
  47. beforeSend: function (request) {
  48. request.setRequestHeader("token", $.cookie("token"));
  49. },
  50. success: function (data) {
  51. if(data.code===0){
  52. $("#seqNo").val($("#seqNo_scan").val());
  53. $("#orderNo").val(data.row.orderNo);
  54. $("#scheduleDate").val(data.row.sScheduledDate);
  55. $("#partNo").val(data.row.partNo);
  56. $("#partDesc").val(data.row.partDesc);
  57. $("#shiftNo").val(data.row.sShiftNo);
  58. $("#scheduleQty").val(data.row.qtyRequired);
  59. $("#unApproveQty").val(0);
  60. $("#operatorId").val(data.row.operatorId);
  61. }else{
  62. layer.msg(data.msg,{
  63. offset:['20%','30%'],
  64. });
  65. $("#seqNo_scan").val("");
  66. $("#seqNo_scan").focus();
  67. }
  68. },
  69. error: function (data) {
  70. var responseText = data.responseText;
  71. var json_str = JSON.parse(responseText);
  72. var status = json_str.status;
  73. var message = json_str.message;
  74. //判断是否是session超时
  75. if (403 == status) {
  76. layer.alert(message, function () {
  77. window.location.href = "/login";
  78. });
  79. }
  80. layer.closeAll('loading');
  81. }
  82. })
  83. }
  84. function defectModal(){
  85. }
  86. function defectAdd() {
  87. let id= Math.floor(Math.random() *1000)
  88. let str = '<tr id = '+id+'>' +
  89. '<th class="" style="text-align:center;background-color: #ffff;" width="25%">' +
  90. '<span>'+"不良代码号"+'</span></th>' +
  91. '<th class="" style="text-align:center;background-color: #ffff;" width="25%">' +
  92. '<span>'+"不良原因啊"+'</span></th>' +
  93. '<th class="" style="text-align:center;background-color: #ffff;" width="25%">' +
  94. '<span>'+id+'</span></th>' +
  95. '<th class="" style="text-align:center;background-color: #ffff;" width="25%">' +
  96. '<button onclick="removeColomn(\''+id+'\')">删除</button></th>' +
  97. '</tr>';
  98. defectList.push({
  99. id:id,
  100. desc:'不良代码号',
  101. })
  102. $("#defect_table").append(str);
  103. }
  104. //不良原因删除
  105. function removeColomn(id){
  106. tableDatailRemo(id);
  107. defectList = defectList.filter(item => item.id != id );
  108. layer.msg("移除成功!");
  109. }
  110. // 移除table
  111. function tableDatailRemo(id){
  112. $table=$("#defect_table tr");
  113. $("tr[id='" + id + "']").remove();
  114. }