var matCodeData = []
|
var tableIns, tableInsLoc;
|
// 搜索条件-库位号
|
var locNo = ''
|
// 库存明细
|
var locData = []
|
var form = null
|
layui.use(['table', 'form'], function () {
|
var table = layui.table
|
var $ = layui.jquery
|
form = layui.form;
|
|
// 获取出库口
|
function fetchSelect() {
|
$.ajax({
|
url: baseUrl + "/locCombOutStartCheckSite/site",
|
headers: {'token': localStorage.getItem('token')},
|
method: 'POST',
|
success: function (res) {
|
if (res.code === 200) {
|
var html = res.data.map((item) => {
|
return `<option value="${item}">${item}</option>`
|
})
|
$('#putSiteSelect').append(html);
|
form.render('select');
|
} else if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
} else {
|
layer.msg(res.msg)
|
}
|
}
|
})
|
}
|
// 加载出库口信息
|
fetchSelect()
|
|
// 库位物料
|
tableInsLoc = table.render({
|
elem: '#locDetail'
|
, headers: {token: localStorage.getItem('token')}
|
, url: baseUrl + '/locDetl/pageList/auth'
|
, cols: [[ //标题栏
|
{field: 'locNo', title: '库位', width: 120}
|
, {field: 'maktx', title: '商品名', width: 300}
|
, {field: 'matnr', title: '商品号', width: 200}
|
, {field: 'specs', title: '规格', width: 300}
|
, {field: 'anfme', title: '数量', width: 100}
|
]]
|
, page: true //是否显示分页
|
, request: {
|
pageName: 'curr',
|
pageSize: 'limit',
|
},
|
where: {'locNo': locNo}
|
, limits: [5]
|
, limit: 5, //每页默认显示的数量
|
parseData: function (res) {
|
if (res.code === 201) {
|
return ''
|
}
|
locData = res.data.records
|
return {
|
'code': res.code,
|
'msg': res.msg,
|
'count': res.data.total,
|
'data': res.data.records
|
}
|
},
|
response: {
|
statusCode: 200
|
},
|
done: function (res, curr, count) {
|
if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
}
|
}
|
})
|
|
// 新增物料
|
tableIns = table.render({
|
elem: '#chooseData',
|
id: 'chooseData',
|
data: [],
|
limit: 500,
|
cellMinWidth: 50,
|
cols: [[
|
{
|
fixed: 'left',
|
align: 'center',
|
field: 'count',
|
title: '数量',
|
style: 'color: blue',
|
width: 100,
|
edit: 'text',
|
width: 120,
|
style: 'color: blue;font-weight: bold'
|
},
|
{field: 'matnr', align: 'center', title: '商品编号'},
|
{field: 'maktx', align: 'center', title: '商品名称'},
|
{field: 'specs', align: 'center', title: '规格'},
|
{fixed: 'right', title: '操作', align: 'center', toolbar: '#operate', width: 200}
|
]]
|
});
|
|
// 监听table的移除事件
|
table.on('tool(chooseData)', function (obj) {
|
var data = obj.data;
|
switch (obj.event) {
|
case 'remove':
|
const findIndex = matCodeData.findIndex(item => item.id === data.id)
|
matCodeData.splice(findIndex, 1)
|
tableIns.reload({data: matCodeData, limit: matCodeData.length});
|
break;
|
}
|
});
|
|
table.on('edit(chooseData)', function (obj) {
|
matCodeData = matCodeData.map(item => {
|
if (item.id === obj.data.id) {
|
return {
|
...item,
|
count: obj.value
|
}
|
}
|
return item
|
})
|
});
|
|
// 搜索按钮
|
$("#searchFor").click(function () {
|
table.reload('locDetail', {
|
where: {'locNo': locNo},
|
page: { // 分页参数
|
curr: 1 // 重新从第一页开始
|
},
|
// 其他参数
|
})
|
})
|
})
|
// 获取输入框值
|
$("#locNo").on("input", function (e) {
|
//获取input输入的值
|
locNo = e.delegateTarget.value;
|
});
|
|
// 补料出库
|
$("#outbound").click(function () {
|
if (locNo === "" || locNo.length != 7) {
|
layer.msg("库位号错误");
|
return;
|
}
|
//判断库位数据
|
if (locData == null || locData.length === 0) {
|
layer.msg("并板库位没有库存数据");
|
return;
|
}
|
// 判断是否存在产品
|
if (matCodeData.length === 0) {
|
layer.msg("请先添加产品");
|
return;
|
}
|
// 判断产品数量是否存在异常
|
for (var i = 0; i < matCodeData.length; i++) {
|
if (isNaN(matCodeData[i].count)) {
|
layer.msg("请输入数字");
|
return;
|
}
|
if (matCodeData[i].count === 0) {
|
layer.msg("数量不能为零");
|
return;
|
}
|
}
|
// 判断出站口
|
var outNo = $('#putSiteSelect').val()
|
if (outNo.length === 0) {
|
layer.msg("请选择出库口");
|
return;
|
}
|
|
$.ajax({
|
url: baseUrl + "/locComb/out/start",
|
headers: {'token': localStorage.getItem('token')},
|
data: JSON.stringify({
|
locNo: locNo,
|
devpNo: Number(outNo),
|
list: matCodeData
|
}),
|
contentType: 'application/json;charset=UTF-8',
|
method: 'POST',
|
async: false,
|
success: function (res) {
|
if (res.code === 200) {
|
layer.msg(res.msg);
|
// 清空出库口选择
|
$("#putSiteSelect").val('');
|
form.render();
|
// 清空输入的库位
|
$("#locNo").val("");
|
locNo = ''
|
// 清空增加的明细数据
|
matCodeData = [];
|
tableIns.reload({data: []});
|
// 清空库位明细数据
|
tableInsLoc.reload({data: [], where: {'locNo': ''}});
|
locData = []
|
} else if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
} else {
|
layer.msg(res.msg)
|
}
|
}
|
})
|
})
|
|
// 提取物料
|
var matCodeLayerIdx;
|
|
// 打开商品弹窗
|
function getMat() {
|
matCodeLayerIdx = layer.open({
|
type: 2,
|
title: '物料',
|
shade: [0.3, '#000'],
|
area: ['90%', '80%'],
|
content: 'matQuery.html',
|
success: function (layero, index) {
|
$('.layui-layer-title').css('font-size', '16px');
|
},
|
end: function () {
|
$('#addmatnr').focus();
|
}
|
});
|
}
|
|
// 打开商品弹窗
|
function getBomMat() {
|
matCodeLayerIdx = layer.open({
|
type: 2,
|
title: 'Bom物料',
|
shade: [0.3, '#000'],
|
area: ['90%', '80%'],
|
content: 'bomMatQuery.html',
|
success: function (layero, index) {
|
$('.layui-layer-title').css('font-size', '16px');
|
},
|
end: function () {
|
$('#addBomMatnr').focus();
|
}
|
});
|
}
|
|
// 添加表格数据
|
var matData = [];
|
|
// 获取弹窗返回的值
|
function addTableData(data) {
|
for (var i = 0; i < data.length; i++) {
|
data[i]["count"] = 0
|
}
|
matCodeData = data
|
// 对于options的各项参数有点迷惑,但是试了好多方法,发现加一条limit属性,取数据源长度即可
|
tableIns.reload({data: matCodeData, limit: matCodeData.length});
|
layer.close(matCodeLayerIdx);
|
}
|