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
/**
 * 
 */
 
// 全局变量
var billNo = '';
var i = 0; //计算扫描条码数量
var WLBM = "";//物料编码
var matterTable = null;
var PopPicker = new mui.PopPicker();
 
//初始化,默认焦点
mui.plusReady(function(){    
    app.init();
    mui("#txtBillNo")[0].focus();
    //SetBillNo();
    $('#info').height($(window).height()- $("#row001").height() - $("#div001").height()- $("#div002").height() - 70);
});        
// $(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 GetBarInfoT() {
     if(event.keyCode == 13) {
         //用户ID
        var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
           var user_id = currentSession.user_id;
           
//        var user_id = "admin";
         $.ajax({
             url: app.API_URL_HEADER + "/WARBAB/GetBarInfoNAME",
                 
             data: {
                 txtBillNoN: $("#txtBillNoN").val(),                                            
                 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("#txtBillNoN")[0].focus();
                        $("#txtBillNoN").val("");
                     });            
                     return;
                 } else {
                     matterTable = data.data.matterTable;
                    $("#txtBillNo").val("");//先清空一下数据源
                     $("#txtBillNo").val(data.data.NAME);//填入条码明细信息    
                     mui("#txtGX")[0].focus();
                    
                    
                 }
             },
             error: function(xhr, type, errorThrown) {
                 alert("获取数据异常:" + JSON.stringify(errorThrown));
             }
         });
     }
 };
 
 
 //扫描工单条码处理方法
 function GetBarInfo() {
     if(event.keyCode == 13) {
         //如果未输入条码,跳出方法
         
        if($("#txtHBGD").val() == "") {
            $("#txtHBGD").focus();
            playerAudio("NG");
            mui.toast("请先扫描合并工单条码!");            
            return;
        }    
        
        if($("#txtGX").val() == "") {
            $("#txtGX").focus();
            playerAudio("NG");
            mui.toast("请先扫描工序!");            
            return;
        }
        console.log(1);
                    
        if($("#txtBillNo").val() == "") {
            $("#txtBillNoN").focus();
            playerAudio("NG");
            mui.toast("请先选择入库人员!");
            //$("#txtBillNoN").val("");
            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 + "/WARBAB/GetHBGDInfo_BG",
                 
             data: {
                 HBGD: $("#txtHBGD").val(),
                 GX: $("#txtGX").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("#txtHBGD")[0].focus();
                        $("#txtHBGD").val("");
                     });            
                     return;
                 } else {
                    console.log(data.data);
                     populateTable(data.data);
                    mui("#txtSL")[0].focus();
                    $("#txtSL").val("");
                 }
             },
             error: function(xhr, type, errorThrown) {
                 alert("获取数据异常:" + JSON.stringify(errorThrown));
             }
         });
     }
 };
 
 function populateTable(data) {
      
      console.log('1');
    let tbody = document.querySelector("#myTable tbody");
  
    // 清空表格内容
    tbody.innerHTML = "";
  
    let totalQuantity = 0; // 初始化报工数量总和为0
  
    // 循环遍历数据,生成表格行
    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);
  
      totalQuantity += parseInt(data["报工数量"][i]); // 累加报工数量总和
  
      tbody.appendChild(tr);
    }
    
    // 创建表格行来显示报工数量的汇总
    let summaryRow = document.createElement("tr");
    let summaryLabel = document.createElement("td");
    summaryLabel.textContent = "报工数量汇总:";
    let summaryValue = document.createElement("td");
    summaryValue.textContent = totalQuantity;
    summaryValue.setAttribute("colspan", "3"); // 设置该单元格横跨3列
    summaryRow.appendChild(summaryLabel);
    summaryRow.appendChild(summaryValue);
  
    tbody.appendChild(summaryRow);
  };
 
//扫描库位处理方法
function GetBarGX() {    
    
    if(event.keyCode == 13) {
        
        if($("#txtGX").val() == "") {
            $("#txtGX").focus();
            playerAudio("NG");
            mui.toast("请扫描工序");
            $("#txtGX").val("");
            return;
        }    
        $("#txtHBGD").focus();
    }
 
    
}
 
 
//确认报工数量
function HBBG() {        
    
    if(event.keyCode == 13)
    {
        if($("#txtSL").val() == "") {
            $("#txtSL").focus();
            playerAudio("NG");
            mui.toast("请输入数量");
            $("#txtSL").val("");
            return;
        }    
        var user_id =$("#txtBillNo").val(); //currentSession.user_id;
        var currentSession = app.loadconfig(app.CONFIG_CURRENT_SESSION);
        var BG_RY =currentSession.user_id;//
        $.ajax({
            url: app.API_URL_HEADER + "/WARBAB/HBBG",
                
            data: {
                 HBGD: $("#txtHBGD").val(),
                 GX: $("#txtGX").val(), //当前库位    
                SL: $("#txtSL").val(), //当前库位    
                user_id: user_id,//Admin //先写死,便于调试
                BG_RY:BG_RY,
                
            },
            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("#txtSL")[0].focus();
                        $("#txtSL").val("");
                    });            
                    return;
                } else {
                    $("#txtSL").val("");//先清空一下数据源
                    mui("#txtSL")[0].focus();
                    GetBarInfo();
 
                    mui.toast(data.message);        
                    //initBluetooth();
         
                }
            },
            error: function(xhr, type, errorThrown) {
                alert("获取数据异常:" + JSON.stringify(errorThrown));
            }
        });
    }
    
        
    
}
 
 
/* 当页面的文本失去焦点时,让其再次获取焦点 */
 
 
/**
 *  @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();
//    }
//}