You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
307 lines
7.5 KiB
307 lines
7.5 KiB
var userId = $("#current_id").val();
|
|
var userName = $("#current_username").val();
|
|
var site = $("#current_site").val();
|
|
|
|
var titleName = $("#current_titleName").val();
|
|
|
|
var currentData = null;
|
|
|
|
|
|
|
|
var wareHouseId = '';
|
|
|
|
var partNoData = null;
|
|
|
|
var inventoryData = null;
|
|
|
|
var tableList = new Array();
|
|
|
|
//页面初始化
|
|
$(function(){
|
|
if(titleName != null && titleName != ""){
|
|
$("#titleName").text(titleName);
|
|
}else {
|
|
window.location.href="/login";
|
|
}
|
|
$("#remark").val("库存报废")
|
|
|
|
$("#partNo_search").focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
function changeTableList(){
|
|
var qtyOut = $("#qtyOut").val();
|
|
var tableData = {
|
|
site: inventoryData.site,
|
|
partNo : inventoryData.partNo,
|
|
qtyOut : qtyOut,
|
|
batchNo : inventoryData.batchNo,
|
|
locationId : inventoryData.locationId,
|
|
warehouseId : inventoryData.warehouseId,
|
|
}
|
|
tableList.push(tableData);
|
|
changeTable();
|
|
}
|
|
|
|
function changeTable(){
|
|
var str = '';
|
|
// rqrq:首张标签写入发料仓库展示,混仓在 getInventoryData 中拦截
|
|
if(tableList.length > 0){
|
|
$("#wareHouse").val(tableList[0].warehouseId);
|
|
}
|
|
for (let i = 0; i < tableList.length; i++) {
|
|
str += '<tr id = '+tableList[i].partNo +'>' +
|
|
'<th class="" style="text-align:center;background-color: #ffff;width: 15%;">' +
|
|
'<span>'+tableList[i].partNo+'</span></th>' +
|
|
'<th class="" style="text-align:center;background-color: #ffff;width: 10%;">' +
|
|
'<span>'+tableList[i].qtyOut+'</span></th>' +
|
|
'<th class="" style="text-align:center;background-color: #ffff;width: 15%;">' +
|
|
'<span>'+tableList[i].batchNo+'</span></th>' +
|
|
'<th class="" style="text-align:center;background-color: #ffff;width: 15%;">' +
|
|
'<span>'+tableList[i].locationId+'</span></th>'+
|
|
'</tr>';
|
|
}
|
|
$("#issue_table").html("").append(str);
|
|
$("#issue_cancel").click();
|
|
}
|
|
|
|
$("#partNo_search").bind("keydown",function(event){
|
|
if (event.keyCode == 13) {
|
|
queryPart();
|
|
}
|
|
});
|
|
|
|
function queryPart(){
|
|
var partNoSearch = $("#partNo_search").val();
|
|
if(partNoSearch == null || partNoSearch === ""){
|
|
layer.msg("请扫描物料标签!");
|
|
return false
|
|
}
|
|
var strList = partNoSearch.split("|");
|
|
partNoData = {
|
|
site : '',
|
|
partNo : '',
|
|
wareHouseId : '',
|
|
batchNo: '',
|
|
locationId : '',
|
|
}
|
|
if(strList.length < 5){
|
|
layer.msg("物料标签错误!");
|
|
return false
|
|
}
|
|
for (let i = 0; i < strList.length; i++) {
|
|
if(i == 0){
|
|
partNoData.site = strList[i];
|
|
}else if(i == 1){
|
|
partNoData.partNo = strList[i];
|
|
}else if(i == 2){
|
|
partNoData.wareHouseId = strList[i];
|
|
}else if(i == 3){
|
|
partNoData.batchNo = strList[i];
|
|
}else if(i == 4){
|
|
partNoData.locationId = strList[i];
|
|
}
|
|
}
|
|
|
|
getInventoryData()
|
|
}
|
|
|
|
function getInventoryData(){
|
|
// rqrq:首张确定仓库,后续标签仓库必须一致
|
|
if (tableList.length > 0 && tableList[0].warehouseId !== partNoData.wareHouseId) {
|
|
layer.msg("仓库与首张标签不一致,不能混仓其他出库!当前应扫仓库:" + tableList[0].warehouseId);
|
|
return false;
|
|
}
|
|
var jsonData = {
|
|
site : partNoData.site,
|
|
warehouseId : partNoData.wareHouseId,
|
|
batchNo : partNoData.batchNo,
|
|
locationId : partNoData.locationId,
|
|
partNo : partNoData.partNo,
|
|
}
|
|
$.ajax({
|
|
url: "/pdaOrder/getInventoryStockDataForOut",
|
|
contentType: 'application/json',
|
|
type:"POST",
|
|
data:JSON.stringify(jsonData),//你的formid
|
|
dataType:"JSON",
|
|
async: true,
|
|
beforeSend: function(request) {
|
|
request.setRequestHeader("token", $.cookie("token"));
|
|
},
|
|
success: function (data) {
|
|
if(data.code == 0){
|
|
var row = data.row;
|
|
if(row != null && row.site != null){
|
|
inventoryData = row;
|
|
wareHouseId = row.warehouseId;
|
|
initIssueModel();
|
|
}else {
|
|
layer.msg("仓库无此物料信息!");
|
|
}
|
|
}else {
|
|
layer.confirm(data.msg, {
|
|
btn: ['确定']
|
|
}, function (index) {
|
|
layer.close(index);
|
|
});
|
|
}
|
|
},
|
|
error: function(data) {
|
|
var responseText = data.responseText;
|
|
var json_str = JSON.parse(responseText);
|
|
var status = json_str.status;
|
|
var message = json_str.message;
|
|
//判断是否是session超时
|
|
if(403==status){
|
|
layer.alert(message,function(){
|
|
window.location.href="/login";
|
|
});
|
|
}
|
|
layer.closeAll('loading');
|
|
}
|
|
})
|
|
}
|
|
|
|
function initIssueModel(){
|
|
$("#qtyOut").val(inventoryData.qtyOnHand);
|
|
if(inventoryData.weightFactor!='-1'&&inventoryData.weightFactor!='0'&&inventoryData.weightFactor!=''&&inventoryData.weightFactor!=null){
|
|
$("#qtyOutKG").val((inventoryData.qtyOnHand*inventoryData.weightFactor).toFixed(1));
|
|
$("#qtyOutKG").removeAttr("disabled");
|
|
}else {
|
|
$("#qtyOutKG").val('');
|
|
$("#qtyOutKG").attr("disabled", "disabled");
|
|
}
|
|
$("#issue_modal").modal();
|
|
}
|
|
//失去焦点事件
|
|
$('#qtyOutKG').blur(function () {
|
|
let qtyOutKG=$('#qtyOutKG').val();
|
|
let weightFactor=inventoryData.weightFactor;
|
|
if(weightFactor!=0&&weightFactor!=-1&&qtyOutKG!=''){
|
|
$('#qtyOut').val((qtyOutKG/weightFactor).toFixed(1))
|
|
}
|
|
})
|
|
|
|
//失去焦点事件
|
|
$('#qtyOut').blur(function () {
|
|
let qtyOut=$('#qtyOut').val();
|
|
let weightFactor=inventoryData.weightFactor;
|
|
if(weightFactor!=0&&weightFactor!=-1&&qtyOut!=''){
|
|
$('#qtyOutKG').val((qtyOut*weightFactor).toFixed(1))
|
|
}
|
|
})
|
|
//模态框显示触发
|
|
$("#issue_modal").on("shown.bs.modal",function(){
|
|
$("#qtyOut").focus();
|
|
});
|
|
|
|
//模态框隐藏触发
|
|
$("#issue_modal").on("hidden.bs.modal",function(){
|
|
$("#partNo_search").val("").focus();
|
|
});
|
|
|
|
$("#qtyOut").bind("keydown",function(event){
|
|
if (event.keyCode == 13) {
|
|
saveTable();
|
|
}
|
|
});
|
|
|
|
function saveTable(){
|
|
var qtyOut = $("#qtyOut").val();
|
|
if(qtyOut == null || qtyOut == "" || qtyOut <= 0){
|
|
layer.msg("其他出库数量错误!");
|
|
return false;
|
|
}
|
|
changeTableList();
|
|
}
|
|
|
|
//下级界面页面跳转
|
|
function clearAll(){
|
|
$("#wareHouse").val("")
|
|
$("#remark").val("库存报废")
|
|
$("#partNo_search").val("")
|
|
$("#qtyOut").val("")
|
|
$("#qtyOutKG").val("")
|
|
tableList= []
|
|
changeTable();
|
|
}
|
|
|
|
/**
|
|
* rqrq:提交其他出库(Inventory_Create_TransHeader_other + 逐行 Out_other)
|
|
*/
|
|
function saveData(){
|
|
if (!tableList || tableList.length === 0) {
|
|
layer.msg("请先扫描并添加出库明细");
|
|
return;
|
|
}
|
|
var payload = {
|
|
userName: userName,
|
|
remark: ($("#remark").val() || ""),
|
|
lines: tableList.map(function (r) {
|
|
return {
|
|
site: r.site,
|
|
warehouseId: r.warehouseId,
|
|
partNo: r.partNo,
|
|
batchNo: r.batchNo,
|
|
locationId: r.locationId,
|
|
qtyOut: parseFloat(r.qtyOut)
|
|
};
|
|
})
|
|
};
|
|
if (payload.lines.some(function (x) { return isNaN(x.qtyOut) || x.qtyOut <= 0; })) {
|
|
layer.msg("存在无效数量");
|
|
return;
|
|
}
|
|
var loadIdx = layer.load(1, { shade: [0.2, '#000'] });
|
|
console.log(payload);
|
|
|
|
$.ajax({
|
|
url: "/pda/stockOtherOut/save",
|
|
contentType: "application/json",
|
|
type: "POST",
|
|
data: JSON.stringify(payload),
|
|
dataType: "JSON",
|
|
beforeSend: function (request) {
|
|
request.setRequestHeader("token", $.cookie("token"));
|
|
},
|
|
success: function (data) {
|
|
layer.close(loadIdx);
|
|
if (data.code === 0) {
|
|
layer.msg(data.msg || "保存成功");
|
|
clearAll();
|
|
} else {
|
|
layer.msg(data.msg || "保存失败");
|
|
}
|
|
},
|
|
error: function (xhr) {
|
|
layer.close(loadIdx);
|
|
var msg = "请求失败";
|
|
try {
|
|
var json = JSON.parse(xhr.responseText);
|
|
if (json && json.msg) {
|
|
msg = json.msg;
|
|
}
|
|
} catch (e) { }
|
|
layer.msg(msg);
|
|
if (xhr.status === 403) {
|
|
layer.alert(msg, function () {
|
|
window.location.href = "/login";
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
//初始化下拉框
|
|
function selectInit(){
|
|
$('.selectpicker').selectpicker({
|
|
noneSelectedText: '',
|
|
noneResultsText: '',
|
|
liveSearch: true,
|
|
width:140,
|
|
size:5 //设置select高度,同时显示5个值
|
|
});
|
|
}
|