当前位置:Gxlcms > PHP教程 > ThinkPHP+EasyUI的实例讲解

ThinkPHP+EasyUI的实例讲解

时间:2021-07-01 10:21:17 帮助过:41人阅读

  假设数据库中会计科目数据表的字段为:id,code,name,islast。分别为自增主键,科目编码,科目名称,是否为末级("1"表示末级科目)。这里在Thinkphp的模型层中使用递归来构建ComboTree所需的数据,代码及注解如下:

 AccountModel   = ->field('id,code,name,islast')->(  & = (['code'( == 3['pid'] = 0['pid'] = (['code'],0,-2 ->createTree(  createSubTree(, = (  =>(['pid'] ==  = 'id' => ['id'],
                    'text'=>['name'],
                    'state'=>(['islast'] != 1)?'closed':'open'(['islast'] != 1 = ->createSubTree(,['code'(!(['children'] = (,   createTree( = (   => (['pid'] == 0 = 'id' => ['id'],
                    'text'=>['name'],
                    'state'=>'closed' = ->createSubTree(,['code'(!(['children'] = [] =

  类似上述的数据(如部门,地区等)需要构建树形菜单的简单修改代码后基本都能实现类似功能。

以上就是ThinkPHP+EasyUI的实例讲解的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行