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>