'作者', 'review' => '审稿人', 'chief' => '主编', 'editor' => '编辑']; protected $adopt_list = ['review' => '审核中', 'fault' => '拒绝', 'correct' => '通过']; protected $noNeedRight = ['detail', 'is_adopt']; public function _initialize() { parent::_initialize(); $this->model = new UserRoleLog(); $this->assignconfig('site_role_list', $this->role_list); $this->assignconfig('site_adopt_list', $this->adopt_list); } /** * 查看 */ public function index() { //设置过滤方法 $this->request->filter(['strip_tags', 'trim']); if ($this->request->isAjax()) { //如果发送的来源是Selectpage,则转发到Selectpage if ($this->request->request('keyField')) { return $this->selectpage(); } list($where, $sort, $order, $offset, $limit) = $this->buildparams(); $list = $this->model ->with('user') ->where($where) ->order($sort, $order) ->paginate($limit); foreach ($list as $k => $v) { $v->is_adopt_str = $v['is_adopt']; $v->type_str = $v['type']; $v->type = $this->role_list[$v['type']]; $v->is_adopt = $this->adopt_list[$v['is_adopt']]; } $result = array("total" => $list->total(), "rows" => $list->items()); return json($result); } return $this->view->fetch(); } /** * 用户详情 * * @param $ids * @return string * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function detail($user_id = null, $type = null, $ids = null) { $user = \app\admin\model\User::where(['id' => $user_id])->find(); if ($user) { // 如果是审稿或者编辑则走不同页面 if ($type == 'review' || $type == 'chief' || $type == 'editor') { $user_content = UserRoleContent::where(['log_id' => $ids])->find(); if ($user_content) { $journal_ids = explode(',', $user_content['journal_ids']); $channel_name_list = Channel::where(['id' => ['in', $journal_ids]])->column('name'); $user_content['journal_ids'] = $channel_name_list; $this->view->assign('type', $type); $this->view->assign('row', $user_content); } return $this->view->fetch('user/role_log/user_detail'); } $this->view->assign('row', $user); } return $this->view->fetch(); } /** * 用户申请操作 * * @param $ids * @param $adopt * @return void * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function is_adopt($ids = null, $adopt = null) { $user_log = UserRoleLog::where(['id' => $ids])->find(); if ($user_log) { $user_log->is_adopt = $adopt; if ($user_log->save()) { // 更新用户信息 $user = \app\admin\model\User::where(['id' => $user_log['user_id']])->find(); if ($user) { if ($user_log->type == 'author') { $user->is_author = $adopt; } if ($user_log->type == 'review') { $user->is_review = $adopt; } if ($user_log->type == 'chief') { $user->is_chief = $adopt; if ($adopt == 'correct') { $user->is_editor = 'fault'; } } if ($user_log->type == 'editor') { $user->is_editor = $adopt; if ($adopt == 'correct') { $user->is_chief = 'fault'; } } if ($user->save()) { $this->success(); } else { $this->error('用户信息保存失败'); } } else { $this->error('用户信息不正确'); } } else { $this->error('保存失败'); } } else { $this->error('未查询到对应信息'); } } }