/** * 自动引导主页面 */ private function autoGuide() { $bid = $this->getOperatorBid(); if ($this->authHasAction('list', 'rc')) { $u = 'rc/list'; } else { if ($this->authHasAction('list', 'loan')) { $u = 'loan/list'; } else { if ($this->authHasAction('list', 'supervisor')) { $u = 'supervisor/list'; } else { if ($this->authHasAction('list', 'gps')) { $u = 'gps/list'; } else { if ($this->authHasAction('list', 'finance')) { $u = 'finance/list'; } else { if ($this->authHasAction('list', 'afterloan')) { $u = 'afterloan/overdue'; } else { if ($this->authHasAction('list', 'run')) { $u = 'run/list'; } } } } } } } isset($u) and $this->redirect(\Func\url($u, true)); }
public function editAction() { if ($this->isAjax()) { $data = $this->request->getPost(); if (empty($data)) { $this->pageError('param'); } $modelForm = new DepartmentForm('edit'); if ($result = $modelForm->validate($data)) { if ($modelForm->edit()) { $this->success('操作成功'); } else { $this->error('操作失败'); } } $this->error($result); } $oid = $this->dispatcher->getParams()[0]; if (empty($oid)) { $this->pageError('param'); } $operator = Department::findById($oid); if (!$operator) { $this->pageError('param'); } $form = new DepartmentForm('edit', $operator); $this->view->setVars(['formparams' => ['event' => 'edit', 'action' => \Func\url('/department/edit')], 'data' => $operator]); $this->view->pick('department/add'); }
public function editAction() { if ($this->isAjax()) { $data = $this->request->getPost(); if (empty($data)) { $this->pageError('param'); } $modelForm = new RoleForm('edit'); if ($result = $modelForm->validate($data)) { if ($modelForm->edit()) { $this->success('操作成功'); } else { $this->error('操作失败'); } } $this->error($result); } $rid = $this->dispatcher->getParams()[0]; if (empty($rid)) { $this->pageError('param'); } $role = Role::findById($rid); $form = new RoleForm('edit', $operator); $this->view->setVars(['page' => ['title' => '编辑角色'], 'formparams' => ['event' => 'edit', 'action' => \Func\url('/role/edit')], 'data' => $role]); $this->view->pick('role/add'); }
public function editAction() { if ($this->isAjax()) { $data = $this->request->getPost(); if (empty($data)) { $this->pageError('param'); } $modelForm = new AdminiForm('edit'); if ($result = $modelForm->validate($data)) { if ($modelForm->edit()) { $this->success('操作成功'); } else { $this->error('操作失败'); } } $this->error($result); } $id = $this->dispatcher->getParams()[0]; if (empty($id)) { $this->pageError('param'); } $admini = Admini::findById($id); if (!$admini) { $this->pageError('param'); } $form = new AdminiForm('edit', $admini); $this->view->setVars(['page' => ['title' => '编辑成员'], 'formparams' => ['event' => 'edit', 'action' => \Func\url('/admini/edit')], 'data' => $admini]); $this->view->pick('admini/add'); }
/** * 案件详情 */ public function caseAction($uid) { empty($uid) and $this->pageError('param'); $infos = User::infos($uid); !$infos and $this->redirect(\Func\url('rc/list', true)); $infos['advise_types'] = \App\Config\Loan::adviseTypes(); $infos['can_modify_actions'] = $this->canModifyActions($uid, $infos['loansketch']['status']); $this->view->setVars($infos); }
/** * 给角色分配权限 */ public function allotAction() { if ($this->isAjax()) { $data = $this->request->getPost(); $data['auth'] = serialize(self::toArray($data['auth'])); switch ($data['type']) { case 'role': $modelForm = new RoleForm('auth'); $data['rid'] = $data['id']; unset($data['id']); break; case 'operator': $data['oid'] = $data['id']; unset($data['id']); $modelForm = new OperatorForm('auth'); break; default: $this->error('参数错误'); break; } if ($result = $modelForm->validate($data)) { if ($modelForm->allot()) { $this->success('操作成功'); } else { $this->success('操作失败'); } } $this->error('操作失败'); } $params = $this->dispatcher->getParams(); $type = $params[0]; $id = $params[1]; if (empty($type) || empty($id)) { $this->pageError('param'); } switch ($type) { case 'role': $info = Role::findById($id); $modelForm = new RoleForm('auth', $info); break; case 'operator': $info = Operator::findById($id); $modelForm = new OperatorForm('auth', $info); break; } $this->view->setVars(['info' => $info, 'form' => $modelForm, 'authorities' => self::allAuthorities(), 'formparams' => ['action' => \Func\url('/authority/allot/role/'), 'type' => $type, 'id' => $id]]); }
/** * 获取当前角色对于每笔贷款的操作权限 */ public function operators() { static $operators = ['face', 'reface', 'visit', 'car', 'detail']; static $allow_operators = null; if ($allow_operators and is_array($allow_operators)) { return $allow_operators; } $allow_actions = $this->getActionsByAuth($this->getAuthByController()); if (empty($allow_actions) || !is_array($allow_actions)) { return []; } $allow_operators = []; foreach ($allow_actions as $key => $val) { if (in_array($key, $operators) and $val['operator']) { array_push($allow_operators, ['url' => \Func\url('loan/' . $key), 'operate' => $key, 'text' => $val['text']]); } } return $allow_operators; }
/** * 添加门店 */ public function addAction() { if ($this->isAjax()) { $data = $this->request->getPost(); if (empty($data)) { $this->error('参数错误'); } $modelForm = new BranchForm(); if ($result = $modelForm->validate($data)) { if ($modelForm->add()) { $this->success('操作成功'); } else { $this->error('操作失败'); } } $this->error($result); } $this->view->setVars(['formparams' => ['action' => \Func\url('/branch/add')]]); }
function login() { $this->redirect(\Func\url('/public/login', true)); }
public function logoutAction() { $this->logout(); $this->pageSuccess('退出成功', \Func\url('/'), 1); }
public static function fields() { return ['add' => ['bid' => ['label' => '所属分店', 'type' => 'select', 'inputOptions' => [], 'options' => Branch::options(['all' => true]), 'default' => null, 'validator' => ['required' => true]], 'username' => ['label' => '账号', 'type' => 'text', 'inputOptions' => ['class' => 'col-lg-3'], 'validator' => ['required' => true, 'minlength' => 3, 'maxlength' => 20, 'regex' => '^[\\\\w_]+$', 'remote' => \Func\url('/admini/exist')], 'remark' => '用户名在3-20个字符之间, 字母数字或下划线组成', 'remarkOptions' => ['class' => 'col-lg-4']], 'password' => ['label' => '密码', 'type' => 'password', 'inputOptions' => ['class' => 'col-lg-3'], 'validator' => ['required' => true, 'minlength' => 6, 'maxlength' => 12]], 'repassword' => ['label' => '确认密码', 'type' => 'password', 'inputOptions' => ['class' => 'col-lg-3'], 'validator' => ['required' => true, 'equalTo' => '[name=password]']]], 'edit' => ['aid' => ['type' => 'hidden'], 'username' => ['label' => '用户名', 'type' => 'plain', 'default' => null], 'bid' => ['label' => '所属分店', 'type' => 'select', 'inputOptions' => [], 'options' => Branch::options(['all' => true]), 'default' => null, 'validator' => ['required' => true]], 'password' => ['label' => '密码', 'type' => 'password', 'inputOptions' => [], 'validator' => ['minlength' => 6, 'maxlength' => 12]], 'repassword' => ['label' => '确认密码', 'type' => 'password', 'inputOptions' => [], 'validator' => ['equalTo' => '[name=password]']]], 'login' => ['username' => ['label' => '用户名', 'type' => 'text', 'inputOptions' => ['class' => 'col-lg-8'], 'validator' => ['required' => true]], 'password' => ['label' => '密码', 'type' => 'password', 'inputOptions' => ['class' => 'col-lg-8'], 'validator' => ['required' => true]], 'captcha' => ['label' => '验证码', 'type' => 'captcha', 'inputOptions' => ['class' => 'col-lg-8'], 'validator' => ['required' => true]]]]; }
/** * 修改字段url地址 */ public static function baseUrl($url) { return \Func\url($url); }
public static function fields() { return ['add' => ['oid' => null, 'bid' => ['label' => '所属分店', 'type' => 'select', 'inputOptions' => [], 'options' => Branch::options(), 'default' => null, 'validator' => ['required' => true]], 'did' => ['label' => '所属部门', 'type' => 'select', 'inputOptions' => ['class' => 'col-lg-3'], 'options' => Department::options(), 'default' => 0, 'validator' => ['required' => true]], 'rid' => ['label' => '角色名称', 'type' => 'select', 'inputOptions' => ['class' => 'col-lg-3'], 'options' => Role::options(), 'default' => 0, 'validator' => ['required' => true]], 'username' => ['label' => '用户名', 'type' => 'text', 'inputOptions' => ['class' => 'col-lg-3'], 'validator' => ['required' => true, 'minlength' => 3, 'maxlength' => 20, 'regex' => '^[\\\\w_]+$', 'remote' => \Func\url('/operator/exist')], 'remark' => '用户名在3-20个字符之间, 字母数字或下划线组成', 'remarkOptions' => ['class' => 'col-lg-4']], 'password' => ['label' => '密码', 'type' => 'password', 'inputOptions' => ['class' => 'col-lg-3'], 'validator' => ['required' => true, 'minlength' => 6, 'maxlength' => 12]], 'repassword' => ['label' => '确认密码', 'type' => 'password', 'inputOptions' => ['class' => 'col-lg-3'], 'validator' => ['required' => true, 'equalTo' => '[name=password]']]], 'edit' => ['oid' => ['type' => 'hidden'], 'username' => ['label' => '用户名', 'type' => 'plain', 'default' => null], 'bid' => ['label' => '所属分店', 'type' => 'select', 'inputOptions' => [], 'options' => Branch::options(), 'default' => null, 'validator' => ['required' => true]], 'did' => ['label' => '所属部门', 'type' => 'select', 'inputOptions' => ['class' => 'col-lg-3'], 'options' => Department::options(), 'default' => 0, 'validator' => ['required' => true]], 'rid' => ['label' => '角色名称', 'type' => 'select', 'inputOptions' => [], 'options' => Role::options(), 'default' => null, 'validator' => ['required' => true]], 'password' => ['label' => '密码', 'type' => 'password', 'inputOptions' => [], 'validator' => ['minlength' => 6, 'maxlength' => 12]], 'repassword' => ['label' => '确认密码', 'type' => 'password', 'inputOptions' => [], 'validator' => ['equalTo' => '[name=password]']]]]; }
/** * 根据角色获取能操作的actions * 用于放在页面顶部作为快捷链接 */ public static function getQuickLinks() { static $links = null; if (!is_null($links)) { return $links; } //操作者权限 $_authes = \App::session('auth', 'operator'); if (!is_array($_authes)) { return $links; } //当前操作者在当前app下的权限 $_authes = self::getAuthoriesByAppname($_authes, APP_NAME); $links = []; //将允许的控制器和方法放入数组 $allowed_actions = []; foreach ($_authes as $controller => $actions) { $_controller = ucfirst($controller) . 'Controller'; //控制器的actions $_actions = $_controller::actions(); if (!$_actions) { continue; } $allowed_controller_actions = []; foreach ($actions as $action) { $allowed_controller_actions = array_merge($allowed_controller_actions, $_actions[$action]); } $allowed_actions[$controller] = $allowed_controller_actions; } $_exists = []; if (!empty($allowed_actions)) { foreach ($allowed_actions as $controller => $actions) { foreach ($actions as $action => $text) { if (is_null($text)) { continue; } if (is_array($text) and $text['link'] and !in_array($text['text'], $_exists)) { $action == 'index' and $action = ''; $links[] = ['url' => \Func\url("{$controller}/{$action}"), 'text' => $text['text']]; $_exists[] = $text['text']; } } } } return $links; }