var nowcurr = 1 //当前页
//第一个实例
var tableIns = table.render({
id: "role",
elem: '#demo',
limit: 20,
size: 'lg',
method: 'POST',
url: '/admin/root/roleList' //数据接口
,
page: true //开启分页
,
where: {
"token": localStorage.getItem('token'),
},
totalRow: true,
limits: [20, 40, 60, 80, 100],
limit: 1,
cols: [
[ //表头
{
field: 'roleId',
title: 'ID',
align: 'center'
}, {
field: 'name',
title: '用户昵称',
align: 'center',
}, {
field: 'desc',
title: '描述',
align: 'center',
}, {
field: 'status',
title: '是否启用',
align: 'center',
templet: function (d) {
if (d.status == 0) { //未打卡
return ' <span class="layui-btn layui-btn-normal layui-btn-mini">已启用</span></td>';
} else {
return "已打开"
}
}
}, {
toolbar: '#bianji',
title: '编辑',
align: 'center',
width: 200
},
]
],
id: 'testReload',
parseData: function (res) { //res 即为原始返回的数据
}, done: function (res, curr, count) { //返回数据执行回调函数
nowcurr = curr //设置当前页
layer.close(loading); //返回数据关闭loading
}
});
弹出框 一定时间之后回调 保证弹框内容能看清楚
layer.msg(result.msg, {
icon: 6, time: 1500, shade: 0.4
}, function () {
layer.closeAll();//疯狂模式,关闭所有层
tableIns.reload({
page: {
curr: nowcurr
}
});
});