var pageCurr; var locNo; 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; layDate.render({ elem: '.layui-laydate-range' ,type: 'datetime' ,range: true }); // 数据渲染 tableIns = table.render({ elem: '#stoQue', headers: {token: localStorage.getItem('token')}, url: baseUrl+'/locMast/page/auth', page: true, limit: 20, limits: [20, 30, 50, 100, 200, 500], even: true, toolbar: '#toolbar', cellMinWidth: 50, cols: [[ {type: 'checkbox'} ,{field: 'locNo', align: 'center',title: '库位号'} ,{field: 'locSts$', align: 'center',title: '库位状态', width: 180, style: 'color: #8E2323'} ,{field: 'whsType$', align: 'center',title: '库位类型'} ,{field: 'barcode', align: 'center',title: '托盘码'} //,{field: 'crnNo', align: 'center',title: '堆垛机号'} ,{field: 'row1', align: 'center',title: '排'} ,{field: 'bay1', align: 'center',title: '列'} ,{field: 'lev1', align: 'center',title: '层'} ,{field: 'owner', align: 'center',title: '货主'} ,{field: 'fullPlt', align: 'center',title: '满板', templet:function(row){ var html = " { let locNo = item.locNo; let pics = item.pics; pics.forEach((pic) => { let tmp = '
' + locNo + '
'; imgHtml += tmp; }) }) imgHtml += ""; layer.open({ type: 1, title: '查看图片', area: [top.detailWidth, top.detailHeight], shadeClose: true, content: imgHtml, success: function(layero, index){ } }); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } } }); break; } }); // iframe物料详情 function locDetlToLayer(val) { locNo = val; layer.open({ type: 2, title: '库存明细', maxmin: true, area: [top.detailWidth, top.detailHeight], shadeClose: true, content: '../report/locDetl.html', success: function(layero, index){ } }); } // div物料详情 var pageCur; function locDetl(locNo){ $('#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: [[ // {type: 'checkbox'} {field: 'locNo$', align: 'center',title: '库位号'} ,{field: 'matnr', align: 'center',title: '物料'} ,{field: 'lgnum', align: 'center',title: '仓库号'} ,{field: 'tbnum', align: 'center',title: '转储请求编号'} // ,{field: 'tbpos', align: 'center',title: '行项目'} ,{field: 'zmatid', align: 'center',title: '物料标签ID'} ,{field: 'maktx', align: 'center',title: '物料描述'} ,{field: 'werks', align: 'center',title: '工厂'} ,{field: 'anfme', align: 'center',title: '数量'} ,{field: 'altme', align: 'center',title: '单位'} ,{field: 'zpallet', align: 'center',title: '托盘条码'} ,{field: 'bname', align: 'center',title: '用户ID'} ]], 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'; } }); } }); } // 搜索栏重置事件 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); } }); } }); // 关闭动作 $(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(); } });