var pageCurr; 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 layDate = layui.laydate; var form = layui.form; var admin = layui.admin; // 获取出库口 function getOutBound(){ $.ajax({ url: baseUrl+"/available/empty/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); if (typeof I18n !== 'undefined') { I18n.updatePage($('#staNoSelect')); } form.render('select'); } else if (res.code === 403){ top.location.href = baseUrl+"/"; }else { layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg, {icon: 2}) } } }) } // 数据渲染 function getCol() { var i18n = (typeof I18n !== 'undefined' && I18n.isReady()); return [[ {type: 'checkbox', fixed: 'left'} ,{field: 'locNo', align: 'center',title: i18n ? I18n.t('location_no') : '库位号',sort:true} ,{field: 'locSts$', align: 'center',title: i18n ? I18n.t('location_status') : '库位状态',width:200, templet: function(d) { var key = 'loc_status_' + d.locSts; var text = (typeof I18n !== 'undefined' && I18n.isReady()) ? I18n.t(key) : ''; return (text && text !== key) ? text : (d.locSts$ || d.locSts); }} // ,{field: 'whsType$', align: 'center',title: '库位类型'} ,{field: 'crnNo', align: 'center',title: i18n ? I18n.t('crane_no') : '堆垛机号'} ,{field: 'row1', align: 'center',title: i18n ? I18n.t('row') : '排'} ,{field: 'bay1', align: 'center',title: i18n ? I18n.t('bay') : '列'} ,{field: 'lev1', align: 'center',title: i18n ? I18n.t('level') : '层'} ,{field: 'fullPlt', align: 'center',title: i18n ? I18n.t('full_pallet') : '满板', templet:function(row){ var html = " 0) { I18n.updateLayuiPagination(); } if (attempts >= 5) { clearInterval(interval); } }, 100); } } }); }; initTable(); if (typeof I18n === 'undefined' || !I18n.isReady()) { $(document).on('i18n:ready', initTable); } // 监听头工具栏事件 table.on('toolbar(locMast)', function (obj) { var data = table.checkStatus(obj.config.id).data; switch (obj.event) { case 'outbound': var i18n = (typeof I18n !== 'undefined' && I18n.isReady()); var staNo = $("#staNoSelect").val(); if (staNo === "" || staNo === null){ layer.msg(i18n ? I18n.t('please_select_outbound_station') : '请选择出库口'); return; } var locNos = []; data.forEach(function(elem) { locNos.push(elem.locNo); }); if (data.length === 0){ layer.msg(i18n ? I18n.t('select_one_data') : '请选择一条数据'); } else { $.ajax({ url: baseUrl+"/empty/plate/out/start", headers: {'token': localStorage.getItem('token')}, data: { outSite: staNo, locNos: locNos }, method: 'POST', traditional:true, success: function (res) { if (res.code === 200){ tableReload(); // 重载表格 getOutBound(); // 重载出库口 layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg); } else if (res.code === 403){ top.location.href = baseUrl+"/"; } else { layer.msg(typeof I18n !== 'undefined' ? I18n.t(res.msg) : res.msg) } } }); } break; } }); $(document).on('i18n:languageChanged', function() { initTable(); $('[data-i18n-placeholder]').each(function() { var key = $(this).attr('data-i18n-placeholder'); $(this).attr('placeholder', I18n.t(key)); }); I18n.updatePage(); form.render('select'); }); // 搜索栏搜索事件 form.on('submit(search)', function (data) { pageCurr = 1; $('#detlTable').css("display", 'none'); tableReload(false); getOutBound(); }); // 搜索栏重置事件 form.on('submit(reset)', function (data) { pageCurr = 1; clearFormVal($('#search-box')); $('#detlTable').css("display", 'none'); tableReload(false); getOutBound(); }); }) 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); if (typeof I18n !== 'undefined') { I18n.updatePage(); var attempts = 0; var interval = setInterval(function() { attempts++; if ($('.layui-laypage').length > 0) { I18n.updateLayuiPagination(); } if (attempts >= 5) { clearInterval(interval); } }, 100); } } }); }