|
@@ -41,196 +41,83 @@ class School extends Controller
|
|
|
*/
|
|
|
public function index()
|
|
|
{
|
|
|
- $this->title = '学校管理';
|
|
|
- $query = $this->_query($this->table);
|
|
|
- $query->equal('status')->dateBetween('login_at,create_at');
|
|
|
- $query->like('name,contact_phone#phone,contact_mail#mail');
|
|
|
- // 加载对应数据列表
|
|
|
- $this->type = input('type', 'all');
|
|
|
- if ($this->type === 'all') {
|
|
|
- $query->where(['is_deleted' => 0, 'status' => 1]);
|
|
|
- } elseif ($this->type = 'recycle') {
|
|
|
- $query->where(['is_deleted' => 0, 'status' => 0]);
|
|
|
- }
|
|
|
- // 列表排序并显示
|
|
|
- $query->order('sort desc,id desc')->page();
|
|
|
+ $this->title = '学校信息管理';
|
|
|
+ $county_id = session('user.county_id');
|
|
|
+ $query = $this->_query($this->table)->where('county_id',$county_id)->where('is_deleted',0)->like('name')->equal('school_code,office_phone,type');
|
|
|
+ $query->order('id desc')->page();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 添加学校
|
|
|
- * @auth true
|
|
|
+ * 数据列表处理
|
|
|
+ * @param array $data
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
*/
|
|
|
- public function add()
|
|
|
+ protected function _index_page_filter(&$data)
|
|
|
{
|
|
|
- $this->_applyFormToken();
|
|
|
- $this->_form($this->table, 'form');
|
|
|
- }
|
|
|
+ foreach ($data as &$value){
|
|
|
|
|
|
- /**
|
|
|
- * 编辑学校
|
|
|
- * @auth true
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public function edit()
|
|
|
- {
|
|
|
- $this->_applyFormToken();
|
|
|
- $this->_form($this->table, 'form');
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改用户密码
|
|
|
- * @auth true
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- public function pass()
|
|
|
- {
|
|
|
- $this->_applyFormToken();
|
|
|
- if ($this->request->isGet()) {
|
|
|
- $this->verify = false;
|
|
|
- $this->_form($this->table, 'pass');
|
|
|
- } else {
|
|
|
- $data = $this->_vali([
|
|
|
- 'id.require' => '用户ID不能为空!',
|
|
|
- 'password.require' => '登录密码不能为空!',
|
|
|
- 'repassword.require' => '重复密码不能为空!',
|
|
|
- 'repassword.confirm:password' => '两次输入的密码不一致!',
|
|
|
- ]);
|
|
|
- if (data_save('system_user', ['id' => $data['id'], 'password' => md5($data['password'])], 'id')) {
|
|
|
- sysoplog('学校管理', "修改用户[{$data['id']}]密码成功");
|
|
|
- $this->success('密码修改成功,请使用新密码登录!', '');
|
|
|
- } else {
|
|
|
- $this->error('密码修改失败,请稍候再试!');
|
|
|
- }
|
|
|
}
|
|
|
+ $this->type_arr = array('1'=>'幼儿园','2'=>'小学','3'=>'初中','4'=>'高中','5'=>'特教','6'=>'工读','7'=>'中职');
|
|
|
+ $this->county_list = $this->app->db->name('county_list')->column('name','id');
|
|
|
}
|
|
|
+ protected function _form_filter(&$data){
|
|
|
+ if($this->request->isGet()) {
|
|
|
|
|
|
- /**
|
|
|
- * 表单数据处理
|
|
|
- * @param array $data
|
|
|
- * @throws \think\db\exception\DataNotFoundException
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
- * @throws \think\db\exception\ModelNotFoundException
|
|
|
- */
|
|
|
- protected function _form_filter(array &$data)
|
|
|
- {
|
|
|
- if ($this->request->isPost()) {
|
|
|
+ }elseif ($this->request->isPost()){
|
|
|
if (isset($data['id']) && $data['id'] > 0) {
|
|
|
- unset($data['username']);
|
|
|
- } else {
|
|
|
- // 检查登录账号是否出现重复
|
|
|
- if (empty($data['username'])) $this->error('登录账号不能为空!');
|
|
|
- $where = ['username' => $data['username'], 'is_deleted' => 0];
|
|
|
- if ($this->app->db->name('system_user')->where($where)->count() > 0) {
|
|
|
- $this->error("账号已经存在,请使用其它账号!");
|
|
|
+ $is_set = $this->app->db->name('school2')->where('username',$data['username'])->where('id','<>',$data['id'])->find();
|
|
|
+ if($is_set){
|
|
|
+ $this->error('不能设置重复的账号');
|
|
|
}
|
|
|
- // 新添加的用户密码与账号相同
|
|
|
- // $data['password'] = md5($data['username']);
|
|
|
+ $data['password'] = md5($data['visible_password']);
|
|
|
}
|
|
|
- // 账号权限绑定处理
|
|
|
- // $data['authorize'] = arr2str($data['authorize'] ?? []);
|
|
|
- } else {
|
|
|
- /*$data['authorize'] = str2arr($data['authorize'] ?? '');
|
|
|
- $query = $this->app->db->name('SystemAuth')->where(['status' => 1]);
|
|
|
- $this->authorizes = $query->order('sort desc,id desc')->select()->toArray();*/
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
- * 修改用户状态
|
|
|
+ * 编辑学校
|
|
|
* @auth true
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\db\exception\DataNotFoundException
|
|
|
+ * @throws \think\db\exception\ModelNotFoundException
|
|
|
+ * @throws \think\exception\DbException
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
*/
|
|
|
- public function state()
|
|
|
+ public function edit()
|
|
|
{
|
|
|
- $this->_checkInput();
|
|
|
- $this->_applyFormToken();
|
|
|
- $this->_save($this->table, $this->_vali([
|
|
|
- 'status.in:0,1' => '状态值范围异常!',
|
|
|
- 'status.require' => '状态值不能为空!',
|
|
|
- ]));
|
|
|
+ $this->title = '编辑';
|
|
|
+ $this->_form($this->table, 'form');
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
* 删除学校
|
|
|
* @auth true
|
|
|
- * @throws \think\db\exception\DbException
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
*/
|
|
|
public function remove()
|
|
|
{
|
|
|
- $this->_checkInput();
|
|
|
- $this->_applyFormToken();
|
|
|
- $this->_delete($this->table);
|
|
|
+ $this->_save($this->table, ['is_deleted' => '1']);
|
|
|
}
|
|
|
-
|
|
|
- /**
|
|
|
- * 检查输入变量
|
|
|
- */
|
|
|
- private function _checkInput()
|
|
|
- {
|
|
|
- if (in_array('10000', str2arr(input('id', '')))) {
|
|
|
- $this->error('系统超级账号禁止删除!');
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
- * 表单结果处理
|
|
|
- * @param bool $result
|
|
|
- */
|
|
|
- protected function _add_form_result(bool $result)
|
|
|
- {
|
|
|
- if ($result) {
|
|
|
- $id = $this->app->db->name($this->table)->getLastInsID();
|
|
|
- $res=$this->app->db->name($this->table)->where('id',$id)->find();
|
|
|
- $data['username']=$res['username'];
|
|
|
- $data['authorize']=1;
|
|
|
- $data['nickname']='学校管理员';
|
|
|
- $data['is_shcool']=1;
|
|
|
- $admin_id=$this->app->db->name('system_user')->insertGetId($data);
|
|
|
- $this->app->db->name($this->table)->where('id',$id)->update(['admin_id'=>$admin_id]);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 表单结果处理
|
|
|
- * @param boolean $result
|
|
|
- */
|
|
|
- protected function _edit_form_result(bool $result)
|
|
|
- {
|
|
|
- if ($result) {
|
|
|
- $id = input('id') ?: 0;
|
|
|
- sysoplog('学校管理', "修改学校[{$id}]成功");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 状态结果处理
|
|
|
- * @param boolean $result
|
|
|
+ * 禁用学校
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
*/
|
|
|
- protected function _state_save_result(bool $result)
|
|
|
+ public function forbid()
|
|
|
{
|
|
|
- if ($result) {
|
|
|
- [$id, $state] = [input('id'), input('status')];
|
|
|
- sysoplog('学校管理', ($state ? '激活' : '禁用') . "学校[{$id}]成功");
|
|
|
- }
|
|
|
+ $this->_save($this->table, ['status' => '0']);
|
|
|
}
|
|
|
-
|
|
|
/**
|
|
|
- * 删除结果处理
|
|
|
- * @param boolean $result
|
|
|
+ * 启用学校
|
|
|
+ * @auth true
|
|
|
+ * @throws \think\Exception
|
|
|
+ * @throws \think\exception\PDOException
|
|
|
*/
|
|
|
- protected function _remove_delete_result(bool $result)
|
|
|
+ public function resume()
|
|
|
{
|
|
|
- if ($result) {
|
|
|
- $id = input('id') ?: 0;
|
|
|
- sysoplog('学校管理', "删除学校[{$id}]成功");
|
|
|
- }
|
|
|
+ $this->_save($this->table, ['status' => '1']);
|
|
|
}
|
|
|
|
|
|
}
|