From fa330ad525bed6a4f6356ecc47a0d55f4b7a7c32 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Wed, 28 Feb 2024 11:07:33 +0800 Subject: [PATCH] update --- .../ProjectRectificationLists.php | 153 +++++++++--------- .../ProjectRectificationLogic.php | 14 +- .../ProjectRectification.php | 6 +- 3 files changed, 87 insertions(+), 86 deletions(-) diff --git a/app/adminapi/lists/project_process_management/ProjectRectificationLists.php b/app/adminapi/lists/project_process_management/ProjectRectificationLists.php index 42a581946..3a6bc99ad 100644 --- a/app/adminapi/lists/project_process_management/ProjectRectificationLists.php +++ b/app/adminapi/lists/project_process_management/ProjectRectificationLists.php @@ -1,77 +1,78 @@ - ['num', 'project', 'project_num'], - ]; - } - - - /** - * @notes 获取列表 - * @return array - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException - * @author likeadmin - * @date 2024/02/23 11:22 - */ - public function lists(): array - { - return ProjectRectification::where($this->searchWhere) - ->field(['id', 'dataid', 'num', 'project', 'project_num', 'wt_unit', 'xm_master', 'zx_type', 'zg_master', 'dj_person', 'apptime', 'problem', 'deal_desc']) - ->limit($this->limitOffset, $this->limitLength) - ->order(['id' => 'desc']) - ->select() - ->toArray(); - } - - - /** - * @notes 获取数量 - * @return int - * @author likeadmin - * @date 2024/02/23 11:22 - */ - public function count(): int - { - return ProjectRectification::where($this->searchWhere)->count(); - } - + ['num', 'project', 'project_num'], + + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/02/23 11:22 + */ + public function lists(): array + { + return ProjectRectification::with(['projectInfo']) + ->where($this->searchWhere) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2024/02/23 11:22 + */ + public function count(): int + { + return ProjectRectification::where($this->searchWhere)->count(); + } + } \ No newline at end of file diff --git a/app/adminapi/logic/project_process_management/ProjectRectificationLogic.php b/app/adminapi/logic/project_process_management/ProjectRectificationLogic.php index a64910de0..426fc5d27 100644 --- a/app/adminapi/logic/project_process_management/ProjectRectificationLogic.php +++ b/app/adminapi/logic/project_process_management/ProjectRectificationLogic.php @@ -41,10 +41,9 @@ class ProjectRectificationLogic extends BaseLogic Db::startTrans(); try { ProjectRectification::create([ - 'dataid' => $params['dataid'], - 'num' => $params['num'], - 'project' => $params['project'], - 'project_num' => $params['project_num'], + 'dataid' => generate_sn(ProjectRectification::class, 'dataid'), + 'num' => generate_sn(ProjectRectification::class, 'num'), + 'project_id' => $params['project_id'], 'wt_unit' => $params['wt_unit'], 'xm_master' => $params['xm_master'], 'zx_type' => $params['zx_type'], @@ -79,10 +78,7 @@ class ProjectRectificationLogic extends BaseLogic Db::startTrans(); try { ProjectRectification::where('id', $params['id'])->update([ - 'dataid' => $params['dataid'], - 'num' => $params['num'], - 'project' => $params['project'], - 'project_num' => $params['project_num'], + 'project_id' => $params['project_id'], 'wt_unit' => $params['wt_unit'], 'xm_master' => $params['xm_master'], 'zx_type' => $params['zx_type'], @@ -127,6 +123,6 @@ class ProjectRectificationLogic extends BaseLogic */ public static function detail($params): array { - return ProjectRectification::findOrEmpty($params['id'])->toArray(); + return ProjectRectification::with(['projectInfo'])->findOrEmpty($params['id'])->toArray(); } } \ No newline at end of file diff --git a/app/common/model/project_process_management/ProjectRectification.php b/app/common/model/project_process_management/ProjectRectification.php index 16e8a8377..6f6cf3927 100644 --- a/app/common/model/project_process_management/ProjectRectification.php +++ b/app/common/model/project_process_management/ProjectRectification.php @@ -16,6 +16,7 @@ namespace app\common\model\project_process_management; use app\common\model\BaseModel; +use app\common\model\cost_project\CostProject; use think\model\concern\SoftDelete; @@ -30,5 +31,8 @@ class ProjectRectification extends BaseModel protected $name = 'project_rectification'; protected $deleteTime = 'delete_time'; - + public function projectInfo() + { + return $this->hasOne(CostProject::class, 'id', 'project_id'); + } } \ No newline at end of file