This commit is contained in:
chenbo 2024-02-27 18:09:00 +08:00
parent e1d9cfbfcf
commit 8a377c9e7c
3 changed files with 11 additions and 5 deletions

View File

@ -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()

View File

@ -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'],

View File

@ -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;
}
}