layui 数据表格 toolbar 模板判断

https://www.layui.com/demo/laytpl.html

   //列表
        function reportList() {
            const url = api.baogaolist;
            let data = {
                token: localStorage.getItem('token'),
                start_time: start_time,
                end_time: end_time,
                baogao_leixing_id:baogao_leixing_id,
                type:type,
                gongsi_name:gongsi_name,
                page:page,
                pagecount:pagecount
            }
            Ajax(url, data, function (res) {
                if (res.errorCode == 0) {
                    let getLocal = localStorage.getItem('role').split(',');
                    let newArr =  res.info.list;
                    newArr.map(function (item,index) {
                        item.role = getLocal;
                    })
                    console.log(newArr)
                    count = res.info.count
                    layui.use('table', function () {
                        var table = layui.table;
                        table.render({
                            elem: '#test'
                            , url: ''
                            , cols: [[
                                {type: 'checkbox'}
                                , {field: 'id', width: 50, title: 'ID',}
                                , {field: 'shangchuan_time_data', width: 200, title: '上传时间'}
                                , {field: 'jituan_name', title: '集团名称'}
                                , {field: 'gongsi_name', title: '公司名称'}
                                , {field: 'baogaomingcheng', title: '报告名称'}
                                , {field: 'baogao_leixing_name', width: 150, title: '报告类型'}
                                , {field: 'jiancexiangmu', width: 200, title: '监测项目' ,toolbar: '#monitor'}
                                , {field: 'wealth', width: 160, title: '操作', toolbar: '#barDemo'}
                            ]]
                            , page: false,
                            data:newArr
                        });

                    });




                } else {
                    alert(res.errorValue)

                }
            })
        }
        reportList();
<!--操作-->
<script type="text/html" id="barDemo">
    {{# layui.each(d.role, function(index, item){     }}
    {{# if(item == 25){ }}
    <a class="layui-btn layui-btn-xs editFile" data-id="{{d.id}}">编辑</a>
    {{#}}}
    {{# });  }}
    {{# layui.each(d.role, function(index, item){     }}
    {{# if(item == 23){ }}
    <a class="layui-btn layui-btn-xs uploadFile" data-url="{{d.url}}" lay-event="edit">下载</a>
    {{#}}}
    {{# });  }}

    {{# layui.each(d.role, function(index, item){     }}
    {{# if(item == '24'){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs deleteFile" data-id="{{d.id}}" lay-event="del">删除</a>
    {{# } }}
    {{# });  }}
</script>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值