From bfc7e8d20b5160cb41408ce4958d5e47bb050ecf Mon Sep 17 00:00:00 2001 From: weiz Date: Sat, 9 Dec 2023 10:22:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=AB=8B=E9=A1=B9=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/adminapi/lists/project/ProjectLists.php | 10 ++++----- app/adminapi/logic/project/ProjectLogic.php | 6 ++---- .../validate/project/ProjectValidate.php | 21 +++++++++++++++---- app/common.php | 6 ++++++ 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/app/adminapi/lists/project/ProjectLists.php b/app/adminapi/lists/project/ProjectLists.php index b8b0cb1ac..2b74f110a 100644 --- a/app/adminapi/lists/project/ProjectLists.php +++ b/app/adminapi/lists/project/ProjectLists.php @@ -39,8 +39,8 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface public function setSearch(): array { return [ - '=' => ['project_type', 'project_content', 'project_estimation', 'estimated_construction', 'bidding_time', 'bidding_method', 'contacts', 'position', 'telephone', 'department', 'person', 'relationship', 'discovery_time', 'information_sources', 'competitor', 'construction_funds_sources', 'construction_payment_method', 'construction_financial_status', 'construction_recognition', 'my_construction_recognition', 'strategic_significance', 'industry', 'unit_nature', 'annex', 'status'], - '%like%' => ['project_code','project_address'] + '=' => ['status','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources'], + '%like%' => ['project_code','name','project_address','person'] ]; } @@ -58,12 +58,12 @@ class ProjectLists extends BaseAdminDataLists implements ListsSearchInterface { $params = $this->request->param(); $condition = []; - if(isset($params['custom_id']) && $params['custom_id'] != ''){ - $customIds = Custom::where('name','like','%'.$params['custom_id'].'%')->column('id'); + if(isset($params['custom_name']) && $params['custom_name'] != ''){ + $customIds = Custom::where('name','like','%'.$params['custom_name'].'%')->column('id'); $condition[] = ['custom_id','in',$customIds]; } return Project::where($this->searchWhere)->where($condition) - ->field(['id', 'custom_id', 'project_type', 'project_code', 'project_content', 'project_estimation', 'project_address', 'estimated_construction', 'bidding_time', 'bidding_method', 'contacts', 'position', 'telephone', 'department', 'person', 'relationship', 'discovery_time', 'information_sources', 'competitor', 'construction_funds_sources', 'construction_payment_method', 'construction_financial_status', 'construction_recognition', 'my_construction_recognition', 'strategic_significance', 'industry', 'unit_nature', 'annex', 'status']) + ->field(['id','custom_id','project_code','name','status','project_address','project_type','strategic_significance','industry','unit_nature','bidding_method','information_sources','person']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select()->each(function($item){ diff --git a/app/adminapi/logic/project/ProjectLogic.php b/app/adminapi/logic/project/ProjectLogic.php index d889c7b55..e0c4de653 100644 --- a/app/adminapi/logic/project/ProjectLogic.php +++ b/app/adminapi/logic/project/ProjectLogic.php @@ -45,7 +45,7 @@ class ProjectLogic extends BaseLogic 'custom_id' => $params['custom_id'], 'name' => $params['name'], 'project_type' => $params['project_type'], - 'project_code' => $params['project_code'], + 'project_code' => project_code(), 'project_content' => $params['project_content'], 'project_estimation' => $params['project_estimation'], 'project_address' => $params['project_address'], @@ -70,7 +70,7 @@ class ProjectLogic extends BaseLogic 'industry' => $params['industry'], 'unit_nature' => $params['unit_nature'], 'annex' => $params['annex'], - 'status' => $params['status'] + 'status' => 0 ]); Db::commit(); @@ -98,7 +98,6 @@ class ProjectLogic extends BaseLogic 'custom_id' => $params['custom_id'], 'name' => $params['name'], 'project_type' => $params['project_type'], - 'project_code' => $params['project_code'], 'project_content' => $params['project_content'], 'project_estimation' => $params['project_estimation'], 'project_address' => $params['project_address'], @@ -123,7 +122,6 @@ class ProjectLogic extends BaseLogic 'industry' => $params['industry'], 'unit_nature' => $params['unit_nature'], 'annex' => $params['annex'], - 'status' => $params['status'] ]); Db::commit(); diff --git a/app/adminapi/validate/project/ProjectValidate.php b/app/adminapi/validate/project/ProjectValidate.php index dcb422b50..ec7050c2d 100644 --- a/app/adminapi/validate/project/ProjectValidate.php +++ b/app/adminapi/validate/project/ProjectValidate.php @@ -32,11 +32,24 @@ class ProjectValidate extends BaseValidate */ protected $rule = [ 'id' => 'require', - 'custom_id' => 'require', - 'project_code' => 'require', - 'project_type' => 'require', + 'custom_id' => 'require|integer', + 'project_type' => 'require|integer', 'name' => 'require', + 'discovery_time' => 'require', + 'information_sources' => 'require|integer' ]; + + protected $message = [ + 'id.require' => '缺少数据主键', + 'custom_id.require' => '请选择客户', + 'custom_id.integer' => '客户数据格式错误', + 'project_type.require' => '请选择工程类型', + 'project_type.integer' => '工程类型据格式错误', + 'name.require' => '请填写工程名称', + 'discovery_time.require' => '请选择发现时间', + 'information_sources.require' => '请选择信息来源', + 'information_sources.integer' => '信息来源据格式错误', + ]; /** @@ -68,7 +81,7 @@ class ProjectValidate extends BaseValidate */ public function sceneEdit() { - return $this->only(['id']); + return $this->append(['id']); } diff --git a/app/common.php b/app/common.php index c714b4634..1d9f5349b 100755 --- a/app/common.php +++ b/app/common.php @@ -297,3 +297,9 @@ function format_amount($float) } return $float; } + +//生成项目编码 +function project_code(): string +{ + return 'P'.date('Ymd',time()).'-'.mt_rand(100000, 999999); +}