123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\admin\controller\csmadmin;
- use addons\csmadmin\library\CsmBackend;
- use addons\csmadmin\library\CsmUtils;
- use addons\csmadmin\library\CsmadminUtils;
- /**
- * 角色组授权部门
- *
- * @icon fa fa-circle-o
- */
- class Group2depart extends CsmBackend
- {
-
- /**
- * Group2depart模型对象
- * @var \app\admin\model\csmadmin\Group2depart
- */
- protected $model = null;
- public function _initialize()
- {
- parent::_initialize();
- $this->model = new \app\admin\model\csmadmin\Group2depart;
- }
-
- public function index()
- {
- // 当前页面必须从活动页面跳转过来
- $parentid = $this->csmreq("parentid", true);
- $parent = $this->csmGetDbRowByReqest(new \app\admin\model\AuthGroup(), "parentid");
- $this->assign('parent', $parent);
-
- // 设置过滤方法
- $this->request->filter([
- 'strip_tags'
- ]);
- if ($this->request->isAjax()) {
- // 如果发送的来源是Selectpage,则转发到Selectpage
- if ($this->request->request('keyField')) {
- return $this->selectpage();
- }
- list ($where, $sort, $order, $offset, $limit) = $this->buildparams();
- $total = $this->model->where($where)
- ->where("auth_group_id", "=", $parentid)
- ->order($sort, $order)
- ->count();
-
- $list = $this->model->where($where)
- ->where("auth_group_id", "=", $parentid)
- ->order($sort, $order)
- ->limit($offset, $limit)
- ->select();
-
- CsmUtils::convertListColumn($list, "auth_group_id", new \app\admin\model\AuthGroup(),'name');
-
- $ids = [];
- foreach($list as $item){
- $ids[] = $item['csmadmin_depart_id'];
- }
-
- $ll = CsmadminUtils::getDepartWithParentname($ids);
-
- foreach($list as &$item){
- if(isset($ll['ID#'.$item->csmadmin_depart_id])){
- $item['departname'] = $ll['ID#'.$item->csmadmin_depart_id];
- }
-
-
- }
-
- $list = collection($list)->toArray();
- $result = array(
- "total" => $total,
- "rows" => $list
- );
-
- return json($result);
- }
- return $this->view->fetch();
- }
- }
|