企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
简单案例 ~~~ $list = [['id'=>1,'title'=>'名称1'],['id'=>2,'title'=>'名称2']]; return TBuilder('table',$this) ->setRowList($list) // 设置表格数据 ->setColumns([ // 批量设置数据列 ['id', 'ID'], ['title', '名称'], ['edit.edit_data|id+title,del', '操作', ['type'=>'btn']] ]) ->fetch(); ~~~ ![](https://box.kancloud.cn/1ddd8a15c4eb911a09a858e8e485491d_954x177.png) 完整案例 ~~~ $list = []; for ($i=0;$i<10;$i++){ $list[] = [ 'id' => $i, 'title' => 'title'.$i, 'pid' => $i+10, 'group' => 'group'.$i, 'url' => 'url'.$i, 'icon_class'=> 'icon_class'.$i, 'is_dev' => 1, 'hide' => 0, ]; } $this->assign(['page'=>'']); $this->param['pid'] = $pid; return TBuilder('table',$this) ->setRowList($list) // 设置表格数据 ->setRequestParam($this->param) ->setColumns([ // 批量设置数据列 ['id', 'ID'], ['title', '名称|必须'], ['pid', '上级菜单',['func'=>'get_parent_menu_name']], ['icon_class', '图标类名'], ['group', '分组'], //['answer_status','状态', ['func'=>'c_name','config_name'=>'answer_status'] ], ['url', 'URL',['type'=>'url', 'url'=>'menu/index', 'p'=>'id.pid']], ['is_dev', '仅开发者模式显示', ['func'=>'yes_no']], ['hide', '隐藏', ['func'=>'yes_no']], ['edit.edit_data|id+title,del', '操作', ['type'=>'btn']] ]) /* // 设置自定义列表按钮 //------------------------------------------------------------------ // 添加相关操作按钮 ->addListButton([ 'type' => 'edit', 'icon_class'=> 'fa fa-pencil', 'popup' => true, 'attr' => ['modal-wh'=>'650|230'], ]) ->addListButton([ 'title' => '查看', 'href_base' => 'menu/index', 'href_param'=> 'id', 'icon_class'=> 'fa fa-list', 'target'=>'_blank' // 新标签打开链接 ]) ->addListButton([ 'title' => '查看2', 'href_base' => 'menu/index', 'href_param'=> 'pid.id', 'icon_class'=> 'fa fa-list', ]) ->addListButton([ 'title' => '查看3', 'href_base' => array('menu/index',array('date'=>'2017-05-06') ), 'href_param'=> 'pid.id+type+classify_id.cid', 'icon_class'=> 'fa fa-list', ]) // 使用show_map设置btn显示条件 //------------------------------------------------------------------ ->addListButton([ 'title' => '禁用', 'href_base' => 'disable', 'item_class'=> 'btn-warning ajax-get', 'icon_class'=> 'fa fa-cog', 'show_map' => ['status'=>['eq',1],'is_install'=>['eq',1]] ]) ->addListButton([ 'title' => '启用', 'href_base' => 'enable', 'item_class'=> 'btn-success ajax-get', 'icon_class'=> 'fa fa-cog', 'show_map' => ['status'=>['eq',0],'is_install'=>['eq',1]] ]) */ // 批量添加顶部按钮 ->addTopButtons('add,disable|pid+group,del|pid') //添加系统自带样式按钮 ->addTopButton([ 'type' => 'enable', 'href' => url('enable',['pid'=>$pid]), ]) //添加自定义按钮 ->addTopButton([ 'title' => '自定义按钮', 'icon_class' => 'fa fa-sitemap', 'item_class' => 'ajax-get confirm', 'href' => url('diyurl',['pid'=>$pid]), ]) ->showIdsCheckbox() //显示列表左侧的checkbox ->addFilters([ // 添加文本输入筛选筛选 ['keyword','请输入关键词','input'], ]) ->fetch(); ~~~ ![](https://box.kancloud.cn/78223acff0f46bbe322580d4951cfbf9_1714x673.png) 配合数据构建器案例 ~~~ $list = DBuilder('Member')->quickEdit()->setOrder('id asc')->getLists(); $groupList = db('api_group')->field('id,title')->select(); $groupList = getIdIndexArr($groupList); return TBuilder('table',$this) ->setRowList($list) // 设置表格数据 ->setColumns([ // 批量设置数据列 ['id', 'ID'], ['username', '名称'], //['summary_info_arr>project_info>title','名称'], //多维数组取其内部字段使用>号分割各曾提及字段 ['head_pic_id', '头像', ['type'=>'img']], //['group_id.select', '接口分组',['listdata'=>$groupList,'key_relevance'=>'id|title']], ['sex.select', '性别', ['func'=>'c_name','config_name'=>'sex'] ], ['qq.text', 'QQ'], ['score', '分值'], ['last_login_ip', '最后登录IP',['func'=>'long2ip']], ['last_login_time', '最后登录时间', ['func'=>'datetime_format'] ], ['status.select', '状态', ['func'=>'c_name','config_name'=>'status'] ], ['edit.updateUser,del', '操作', [ 'type' =>'btn', 'btn_config'=>['key_field'=>'id'] ]] ]) ->addTopButtons('add,sort') // 批量添加顶部按钮 ->addFilters([ // 添加文本输入筛选筛选 ['keyword','请输入关键词'], ]) ->fetch(); ~~~ ![](https://box.kancloud.cn/d38254790b4e6f1b03b9ffadf774d1fa_1722x353.png)