cdk
2025-04-06 96f89d76286ad12defae0c523ea43bc7580ddb96
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
/**
 * 作者:G98138 黎锋
 * 时间:2018-09-04
 * 描述:库位 绑定
 * 
 * 业务思路:
 * 1. 扫描条码
 *  1.1 非条码库存表的条码, 提示( OK) *
 *    1.2 非待入库条码, 提示( OK) *
 *    1.3 通过条码找到上一次该物料的库位, 作为推荐库位( OK)
 *    注意: 如果勾选了“默认库位”, 且在上一次绑定的库位和当前界面显示的库位一致 , 则直接绑定库位, 不需要再扫描库位 *
 
 * 2. 扫描库位条码 *
 *    2.1 非库位条码, 提示( OK) *
 *    2.2 非该仓库的库位, 提示( OK) *
 */
 
// 全局变量
var billNo = '';
var DH = '';
var i = 0; //计算扫描条码数量
var WLBM = "";//物料编码
var matterTable = null;
 
// mui.ready(function(){
 
//     GetBill();
 
// });    
//初始化,默认焦点
mui.plusReady(function(){
    app.init();
    //GetBill();
    
    $('#info').height($(window).height()- $("#row001").height() - $("#div001").height()- $("#div002").height() - 70);
});        
 
function GetInfoQTCK() {
    $.ajax({
            url: app.API_URL_HEADER + "/XKYDHD/GetBarInfoQTNO",
            data: {
                DBNO:$("#QTNO").val(),
                // DAB001: $("#DAB001").val(),
                // logID: user_id //user_id,//Admin //先写死,便于调试
            },
            DataType: "json",
            type: "post",
            async: false,
            //timeout: 15000,
            success: function(data) {
                
                console.log(JSON.stringify(data));
            if (data.status == 0) {
    
              matterTable = data.data.matterTable;
              populateTable(matterTable);
              $("#DAB001").val("");
               mui("#DAB001")[0].focus();
            } else {
                                
              alert("获取数据异常:" + response.message);
            }
                           
            },
            error: function(xhr, type, errorThrown) {
                alert("获取数据异常:" + JSON.stringify(errorThrown));
            }
        });
    }
