fastadmin自定义button根据条件展示

{
                            field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [

                                {
                                    name: 'yulan',
                                    extend: 'data-area=["90%","90%"]',
                                    text: __('预览文章'),
                                    title: __('预览文章'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-magic',
                                    url: 'match/article/yulan?id={id}'
                                },
                                {
                                    name: 'edit',
                                    extend: 'data-area=["90%","90%"]',
                                    text: __('编辑文章'),
                                    title: __('编辑文章'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-pencil',
                                    url: 'match/article/edit?id={id}'
                                },
                                {
                                    name: 'annotate',
                                    extend: 'data-area=["90%","90%"]',
                                    text: __('文章批注'),
                                    title: __('文章批注'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-magic',
                                    url: 'match/article/annotate?id={id}'
                                },
                                {
                                    name: 'view_annotate',
                                    extend: 'data-area=["50%","50%"]',
                                    text: __('审核批注'),
                                    title: __('审核批注'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-magic',
                                    url: 'match/article/view_annotate?id={id}',
                                    visible: function (row) {
                                        if (row.is_annotate == 1) {
                                            return true;
                                        } else {
                                            return false;
                                        }
                                    }
                                }
                            ]
                        }
visible: function (row) {
                                        if (row.is_annotate == 1) {
                                            return true;
                                        } else {
                                            return false;
                                        }
                                    }

 

根据管理员权限控制是否展示

<table id="table" class="table table-striped table-bordered table-hover table-nowrap"
                           data-show-export="false" data-show-toggle="false" data-show-columns="false"
                           data-operate-edit="{:$auth->check('match/article/edit')}"
                           data-operate-del="{:$auth->check('match/article/del')}"
                           data-operate-view_annotate="{:$auth->check('match/article/view_annotate')}"
                           width="100%">
                    </table>

 

posted @ 2022-10-31 16:34  U丶Zero  阅读(515)  评论(0编辑  收藏  举报