123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- namespace app\admin\controller;
- use app\common\controller\Backend;
- use app\utils\AppResult;
- use think\Db;
- use think\exception\DbException;
- use think\response\Json;
- /**
- * vue 页面控制
- *
- * @icon fa fa-circle-o
- */
- class Vue extends Backend
- {
- protected $noNeedRight = '*';
- /**
- * 菜单操作按钮
- *
- * @return string|Json
- * @throws \think\Exception
- * @throws DbException
- */
- public function operationPermissions()
- {
- // post请求获取数据
- $params = $this->request->param();
- $role = $this->auth->getRuleIds()[0] ?? '';
- $menu_rule = $params['menu_rule'];
- $menu_id = Db::name('auth_rule')->where('name', $menu_rule)->where('ismenu', 1)->value('id');
- $btn_list = Db::name('auth_rule')->where('pid', $menu_id)->where('ismenu', 0);
- if ($role != '*') {
- $role_menus_ids = explode(',',$role);
- $btn_list->whereIn('id', $role_menus_ids);
- }
- $btn_list = $btn_list->where('status', 'normal')->field(['id', 'title as name', 'name as path', 'name as action', 'icon'])->select();
- $btn = [];
- foreach ($btn_list as $value) {
- $action = explode('/',$value['action']);
- $action = end($action);
- $btn[$action] = [
- 'name' => $value['name'],
- 'path' => $value['path'],
- 'action' => $action,
- 'icon' => $value['icon'],
- ];
- }
- return AppResult::response200('success', $btn);
- }
- }
|