From 3e364fcafb41c7438c1546b744e2c806fbb061ce Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Wed, 22 May 2024 15:04:12 +0800 Subject: [PATCH] update --- .../controller/dept/DeptController.php | 2 +- .../controller/dept/OrgsController.php | 2 +- app/adminapi/lists/dept/DeptLists.php | 23 ++++++------------- app/adminapi/lists/dept/JobsLists.php | 17 ++++---------- app/adminapi/lists/dept/OrgsLists.php | 4 ++-- app/adminapi/logic/dept/DeptLogic.php | 10 +++----- app/adminapi/logic/dept/JobsLogic.php | 3 --- app/adminapi/logic/dept/OrgsLogic.php | 4 +--- app/adminapi/validate/dept/DeptValidate.php | 14 +---------- app/adminapi/validate/dept/OrgsValidate.php | 6 ++--- 10 files changed, 23 insertions(+), 62 deletions(-) diff --git a/app/adminapi/controller/dept/DeptController.php b/app/adminapi/controller/dept/DeptController.php index ea5f136c8..6cb11956e 100755 --- a/app/adminapi/controller/dept/DeptController.php +++ b/app/adminapi/controller/dept/DeptController.php @@ -106,7 +106,7 @@ class DeptController extends BaseAdminController if(empty($params['org_id'])){ return $this->fail('参数错误'); } - $data = Dept::field('id,name,leader,mobile,status')->where('org_id',$params['org_id'])->select()->toArray(); + $data = Dept::field('id,name,mobile,status')->where('org_id',$params['org_id'])->select()->toArray(); return $this->success('请求成功',$data); } diff --git a/app/adminapi/controller/dept/OrgsController.php b/app/adminapi/controller/dept/OrgsController.php index 019cf1a32..b93a25cc3 100644 --- a/app/adminapi/controller/dept/OrgsController.php +++ b/app/adminapi/controller/dept/OrgsController.php @@ -108,7 +108,7 @@ class OrgsController extends BaseAdminController //获取所有组织 public function getAll(): \think\response\Json { - $data = Orgs::field('id,name,master,status,create_time')->select(); + $data = Orgs::field('id,name,status,create_time')->select(); return $this->success('请求成功',$data->toArray()); } } \ No newline at end of file diff --git a/app/adminapi/lists/dept/DeptLists.php b/app/adminapi/lists/dept/DeptLists.php index 6f1dfca15..6c4cbc9e8 100644 --- a/app/adminapi/lists/dept/DeptLists.php +++ b/app/adminapi/lists/dept/DeptLists.php @@ -4,12 +4,11 @@ use app\adminapi\lists\BaseAdminDataLists; use app\common\lists\ListsSearchInterface; - use app\common\model\auth\Admin; use app\common\model\dept\Dept; use app\common\model\dept\Orgs; class DeptLists extends BaseAdminDataLists implements ListsSearchInterface { - + private $where = []; /** * @notes 设置搜索条件 * @return \string[][] @@ -19,7 +18,7 @@ public function setSearch(): array { return [ - '%like%' => ['name','leader','mobile'], + '%like%' => ['name','mobile'], '=' => ['status'] ]; } @@ -34,20 +33,18 @@ public function lists(): array { $params = $this->request->param(); - $where = []; if(isset($params['org_name']) && $params['org_name'] != ''){ $orgs = Orgs::where('name','like','%'.$params['org_name'].'%')->column('id'); - $where[] = ['org_id','in',$orgs]; + $this->where[] = ['org_id','in',$orgs]; } - return Dept::where($this->searchWhere)->where($where) - ->field('id,name,org_id,leader,mobile,status,sort,create_time') + return Dept::where($this->searchWhere)->where($this->where) + ->field('id,name,org_id,mobile,status,sort,create_time') ->limit($this->limitOffset, $this->limitLength) ->order(['sort' => 'desc', 'id' => 'desc']) ->select()->each(function($item){ $org = Orgs::where('id',$item['org_id'])->findOrEmpty(); - $admin = Admin::field('name')->where('id',$item['leader'])->findOrEmpty(); $item['org_name'] = $org->isEmpty() ? '' : $org['name']; - $item['leader'] = $admin['name']; + $item['status_text'] = $item->status_text; return $item; }) ->toArray(); @@ -61,12 +58,6 @@ */ public function count(): int { - $params = $this->request->param(); - $where = []; - if(isset($params['org_name']) && $params['org_name'] != ''){ - $orgs = Orgs::where('name','like','%'.$params['org_name'].'%')->column('id'); - $where[] = ['org_id','in',$orgs]; - } - return Dept::where($this->searchWhere)->where($where)->count(); + return Dept::where($this->searchWhere)->where($this->where)->count(); } } \ No newline at end of file diff --git a/app/adminapi/lists/dept/JobsLists.php b/app/adminapi/lists/dept/JobsLists.php index 8cd3fa9ec..5c18bca51 100755 --- a/app/adminapi/lists/dept/JobsLists.php +++ b/app/adminapi/lists/dept/JobsLists.php @@ -27,7 +27,7 @@ use app\common\model\dept\Orgs; */ class JobsLists extends BaseAdminDataLists implements ListsSearchInterface { - + private $where = []; /** * @notes 设置搜索条件 * @return \string[][] @@ -51,13 +51,11 @@ class JobsLists extends BaseAdminDataLists implements ListsSearchInterface */ public function lists(): array { - $params = $this->request->param(); - $where = []; if(isset($params['dept_name']) && $params['dept_name'] != ''){ $deps = Dept::where('name','like','%'.$params['dept_name'].'%')->column('id'); - $where[] = ['dept_id','in',$deps]; + $this->where[] = ['dept_id','in',$deps]; } - return Jobs::where($this->searchWhere)->where($where)->field('id,dept_id,name,status,sort,create_time') + return Jobs::where($this->searchWhere)->where($this->where)->field('id,dept_id,name,status,sort,create_time') ->limit($this->limitOffset, $this->limitLength) ->order(['sort' => 'desc', 'id' => 'desc']) ->select()->each(function($item){ @@ -65,6 +63,7 @@ class JobsLists extends BaseAdminDataLists implements ListsSearchInterface $org = Orgs::field('name')->where('id',$dept['org_id'])->findOrEmpty(); $item['org_name'] = $org->isEmpty() ? '' : $org['name']; $item['dept_name'] = $dept->isEmpty() ? '' : $dept['name']; + $item['status_text'] = $item->status_text; return $item; }) ->toArray(); @@ -79,13 +78,7 @@ class JobsLists extends BaseAdminDataLists implements ListsSearchInterface */ public function count(): int { - $params = $this->request->param(); - $where = []; - if(isset($params['dept_name']) && $params['dept_name'] != ''){ - $deps = Dept::where('name','like','%'.$params['dept_name'].'%')->column('id'); - $where[] = ['dept_id','in',$deps]; - } - return Jobs::where($this->searchWhere)->where($where)->count(); + return Jobs::where($this->searchWhere)->where($this->where)->count(); } } \ No newline at end of file diff --git a/app/adminapi/lists/dept/OrgsLists.php b/app/adminapi/lists/dept/OrgsLists.php index fac0a9cd8..12767e353 100644 --- a/app/adminapi/lists/dept/OrgsLists.php +++ b/app/adminapi/lists/dept/OrgsLists.php @@ -39,7 +39,7 @@ { return [ '=' => ['status'], - '%like%' => ['name', 'master'], + '%like%' => ['name'], ]; } @@ -56,7 +56,7 @@ public function lists(): array { return Orgs::where($this->searchWhere) - ->field(['id', 'name', 'master', 'status', 'create_time']) + ->field(['id', 'name', 'status', 'create_time']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function ($data) { diff --git a/app/adminapi/logic/dept/DeptLogic.php b/app/adminapi/logic/dept/DeptLogic.php index 4b4a180ce..90a615fbc 100755 --- a/app/adminapi/logic/dept/DeptLogic.php +++ b/app/adminapi/logic/dept/DeptLogic.php @@ -41,8 +41,7 @@ class DeptLogic extends BaseLogic Dept::create([ 'org_id' => $params['org_id'], 'name' => $params['name'], - 'leader' => $params['leader'] ?? 0, - 'mobile' => $params['mobile'], + 'mobile' => $params['mobile'] ?? '', 'status' => $params['status'], 'sort' => $params['sort'] ?? 0 ]); @@ -63,8 +62,7 @@ class DeptLogic extends BaseLogic 'id' => $params['id'], 'org_id' => $params['org_id'], 'name' => $params['name'], - 'leader' => $params['leader'] ?? 0, - 'mobile' => $params['mobile'], + 'mobile' => $params['mobile'] ?? '', 'status' => $params['status'], 'sort' => $params['sort'] ?? 0 ]); @@ -102,15 +100,13 @@ class DeptLogic extends BaseLogic */ public static function detail($params): array { - $data = Dept::field('id,name,org_id,leader,mobile,status,sort,create_time')->where('id',$params['id'])->findOrEmpty(); + $data = Dept::field('id,name,org_id,mobile,status,sort,create_time')->where('id',$params['id'])->findOrEmpty(); if($data->isEmpty()){ return []; } $org = Orgs::where('id',$data['org_id'])->findOrEmpty(); $data['org_name'] = $org->isEmpty() ? '' : $org['name']; $data['status_text'] = $data->status_text; - $admin = Admin::field('name')->where('id',$data['leader'])->findOrEmpty(); - $data['leader_name'] = $admin['name']; return $data->toArray(); } diff --git a/app/adminapi/logic/dept/JobsLogic.php b/app/adminapi/logic/dept/JobsLogic.php index 001efe937..78161510c 100755 --- a/app/adminapi/logic/dept/JobsLogic.php +++ b/app/adminapi/logic/dept/JobsLogic.php @@ -96,9 +96,6 @@ class JobsLogic extends BaseLogic public static function detail($params) : array { $jobs = Jobs::field('id,dept_id,name,status,sort,create_time')->where('id',$params['id'])->findOrEmpty(); - if($jobs->isEmpty()){ - return []; - } $dept = Dept::where('id',$jobs['dept_id'])->findOrEmpty(); $org = Orgs::where('id',$dept['org_id'])->findOrEmpty(); $jobs['dept_name'] = $dept->isEmpty() ? '' : $dept['name']; diff --git a/app/adminapi/logic/dept/OrgsLogic.php b/app/adminapi/logic/dept/OrgsLogic.php index 76d67c277..f59d316d4 100644 --- a/app/adminapi/logic/dept/OrgsLogic.php +++ b/app/adminapi/logic/dept/OrgsLogic.php @@ -43,7 +43,6 @@ class OrgsLogic extends BaseLogic try { Orgs::create([ 'name' => $params['name'], - 'master' => $params['master'], 'status' => $params['status'] ]); @@ -70,7 +69,6 @@ class OrgsLogic extends BaseLogic try { Orgs::where('id', $params['id'])->update([ 'name' => $params['name'], - 'master' => $params['master'], 'status' => $params['status'] ]); @@ -112,7 +110,7 @@ class OrgsLogic extends BaseLogic */ public static function detail($params): array { - $res = Orgs::field('id,name,master,status,create_time')->findOrEmpty($params['id']); + $res = Orgs::field('id,name,status,create_time')->findOrEmpty($params['id']); $res['status_text'] = $res->status_text; return $res->toArray(); } diff --git a/app/adminapi/validate/dept/DeptValidate.php b/app/adminapi/validate/dept/DeptValidate.php index 433ad59b2..f12638049 100755 --- a/app/adminapi/validate/dept/DeptValidate.php +++ b/app/adminapi/validate/dept/DeptValidate.php @@ -33,7 +33,6 @@ 'id' => 'require|checkDept', 'org_id' => 'require|checkOrg', 'name' => 'require|length:1,30', - 'leader' => 'checkLeader', 'mobile' => 'mobile', 'status' => 'require|in:0,1', 'sort' => 'egt:0', @@ -46,7 +45,6 @@ 'name.require' => '请填写部门名称', 'name.length' => '部门名称长度须在1-30位字符', 'name.unique' => '部门名称已存在', - 'leader.require' => '请选择部门负责人', 'mobile.require' => '请填写部门负责人联系电话', 'mobile.mobile' => '部门负责人联系电话格式错误', 'status.require' => '请选择部门状态', @@ -86,7 +84,7 @@ */ public function sceneEdit() { - return $this->only(['id', 'org_id', 'name', 'leader', 'mobile', 'status'])->append('name', 'checkUniqueByEdit');; + return $this->only(['id', 'org_id', 'name', 'mobile', 'status'])->append('name', 'checkUniqueByEdit');; } @@ -140,14 +138,4 @@ return true; } - public function checkLeader($value) - { - if (empty($value)) return true; - $data = Admin::where('id', $value)->findOrEmpty(); - if ($data->isEmpty()) { - return '负责人信息不存在'; - } - return true; - } - } \ No newline at end of file diff --git a/app/adminapi/validate/dept/OrgsValidate.php b/app/adminapi/validate/dept/OrgsValidate.php index cfac038b3..a8871d147 100644 --- a/app/adminapi/validate/dept/OrgsValidate.php +++ b/app/adminapi/validate/dept/OrgsValidate.php @@ -34,7 +34,6 @@ protected $rule = [ 'id' => 'require', 'name' => 'require', - 'master' => 'require', 'status' => 'require|integer|in:0,1', ]; @@ -46,7 +45,6 @@ protected $field = [ 'id' => 'id', 'name' => '组织名称', - 'master' => '组织负责人', 'status' => '组织状态', ]; @@ -59,7 +57,7 @@ */ public function sceneAdd() { - return $this->only(['name', 'master', 'status'])->append('name', 'checkUniqueByAdd'); + return $this->only(['name', 'status'])->append('name', 'checkUniqueByAdd'); } @@ -71,7 +69,7 @@ */ public function sceneEdit() { - return $this->only(['id', 'name', 'master', 'status'])->append('name', 'checkUniqueByEdit'); + return $this->only(['id', 'name', 'status'])->append('name', 'checkUniqueByEdit'); }