diff --git a/app/adminapi/lists/ProjectCommissionLists.php b/app/adminapi/lists/ProjectCommissionLists.php index a5e093d45..9006a183a 100644 --- a/app/adminapi/lists/ProjectCommissionLists.php +++ b/app/adminapi/lists/ProjectCommissionLists.php @@ -55,7 +55,7 @@ class ProjectCommissionLists extends BaseAdminDataLists implements ListsSearchIn */ public function lists(): array { - return ProjectCommission::where($this->searchWhere) + return ProjectCommission::with(['projectInfo'])->where($this->searchWhere) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) ->select() diff --git a/app/adminapi/logic/ProjectCommissionDetailLogic.php b/app/adminapi/logic/ProjectCommissionDetailLogic.php index c893ff73e..91b037f39 100644 --- a/app/adminapi/logic/ProjectCommissionDetailLogic.php +++ b/app/adminapi/logic/ProjectCommissionDetailLogic.php @@ -41,7 +41,7 @@ class ProjectCommissionDetailLogic extends BaseLogic Db::startTrans(); try { ProjectCommissionDetail::create([ - 'project_commission_dataid' => $params['project_commission_dataid'], + 'project_commission_id' => $params['project_commission_id'], 'engineer' => $params['engineer'], 'engineer_id' => $params['engineer_id'], 'task_name' => $params['task_name'], @@ -78,7 +78,6 @@ class ProjectCommissionDetailLogic extends BaseLogic Db::startTrans(); try { ProjectCommissionDetail::where('id', $params['id'])->update([ - 'project_commission_dataid' => $params['project_commission_dataid'], 'engineer' => $params['engineer'], 'engineer_id' => $params['engineer_id'], 'task_name' => $params['task_name'], diff --git a/app/adminapi/logic/ProjectCommissionLogic.php b/app/adminapi/logic/ProjectCommissionLogic.php index 8862c901b..2b415f6d5 100644 --- a/app/adminapi/logic/ProjectCommissionLogic.php +++ b/app/adminapi/logic/ProjectCommissionLogic.php @@ -17,6 +17,7 @@ namespace app\adminapi\logic; use app\common\model\ProjectCommission; use app\common\logic\BaseLogic; +use app\common\model\ProjectCommissionDetail; use think\facade\Db; @@ -40,7 +41,7 @@ class ProjectCommissionLogic extends BaseLogic { Db::startTrans(); try { - ProjectCommission::create([ + $projectCommission = ProjectCommission::create([ 'dataid' => generate_sn(ProjectCommission::class,'dataid'), 'num' => generate_sn(ProjectCommission::class,'num'), 'project_id' => $params['project_id'], @@ -56,6 +57,10 @@ class ProjectCommissionLogic extends BaseLogic 'remark' => $params['remark'], ]); + foreach ($params['project_commission_detail'] as $item) { + $item['project_commission_id'] = $projectCommission->id; + ProjectCommissionDetailLogic::add($item); + } Db::commit(); return true; } catch (\Exception $e) { @@ -123,6 +128,8 @@ class ProjectCommissionLogic extends BaseLogic */ public static function detail($params): array { - return ProjectCommission::findOrEmpty($params['id'])->toArray(); + $data = ProjectCommission::with(['projectInfo'])->findOrEmpty($params['id'])->toArray(); + $data['project_commission_detail'] = ProjectCommissionDetail::where('project_commission_id', $params['id'])->select()->toArray(); + return $data; } } \ No newline at end of file