说明:
扫描的多货条码在列表中存在只需更新多货数量,反之,新增一条数据。
//客户产品号(全局变量)
var pbCodeArr = [];
/多货异常绑定箱号
function multipleCargoAbnormalBindingContainerNumber(int) {
var HTML = "", ordersCode = $("#orderCode").text();
HTML += "<h>单号:" + $("#offshelfcode").text() + "<input type='hidden' name='warehouseId' value='" + needScanedOrdersSum[ordersCode]['warehouse_id'] + "'></h><br/>";
HTML += "<h>扫描多货条码:<input type='text' name='pb_code' value='' onchange='scanMultipleBarcode();' style='text-align: center'></h>";
HTML += "<table width='100%' height='100%' border='1' style='text-align: center; margin-top: 20px;' class='more'>";
HTML += "<tr>";
HTML += "<th>客户产品号</th>";
HTML += "<th>多货数量</th>";
HTML += "</tr>";
HTML += "</table><br/>";
HTML += "<h>";
HTML += "编号:<input type='text' name='number' value='' size='30' style='text-align: center'>";
HTML += " <input type='button' value='确认' class='button' onclick='affirm(" + int + ")'>";
HTML += "</h>";
$("#abnormalBindingBoxNumberDialog").html(HTML).dialog({width: 500});
}
//扫描多货条码
function scanMultipleBarcode() {
var pbCode = $("[name='pb_code']").val(), key = 0, originalQuantity = 0, HTML = "";
//扫描的多货条码是否在列表中存在
if ($.inArray(pbCode, pbCodeArr) != -1) {
//获取存在多货条码的键
key = $.inArray(pbCode, pbCodeArr);
//原始数量
originalQuantity = $(".quantity" + key).text();
//多配数量 = 原始数量 + 1
$(".quantity" + key).html(Number(originalQuantity) + 1);
$(".quantity" + key).append("<input type='hidden' name='exception_quantity[]' value='" + $(".quantity" + key).html() + "'>");
} else {
//不存在新增一条数据
key = pbCodeArr.length;
HTML += "<tr><td class='productId" + key + "'><input type='hidden' name='product_id[]' value='" + pbCode + "'>" + pbCode + "</td>";
HTML += "<td class='quantity" + key + "'><input type='hidden' name='exception_quantity[]' value='1'>1</td></tr>";
$(".more").append(HTML);
}
//获取所有扫描过的多货条码
$("[name='product_id[]']").each(function (index, value) {
pbCodeArr[index] = value.value;
index++;
});
//清空扫描多货条码
$("[name='pb_code']").val('');
}
//确认
function affirm(int) {
var number = $("[name='number']").val(), productId = [], wsCode = [], exceptionQuantity = [], re = /^\d+$/;
if (!number) {
alertTip("编号不能为空!");
return false;
}
$("[name='product_id[]']").each(function (index, value) {
productId[index] = value.value;
index++;
});
$("[name='ws_code[]']").each(function (index, value) {
wsCode[index] = value.value;
index++;
});
$("[name='exception_quantity[]']").each(function (index, value) {
if (!value.value || !re.test(value.value)) {
alertTip("第 " + (index + 1) + " 行未扫描数量框中填写正整数!");
return false;
}
exceptionQuantity[index] = value.value;
index++;
//少货数量
leakageQuantity += value.value;
});
$.ajax({
type: "post",
async: false,
dataType: "json",
url: "/warehouse/pack-check/package-binding-box-number",
data: {
opCode: $("#offshelfcode").text(),
warehouseId: $("[name='warehouseId']").val(),
ordersCode: $("#orderCode").text(),
productId: productId,
wsCode: wsCode,
exceptionQuantity: exceptionQuantity,
number: number,
type: int,
},
success: function (json) {
if (json.ask) {
$("#abnormalBindingBoxNumberDialog").dialog("close");
}
alertTip(json.msg);
}
});
closeLoading();
}
确定数据以数组对应传值: