/**
|
* 作者:G98138 黎锋
|
* 时间:2018-09-04
|
* 描述:库位 绑定
|
*
|
* 业务思路:
|
* 1. 扫描条码
|
* 1.1 非条码库存表的条码, 提示( OK) *
|
* 1.2 非待入库条码, 提示( OK) *
|
* 1.3 通过条码找到上一次该物料的库位, 作为推荐库位( OK)
|
* 注意: 如果勾选了“默认库位”, 且在上一次绑定的库位和当前界面显示的库位一致 , 则直接绑定库位, 不需要再扫描库位 *
|
|
* 2. 扫描库位条码 *
|
* 2.1 非库位条码, 提示( OK) *
|
* 2.2 非该仓库的库位, 提示( OK) *
|
*/
|
|
// 全局变量
|
var billNo = '';
|
var i = 0; //计算扫描条码数量
|
var WLBM = ""; //物料编码
|
var matterTable = null;
|
var HBID = "";
|
|
|
//初始化,默认焦点
|
mui.plusReady(function() {
|
app.init();
|
mui("#DAB001")[0].focus();
|
|
$('#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 GetBillList() {
|
var billDate = $("#txtBillDate").val();
|
var o = {};
|
o["billDate"] = billDate;
|
|
$.ajax({
|
url: app.API_URL_HEADER + '/IQCPBA/GetBillNoListsT',
|
data: "",
|
dataType: "json",
|
type: "post",
|
success: function(resdata) {
|
var dataWorkers = null;
|
dataWorkers = $.parseJSON(resdata.data);
|
PopPicker.setData(dataWorkers);
|
},
|
error: function(xhr, type, errorThrown) {
|
alert("获取数据异常:" + JSON.stringify(errorThrown));
|
}
|
});
|
}
|
|
|
|
//数字拖动之后调整数字小图标位置
|
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 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("#DAB001")[0].focus();
|
|
|
}
|
},
|
error: function(xhr, type, errorThrown) {
|
alert("获取数据异常:" + JSON.stringify(errorThrown));
|
}
|
});
|
}
|
};
|
|
//扫描条码处理方法
|
function GetBarInfo() {
|
if (event.keyCode == 13) {
|
console.log(1);
|
//如果未输入条码,跳出方法
|
if ($("#DAB001").val() == "") {
|
$("#DAB001").focus();
|
playerAudio("NG");
|
mui.toast("请先扫描物料条码!");
|
return;
|
}
|
|
if (HBID == "") {
|
let uniqueId = generateGUID();
|
HBID = uniqueId
|
|
}
|
console.log("合并ID:");
|
console.log(HBID);
|
|
//用户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 + "/WARBABChag/GetBarInfo_HBBar",
|
|
data: {
|
DAB001: $("#DAB001").val(),
|
HBID: HBID,
|
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 {
|
console.log("成功");
|
playerAudio("OK");
|
$("#DAB001").val("");
|
$("#DAB001").focus();
|
console.log(data.data);
|
populateTable(data.data);
|
mui.toast("清点完成!");
|
//mui.alert("入库成功,测试后删除该提示!!!");
|
|
}
|
},
|
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) {}
|
});
|
}
|
|
//自定义NEWID()函数
|
function generateGUID() {
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
var r = Math.random() * 16 | 0,
|
v = c === 'x' ? r : (r & 0x3 | 0x8);
|
return v.toString(16);
|
});
|
}
|
|
//把数据填充到table表中
|
function populateTable(data) {
|
console.log('1');
|
let tbody = document.querySelector("#myTable tbody");
|
let tfoot = document.querySelector("#myTable tfoot"); // 获取tfoot元素
|
let totalStock = 0.0; // 初始化库存总和为0
|
|
// 清空表格内容(包括tfoot中的任何现有内容)
|
tbody.innerHTML = "";
|
tfoot.innerHTML = ""; // 清空tfoot,以防之前有内容
|
|
// 循环遍历数据,生成表格行
|
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中
|
tbody.appendChild(tr);
|
|
// 累加库存数量
|
let stockQuantity = parseFloat(data["库存数量"][i]);
|
totalStock += stockQuantity;
|
}
|
|
// 在tfoot中添加汇总行
|
let totalRow = document.createElement("tr");
|
let totalTd = document.createElement("td");
|
totalTd.colSpan = 3; // 合并前面的5列
|
totalTd.textContent = "库存总和";
|
totalRow.appendChild(totalTd);
|
|
let totalStockTd = document.createElement("td");
|
totalStockTd.colSpan = 3;
|
totalStockTd.textContent = totalStock.toFixed(6); // 保留6位小数
|
totalRow.appendChild(totalStockTd);
|
|
tfoot.appendChild(totalRow); // 将汇总行添加到tfoot中
|
|
}
|
|
|
function confirmQuantity() {
|
|
// 假设HBID是一个之前已经定义并可能赋值的变量
|
if (typeof HBID === "undefined" || HBID.trim() === "") {
|
$("#DAB001").focus();
|
playerAudio("NG");
|
mui.toast("请先扫描物料条码后,再确认!");
|
return; // 跳出函数,如果这是函数的一部分
|
}
|
|
var kwValue = $("#KW").val();
|
console.log(kwValue);
|
|
// 检查kwValue是否为空、undefined、null或仅包含空格
|
if (!kwValue || kwValue.trim() === "") {
|
$("#KW").focus();
|
playerAudio("NG");
|
mui.toast("请先扫描库位!");
|
return; // 跳出函数,如果这是函数的一部分
|
}
|
|
|
console.log("合并ID:");
|
console.log(HBID);
|
|
//用户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 + "/WARBABChag/HBBarcode",
|
|
data: {
|
KW: $("#KW").val(),
|
HBID: HBID,
|
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() {
|
$("#KW").val("");
|
$("#KW").focus();
|
// mui("#DAB001")[0].focus();
|
// $("#DAB001").val("");
|
});
|
return;
|
} else {
|
console.log("成功");
|
playerAudio("OK");
|
console.log("开始打印!!");
|
|
var str = data.data.BARID.toString();
|
console.log(str); // 将BARID转换为字符串并打印输出
|
printByIds(str);
|
|
|
$("#DAB001").val("");
|
$("#KW").val("");
|
$("#DAB001").focus();
|
console.log(data.data);
|
populateTable(data.data);
|
mui.toast("合并完成!");
|
//mui.alert("入库成功,测试后删除该提示!!!");
|
|
}
|
},
|
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();
|
// }
|
//}
|