From a48e6e7ebd9ceb8070cc2020bb84af985a5ec1e4 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Sat, 20 Jan 2024 11:37:22 +0800 Subject: [PATCH] update --- .../lists/custom/CustomServiceLists.php | 22 +++------- .../logic/custom/CustomServiceLogic.php | 15 ++----- .../validate/custom/CustomServiceValidate.php | 42 +++++++------------ 3 files changed, 23 insertions(+), 56 deletions(-) diff --git a/app/adminapi/lists/custom/CustomServiceLists.php b/app/adminapi/lists/custom/CustomServiceLists.php index 37e1b969a..12a05216e 100644 --- a/app/adminapi/lists/custom/CustomServiceLists.php +++ b/app/adminapi/lists/custom/CustomServiceLists.php @@ -41,7 +41,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf public function setSearch(): array { return [ - '=' => ['project_id', 'classification', 'urgency', 'processing_result', 'processed_user'], + '=' => ['custom_id', 'project_id', 'classification', 'urgency', 'processing_result', 'processed_user'], '%like%' => ['name','receiver'] ]; } @@ -58,21 +58,15 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf */ public function lists(): array { - $params = $this->request->get(['custom_id']); - $where = []; - if(isset($params['custom_id']) && $params['custom_id'] != ''){ - $project_ids = Project::where('custom_id',$params['custom_id'])->column('id'); - $where[] = ['project_id','in',$project_ids]; - } - return CustomService::field('id,project_id,contract_id,custom_service_code,name,receiver,date,classification,processing_result,urgency,processed_user,is_solve,done_date,score') - ->where($this->searchWhere)->where($where)->limit($this->limitOffset, $this->limitLength)->order(['id' => 'desc']) + return CustomService::field('id,custom_id,project_id,contract_id,custom_service_code,name,receiver,date,classification,processing_result,urgency,processed_user,is_solve,done_date,score') + ->where($this->searchWhere)->limit($this->limitOffset, $this->limitLength)->order(['id' => 'desc']) ->select()->each(function($item){ $item['classification'] = $item->classification_text; $item['processing_result'] = $item->processing_result_text; $item['urgency'] = $item->urgency_text; $item['is_solve_text'] = $item->is_solve_text; $project = Project::field('custom_id,name,project_code')->where('id',$item['project_id'])->findOrEmpty(); - $custom = Custom::field('name,master_name,master_phone')->where('id',$project['custom_id'])->findOrEmpty(); + $custom = Custom::field('name,master_name,master_phone')->where('id',$item['custom_id'])->findOrEmpty(); $contract = Contract::field('contract_code')->where('id',$item['contract_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$item['processed_user'])->findOrEmpty(); $item['project_name'] = $project['name']; @@ -96,13 +90,7 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf */ public function count(): int { - $params = $this->request->get(['custom_id']); - $where = []; - if(isset($params['custom_id']) && $params['custom_id'] != ''){ - $project_ids = Project::where('custom_id',$params['custom_id'])->column('id'); - $where[] = ['project_id','in',$project_ids]; - } - return CustomService::where($this->searchWhere)->where($where)->count(); + return CustomService::where($this->searchWhere)->count(); } } \ No newline at end of file diff --git a/app/adminapi/logic/custom/CustomServiceLogic.php b/app/adminapi/logic/custom/CustomServiceLogic.php index e8f62867b..9f37bb537 100644 --- a/app/adminapi/logic/custom/CustomServiceLogic.php +++ b/app/adminapi/logic/custom/CustomServiceLogic.php @@ -20,8 +20,6 @@ use app\common\model\auth\Admin; use app\common\model\contract\Contract; use app\common\model\custom\Custom; use app\common\model\custom\CustomService; -use app\common\model\dept\Dept; -use app\common\model\dept\Orgs; use app\common\model\project\Project; use think\facade\Db; @@ -47,8 +45,7 @@ class CustomServiceLogic extends BaseLogic Db::startTrans(); try { CustomService::create([ - 'org_id' => $params['org_id'], - 'dept_id' => $params['dept_id'], + 'custom_id' => $params['custom_id'], 'project_id' => $params['project_id'], 'contract_id' => $params['contract_id'], 'custom_service_code' => data_unique_code('售后工单'), @@ -60,7 +57,7 @@ class CustomServiceLogic extends BaseLogic 'name' => $params['name'], 'description' => $params['description'] ?? '', 'notes' => $params['notes'] ?? '', - 'annex' => $params['annex'] ?? null + 'annex' => $params['annex'] ? json_encode($params['annex']) : null ]); Db::commit(); return true; @@ -125,16 +122,12 @@ class CustomServiceLogic extends BaseLogic */ public static function detail($params): array { - $field = 'id,org_id,dept_id,project_id,contract_id,custom_service_code,date,classification,urgency,receiver,processed_user,name,description,notes,annex,processing_result,processing_process,processing_hours,done_date,score,is_solve,feedback'; + $field = 'id,project_id,contract_id,custom_service_code,date,classification,urgency,receiver,processed_user,name,description,notes,annex,processing_result,processing_process,processing_hours,done_date,score,is_solve,feedback'; $data = CustomService::field($field)->findOrEmpty($params['id']); - $org = Orgs::field('name')->where('id',$data['org_id'])->findOrEmpty(); - $dept = Dept::field('name')->where('id',$data['dept_id'])->findOrEmpty(); $project = Project::field('name,project_code')->where('id',$data['project_id'])->findOrEmpty(); - $custom = Custom::field('name,master_name,master_phone')->where('id',$project['custom_id'])->findOrEmpty(); + $custom = Custom::field('name,master_name,master_phone')->where('id',$data['custom_id'])->findOrEmpty(); $contract = Contract::field('contract_code')->where('id',$data['contract_id'])->findOrEmpty(); $admin = Admin::field('name')->where('id',$data['processed_user'])->findOrEmpty(); - $data['org_name'] = $org['name']; - $data['dept_name'] = $dept['name']; $data['project_name'] = $project['name']; $data['project_code'] = $project['project_code']; $data['custom_name'] = $custom['name']; diff --git a/app/adminapi/validate/custom/CustomServiceValidate.php b/app/adminapi/validate/custom/CustomServiceValidate.php index 66386f551..714f7c47c 100644 --- a/app/adminapi/validate/custom/CustomServiceValidate.php +++ b/app/adminapi/validate/custom/CustomServiceValidate.php @@ -17,8 +17,7 @@ namespace app\adminapi\validate\custom; use app\common\model\auth\Admin; use app\common\model\contract\Contract; -use app\common\model\dept\Dept; -use app\common\model\dept\Orgs; +use app\common\model\custom\Custom; use app\common\model\dict\DictData; use app\common\model\project\Project; use app\common\validate\BaseValidate; @@ -38,8 +37,7 @@ class CustomServiceValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'org_id' => 'require|checkOrg', - 'dept_id' => 'require|checkDept', + 'custom_id' => 'require|checkCustom', 'project_id' => 'require|checkProject', 'contract_id' => 'require|checkContract', 'date' => 'require|dateFormat:Y-m-d', @@ -58,10 +56,8 @@ class CustomServiceValidate extends BaseValidate protected $message = [ 'id.require' => '缺少必要参数', - 'org_id.require' => '请选择组织', - 'dept_id.require' => '请选择部门', - 'project_id.require' => '请选择项目', 'custom_id.require' => '请选择客户', + 'project_id.require' => '请选择项目', 'contract_id.require' => '请选择项目合同', 'date.require' => '请选择日期', 'date.dateFormat' => '日期格式错误', @@ -93,7 +89,7 @@ class CustomServiceValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['org_id','dept_id','project_id','contract_id','date','classification','urgency','processed_user','name']); + return $this->remove('id',true); } @@ -105,7 +101,7 @@ class CustomServiceValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id','processing_result','processing_hours','done_date','score','is_solve']); + } @@ -132,33 +128,24 @@ class CustomServiceValidate extends BaseValidate return $this->only(['id']); } - public function checkOrg($value): bool|string + public function checkCustom($value): bool|string { - $org = Orgs::where('id',$value)->findOrEmpty(); - if($org->isEmpty()){ - return '组织不存在'; + $custom = Custom::where('id',$value)->findOrEmpty(); + if($custom->isEmpty()){ + return '客户信息不存在'; } return true; } - public function checkDept($value,$rule,$data): bool|string - { - $dept = Dept::where('id',$value)->findOrEmpty(); - if($dept->isEmpty()){ - return '部门不存在'; - } - if($dept['org_id'] != $data['org_id']){ - return '部门无效'; - } - return true; - } - - public function checkProject($value): bool|string + public function checkProject($value,$rule,$data): bool|string { $project = Project::where('id',$value)->findOrEmpty(); if($project->isEmpty()){ return '项目不存在'; } + if($project['custom_id'] != $data['custom_id']){ + return '项目信息无效'; + } return true; } @@ -204,8 +191,7 @@ class CustomServiceValidate extends BaseValidate public function checkAnnex($value): bool|string { if(!empty($value) && $value != ''){ - $annex = $value;//json_decode($value,true); - if(empty($annex) || !is_array($annex)){ + if(!is_array($value)){ return '附件格式错误'; } }