diff --git a/app/adminapi/lists/custom/CustomServiceLists.php b/app/adminapi/lists/custom/CustomServiceLists.php index 0a24e85e8..7c6faf7f7 100644 --- a/app/adminapi/lists/custom/CustomServiceLists.php +++ b/app/adminapi/lists/custom/CustomServiceLists.php @@ -21,10 +21,7 @@ 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; /** * CustomService列表 @@ -61,15 +58,21 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf */ public function lists(): array { + $params = $this->request->get(); + $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,custom_id,contract_id,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']) + ->where($this->searchWhere)->where($where)->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'] = $item->is_solve_text; $project = Project::field('name,project_code')->where('id',$item['project_id'])->findOrEmpty(); - $custom = Custom::field('name,master_name,master_phone')->where('id',$item['custom_id'])->findOrEmpty(); + $custom = Custom::field('name,master_name,master_phone')->where('id',$project['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']; @@ -93,7 +96,13 @@ class CustomServiceLists extends BaseAdminDataLists implements ListsSearchInterf */ public function count(): int { - return CustomService::where($this->searchWhere)->count(); + $params = $this->request->get(); + $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(); } } \ No newline at end of file diff --git a/app/adminapi/logic/custom/CustomServiceLogic.php b/app/adminapi/logic/custom/CustomServiceLogic.php index 667ceec90..68872c2c2 100644 --- a/app/adminapi/logic/custom/CustomServiceLogic.php +++ b/app/adminapi/logic/custom/CustomServiceLogic.php @@ -50,7 +50,6 @@ class CustomServiceLogic extends BaseLogic 'org_id' => $params['org_id'], 'dept_id' => $params['dept_id'], 'project_id' => $params['project_id'], - 'custom_id' => $params['custom_id'], 'contract_id' => $params['contract_id'], 'date' => strtotime($params['date']), 'classification' => $params['classification'], @@ -130,7 +129,7 @@ class CustomServiceLogic extends BaseLogic $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',$data['custom_id'])->findOrEmpty(); + $custom = Custom::field('name,master_name,master_phone')->where('id',$project['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']; diff --git a/app/adminapi/validate/custom/CustomServiceValidate.php b/app/adminapi/validate/custom/CustomServiceValidate.php index 3cbbb96cb..bef3c8e24 100644 --- a/app/adminapi/validate/custom/CustomServiceValidate.php +++ b/app/adminapi/validate/custom/CustomServiceValidate.php @@ -17,7 +17,6 @@ namespace app\adminapi\validate\custom; use app\common\model\auth\Admin; use app\common\model\contract\Contract; -use app\common\model\custom\Custom; use app\common\model\dept\Dept; use app\common\model\dept\Orgs; use app\common\model\dict\DictData; @@ -42,7 +41,6 @@ class CustomServiceValidate extends BaseValidate 'org_id' => 'require|checkOrg', 'dept_id' => 'require|checkDept', 'project_id' => 'require|checkProject', - 'custom_id' => 'require|checkCustom', 'contract_id' => 'require|checkContract', 'date' => 'require|dateFormat:Y-m-d', 'classification' => 'require|checkClassify', @@ -95,7 +93,7 @@ class CustomServiceValidate extends BaseValidate */ public function sceneAdd() { - return $this->only(['org_id','dept_id','project_id','custom_id','contract_id','date','classification','urgency','processed_user','name']); + return $this->only(['org_id','dept_id','project_id','contract_id','date','classification','urgency','processed_user','name']); } @@ -164,19 +162,6 @@ class CustomServiceValidate extends BaseValidate return true; } - public function checkCustom($value,$rule,$data): bool|string - { - $custom = Custom::where('id',$value)->findOrEmpty(); - if($custom->isEmpty()){ - return '客户不存在'; - } - $project = Project::where('id',$data['project_id'])->findOrEmpty(); - if($value != $project['custom_id']){ - return '客户信息与项目客户信息不一致'; - } - return true; - } - public function checkContract($value,$rule,$data): bool|string { $contract = Contract::where('id',$value)->findOrEmpty();