当一个页面里存在多个table表格时,加载页面通过以下方式获取表格数据:
var tableIns = table.render({
elem: '#purchaseList',
url: ctx + '/purchase/list',
height: "full-125",
page: true,
limits: [10, 15, 20, 25],
id: "purchaseListTable",
cols: [[
{field: "id", title: '编号', fixed: "true", width: 80},
{field: 'purchaseNumber', title: '采购单号', minWidth: 50, align: "center"},
{field: 'purchaseDate', title: '日期', minWidth: 50, align: "center"},
{field: 'supplierName', title: '供应商', minWidth: 100, align: 'center'},
{field: 'amountPayable', title: '金额', minWidth: 100, align: 'center'},
{field: 'userName', title: '操作员', minWidth: 100, align: 'center'},
{field: 'remarks', title: '备注', minWidth: 100, align: 'center'},
{title: '操作', minWidth: 150, templet: '#purchaseListBar', fixed: "right", align: "center"}
]]
});
var tableIns02 = table.render({
elem: '#purchaseListGoods',
url: ctx + '/purchaseListGoods/list',
height: "full-125",
page: true,
limits: [10, 15, 20, 25],
id: "purchaseListGoodsTable",
cols: [[
{field: 'code', title: '药品编码', minWidth: 50, align: "center"},
{field: 'name', title: '药品名称', minWidth: 50, align: "center"},
{field: 'model', title: '规格', minWidth: 100, align: 'center'},
{field: 'price', title: '单价', minWidth: 80, align: 'center'},
{field: 'num', title: '数量', minWidth: 70, align: 'center'},
{field: 'unit', title: '剂型', minWidth: 100, align: 'center'},
{field: 'total', title: '总金额', minWidth: 80, align: 'center'},
{title: '操作', minWidth: 70, templet: '#purchaseListGoodsBar', fixed: "right", align: "center"}
]]
});
可以通过layui.table.cache.【tablename】分别获取表格的数据(数据分页时,是当页还是全部还在验证);tablename为上面代码标红部分