function GetBill() {
    console.log(1);
    $.ajax({
        url: app.API_URL_HEADER + "/XKYDHD/GetQTCKNO",
        
        DataType: "json",
        type: "post",
        async: false,
        //timeout: 15000,
    success: function(data) {
            
            console.log(JSON.stringify(data));
        if (data.status == 0) {
                              //console.log(response);
         /// console.log(JSON.stringify(response));
          var selectElementD = document.getElementById('QTNO');
          selectElementD.innerHTML = "";
          matterTable = data.data.matterTable;
                            
                            var option = document.createElement("option");
                            option.value = "";
                            option.text = "请选择单号";
                            selectElementD.appendChild(option);
                            
          for (var i = 0; i < matterTable.length; i++) {
            var option = document.createElement("option");
            option.value = matterTable[i]["QTCK_NO"];
            option.text = matterTable[i]["QTCK_NO"];
            selectElementD.appendChild(option);
          }
                            
        } else {
                            
          alert("获取数据异常:" + response.message);
        }
                       
        },
        error: function(xhr, type, errorThrown) {
            alert("获取数据异常:" + JSON.stringify(errorThrown));
        }
    });
    
    
    //fetchCYSData();
}
 
 
 
 function GetZJDBCK() {
      if(event.keyCode == 13) {
          //如果未输入条码,跳出方法
          if($("#DAB001").val() == "") {
              return;
          }
         
         
                     
          //用户ID
         var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
            //var user_id = currentSession.user_id;
            if($("#txtBillNo").val() == ""){
            var user_id =currentSession.user_id;
            }else{
            var user_id =$("#txtBillNo").val();
            }
 //        var user_id = "admin";
          $.ajax({
              url: app.API_URL_HEADER + "/XKYDHD/GetDBAInfoQTBARCK",
                  
              data: {
               DBNO:$("#QTNO").val(),
               DAB001: $("#DAB001").val(),
               logID: user_id //user_id,//Admin //先写死,便于调试
                  
              },
              DataType: "json",
              type: "post",
              async: false,
              //timeout: 15000,
              success: function(data) {
                  console.log(JSON.stringify(data));
                  if(data.status != 0) {
                     playerAudio("NG");
                      mui.alert(data.message,"","",function(){ 
                          mui("#DAB001")[0].focus();
                         $("#DAB001").val("");
                      });            
                      return;
                  } else {
                    matterTable = data.data.matterTable;
                    $("#DAB002").val(matterTable[0]["ITEMNO"].toString());
                    $("#DAB003").val(matterTable[0]["DBA005"].toString() === null ? 0 : matterTable[0]["DBA005"].toString());
                    $("#FLSL").val(matterTable[0]["QUANTITY"].toString() === null ? 0 : matterTable[0]["QUANTITY"].toString());            
    
                    var DAB003 = parseFloat($("#DAB003").val());
                    var FLSL = parseFloat($("#FLSL").val());
                    var ISEXIST = parseInt(matterTable[0]["ISEXIST"].toString() === null ? 0 : matterTable[0]["ISEXIST"].toString());    
                    // 大于0的表示在表GS_QTWL中,不做限制
                    if (DAB003 <= FLSL || ISEXIST > 0) {
                      // txtSL的值小于FLSL的值
                      //console.log("生成领料单1");
                      CreateZJDBCK();
                      GetInfoQTCK();
                      mui("#DAB001")[0].focus();
                      $("#DAB001").val("");//先清空一下数据源
                      $("#DAB002").val("");//先清空一下数据源
                      $("#DAB003").val("");//先清空一下数据源
                      $("#FLSL").val("");//先清空一下数据源
                    } else{
                        mui("#FLSL")[0].focus();
                    }
                  }
              },
              error: function(xhr, type, errorThrown) {
                  alert("获取数据异常:" + JSON.stringify(errorThrown));
              }
          });
      }
  };
  
  function CreateZJDBCK() {
       //用户ID
     var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
     var user_id =currentSession.user_id; //currentSession.user_id;
     
    $.ajax({
        url: app.API_URL_HEADER + "/XKYDHD/GetBarInfoQTBARCK",
            
        data: {
               DBNO:$("#QTNO").val(),
               DAB001: $("#DAB001").val(),
               logID: user_id //user_id,//Admin //先写死,便于调试
            
        },
        DataType: "json",
        type: "post",
        async: false,
        //timeout: 15000,
        success: function(data) {
            //console.log(JSON.stringify(data));
            if(data.status != 0) {
                playerAudio("NG");
                mui.alert(data.message,"","",function(){ 
                    mui("#DAB001")[0].focus();
                    $("#DAB001").val("");
                    $("#DAB003").val("");//先清空一下数据源
                });            
                return;
            } else {
                $("#DAB003").val("");//先清空一下数据源
                $("#FLSL").val("");//先清空一下数据源
 
                //mui("#FLSL")[0].focus();
 
                playerAudio("OK");
                mui.toast("出库成功");        
 
            }
        },
        error: function(xhr, type, errorThrown) {
            alert("获取数据异常:" + JSON.stringify(errorThrown));
        }
    });
  };
  
  // 扫描条码处理方法
  function is_CreateSCLLD() {
    if (event.keyCode == 13) {
      var DAB003Value = parseFloat($("#DAB003").val());
      var FLSLValue = parseFloat($("#FLSL").val());
  
      // 比较数值大小
      if (DAB003Value <= FLSLValue) {
        // txtSL的值小于FLSL的值
        console.log("生成领料单");
        // CreateSCLLD();
        // GETGDINFO_SX();
      } else if (DAB003Value > FLSLValue) {
        // txtSL的值大于FLSL的值
        //console.log("确认是否拆分领料");
        mui.confirm('是否拆分该条码?', '请确认', ['确认', '取消'], function(e) {
          if (e.index === 0) {
              PrintSplit();
            GetInfoQTCK();
            console.log("刷新成功!");
            mui("#DAB001")[0].focus();
            $("#DAB001").val("");//先清空一下数据源
          } else {
            // 用户点击了取消按钮
            mui("#FLSL")[0].focus();
          }
        });
      }
    }
  };
  
  function PrintSplit() {
       //用户ID
     var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
     var user_id =currentSession.user_id; //currentSession.user_id;
 
    $.ajax({
        url: app.API_URL_HEADER + "/XKYDHD/GetBarInfoQTBARCK_S",
            
        data: {
               DBNO:$("#QTNO").val(),
               DAB001: $("#DAB001").val(),
               logID: user_id, //user_id,//Admin //先写死,便于调试
             SL:$("#FLSL").val()
        },
        DataType: "json",
        type: "post",
        async: false,
        //timeout: 15000,
        success: function(data) {
            //console.log(JSON.stringify(data));
            if(data.status != 0) {
                playerAudio("NG");
                mui.alert(data.message,"","",function(){ 
                    mui("#DAB001")[0].focus();
                    $("#DAB001").val("");
                    $("#DAB003").val("");//先清空一下数据源
                });            
                return;
            } else {
 
                console.log("开始打印!!");
                
                var str = data.data.BARID.toString();
                console.log(str); // 将BARID转换为字符串并打印输出
                //$("#DAB001").val(data.data.NEWBAR.toString());
                printByIds(str);
                console.log("打印成功!!");
                playerAudio("OK");
                mui.toast("拆分成功");
 
            }
        },
        error: function(xhr, type, errorThrown) {
            alert("获取数据异常:" + JSON.stringify(errorThrown));
        }
    });
  };
  
 function populateTable(data) {
     
     console.log(data);
   let tbody = document.querySelector("#myTable tbody");
 
   // 清空表格内容
   tbody.innerHTML = "";
 
   // 循环遍历数据,生成表格行
   for (let i = 0; i < data.length; i++) {
     let tr = document.createElement("tr");
  
     // 创建表格单元格,并将数据填入
     let td1 = document.createElement("td");
     td1.textContent = data[i]["物料名称"];
     tr.appendChild(td1);
 
     let td2 = document.createElement("td");
     td2.textContent = data[i]["物料代码"];
     tr.appendChild(td2);
 
     let td3 = document.createElement("td");
     td3.textContent = data[i]["申请数量"];
     tr.appendChild(td3);
     
     let td4 = document.createElement("td");
     td4.textContent = data[i]["已扫数量"];
     tr.appendChild(td4);
    
    let td5 = document.createElement("td");
    td5.textContent = data[i]["超额管理"];
    tr.appendChild(td5);
 
    let td6 = document.createElement("td");
    td6.textContent = data[i]["推荐仓位"];
    tr.appendChild(td6);
 
     tbody.appendChild(tr);
   }
 };
 
/* 当页面的文本失去焦点时,让其再次获取焦点 */
 
 
/**
 *  @param {出发DOM控件:this} e
 */
//function SetInputFoucs(codeID) {
//    var itemTag = document.activeElement.tagName; //获取元素的标签名
//    var name = document.activeElement.name; //获取元素的名称    
//    //如果控件不是文本
//    //如果控件是文本,Name非空时(如checkbox)
//    //条码获取焦点
//    if ((itemTag != 'INPUT') ||
//        (itemTag == 'INPUT' && name != '')) {
//        $(codeID).focus();
//    }
//}