cdk
2025-03-10 54056f0767e4fe500fbea3aa4c5553dd4db51815
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
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
/**
 * 
 */
 
// 全局变量
var billNo = '';
var i = 0; //计算扫描条码数量
var WLBM = "";//物料编码
var matterTable = null;
var PopPicker = new mui.PopPicker();
 
//初始化,默认焦点
 
// $(function(){
 //    billNo= GetMaxBillNO("1201",GetSysDateTime());//调拨单号,只要不离开界面,单号不变
//      $('#info').height($(window).height()- $("#row001").height() - $("#div001").height()- $("#div002").height() - 70);
// })
 
// $(function() {    
// SetBillNo();
// });
 
function SetBillNo() {
    $("#txtBillNo").click(function() {        
        GetBillList();        
        PopPicker.show(function(items) {
            var billNo = items[0].text;
            $("#txtBillNo").val(billNo);
        });
    });
}
 
//数字拖动之后调整数字小图标位置
function onStopDrag(e) {
    var d = e.data;
    if(d.left < 0) {
        d.left = 0
    }
    if(d.top < 0) {
        d.top = 0
    }
    if(d.top + $(d.target).outerHeight() > $(d.parent).height()) {
        $("#dgWOMDAG-sum")[0].innerHTML = "0";
        $("#dgWOMDAG-sum").css("top", d.startTop + "px");
        $("#dgWOMDAG-sum").css("left", d.startLeft + "px");
        $("#dgWOMDAG-sum").css("position", "initial");
        i = 0;
    }
}
 //扫描条码处理方法
 function GetBarInfo() {
     if(event.keyCode == 13) {
         //如果未输入条码,跳出方法
         
        if($("#DAB001").val() == "") {
            $("#DAB001").focus();
            playerAudio("NG");
            mui.toast("请先扫描物料条码!");            
            return;
        }    
        
         //用户ID
        var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
           var user_id =$("#txtBillNo").val(); //currentSession.user_id;
           var  mun=$("#txtSL").val();
//        var user_id = "admin";
         $.ajax({
             url: app.API_URL_HEADER + "/WARBABChag/GetBarInfo",
                 
             data: {
                 DAB001: $("#DAB001").val(),
                 check: $("#txtSL").val(), //获取复选框是否被选中(true,false)
                 billNo:billNo,
                 logID: 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("");
                        $("#info").val("");//先清空一下数据源
                        $("#txtBillNo").val("");//先清空一下数据源
                        $("#txtSL").val("");//先清空一下数据源
                     });            
                     return;
                 } else {
                     matterTable = data.data.matterTable;
                    $("#info").val("");//先清空一下数据源
                    $("#txtBillNo").val("");//先清空一下数据源
                    $("#txtSL").val("");//先清空一下数据源
                     $("#info").val(data.data.infos);//填入条码明细信息
                    $("#txtBillNo").val(data.data.WLBM);//填入物料编码
                    $("#txtSL").val(data.data.SL);//填入条码数量
                    
                    if(document.getElementById('MBA001').value.trim() !== ''){
                        GetStore();
                    }
                    mui("#MBA001")[0].focus();
 
                    //GetStore();
                 }
             },
             error: function(xhr, type, errorThrown) {
                 alert("获取数据异常:" + JSON.stringify(errorThrown));
             }
         });
     }
 };
 
 function BarcodePutInStorageHint(){
     $.ajax({
         url: app.API_URL_HEADER + app.API_METHOD_ESP,
         data: {
             spname: "BarcodePutInStorageHint",
             returnvalue: 1,
             _sp_DAB001: $("#DAB001").val()
         },
         type: "post",
         success: function(data) {
             console.log(JSON.stringify(data));
             if(data.status == 0) {
                $("#hint")[0].innerHTML=
                "个数/扫描数/送货数:"+
                data.data[0]["A1"]+"/"+
                data.data[0]["B1"]+"/"+
                data.data[0]["B"];
                
                ;
             } else {
                $("#hint")[0].innerHTML="";
             }
         },
         error: function(xhr, type, errorThrown) {
         }
     });
 }
 
