Group2admin.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\admin\controller\csmadmin;
  3. use addons\csmadmin\library\CsmBackend;
  4. use addons\csmadmin\library\CsmUtils;
  5. /**
  6. * 角色组授权人员
  7. *
  8. * @icon fa fa-circle-o
  9. */
  10. class Group2admin extends CsmBackend
  11. {
  12. /**
  13. * Group2admin模型对象
  14. * @var \app\admin\model\csmadmin\Group2admin
  15. */
  16. protected $model = null;
  17. public function _initialize()
  18. {
  19. parent::_initialize();
  20. $this->model = new \app\admin\model\csmadmin\Group2admin;
  21. }
  22. public function index()
  23. {
  24. // 当前页面必须从活动页面跳转过来
  25. $parentid = $this->csmreq("parentid", true);
  26. $parent = $this->csmGetDbRowByReqest(new \app\admin\model\AuthGroup(), "parentid");
  27. $this->assign('parent', $parent);
  28. // 设置过滤方法
  29. $this->request->filter([
  30. 'strip_tags'
  31. ]);
  32. if ($this->request->isAjax()) {
  33. // 如果发送的来源是Selectpage,则转发到Selectpage
  34. if ($this->request->request('keyField')) {
  35. return $this->selectpage();
  36. }
  37. list ($where, $sort, $order, $offset, $limit) = $this->buildparams();
  38. $total = $this->model->where($where)
  39. ->where("auth_group_id", "=", $parentid)
  40. ->order($sort, $order)
  41. ->count();
  42. $list = $this->model->where($where)
  43. ->where("auth_group_id", "=", $parentid)
  44. ->order($sort, $order)
  45. ->limit($offset, $limit)
  46. ->select();
  47. CsmUtils::convertListColumn($list, "auth_group_id", new \app\admin\model\AuthGroup(),'name');
  48. $dao = new \app\admin\model\Admin();
  49. CsmUtils::fillListColumn($list, "faadmin_id", $dao->where("status",'=','normal')->field("id,username,nickname,email"),'id');
  50. $list = collection($list)->toArray();
  51. $result = array(
  52. "total" => $total,
  53. "rows" => $list
  54. );
  55. return json($result);
  56. }
  57. return $this->view->fetch();
  58. }
  59. }