diff --git a/application/admin/controller/AuthRule.php b/application/admin/controller/AuthRule.php index deaa66ab..b5213beb 100644 --- a/application/admin/controller/AuthRule.php +++ b/application/admin/controller/AuthRule.php @@ -223,4 +223,6 @@ class AuthRule extends Base // 返回信息 return json($data); } + + } diff --git a/application/admin/controller/Index.php b/application/admin/controller/Index.php index 462cbc2a..7ecda922 100644 --- a/application/admin/controller/Index.php +++ b/application/admin/controller/Index.php @@ -21,6 +21,7 @@ class Index extends Base $list['title'] = '管理员列表'; $list['count'] = $count; + // 模板赋值 $this->assign('list',$list); diff --git a/application/admin/model/AuthRule.php b/application/admin/model/AuthRule.php index dec70105..640a0b89 100644 --- a/application/admin/model/AuthRule.php +++ b/application/admin/model/AuthRule.php @@ -8,45 +8,61 @@ use app\common\model\Base; class AuthRule extends Base { - // 顶级权限列表 - public function getRule($pid = 0) + // 父级菜单数据模型关联 + public function authPid() { - return $this - ->where('pid',$pid) - ->where('status',1) - ->field('id,title') - ->order(['paixu']) - ->select(); + return $this->belongsTo('AuthRule','pid','id'); } - // 是否是菜单获取器 - public function getIsmenuAttr($value) - { - $arr = array('0'=>'否','1'=>'是'); - return $arr[$value]; + // 子菜单数据模型关联 + public function authCid() + { + return $this->hasMany('AuthRule','pid','id'); } - // 父级菜单名获取器 - public function getPidAttr($value) - { - return $this->where('id',$value)->value('title'); - } + // // 顶级权限列表 + // public function getRule($pid = 0) + // { + // return $this + // ->where('pid',$pid) + // ->where('status',1) + // ->field('id,title') + // ->order(['paixu']) + // ->select(); + // } - // 获取二级菜单 - public function getMymenuAttr($value) - { - return $this - ->where('pid',$this->getAttr('id')) - ->where('status&ismenu',1) - ->field('title,url,name') - ->order(['paixu']) - ->select(); - } + // // 是否是菜单获取器 + // public function getIsmenuAttr($value) + // { + // $arr = array('0'=>'否','1'=>'是'); + + // return $arr[$value]; + // } + + + // // 父级菜单名获取器 + // public function getPidAttr($value) + // { + + // return $this->where('id',$value)->value('title'); + // } + + + // // 获取二级菜单 + // public function getMymenuAttr($value) + // { + // return $this + // ->where('pid',$this->getAttr('id')) + // ->where('status&ismenu',1) + // ->field('title,url,name') + // ->order(['paixu']) + // ->select(); + // } diff --git a/application/index/controller/Index.php b/application/index/controller/Index.php index 3a8ca828..226cab28 100644 --- a/application/index/controller/Index.php +++ b/application/index/controller/Index.php @@ -41,6 +41,23 @@ class Index extends Base // 获取版本号 $list->version = config('app.chengji.version'); + + // 实例化权限数据模型 + $authrule = new \app\admin\model\AuthRule; + + $list['menu'] = $authrule + ->where('pid',0) + ->where('status&ismenu',1) + ->field('id,title,font,name,pid') + ->with([ + 'authCid'=>function($query){ + $query->field('id,title,name,pid,url'); + }, + ]) + ->order(['paixu']) + ->select(); + // dump($list['menu']);halt('aa'); + // 模版赋值 $this->assign('list',$list); @@ -87,4 +104,5 @@ class Index extends Base return $this->fetch(); } + } diff --git a/application/index/view/index/index.html b/application/index/view/index/index.html index c084da48..94aa8792 100644 --- a/application/index/view/index/index.html +++ b/application/index/view/index/index.html @@ -7,14 +7,13 @@ - - + {load href="__STATIC__/xadmin/css/font.css" /} + {load href="__STATIC__/xadmin/css/xadmin.css" /} - - - - + {load href="__STATIC__/xadmin/lib/layui/layui.js" /} + {load href="__STATIC__/xadmin/js/xadmin.js" /} + {load href="__STATIC__/xadmin/js/cookie.js" /}