//扫描库位处理方法
function GetStore() {                
        //用户ID
        var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
        var user_id = currentSession.user_id;
        var userRY=$("#txtBillNo").val();
        if(document.getElementById('MBA001').value.trim() === ''){
            mui.alert("请扫描库位!!!");
            return;
        }
        $.ajax({
            url: app.API_URL_HEADER + "/WARBABChag/UpdateCurStoreByBarcode",
           // url: "http://localhost:27611/api/WARBAB/GetStore",
            data:{
                DAB001:$("#DAB001").val(),
                logID: user_id,//'admin', //先写死,便于调试
                curStore:$("#MBA001").val() == null ? "" : $("#MBA001").val(),
            },
            DataType:"json",
            type:"post",
            async:false,
            //timeout:15000,
            success:function(data){
                //console.log(JSON.stringify(data));
                 if(data.status != 0){
                     mui.alert(data.message);//错误信息弹框
                     $("#MBA001")[0].focus();
                     //$("#MBA001").val("");
                     return;
                 }
                 if(data.data<=0){
                     mui.alert(data.message);
                    $("#info").val("");//先清空一下数据源
                    $("#txtBillNo").val("");//先清空一下数据源
                    $("#txtSL").val("");//先清空一下数据源
                    $("#DAB001").val("");//先清空一下数据源
                    if(document.getElementById('checkdefault').checked)
                    {
                        return;
                    }
                    $("#MBA001").val("");//先清空一下数据源
                     return;
                 }else{
                     $("#DAB001").val("");
                     $("#DAB001")[0].focus();
                     //$("#checkdefault").prop("checked", true);
                     if(WLBM == matterTable[0]["DAB020"].toString())
                        $("#dgWOMDAG-sum")[0].innerHTML = ++i;
                    else{
                        WLBM = matterTable[0]["DAB020"].toString();
                        i = 1;
                        $("#dgWOMDAG-sum")[0].innerHTML = i;
                    }
                     playerAudio("OK");
                     mui.toast("移库成功!");
                    // playerAudio("OK");
               }
             },
            error: function(xhr, type, errorThrown) {
                mui.toast("移库异常!");
                 alert("获取数据异常:" + JSON.stringify(errorThrown));
                 return;
             }
        });
    
}
 
 
 
            //初始化
            mui.ready(function() {
                app.init();
                fetchData();
            });
            
            //获取发货通知单
            function fetchData() {
              mui.ajax({
                url: app.API_URL_HEADER + "/WARBABChag/GetCOMDFA",
                type: "GET",
                dataType: "json",
                success: function(response) {
                    console.log(JSON.stringify(response)); 
                  if (response.status === 0) {
                    var selectElement = document.getElementById('order');
                    selectElement.innerHTML = "";
                    var options = response.data.DFA001;
 
                    for (var i = 0; i < options.length; i++) {
                      var option = document.createElement("option");
                      option.value = options[i]+'--'+response.data.DFB002[i];
                      option.text = options[i]+'--'+response.data.DFB002[i];
                      selectElement.appendChild(option);
                    }
                    
                  } else {
                    alert("获取数据异常:" + response.message);
                  }
                },
                error: function(xhr, type, errorThrown) {
                  mui.toast("获取数据异常:" + JSON.stringify(errorThrown));
                  alert("获取数据异常:");
                }
              });
            }
            
            document.getElementById('order').addEventListener('change', function() {
              // 获取选中的值
              var selectedValue = this.value;
              console.log(selectedValue);
              var splitValues = selectedValue.split("--");
              
              if (splitValues.length === 2) {
                  var DFA001 = splitValues[0]; // 第一个值存入 DFA001
                  var DFB002 = splitValues[1]; // 第二个值存入 DFB002
                  }
 
              // 发起 AJAX 请求
              mui.ajax({
                url: app.API_URL_HEADER + "/WARBABChag/GetCOMDFB", // 后台接口的URL
                type: 'POST', // 请求方法
                data: { 
                    DFA001: DFA001,
                    DFB002: DFB002, //获取复选框是否被选中(true,false)
                    }, // 请求参数,根据后台接口的要求进行修改
                dataType: 'json', // 接收到的数据类型
                success: function(response) {
                  // 处理成功响应
                      console.log(response); // 输出响应数据,你可以根据实际接口返回的数据进行相应的处理
                      
                      if (response.status === 0) {
                          // 表格数据获取成功
                          var data = response.data;
                          var tableBody = document.querySelector("#myTable tbody");
                          tableBody.innerHTML = ""; // 清空表格内容
                          
                          for (var i = 0; i < data.物料名称.length; i++) {
                              // 创建新的表格行
                              var newRow = document.createElement("tr");
                              
                              // 创建并设置物料名称单元格
                              var nameCell = document.createElement("td");
                              nameCell.innerText = data.物料名称[i];
                              newRow.appendChild(nameCell);
                              
                              // 创建并设置物料代码单元格
                              var codeCell = document.createElement("td");
                              codeCell.innerText = data.物料代码[i];
                              newRow.appendChild(codeCell);
                              
                              // 创建并设置代发数量单元格
                              var pendingCell = document.createElement("td");
                              pendingCell.innerText = data.待发数量[i];
                              newRow.appendChild(pendingCell);
                              
                              // 创建并设置已发数量单元格
                              var shippedCell = document.createElement("td");
                              shippedCell.innerText = data.已发数量[i];
                              newRow.appendChild(shippedCell);
                              
                              // 创建并设置推荐仓位单元格
                              var locationCell = document.createElement("td");
                              locationCell.innerText = data.推荐仓位[i];
                              newRow.appendChild(locationCell);
                              
                              // 创建并设置规格型号单元格
                              var specificationCell = document.createElement("td");
                              specificationCell.innerText = data.规格型号[i];
                              newRow.appendChild(specificationCell);
                              
                              // 创建并设置图号单元格
                              var drawingCell = document.createElement("td");
                              drawingCell.innerText = data.图号[i];
                              newRow.appendChild(drawingCell);
                              
                              // 将新的表格行添加到表格体中
                              tableBody.appendChild(newRow);
                          }
                      } else {
                          // 表格数据获取失败
                          alert("发生错误:" + response.message); // 使用弹窗显示错误信息
                      }
                },
                error: function(xhr, type, errorThrown) {
                  // 处理错误响应
                  console.log(errorThrown); // 输出错误信息
                  alert("发生错误:" + errorThrown); // 使用弹窗显示错误信息
                }
              });
            });
            
            function GetBarInfo() {
              var barcodeInput = document.getElementById("DAB001");
              var barcodeValue = barcodeInput.value;
            
              
            
              if (event.keyCode == 13) {
            
                // 如果未输入条码,跳出方法
                if (barcodeValue === '') {
                    alert("请扫描条码!!!");
                    return;
                }
                
                var COMDFA = document.getElementById("order");
                var selectedValue = COMDFA.value;
                var splitValues = selectedValue.split("--");
                
                if (splitValues.length === 2) {
                    var DFA001 = splitValues[0]; // 第一个值存入 DFA001
                    var DFB002 = splitValues[1]; // 第二个值存入 DFB002
                    }
                
                console.log('1');
                var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
                var user_id = currentSession.user_id;
                console.log(user_id);
            
                mui.ajax(app.API_URL_HEADER + "/WARBABChag/CreateXSCK", {
                    data: {
                        DAB001: barcodeValue,
                        user_id: user_id,
                        DFA001: DFA001,
                        DFB002: DFB002,
                    },
                    dataType: "json",
                    type: "post",
                    async: false,
                    // timeout: 15000,
                    success: function(data) {
                        // console.log(JSON.stringify(data));
                        if (data.status != 0) {
                            playerAudio("NG");
                            alert(data.message);
                            console.log("1");
                            barcodeInput.value = ''; // 清空输入框的值
                            barcodeInput.blur(); // 先让输入框失去焦点
                            focusOnDAB001();
                            return;
                        } else {
                            matterTable = data.data.matterTable;
                            
            
                            if (document.getElementById('MBA001').value.trim() !== '') {
                                GetStore();
                            }
                            mui("#MBA001")[0].focus();
                        }
                    },
                    error: function(xhr, type, errorThrown) {
                        console.log("失败");
                        mui.alert("获取数据异常:" + JSON.stringify(errorThrown));
                    }
                });
              }
            }
            
            
            function focusOnDAB001() {
              var inputElement = document.getElementById("DAB001");
              MUIinputElement.focus();
            }
 
 
 
/* 当页面的文本失去焦点时,让其再次获取焦点 */
 
 
/**
 *  @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();
//    }
//}