在layui数据表格展现中,使用toolbar,由于权限的控制,需要使用templet模板引擎语法进行控制,控制逻辑为只有大于当前时间的记录才能撤销。
效果图如下:(当前时间为2018-06-06)
即过了当前日期的记录是无法撤销。
代码:
window.demoTable = table
.render({
elem : '#idTest',
id : 'idTest',
url : '<%=path%>/content/getMryxPublishList',
/* width : 1700,
height : 685, */
width : 1700,
height : 650,
cols : [ [ //标题栏
{checkbox : true,LAY_CHECKED : false,filter : 'test'},
{field : 'TITLE',title : '学习主题',width : 200,sort : true,align : 'left'},
{field : 'LEARN_TYPE_NAME',title : '学习类型',width : 200,sort : true,align : 'center'},
{field : 'CONTENT',title : '学习内容',width : 350,sort : true,align : 'center',toolbar : '#view_content'},
{field : 'PUBLISH_DATE',title : '发布时间',width : 200,align : 'center'},
{fixed : 'right',title : '操作',width : 400,align : 'center',toolbar : '#barDemo'}
] ],
page : true //是否显示分页
,
where: { key:"" },
limits : [ 10, 20,50, 100 ],
limit : 10
,done:function(res,curr,count){
$('table tr').on('click',function(){
$('table tr').css('background','');
$(this).css('background','<%=PropKit.use("config.properties").get("table_color")%>');
});
}
//每页默认显示的数量
});
<script type="text/html" id="barDemo">
{{# if(new Date(d.PUBLISH_DATE) > new Date()){ }}
<a class="layui-btn" lay-event="cancel">撤销</a>
{{# } }}
</script>
使用这个要注意PUBLISH_DATE的数据类型,我这里是输出的是JSON字符串,PUBLISH_DATE为字符串类型。而且这种读取电脑时间去比较有些不妥,因为个人的电脑时间是可以随意修改的,最好跟服务器时间作比较。
专业墙纸贴纸厨房用具装饰出售,本人网店经营,访问即是爱
博客对你有用记得访问下哦,增加下访问量,如有需要可以下单购买哦^_^。https://item.taobao.com/item.htm?id=570637716145