var pageCurr; layui.config({ base: baseUrl + "/static/layui/lay/modules/" }).use(['table', 'laydate', 'form'], function () { var table = layui.table; var $ = layui.jquery; var layer = layui.layer; var form = layui.form; // 数据渲染(只读模式,无增删改操作) var tableIns = table.render({ elem: '#inventoryReserveLog', headers: { token: localStorage.getItem('token') }, url: baseUrl + '/inventoryReserveLog/list/auth', page: true, limit: 15, limits: [15, 30, 50, 100, 200], cellMinWidth: 50, height: 'full-150', cols: [[ { type: 'numbers', title: '#' }, { field: 'matnr', align: 'center', title: '物料编码' }, { field: 'maktx', align: 'center', title: '物料名称' }, { field: 'orderNo', align: 'center', title: '订单号', width: 150 }, { field: 'batch', align: 'center', title: '批次', width: 120 }, { field: 'quantity', align: 'center', title: '数量', width: 100 }, { field: 'expiceTime$', align: 'center', title: '过期时间', width: 180 }, { field: 'createTime$', align: 'center', title: '原创建时间', width: 180 }, { field: 'updateTime$', align: 'center', title: '转移时间', width: 180 }, { field: 'memo', align: 'center', title: '过期原因', width: 180 } ]], 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; } }); // 搜索 form.on('submit(search)', function (data) { pageCurr = 1; tableReload(); }); // 重置 form.on('submit(reset)', function (data) { pageCurr = 1; clearFormVal($('#search-box')); tableReload(); }); // 表格重载 function tableReload() { var searchData = {}; $.each($('#search-box [name]').serializeArray(), function () { searchData[this.name] = this.value; }); tableIns.reload({ where: searchData, page: { curr: pageCurr } }); } // 清空表单 function clearFormVal(el) { $(':input', el) .val('') .removeAttr('checked') .removeAttr('selected'); } });