FastAdmin后台操作按钮无权限不显示

之前写过几篇关于FastAdmin后台添加操作按钮的文章,其中一篇讲的是在表格中列表的操作上加按钮。

这种方式加上去的按钮默认只要有这个列表页权限的管理员都是能看到的,那怎么通过权限控制它的显示呢?

比如用户列表,打开列表页对应的index.html页,找到如下代码

<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
   data-operate-edit="{:$auth->check('user/user/edit')}"
   data-operate-del="{:$auth->check('user/user/del')}"
   width="100%">
</table>

假定我们在user.js的表格的operate中加了一个nameinfo的按钮,且后台对应的方法是user/user/user,那可以在上面的代码中加上一行,最后代码如下:

<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
   data-operate-edit="{:$auth->check('user/user/edit')}"
   data-operate-del="{:$auth->check('user/user/del')}"
   data-operate-info="{:$auth->check('user/user/info')}"
   width="100%">
</table>

这样一来没有user/user/info权限的用户就看不到这个按钮了。

Leave a Comment

豫ICP备19001387号-1