/**
|
*
|
*/
|
|
// 全局变量
|
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();
|
// }
|
//}
|