添加合同详情

This commit is contained in:
luofei 2023-07-20 15:10:52 +08:00
parent a69ce60e87
commit 7ec813d4d6

View File

@ -3,6 +3,7 @@
namespace app\api\controller;
use app\common\model\auth\Admin;
use app\common\model\Company;
use app\common\model\contract\Contract;
/**
@ -28,4 +29,22 @@ class ContractController extends BaseApiController
return $this->success('success', ['count' => $count, 'data' => $contract], 1, 1);
}
public function view($id)
{
$contract = Contract::find($id);
if (empty($contract)) {
return $this->fail('合同不存在');
}
$company = Company::where('id', $contract['company_id'])->find();
$company['other_contacts'] = json_decode($company['other_contacts'], true);
$company['qualification'] = json_decode($company['qualification'], true);
$users = Admin::where('company_id', $company['id'])->field('id,name,account,phone,qualification')->select()->toArray();
foreach ($users as &$user) {
$user['is_main'] = $user['id'] == $company['admin_id'] ? 1 : 0;
$user['qualification'] = json_decode($user['qualification'], true);
unset($user['role_id'], $user['dept_id'], $user['jobs_id'], $user['id']);
}
return $this->success('success', ['contract' => $contract, 'company' => $company, 'users' => $users], 1, 1);
}
}