var pageCurr;
|
var locNormalList = [];
|
var locArea = [];
|
|
function getCol() {
|
var cols = [];
|
cols.push(
|
{field: 'anfme', align: 'center', title: '数量', sort: true, edit: 'text'}
|
)
|
cols.push.apply(cols, locNormalCols);
|
cols.push(
|
{field: 'warehouse$', align: 'center', title: '库区'}
|
, {field: 'state', align: 'center', title: '出入库状态', templet: '#locNormalState'}
|
, {field: 'modiUser$', align: 'center', title: '修改人员', hide: true}
|
, {field: 'modiTime$', align: 'center', title: '修改时间', hide: true}
|
, {field: 'appeTime$', align: 'center', title: '创建时间', hide: true}
|
, {field: '', align: 'center', title: '操作', width: 135, fixed: 'right', templet: '#operate'}
|
);
|
return cols;
|
}
|
|
// 获取仓库下拉
|
$.ajax({
|
url: baseUrl + "/locArea/queryAll/auth",
|
headers: {'token': localStorage.getItem('token')},
|
// data: top.reObject(data),
|
method: 'POST',
|
success: function (res) {
|
if (res.data && res.data.length > 0) {
|
locArea = res.data;
|
}
|
},
|
});
|
|
// 库区下拉
|
// 获取仓库下拉
|
$.ajax({
|
url: baseUrl + "/locArea/queryAll/auth",
|
headers: {'token': localStorage.getItem('token')},
|
method: 'POST',
|
success: function (res) {
|
if (res.code === 200) {
|
var html = "";
|
if (res.data && res.data.length > 0) {
|
html += res.data.map(function (item) {
|
return "<Option value=" + item.uuid + ">" + item.name + "</Option>";
|
});
|
}
|
$('#putSiteSelect').append(html);
|
} else if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
} else {
|
layer.msg(res.msg)
|
}
|
}
|
})
|
|
layui.use(['table', 'laydate', 'form', 'upload'], function () {
|
var table = layui.table;
|
var $ = layui.jquery;
|
var layer = layui.layer;
|
var layDate = layui.laydate;
|
var form = layui.form;
|
var upload = layui.upload;
|
|
// 导入excel
|
var uploader = upload.render({
|
elem: '#uploadEx'
|
, url: baseUrl + '/locNormal/import/auth'
|
, headers: {token: localStorage.getItem('token')}
|
, accept: 'file'
|
, exts: 'xls|excel|xlsx'
|
, auto: false
|
, bindAction: '#uploadDo'
|
, before: function (obj) {
|
layer.closeAll();
|
layer.load(1, {shade: [0.1, '#fff']});
|
}
|
, choose: function (obj) {
|
$('#uploadDesc').hide();
|
$('#uploadDemoView').show();
|
obj.preview(function (index, file, result) {
|
$('#fileMame').html(file.name);
|
});
|
}
|
, done: function (res) {
|
limit();
|
$('#uploadDesc').show();
|
$('#uploadDemoView').hide();
|
$('#fileMame').html("");
|
layer.closeAll('loading');
|
layer.msg(res.msg);
|
tableReload(false);
|
}
|
, error: function (index, upload) {
|
layer.closeAll('loading');
|
}
|
});
|
|
/* 导入 */
|
table.on('toolbar(locNormal)', function (obj) {
|
switch (obj.event) {
|
// 导入
|
case 'intoData':
|
layer.open({
|
type: 1,
|
title: '数据导入',
|
shadeClose: true,
|
content: $('#importDataDiv'),
|
success: function (layero, index) {
|
uploader.reload();
|
},
|
end: function () {
|
$('#uploadDesc').show();
|
$('#uploadDemoView').hide();
|
$('#fileMame').html("");
|
}
|
});
|
break;
|
}
|
});
|
|
|
// 数据渲染
|
tableIns = table.render({
|
elem: '#locNormal',
|
headers: {token: localStorage.getItem('token')},
|
url: baseUrl + '/locNomal/list/auth',
|
page: true,
|
limit: 16,
|
limits: [16, 30, 50, 100, 200, 500],
|
even: true,
|
toolbar: '#toolbar',
|
cellMinWidth: 50,
|
cols: [getCol()],
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
// 解析库区名称
|
var records = res.data.records;
|
records.map(function (item) {
|
locArea.map(function (d) {
|
if (d.uuid == item.warehouse) {
|
item.warehouse$ = d.name;
|
}
|
})
|
});
|
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 + "/";
|
}
|
pageCurr = curr;
|
limit();
|
// 当前分页数据存储
|
locNormalList = res.data;
|
}
|
});
|
|
// 监听排序事件
|
table.on('sort(locNormal)', function (obj) {
|
var searchData = {};
|
$.each($('#search-box [name]').serializeArray(), function () {
|
searchData[this.name] = this.value;
|
});
|
searchData['orderByField'] = obj.field;
|
searchData['orderByType'] = obj.type;
|
tableIns.reload({
|
where: searchData,
|
page: {
|
curr: 1
|
},
|
done: function (res, curr, count) {
|
if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
}
|
pageCurr = curr;
|
limit();
|
// 当前分页数据存储
|
locNormalList = res.data;
|
}
|
});
|
});
|
|
// 页面修改
|
table.on('edit(locNormal)', function (obj) {
|
var count = obj.value;
|
var matnr = obj.data.matnr;
|
var id = obj.data.id;
|
|
if (isNaN(count)) {
|
layer.msg("请输入数字");
|
// 数据重载
|
tableIns.reload({
|
data: locNormalList, done: function (res) {
|
limit();
|
}
|
});
|
} else {
|
if (count > 0) {
|
for (var i = 0; i < locNormalList.length; i++) {
|
if (locNormalList[i]["matnr"] === matnr) {
|
locNormalList[i]["anfme"] = count;
|
}
|
}
|
} else {
|
layer.msg("数量必须大于零");
|
}
|
}
|
// 请求更新接口完成数量的更新
|
const param = {
|
matnr: matnr,
|
anfme: count,
|
id: id,
|
warehouse: obj.data.warehouse,
|
supplier: obj.data.supplier,
|
mnemonic: obj.data.mnemonic,
|
}
|
layer.confirm("确定修改" + obj.data.maktx + "的数量吗", {
|
btn: ['确定', '取消']
|
}, function () {
|
// 按钮1的事件
|
$.ajax({
|
url: baseUrl + "/locNormal/update/auth",
|
headers: {'token': localStorage.getItem('token')},
|
data: top.reObject(param),
|
method: 'POST',
|
success: function (res) {
|
layer.msg("")
|
},
|
});
|
}, function () {
|
// 按钮2的事件
|
tableIns.reload();
|
});
|
});
|
|
// 搜索栏重置事件
|
form.on('submit(reset)', function (data) {
|
pageCurr = 1;
|
clearFormVal($('#search-box'));
|
tableReload(false);
|
});
|
|
// 搜索栏搜索事件
|
form.on('submit(search)', function (data) {
|
pageCurr = 1;
|
tableReload(false);
|
});
|
|
// 监听行工具事件
|
table.on('tool(locNormal)', function (obj) {
|
var data = obj.data;
|
var param = {
|
matnr: data.matnr,
|
id: data.id,
|
}
|
switch (obj.event) {
|
case 'outLocNormal':
|
layer.confirm('确定要出库[' + data.matnr + ']吗?', {
|
btn: ['确定', '取消'] //可以无限个按钮
|
}, function (index, layero) {
|
//确定回调-出库
|
$.ajax({
|
url: baseUrl + "/locNormal/outLoc/auth",
|
headers: {'token': localStorage.getItem('token')},
|
data: top.reObject(param),
|
method: 'POST',
|
success: function (res) {
|
tableReload(false);
|
layer.closeAll();
|
layer.msg("出库成功");
|
},
|
});
|
}, function (index) {
|
//按钮【按钮二】的回调
|
});
|
break;
|
case 'removeLocNormal':
|
// 移除
|
layer.confirm('确定要移除[' + data.matnr + ']吗?', {
|
btn: ['确定', '取消'] //可以无限个按钮
|
}, function (index, layero) {
|
//确定回调-移除
|
$.ajax({
|
url: baseUrl + "/locNormal/removeLoc/auth",
|
headers: {'token': localStorage.getItem('token')},
|
data: top.reObject(param),
|
method: 'POST',
|
success: function (res) {
|
tableReload(false);
|
layer.closeAll();
|
layer.msg("移除成功");
|
},
|
});
|
}, function (index) {
|
//按钮【按钮二】的回调
|
});
|
break;
|
}
|
});
|
|
|
});
|
|
/* 表格数据重载 */
|
function tableReload(child) {
|
var searchData = {};
|
$.each($('#search-box [name]').serializeArray(), function () {
|
searchData[this.name] = this.value;
|
});
|
(child ? parent.tableIns : tableIns).reload({
|
where: searchData,
|
page: {
|
curr: pageCurr
|
},
|
done: function (res, curr, count) {
|
if (res.code === 403) {
|
top.location.href = baseUrl + "/";
|
}
|
pageCurr = curr;
|
if (res.data.length === 0 && count !== 0) {
|
tableIns.reload({
|
where: searchData,
|
page: {
|
curr: pageCurr - 1
|
}
|
});
|
pageCurr -= 1;
|
}
|
limit(child);
|
// 当前分页数据存储
|
locNormalList = res.data;
|
}
|
});
|
}
|
|
/* 监听回车事件 */
|
$('body').keydown(function () {
|
if (event.keyCode === 13) {
|
$("#search").click();
|
}
|
});
|
|
// 提取物料
|
var addLocNormalIdx;
|
|
function addLocNormal() {
|
addLocNormalIdx = layer.open({
|
type: 2,
|
title: '新增',
|
maxmin: true,
|
area: [top.detailWidth, '550px'],
|
shadeClose: true,
|
content: 'addLocNormal.html',
|
success: function (layero, index) {
|
}
|
});
|
}
|