var pageCurr;
|
var locNo;
|
var detailLayerIndex;
|
|
// Define i18n mapping for auto-complete fields
|
window.i18nEnumMap = {
|
'basWhsQueryBywhsType': {
|
'1': 'standard_crane_whs',
|
'2': 'flat_whs',
|
'3': 'shuttle_board',
|
'4': 'four_way_vehicle',
|
'5': 'agv'
|
},
|
'basLocStsQueryBylocSts': function(id) {
|
return 'loc_status_' + id;
|
}
|
};
|
|
layui.use(['table','laydate', 'form'], function(){
|
var table = layui.table;
|
var $ = layui.jquery;
|
var layer = layui.layer;
|
var layDate = layui.laydate;
|
var form = layui.form;
|
var tableIns, tableIns1;
|
|
layDate.render({
|
elem: '.layui-laydate-range'
|
,type: 'datetime'
|
,range: true
|
});
|
|
// 获取主表表头
|
function getCol() {
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
return [[
|
{type: 'checkbox'}
|
,{field: 'locNo', align: 'center',title: i18n ? I18n.t('location_no') : '库位号', hide:false}
|
,{field: 'locSts$', align: 'center',title: i18n ? I18n.t('location_status') : '库位状态', width: 180, style: 'color: #8E2323', hide:false, templet: function(d) {
|
if (typeof I18n !== 'undefined' && I18n.isReady() && d.locSts) {
|
var key = 'loc_status_' + d.locSts.trim();
|
var text = I18n.t(key);
|
if (text !== key) return text;
|
}
|
return d.locSts$ || d.locSts;
|
}}
|
,{field: 'whsType$', align: 'center',title: i18n ? I18n.t('location_type') : '库位类型', width: 180, style: 'color: #8E2323', hide:false, templet: function(d) {
|
if (typeof I18n !== 'undefined' && I18n.isReady() && d.whsType) {
|
var map = {
|
'1': 'standard_crane_whs',
|
'2': 'flat_whs',
|
'3': 'shuttle_board',
|
'4': 'four_way_vehicle',
|
'5': 'agv'
|
};
|
var key = map[d.whsType];
|
if (key) return I18n.t(key);
|
}
|
return d.whsType$ || d.whsType;
|
}}
|
,{field: 'crnNo', align: 'center',title: i18n ? I18n.t('crane_no') : '堆垛机号', sort:true, hide:false}
|
,{field: 'row1', align: 'center',title: i18n ? I18n.t('row') : '排', sort:true, hide:true}
|
,{field: 'bay1', align: 'center',title: i18n ? I18n.t('bay') : '列', sort:true, hide:true}
|
,{field: 'lev1', align: 'center',title: i18n ? I18n.t('level') : '层', sort:true, hide:true}
|
,{field: 'gro1', align: 'center',title: i18n ? I18n.t('group') : '组', sort:true, hide:true}
|
,{field: 'fullPlt', align: 'center',title: i18n ? I18n.t('full_pallet') : '满盘', templet:function(row){
|
var html = "<input value='fullPlt' type='checkbox' lay-skin='primary' lay-filter='tableCheckbox' table-index='"+row.LAY_TABLE_INDEX+"'";
|
if(row.fullPlt === 'Y'){html += " checked ";}
|
html += "disabled='disabled' >";
|
return html;
|
},width:80}
|
,{field: 'barcode', align: 'center',title: i18n ? I18n.t('barcode') : '托盘条码', hide:false}
|
,{field: 'locType1$', align: 'center',title: i18n ? I18n.t('high_low_type') : '高低位', hide:true}
|
,{field: 'locType2$', align: 'center',title: i18n ? I18n.t('width_type') : '宽窄板', hide:true}
|
,{field: 'locType3$', align: 'center',title: i18n ? I18n.t('weight_type') : '载重', hide:true}
|
,{field: 'modiUser$', align: 'center',title: i18n ? I18n.t('modifier') : '更新者', hide:true}
|
,{field: 'modiTime$', align: 'center',title: i18n ? I18n.t('modify_time') : '更新时间', width: 180, hide:false}
|
,{ fixed: 'right', title: i18n ? I18n.t('operation') : '操作', align: 'center', toolbar: '#operate'}
|
]];
|
}
|
|
// 数据渲染
|
window.initTable = function() {
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
tableIns = table.render({
|
elem: '#stoQue',
|
headers: {token: localStorage.getItem('token')},
|
url: baseUrl+'/locMast/list/auth',
|
page: true,
|
limit: 20,
|
limits: [20, 30, 50, 100, 200, 500],
|
even: true,
|
toolbar: '#toolbar',
|
cellMinWidth: 50,
|
cols: getCol(),
|
text: {
|
none: i18n ? I18n.t('no_data') : '无数据'
|
},
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
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();
|
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';
|
}
|
});
|
if (count === 1){
|
// locDetl(res.data[0][locNo]);
|
}
|
if (typeof I18n !== 'undefined') {
|
I18n.updatePage();
|
setTimeout(function() {
|
I18n.updateLayuiPagination();
|
}, 50);
|
// 再次尝试,确保分页被翻译
|
var retryCount = 0;
|
var interval = setInterval(function() {
|
if ($('.layui-table-page').length > 0) {
|
I18n.updateLayuiPagination();
|
retryCount++;
|
if (retryCount > 5) clearInterval(interval);
|
} else {
|
clearInterval(interval);
|
}
|
}, 100);
|
}
|
}
|
});
|
}
|
|
initTable();
|
if (typeof I18n === 'undefined' || !I18n.isReady()) {
|
$(document).on('i18n:ready', initTable);
|
}
|
|
$(document).on('i18n:languageChanged', function() {
|
initTable();
|
// Reload detail table if it's visible
|
if ($('#detlTable').css('display') !== 'none' && locNo) {
|
locDetl(locNo);
|
}
|
// Update layer title if open
|
if (detailLayerIndex && $('#layui-layer' + detailLayerIndex).length > 0) {
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
layer.title(i18n ? I18n.t('inventory_detail') : '库存明细', detailLayerIndex);
|
}
|
|
$('[data-i18n-placeholder]').each(function() {
|
var key = $(this).attr('data-i18n-placeholder');
|
if (typeof I18n !== 'undefined' && I18n.isReady()) {
|
$(this).attr('placeholder', I18n.t(key));
|
}
|
});
|
|
I18n.updatePage();
|
form.render('select');
|
});
|
|
// 监听排序事件
|
table.on('sort(stoQue)', 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();
|
}
|
});
|
});
|
|
// 监听头工具栏事件
|
table.on('toolbar(stoQue)', function (obj) {
|
var checkStatus = table.checkStatus(obj.config.id);
|
switch(obj.event) {
|
// 更新库存
|
case 'refreshSto': // todo:luxiaotao
|
alert("还没做");
|
break;
|
case 'exportData':
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
layer.confirm(i18n ? I18n.t('confirm_export_excel') : '确定导出Excel吗', {shadeClose: true}, function(){
|
var titles=[];
|
var fields=[];
|
obj.config.cols[0].map(function (col) {
|
if (col.type === 'normal' && col.hide === false && col.toolbar == null) {
|
titles.push(col.title);
|
fields.push(col.field);
|
}
|
});
|
var exportData = {};
|
$.each($('#search-box [name]').serializeArray(), function() {
|
exportData[this.name] = this.value;
|
});
|
var param = {
|
'wrkLastno': exportData,
|
'fields': fields
|
};
|
$.ajax({
|
url: baseUrl+"/wrkLastno/export/auth",
|
headers: {'token': localStorage.getItem('token')},
|
data: JSON.stringify(param),
|
dataType:'json',
|
contentType:'application/json;charset=UTF-8',
|
method: 'POST',
|
success: function (res) {
|
layer.closeAll();
|
if (res.code === 200) {
|
table.exportFile(titles,res.data,'xls');
|
} else if (res.code === 403) {
|
top.location.href = baseUrl+"/";
|
} else {
|
layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2})
|
}
|
}
|
});
|
});
|
break;
|
}
|
});
|
|
// 监听行工具事件
|
table.on('tool(stoQue)', function(obj) {
|
var data = obj.data;
|
switch (obj.event) {
|
// 查看明细
|
case 'locDetl':
|
// locDetl(data.locNo);
|
if (data.locSts.trim() === ''
|
|| data.locSts.trim() === 'S'
|
|| data.locSts.trim() === 'D'
|
|| data.locSts.trim() === 'O') {
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
layer.msg(i18n ? I18n.t('location_status_no_material') : "此库位的状态不存在物料");
|
return;
|
}
|
locDetlToLayer(data.locNo);
|
break;
|
}
|
});
|
|
// iframe物料详情
|
function locDetlToLayer(val) {
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
locNo = val;
|
detailLayerIndex = layer.open({
|
type: 2,
|
title: i18n ? I18n.t('inventory_detail') : '库存明细',
|
maxmin: true,
|
area: [top.detailWidth, top.detailHeight],
|
shadeClose: true,
|
content: '../report/locDetl.html',
|
success: function(layero, index){
|
}
|
});
|
}
|
// div物料详情
|
var pageCur;
|
function getDetlCols() {
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
return [[
|
// {type: 'checkbox'}
|
{field: 'locNo$', align: 'center',title: i18n ? I18n.t('location_no') : '库位号'}
|
,{field: 'matnr', align: 'center',title: i18n ? I18n.t('material') : '物料'}
|
,{field: 'lgnum', align: 'center',title: i18n ? I18n.t('warehouse_no') : '仓库号'}
|
,{field: 'tbnum', align: 'center',title: i18n ? I18n.t('transfer_req_no') : '搬运凭证'}
|
// ,{field: 'tbpos', align: 'center',title: '行项目'}
|
,{field: 'zmatid', align: 'center',title: i18n ? I18n.t('material_label_id') : '物料标签ID'}
|
,{field: 'maktx', align: 'center',title: i18n ? I18n.t('material_desc') : '物料描述'}
|
,{field: 'werks', align: 'center',title: i18n ? I18n.t('factory') : '工厂'}
|
,{field: 'anfme', align: 'center',title: i18n ? I18n.t('quantity') : '数量'}
|
,{field: 'altme', align: 'center',title: i18n ? I18n.t('unit') : '单位'}
|
,{field: 'zpallet', align: 'center',title: i18n ? I18n.t('pallet_barcode') : '托盘条码'}
|
,{field: 'bname', align: 'center',title: i18n ? I18n.t('user_id') : '用户ID'}
|
]];
|
}
|
|
function locDetl(locNo){
|
var i18n = (typeof I18n !== 'undefined' && I18n.isReady());
|
$('#detlTable').css("display", 'block');
|
// 数据渲染
|
tableIns1 = table.render({
|
elem: '#locDetlByMap',
|
headers: {token: localStorage.getItem('token')},
|
url: baseUrl+'/locDetl/list/auth',
|
page: true,
|
limit: 5,
|
skin: 'line',
|
where: {loc_no: locNo},
|
even: true,
|
cellMinWidth: 50,
|
cols: getDetlCols(),
|
text: {
|
none: i18n ? I18n.t('no_data') : '无数据'
|
},
|
request: {
|
pageName: 'curr',
|
pageSize: 'limit'
|
},
|
parseData: function (res) {
|
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+"/";
|
}
|
pageCur=curr;
|
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';
|
}
|
});
|
if (typeof I18n !== 'undefined') {
|
I18n.updatePage($('#detlTable'));
|
setTimeout(function() {
|
I18n.updateLayuiPagination();
|
}, 50);
|
}
|
}
|
});
|
}
|
|
// 搜索栏重置事件
|
form.on('submit(reset)', function (data) {
|
pageCurr = 1;
|
clearFormVal($('#search-box'));
|
$('#detlTable').css("display", 'none');
|
tableReload(false);
|
});
|
|
// 搜索栏搜索事件
|
form.on('submit(search)', function (data) {
|
pageCurr = 1;
|
$('#detlTable').css("display", 'none');
|
tableReload(false);
|
});
|
|
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 (count === 1){
|
// locDetl(res.data[0][locNo]);
|
}
|
if (res.data.length === 0 && count !== 0) {
|
tableIns.reload({
|
where: searchData,
|
page: {
|
curr: pageCurr-1
|
}
|
});
|
pageCurr -= 1;
|
}
|
limit(child);
|
if (typeof I18n !== 'undefined') {
|
I18n.updatePage();
|
setTimeout(function() {
|
I18n.updateLayuiPagination();
|
}, 50);
|
}
|
}
|
});
|
}
|
});
|
|
// 关闭动作
|
$(document).on('click','#data-detail-close', function () {
|
parent.layer.closeAll();
|
});
|
|
function setFormVal(el, data, showImg) {
|
for (var val in data) {
|
var find = el.find(":input[id='" + val + "']");
|
find.val(data[val]);
|
if (showImg){
|
var next = find.next();
|
if (next.get(0)){
|
if (next.get(0).localName === "img") {
|
find.hide();
|
next.attr("src", data[val]);
|
next.show();
|
}
|
}
|
}
|
}
|
}
|
|
function clearFormVal(el) {
|
$(':input', el)
|
.val('')
|
.removeAttr('checked')
|
.removeAttr('selected');
|
}
|
|
function detailScreen(index) {
|
var detail = layer.getChildFrame('#data-detail', index);
|
var height = detail.height()+60;
|
if (height > ($(window).height()*0.9)) {
|
height = ($(window).height()*0.9);
|
}
|
layer.style(index, {
|
top: (($(window).height()-height)/3)+"px",
|
height: height+'px'
|
});
|
$(".layui-layer-shade").remove();
|
}
|
|
$('body').keydown(function () {
|
if (event.keyCode === 13) {
|
$("#search").click();
|
}
|
});
|