| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341 | 
							- <?php
 
- namespace app\admin\controller;
 
- use app\admin\AdminBaseController;
 
- use app\common\model\TalentUserModel;
 
- use app\common\model\TalentWorkModel;
 
- use app\common\validate\TalentUserValidate;
 
- use think\exception\ValidateException;
 
- use think\facade\Validate;
 
- class Talent extends AdminBaseController
 
- {
 
-     /**
 
-      * 用户列表
 
-      */
 
-     public function user()
 
-     {
 
-         return view('', [
 
-             'status_list' => TalentUserModel::STATUS,
 
-         ]);
 
-     }
 
-     public function listUser()
 
-     {
 
-         $map   = $this->dealEqualInput(['status'], $this->dealLikeInput(['name', 'mobile', 'department']));
 
-         $list  = TalentUserModel::where($map)
 
-             ->limit(input('limit'))
 
-             ->page(input('page'))
 
-             ->append(['status_text'])->select();
 
-         $count = TalentUserModel::where($map)->count();
 
-         if ($count == 0) {
 
-             ajax_return(1, '未查询到数据');
 
-         }
 
-         list_return($list, $count);
 
-     }
 
-     public function delUser()
 
-     {
 
-         $id = input('id/d', 0);
 
-         if (empty($id)) {
 
-             ajax_return(1, '未查询到数据');
 
-         }
 
-         $check = TalentWorkModel::where('user_id', $id)->find();
 
-         if (!empty($check)) {
 
-             ajax_return(1, '该用户已有人才挂钩工作登记表记录,无法删除');
 
-         }
 
-         TalentUserModel::destroy($id);
 
-         ajax_return();
 
-     }
 
-     /**
 
-      * 编辑用户
 
-      */
 
-     public function userForm()
 
-     {
 
-         $id   = input('id/d', 0);
 
-         $info = TalentUserModel::find($id);
 
-         return view('', [
 
-             'info'        => $info,
 
-             'status_list' => TalentUserModel::STATUS,
 
-         ]);
 
-     }
 
-     public function editUser()
 
-     {
 
-         $data = input('post.');
 
-         try {
 
-             validate(TalentUserValidate::class)->check($data);
 
-         } catch (ValidateException $e) {
 
-             ajax_return(1, $e->getError());
 
-         }
 
-         //手机号
 
-         $check_mobile_where = [['mobile', '=', $data['mobile']]];
 
-         if (!empty($data['id'])) {
 
-             $check_mobile_where[] = ['id', '<>', $data['id']];
 
-         }
 
-         $check_mobile = TalentUserModel::where($check_mobile_where)->find();
 
-         if (!empty($check_mobile)) {
 
-             ajax_return(1, '手机号已存在');
 
-         }
 
-         //密码
 
-         if (empty($data['id']) && empty($data['password'])) {
 
-             ajax_return(1, '请输入一个初始密码');
 
-         }
 
-         if (empty($data['password'])) {
 
-             unset($data['password']);
 
-         } else {
 
-             $data['salt']     = rand_str();
 
-             $data['password'] = md5(md5($data['salt']) . $data['password']);
 
-         }
 
-         if (empty($data['id'])) {
 
-             TalentUserModel::create($data);
 
-         } else {
 
-             TalentUserModel::update($data, ['id' => $data['id']]);
 
-         }
 
-         ajax_return();
 
-     }
 
-     /**
 
-      * 用户导入
 
-      */
 
-     public function importUser()
 
-     {
 
-         return view('public/import', [
 
-             'url'           => url('talent/importUserPost'),
 
-             'last_table'    => 'lay-talent-user-table',
 
-             'template_file' => '/static/common/exl/talent_user.xls',
 
-         ]);
 
-     }
 
-     /**
 
-      * 用户导入提交
 
-      */
 
-     public function importUserPost()
 
-     {
 
-         $file_url = input('file_url/s', "");
 
-         if (!file_exists($file_url)) {
 
-             ajax_return(1, '文件不存在');
 
-         }
 
-         //初始化数据
 
-         $data = ['name', 'department', 'mobile'];
 
-         $list = import_exl($file_url, $data, 1);
 
-         if (empty($list)) {
 
-             ajax_return(1, '请上传有数据的文件');
 
-         }
 
-         $empty_check = [
 
-             'name'       => '姓名',
 
-             'department' => '部门',
 
-             'mobile'     => '手机号',
 
-         ];
 
-         //获取手机号
 
-         $mobile_list       = array_column($list, 'mobile');
 
-         $mobile_check_list = TalentUserModel::where('mobile', 'in', $mobile_list)->column('mobile');
 
-         //错误判断
 
-         $validate = Validate::rule('mobile', 'mobile');
 
-         $time     = time();
 
-         foreach ($list as $k => $v) {
 
-             foreach ($empty_check as $key => $value) {
 
-                 if (empty($v[$key])) {
 
-                     return ajax_return(1, '第' . ($k + 2) . '行的' . $value . '不能为空');
 
-                 }
 
-             }
 
-             if (!$validate->check($v)) {
 
-                 return ajax_return(1, '第' . ($k + 2) . '行的手机号格式不对');
 
-             }
 
-             if (!empty(in_array($v['mobile'], $mobile_check_list))) {
 
-                 return ajax_return(1, '第' . ($k + 2) . '行的手机号已存在');
 
-             }
 
-             $list[$k]['salt']        = rand_str();
 
-             $list[$k]['password']    = md5(md5($list[$k]['salt']) . '123456');
 
-             $list[$k]['create_time'] = $list[$k]['update_time'] = $time;
 
-         }
 
-         TalentUserModel::insertAll($list);
 
-         ajax_return(0);
 
-     }
 
-     /**
 
-      * 挂钩工作登记表
 
-      */
 
-     public function work()
 
-     {
 
-         return view();
 
-     }
 
-     public function listWork()
 
-     {
 
-         $model = new TalentWorkModel();
 
-         $param = input('param.');
 
-         //姓名
 
-         if (!empty($param['name'])) {
 
-             $model = $model->where([
 
-                 ['user_id', 'in', function ($query) use ($param) {
 
-                     $query->name('talent_user')->field('id')->where('name', 'like', "%{$param['name']}%")->buildSql();
 
-                 }],
 
-             ]);
 
-         }
 
-         //部门
 
-         if (!empty($param['department'])) {
 
-             $model = $model->where([
 
-                 ['user_id', 'in', function ($query) use ($param) {
 
-                     $query->name('talent_user')->field('id')->where('department', 'like', "%{$param['department']}%")->buildSql();
 
-                 }],
 
-             ]);
 
-         }
 
-         //手机号
 
-         if (!empty($param['mobile'])) {
 
-             $model = $model->where([
 
-                 ['user_id', 'in', function ($query) use ($param) {
 
-                     $query->name('talent_user')->field('id')->where('mobile', 'like', "%{$param['mobile']}%")->buildSql();
 
-                 }],
 
-             ]);
 
-         }
 
-         //月份
 
-         if (!empty($param['month'])) {
 
-             $model = $model->where('month', $param['month']);
 
-         }
 
-         $list  = $model->with('user')->limit(input('limit'))->page(input('page'))->order('update_time desc')->select();
 
-         $count = $model->count();
 
-         if ($count == 0) {
 
-             ajax_return(1, '未查询到数据');
 
-         }
 
-         list_return($list, $count);
 
-     }
 
-     public function workDetail()
 
-     {
 
-         $id = input('id', 0);
 
-         if (empty($id)) {
 
-             return '数据错误,请关闭';
 
-         }
 
-         $info = TalentWorkModel::with('user')->where('id', $id)->find();
 
-         if (empty($info)) {
 
-             return '数据错误,请关闭';
 
-         }
 
-         return view('', [
 
-             'info' => $info,
 
-         ]);
 
-     }
 
-     /**
 
-      * 未登记用户
 
-      */
 
-     public function unRegister()
 
-     {
 
-         $month = date('Y-m');
 
-         return view('', [
 
-             'month' => $month,
 
-         ]);
 
-     }
 
-     public function unRegisterPost()
 
-     {
 
-         $month = input('month', '');
 
-         if (empty($month)) {
 
-             ajax_return();
 
-         }
 
-         $user_ids     = TalentUserModel::where('status', TalentUserModel::STATUS_NORMAL)->column('id');
 
-         $register_ids = TalentWorkModel::where('month', $month)->column('user_id');
 
-         $diff_id      = array_diff($user_ids, $register_ids);
 
-         $user         = TalentUserModel::where('id', 'in', $diff_id)->select();
 
-         $res = [];
 
-         foreach ($user as $item) {
 
-             $res[] = $item['name'] . "(" . $item['department'] . ")";
 
-         }
 
-         ajax_return(0, '', implode(',', $res));
 
-     }
 
-     /**
 
-      * 导出挂钩工作登记表
 
-      */
 
-     public function exportWork()
 
-     {
 
-         $model = new TalentWorkModel();
 
-         $param = input('param.');
 
-         if (!empty($param['id'])) {
 
-             $model = $model->where('id', 'in', $param['id']);
 
-         }
 
-         //姓名
 
-         if (!empty($param['name'])) {
 
-             $model = $model->where([
 
-                 ['user_id', 'in', function ($query) use ($param) {
 
-                     $query->name('talent_user')->field('id')->where('name', 'like', "%{$param['name']}%")->buildSql();
 
-                 }],
 
-             ]);
 
-         }
 
-         //部门
 
-         if (!empty($param['department'])) {
 
-             $model = $model->where([
 
-                 ['user_id', 'in', function ($query) use ($param) {
 
-                     $query->name('talent_user')->field('id')->where('department', 'like', "%{$param['department']}%")->buildSql();
 
-                 }],
 
-             ]);
 
-         }
 
-         //手机号
 
-         if (!empty($param['mobile'])) {
 
-             $model = $model->where([
 
-                 ['user_id', 'in', function ($query) use ($param) {
 
-                     $query->name('talent_user')->field('id')->where('mobile', 'like', "%{$param['mobile']}%")->buildSql();
 
-                 }],
 
-             ]);
 
-         }
 
-         //月份
 
-         if (!empty($param['month'])) {
 
-             $model = $model->where('month', $param['month']);
 
-         }
 
-         $list = $model->with('user')->order('update_time desc')->select();
 
-         foreach ($list as $v) {
 
-             $v['user_name']       = $v['user']['name'];
 
-             $v['user_department'] = $v['user']['department'];
 
-             $v['user_mobile']     = $v['user']['mobile'];
 
-             $v['contact_text']    = implode(',', $v['contact']);
 
-             $v['cate_text']       = implode(',', $v['cate']);
 
-         }
 
-         $xlsCell = [
 
-             ['user_name', '姓名'],
 
-             ['user_department', '部门'],
 
-             ['user_mobile', '手机号'],
 
-             ['month', '月份'],
 
-             ['should_num', '应挂钩人数'],
 
-             ['new_num', '本月新增人数'],
 
-             ['unfinished_num', '未完成挂钩人数'],
 
-             ['reason', '未挂钩联系原因'],
 
-             ['consult_num', '本月回答咨询次数'],
 
-             ['contact_text', '联系方式'],
 
-             ['cate_text', '咨询问题类别'],
 
-             ['description', '具体问题描述及解决措施描述'],
 
-             ['assist', '需协调事项说明'],
 
-             ['update_time', '填表时间'],
 
-         ];
 
-         export_exl("挂钩工作登记表", $xlsCell, $list);
 
-     }
 
- }
 
 
  |