123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- // +----------------------------------------------------------------------
- // | ThinkAdmin
- // +----------------------------------------------------------------------
- // | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
- // +----------------------------------------------------------------------
- // | 官方网站: http://demo.thinkadmin.top
- // +----------------------------------------------------------------------
- // | 开源协议 ( https://mit-license.org )
- // +----------------------------------------------------------------------
- // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
- // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
- // +----------------------------------------------------------------------
- namespace app\user\controller;
- use app\common\constant\CommonConstant;
- use app\common\model\Department;
- use library\Controller;
- /**
- * 员工
- */
- class Member extends Controller
- {
- /**
- * 绑定数据表
- * @var string
- */
- protected $table = 'StoreMember';
- /**
- * 列表
- * @auth true
- * @menu true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- */
- public function index()
- {
- $status = input('status');
- $signature_status = input('signature_status');
- $this->get_status_list = CommonConstant::get_status_list();
- $this->get_signature_status_list = CommonConstant::get_signature_status_list();
- $this->title = '员工列表';
- $query = $this->_query($this->table)
- ->where('is_deleted', CommonConstant::IS_DELETED_0)
- ->when(array_key_exists($status, $this->get_status_list), function ($query) use ($status) {
- $query->where('status', $status);
- })
- ->when(array_key_exists($signature_status, $this->get_signature_status_list), function ($query) use ($signature_status) {
- $query->where('signature_status', $signature_status);
- })
- ->like('name,mobile');
- $query->page();
- }
- /**
- * 列表数据处理
- * @param array $data
- * @throws \Exception
- */
- protected function _index_page_filter(&$data)
- {
- $department_list = Department::column('dept_id,name');
- foreach ($data as &$value) {
- $department_ids = explode(',',$value['department']);
- $department = '';
- foreach ($department_ids as $val){
- if(array_key_exists($val,$department_list)){
- $department .= $department_list[$val].',';
- }
- }
- $value['department_text'] = $department;
- }
- }
- protected function _form_filter(&$data)
- {
- }
- /**
- * 编辑
- * @auth true
- * @throws \think\Exception
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\ModelNotFoundException
- * @throws \think\exception\DbException
- * @throws \think\exception\PDOException
- */
- public function edit()
- {
- $this->title = '编辑';
- $this->_form($this->table, 'form');
- }
- /**
- * 启用
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function resume()
- {
- $this->applyCsrfToken();
- $this->_save($this->table, ['status' => CommonConstant::STATUS_NORMAL]);
- }
- /**
- * 禁用
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function forbid()
- {
- $this->applyCsrfToken();
- $this->_save($this->table, ['status' => CommonConstant::STATUS_FROZEN]);
- }
- /**
- * 审核签名
- * @auth true
- * @throws \think\Exception
- * @throws \think\exception\PDOException
- */
- public function signature_status()
- {
- $signature_status = input('signature_status');
- if(!array_key_exists($signature_status,CommonConstant::get_signature_status_list())){
- $this->controller->error('审核状态参数错误');
- }
- $this->applyCsrfToken();
- $this->_save($this->table, ['signature_status' => $signature_status]);
- }
- }
|