var locDetlLayerIdx;
|
var locDetlData = [];
|
function getCol() {
|
var cols = [
|
];
|
arrRemove(plaCols, 'type', 'checkbox');
|
cols.push.apply(cols, plaCols);
|
cols.push({fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width: 80})
|
return cols;
|
}
|
|
layui.config({
|
base: baseUrl + "/static/layui/lay/modules/"
|
}).use(['table','laydate', 'form', 'admin'], function() {
|
var table = layui.table;
|
var $ = layui.jquery;
|
var layer = layui.layer;
|
var form = layui.form;
|
var admin = layui.admin;
|
|
tableIns = table.render({
|
elem: '#chooseData',
|
headers: {token: localStorage.getItem('token')},
|
data: [],
|
totalRow: true, // 开启合计行
|
height: function(){
|
var otherHeight = $('.function-area').outerHeight() + $('#search-box').outerHeight(); // 自定义其他区域的高度
|
console.log($(window).height() - otherHeight);
|
return $(window).height() - otherHeight - 100; // 返回 number 类型
|
},
|
//height: 'full',
|
even: true,
|
toolbar: '#toolbar',
|
cellMinWidth: 50,
|
cols: [function(){
|
var arr = getCol();
|
|
// 初始化筛选状态
|
var local = layui.data('table-filter-test'); // 获取对应的本地记录
|
layui.each(arr, function(index, item){
|
if(item.field in local){
|
item.hide = local[item.field];
|
}
|
});
|
return arr;
|
}() ],
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
console.log(res)
|
return {
|
'code': res.code,
|
'msg': res.msg,
|
'count': res.data.total,
|
'data': res.data.records,
|
}
|
},
|
response: {
|
statusCode: 200
|
},
|
done: function(res, curr, count) {
|
// 记录筛选状态
|
var that = this;
|
that.elem.next().on('mousedown', 'input[lay-filter="LAY_TABLE_TOOL_COLS"]+', function(){
|
var input = $(this).prev()[0];
|
// 此处表名可任意定义
|
layui.data('table-filter-test', {
|
key: input.name
|
,value: input.checked
|
})
|
});
|
|
//$(".lavui-table-grid-down").hide();
|
if (res.code === 403) {
|
top.location.href = baseUrl+"/";
|
}
|
tableData = table.cache.locDetl;
|
console.log(tableData);
|
pageCurr=curr;
|
limit();
|
form.on('checkbox(tableCheckbox)', function (data) {
|
var _index = $(data.elem).attr('table-index')||0;
|
if(data.elem.checked){
|
res.data[_index][data.value] = 'Y';
|
}else{
|
res.data[_index][data.value] = 'N';
|
}
|
});
|
let headerTop = $('.layui-table-header').offset().top; //获取表格头到文档顶部的距离
|
let headerPage = $('.layui-table-page').offset().top; //获取表格底部文档顶部的距离
|
$(window).scroll(function () {
|
if ((headerTop - $(window).scrollTop()) < 0) { //超过了
|
$('.layui-table-header').addClass('table-header-fixed'); //添加样式,固定住表头
|
} else { //没超过
|
$('.layui-table-header').removeClass('table-header-fixed'); //移除样式
|
}
|
});
|
}
|
});
|
|
// 页面修改
|
table.on('edit(chooseData)', function (obj) {
|
let index = obj.tr.attr("data-index");
|
let data = locDetlData[index];
|
let modify = true;
|
if (obj.field === 'count'){
|
let vle = Number(obj.value);
|
if (isNaN(vle)) {
|
layer.msg("请输入数字", {icon: 2});
|
modify = false;
|
} else {
|
if (vle <= 0) {
|
layer.msg("数量必须大于零", {icon: 2});
|
modify = false;
|
}
|
if (vle > Number(data.anfme)) {
|
layer.msg("出库数量不得大于库存数量", {icon: 2});
|
modify = false;
|
}
|
}
|
}
|
if (modify) {
|
data[obj.field] = obj.value;
|
}
|
tableIns.reload({data: locDetlData});
|
});
|
|
// 监听头工具栏事件
|
table.on('toolbar(chooseData)', function (obj) {
|
switch (obj.event) {
|
case 'outbound':
|
if (locDetlData.length === 0){
|
layer.msg('请先提取商品库存', {icon: 2});
|
} else {
|
var data = locDetlData;
|
var brand;
|
|
for(var i=0; i<data.length; i++){
|
if(data[i].status === "暂入库" || data[i].status === "待入库" || data[i].status === "全部出库"|| data[i].weightAnfme < data[i].qtyAnfme){
|
layer.msg("选中的明细还未入库或者已全部出库或者没有剩余可出重量,请重新选择");
|
return;
|
}
|
|
brand = brand ? brand : data[i].brand;
|
|
if(brand != data[i].brand){
|
layer.msg("选中的明细中含有多种牌号,请重新选择");
|
return;
|
}
|
// if(data[i].stockFreeze === 0){
|
// layer.msg("选中的明细中含有冻结的库存,请解冻后操作");
|
// return;
|
// }
|
}
|
|
layer.open({
|
type: 2,
|
title: '出库',
|
maxmin: true,
|
area: ['800px', top.detailHeight],
|
shadeClose: false,
|
content: 'sellout.html',
|
success: function(layero, index){
|
//layer.getChildFrame('#data-detail-submit-edit', index).hide();
|
top.convertDisabled(layer.getChildFrame('#data-detail :input', index), false);
|
layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
|
|
var iframe = window['layui-layer-iframe' + index];
|
iframe.child(locDetlData)
|
}
|
});
|
}
|
break;
|
}
|
});
|
|
// 监听行工具事件
|
table.on('tool(chooseData)', function(obj){
|
switch (obj.event) {
|
case 'remove':
|
let index = obj.tr.attr("data-index");
|
locDetlData.splice(index, 1);
|
tableIns.reload({data: locDetlData});
|
break;
|
}
|
});
|
|
// 获取出库口
|
function getOutBound(){
|
$.ajax({
|
url: baseUrl+"/available/take/site",
|
headers: {'token': localStorage.getItem('token')},
|
method: 'POST',
|
async: false,
|
success: function (res) {
|
if (res.code === 200){
|
var tpl = $("#takeSiteSelectTemplate").html();
|
var template = Handlebars.compile(tpl);
|
var html = template(res);
|
$('#staNoSelect').append(html);
|
form.render('select');
|
} else if (res.code === 403){
|
top.location.href = baseUrl+"/";
|
}else {
|
layer.msg(res.msg)
|
}
|
}
|
})
|
}
|
|
|
|
$(document).on('click','#mat-query', function () {
|
let loadIndex = layer.msg('请求中...', {icon: 16, shade: 0.01, time: false});
|
locDetlLayerIdx = layer.open({
|
type: 2,
|
title: false,
|
closeBtn: false,
|
maxmin: false,
|
area: ['90%', '85%'],
|
shadeClose: true,
|
content: 'locDetlQuery.html',
|
success: function(layero, index){
|
layer.close(loadIndex);
|
}
|
});
|
})
|
|
})
|
|
// 添加表格数据
|
function addTableData(data) {
|
for (var i=0;i<data.length;i++){
|
let pass = false;
|
for (var j=0;j<locDetlData.length;j++){
|
if (data[i].matnr === locDetlData[j].matnr && data[i].batch === locDetlData[j].batch && data[i].packageNo === locDetlData[j].packageNo) {
|
pass = true;
|
break;
|
}
|
}
|
if (pass) {
|
data.splice(i--, 1);
|
} else {
|
data[i]["count"] = data[i]["anfme"];
|
}
|
}
|
locDetlData.push.apply(locDetlData, data);
|
tableIns.reload({data: locDetlData});
|
layer.close(locDetlLayerIdx);
|
}
|
|
function clearTable(){
|
locDetlData = [];
|
tableIns.reload({data: locDetlData});
|
parent.location.reload();
|
}
|