Vue.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. use app\utils\AppResult;
  5. use think\Db;
  6. use think\exception\DbException;
  7. use think\response\Json;
  8. /**
  9. * vue 页面控制
  10. *
  11. * @icon fa fa-circle-o
  12. */
  13. class Vue extends Backend
  14. {
  15. protected $noNeedRight = '*';
  16. /**
  17. * 菜单操作按钮
  18. *
  19. * @return string|Json
  20. * @throws \think\Exception
  21. * @throws DbException
  22. */
  23. public function operationPermissions()
  24. {
  25. // post请求获取数据
  26. $params = $this->request->param();
  27. $role = $this->auth->getRuleIds()[0] ?? '';
  28. $menu_rule = $params['menu_rule'];
  29. $menu_id = Db::name('auth_rule')->where('name', $menu_rule)->where('ismenu', 1)->value('id');
  30. $btn_list = Db::name('auth_rule')->where('pid', $menu_id)->where('ismenu', 0);
  31. if ($role != '*') {
  32. $role_menus_ids = explode(',',$role);
  33. $btn_list->whereIn('id', $role_menus_ids);
  34. }
  35. $btn_list = $btn_list->where('status', 'normal')->field(['id', 'title as name', 'name as path', 'name as action', 'icon'])->select();
  36. $btn = [];
  37. foreach ($btn_list as $value) {
  38. $action = explode('/',$value['action']);
  39. $action = end($action);
  40. $btn[$action] = [
  41. 'name' => $value['name'],
  42. 'path' => $value['path'],
  43. 'action' => $action,
  44. 'icon' => $value['icon'],
  45. ];
  46. }
  47. return AppResult::response200('success', $btn);
  48. }
  49. }