[ 'class' => LoginBehavior::className(), ], ]); } public function actionIndex() { if(\Yii::$app->request->isAjax){ $form = new CommonRoleListForm(); $form->attributes = \Yii::$app->request->get(); $form->cx_mch_id = $this->cx_mch_id; //本人创建的角色 $form->creator_user_id = \Yii::$app->admin->identity->user_id; $data = $form->search(); return $this->responseHandler($data); } return $this->render('index'); } public function actionEdit($id = 0) { $model = Role::findOne([ 'cx_mch_id' => $this->cx_mch_id, 'is_delete' => 0, 'id' => $id, ]); if($model == null) $model = new Role(); $m = new AdminMenu(); if(\Yii::$app->request->isPost){ $form = new CommonRoleEditForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $form->creator_user_id = \Yii::$app->admin->identity->user_id; $form->model = $model; $form->allows = $m->getMenuUrls($m->getList(false)); $data = $form->save(); return $this->responseHandler($data); } $permissions = $model->isNewRecord || !$model->permission ? [] : json_decode($model->permission->permissions,true); $permission_tree = $m->getPermissionTree($permissions); $return_url = \Yii::$app->request->referrer; return $this->render('edit', [ 'model' => $model, 'return_url' => $return_url, 'permission_tree' => $permission_tree ]); } public function actionDelete() { if(!\Yii::$app->request->isPost){ $data = $this->invaildRequest(); return $this->responseHandler($data); } $form = new CommonRoleActionForm(); $form->attributes = \Yii::$app->request->post(); $form->cx_mch_id = $this->cx_mch_id; $data = $form->delete(); return $this->responseHandler($data); } }