南骏 池
2024-12-14 a6e5d667123496f0129c8e7c3d930c46e7a46ba1
js/CangKuManage_js/GS_HBJCLLD_NEW.js
@@ -14,9 +14,9 @@
//初始化,默认焦点
mui.plusReady(function(){   
   app.init();
   mui("#txtGD")[0].focus();
   mui("#HBLLD")[0].focus();
   console.log("连接测试!");
   //initBluetooth();
   initBluetooth();
   //SetBillNo();
   $('#info').height($(window).height()- $("#row001").height() - $("#div001").height()- $("#div002").height() - 70);
});      
@@ -103,75 +103,39 @@
    tbody.appendChild(tr);
   $(function() {
     // 将标题行的背景颜色设置为灰色
     $('tr:first-child th').css('background-color', 'gray');
     // 遍历表格的每一行,除了标题行
     $('tr').each(function() {
       // 获取实盘数量单元格的值
       var $cell = $(this).find('td:nth-child(3)');
       var quantity = parseInt($cell.text());
       // 判断实盘数量是否为0
       if (quantity == 0) {
         // 设置行的背景颜色为黄色
         $(this).css('background-color', 'greenyellow');
       }else
      {
         $(this).css('background-color', 'beige');
      }
     });
   });
  }
};
//扫描指令工单处理方法
function GetBarInfoDGD(){
    console.log(2);
      if(event.keyCode == 13) {
             //如果未输入条码,跳出方法
            if($("#DGD").val() == "") {
               $("#DGD").focus();
               playerAudio("NG");
               mui.toast("请先输入工单!");
               return;
            }
      $.ajax({
        url: app.API_URL_HEADER + "/XKYDHD/GetGSDGD",
       data: {
          DGD: $("#DGD").val()
            },
       DataType: "json",
       type: "post",
       async: false,
        success: function(data){
          if (data.status === 0) {
                       console.log(data);
                     /// console.log(JSON.stringify(response));
            var selectElement = document.getElementById('txtGD');
            selectElement.innerHTML = "";
            matterTable = data.data.matterTable;
            for (var i = 0; i < matterTable.length; i++) {
              var option = document.createElement("option");
              option.value = matterTable[i]["DAA001"];
              option.text = matterTable[i]["DAA001"];
              selectElement.appendChild(option);
            }
            selectElement.value = matterTable[0]["DAA001"];
                  GETGDINFO_SX();
          } else {
            playerAudio("NG");
            mui.toast("失败!"+data.message);
            alert("获取数据异常:" + data.message);
          }
        },
        error: function(xhr, type, errorThrown) {
          mui.toast("获取数据异常:" + JSON.stringify(errorThrown));
          alert("获取数据异常:");
        }
      });
             //用户ID
             // var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
               //var user_id =$("#txtBillNo").val(); //currentSession.user_id;
               //var  mun=$("#txtSL").val();
            //GETGDINFO_SX();
      //      var user_id = "admin";
          }
};
function GetBarInfoDGDSS(){
    console.log(2);
      if(event.keyCode == 13) {
             //如果未输入条码,跳出方法
            if($("#DGD").val() == "") {
               $("#DGD").focus();
            if($("#HBLLD").val() == "") {
               $("#HBLLD").focus();
               playerAudio("NG");
               mui.toast("请先输入工单!");         
               return;
@@ -179,7 +143,7 @@
      $.ajax({
        url: app.API_URL_HEADER + "/XKYDHD/GetGSDGDSS",
       data: {
          DGD: $("#DGD").val(),
          DGD: $("#HBLLD").val(),
          ITEM: $("#DAB020").val()
            },
       DataType: "json",
@@ -190,7 +154,7 @@
          if (data.status === 0) {
                       console.log(data);
                     /// console.log(JSON.stringify(response));
            var selectElement = document.getElementById('txtGD');
            var selectElement = document.getElementById('HBLLD');
            selectElement.innerHTML = "";
            matterTable = data.data.matterTable;
      
@@ -229,7 +193,9 @@
//扫描指令工单处理方法
function GetBarInfoGD(){
     if (event.keyCode == 13) {
   GETGDINFO_SX();
   }
};
@@ -240,7 +206,7 @@
      url: app.API_URL_HEADER + "/XKYDHD/GetBarInfoHBGD",
         
      data: {
         DAA001: $("#DGD").val(),
         DAA001: $("#HBLLD").val(),
      },
      DataType: "json",
      type: "post",
@@ -294,7 +260,7 @@
             
          data: {
             DAB001: $("#DAB001").val(),
            DAA001: $("#DGD").val(),
            DAA001: $("#HBLLD").val(),
            DEPOT: $("#DEPOT").val(),
            DEPOTSE: $("#DEPOTSE").val(),
             logID: user_id,//Admin //先写死,便于调试
@@ -317,14 +283,13 @@
             } else {
                matterTable = data.data.matterTable;
               $("#txtSL").val("");//先清空一下数据源
               $("#FLSL").val("");//先清空一下数据源
               $("#SFSL").val("");//先清空一下数据源
               $("#txtSL").val(data.data.txtSL);//填入条码数量
               $("#DFSL").val(data.data.FLSL);//填入发料数量
               $("#JCSL").val(data.data.JCNUM);//填入发料数量
               $("#DAB020").val(data.data.DAB020);//填入物料编码
               $("#model").val(data.data.MSG);//填入物料编码
               //mui("#FLSL")[0].focus();
             }
          },
@@ -339,32 +304,42 @@
// 扫描条码处理方法
 $('#doSure').click(function is_CreateSCLLD() {
// console.log(223);
 // console.log(FLSLValue);
      if($("#SFSL").val() == "") {
         $("#SFSL").focus();
         playerAudio("NG");
         mui.toast("请输入实发数量!!!");
         return;
      }
   var txtSLValue = parseFloat($("#txtSL").val());
    var FLSLValue = parseFloat($("#SFSL").val());
    // 比较数值大小
   CreateSCLLD();
   //GetBarInfoDGDSS();
   GETGDINFO_SX();
//     if (txtSLValue <= FLSLValue) {
//       // txtSL的值小于FLSL的值
// //     console.log("生成领料单");
//      CreateSCLLD();
//      GETGDINFO_SX();
//     } else if (txtSLValue > FLSLValue) {
//       // txtSL的值大于FLSL的值
//       //console.log("确认是否拆分领料");
//       mui.confirm('是否拆分该条码?', '请确认', ['确认', '取消'], function(e) {
//         if (e.index === 0) {
//          PrintSplit();
//         GETGDINFO_SX();
//           console.log("刷新成功!");
//         } else {
//           // 用户点击了取消按钮
//         mui("#FLSL")[0].focus();
//         }
//       });
   // }
    if (txtSLValue <= FLSLValue) {
      // txtSL的值小于FLSL的值
     CreateSCLLD();
        GETGDINFO_SX();
     console.log("生成领料单");
     // CreateSCLLD();
     // GETGDINFO_SX();
    } else if (txtSLValue > FLSLValue) {
      // txtSL的值大于FLSL的值
      //console.log("确认是否拆分领料");
      mui.confirm('是否拆分该条码?', '请确认', ['确认', '取消'], function(e) {
        if (e.index === 0) {
         CreateSCLLD_S();
            GETGDINFO_SX();
          console.log("刷新成功!");
        mui("#DAB001")[0].focus();
        $("#DAB001").val("");//先清空一下数据源
        } else {
          // 用户点击了取消按钮
        mui("#SFSL")[0].focus();
        }
      });
    }
});
 
@@ -381,10 +356,11 @@
              data: {
                 DAB001: $("#DAB001").val(),
               DAB020: $("#DAB020").val(),
                DAA001: $("#txtGD").val(),
               FLSL:$("#txtSL").val(),
                DAA001: $("#HBLLD").val(),
               FLSL:$("#SFSL").val(),
               DEPOT:$("#DEPOT").val(),
               DEPOTSE:$("#DEPOTSE").val(),
               STYPE: $("#stype").val(),
                 logID: user_id,//Admin //先写死,便于调试
                 
              },
@@ -404,13 +380,13 @@
                    return;
                 } else {
                   $("#txtSL").val("");//先清空一下数据源
                   $("#FLSL").val("");//先清空一下数据源
                   $("#SFSL").val("");//先清空一下数据源
                  $("#DFSL").val("");//先清空一下数据源
                  $("#JCSL").val("");//先清空一下数据源
    $("#DAB001").val("");//先清空一下数据源
                   // $("#txtSL").val(data.data.txtSL);//填入条码数量
                   // $("#FLSL").val(data.data.FLSL);//填入条码数量
                   mui("#FLSL")[0].focus();
                   mui("#SFSL")[0].focus();
                  playerAudio("OK");
                  mui.toast("领料成功");      
@@ -424,6 +400,76 @@
           });
 };
 
 function CreateSCLLD_S() {
     //用户ID
             var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
            var user_id =currentSession.user_id; //currentSession.user_id;
     //      var user_id = "admin";
     //console.log(1);
            $.ajax({
               url: app.API_URL_HEADER + "/XKYDHD/CreateSCLLDHBJC_S",
               data: {
                  DAB001: $("#DAB001").val(),
                DAB020: $("#DAB020").val(),
                 DAA001: $("#HBLLD").val(),
                FLSL:$("#SFSL").val(),
                DEPOT:$("#DEPOT").val(),
                DEPOTSE:$("#DEPOTSE").val(),
                STYPE: $("#stype").val(),
                  logID: user_id,//Admin //先写死,便于调试
               },
               DataType: "json",
               type: "post",
               async: false,
               //timeout: 15000,
               success: function(data) {
                  console.log(JSON.stringify(data));
                  //console.log(JSON.stringify(data));
                  if(data.status != 0) {
                     playerAudio("NG");
                     mui.alert(data.message,"","",function(){
                       mui("#DAB001")[0].focus();
                      $("#DAB001").val("");
                      $("#txtSL").val("");//先清空一下数据源
                     });
                     return;
                  } else {
                     $("#txtSL").val("");//先清空一下数据源
                     $("#SFSL").val("");//先清空一下数据源
                     $("#DFSL").val("");//先清空一下数据源
                     $("#JCSL").val("");//先清空一下数据源
                     $("#DAB001").val("");//先清空一下数据源
                     mui("#SFSL")[0].focus();
                     playerAudio("OK");
                     mui.toast("领料成功");
                     //console.log(data.data.BARID);
                     console.log("开始打印!!");
                     var str = data.data.BARID.toString();
                     console.log(str); // 将BARID转换为字符串并打印输出
                     printByIds(str);
                     console.log("打印成功!!");
                     playerAudio("OK");
                     mui.toast("领料成功");
                     //initBluetooth();
                  }
               },
               error: function(xhr, type, errorThrown) {
                console.log(2);
                  alert("获取数据异常:" + JSON.stringify(errorThrown));
               }
            });
 };
 function PrintSplit() {
     //用户ID
             var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
@@ -435,8 +481,8 @@
               data: {
                  DAB001: $("#DAB001").val(),
                DAB020: $("#DAB020").val(),
                 DAA001: $("#txtGD").val(),
                FLSL:$("#FLSL").val(),
                 DAA001: $("#HBLLD").val(),
                FLSL:$("#SFSL").val(),
                  logID: user_id,//Admin //先写死,便于调试
                  
               },
@@ -456,11 +502,11 @@
                     return;
                  } else {
                    $("#txtSL").val("");//先清空一下数据源
                    $("#FLSL").val("");//先清空一下数据源
                    $("#SFSL").val("");//先清空一下数据源
     
                    $("#txtSL").val(data.data.txtSL);//填入条码数量
                    $("#FLSL").val(data.data.FLSL);//填入条码数量
                    mui("#FLSL")[0].focus();
                    $("#SFSL").val(data.data.FLSL);//填入条码数量
                    mui("#SFSL")[0].focus();
                   
                  //console.log(data.data.BARID);
                  console.log("开始打印!!");