数据表格示例
2020-02-24 21:12:01HQadmin

表格代码

JS代码

layui.use(['layer', 'form', 'table', 'util', 'dropdown'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var util = layui.util;
        var admin = layui.admin;
        var dropdown = layui.dropdown;

        // 渲染回访表格
        var insTb = table.render({
            elem: '#tableTrack',
            url: "{:url('user/log/index_json')}",
            page: true,
            limit:20,
            cols: [[
                {type: 'numbers', title: '#'},
                {field: 'create_time', sort: true,title: '操作时间'},
                {align: 'center', sort: true, title: '姓名',templet:'#username'},
                {field: 'url', align: 'left', sort: true, title: 'url'},
                {field: 'ip', align: 'center', sort: true, title: 'IP'},
                {field: 'remark', align: 'left', sort: true, title: '操作内容'}
            ]],
            parseData: function(res){ //res 即为原始返回的数据
                return {
                  "code": res.code, //解析接口状态
                  "msg": res.msg, //解析提示文本
                  "count": res.data.total, //解析数据长度
                  "data": res.data.data //解析数据列表
                };
            }
        });

监听工具条

        table.on('tool(tableTrack)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值
            if (layEvent === 'edit') { // 查看
                hqIframe("{:url('user/staff/edit')}?id=" + data.id,'修改用户信息','390px','470px');
            } else if (layEvent === 'del') { // 删除
                hqDelete("{:url('user/staff/del')}?id=" + data.id);
            }
            dropdown.hideAll();
        });

IF语句

                    {{# if(d.id === d.shop.admin_id){ }}
            主账号            {{# } }}

状态切换

                    

修改删除(修改是iframe)

            修改            删除