需求说明
点击不同的模型,进入同一个html中,表格头和表格体的数据都是从后台查询,实现动态表格。
接口说明
接口返回数据格式示例:
{
"success":"true",
"result":[{"id":"id","name","ID"},{"id":"aaa","name","姓名"},{"id":"bbb","name","性别"},{"id":"time","name","时间"}]
}
接口返回数据格式示例:
{
"success":"true",
"result":{
"currentPage": 1,
"pageSize": 10,
"totalPage": 1,
"totalSize": 22,
"list": [{
"id": "1",
"aaa": "张三",
"bbb": "男",
"time": "2021-02-20 11:00:02"
},{
"id": "2",
"aaa": "李莉",
"bbb": "女",
"time": "2021-02-20 11:05:02"
}]
}
}
前端代码
<table class="layui-hide" id="layTable" lay-filter="test"></table>
var cols_arr = [] ;
var table=null;
layui.use('table', function(){
table = layui.table;
var modelId = $("#modelId").val();
$.ajax({
async: false,