|
|
|
|
@ -35,6 +35,7 @@ class VisitController extends CommonController
|
|
|
|
|
* @OA\Parameter(name="my_audit", in="query", @OA\Schema(type="string"), required=false, description="是否显示我审核的记录0否1是,默认0"),
|
|
|
|
|
* @OA\Parameter(name="my_accept_admin", in="query", @OA\Schema(type="string"), required=false, description="是否显示接待人员是自己的0否1是,默认0"),
|
|
|
|
|
* @OA\Parameter(name="long_time", in="query", @OA\Schema(type="string"), required=false, description="是否长期访客0否1是"),
|
|
|
|
|
* @OA\Parameter(name="is_auth", in="query", @OA\Schema(type="string"), required=true, description="is_auth是否鉴权0否1是"),
|
|
|
|
|
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
|
|
|
|
* @OA\Response(
|
|
|
|
|
* response="200",
|
|
|
|
|
@ -45,7 +46,8 @@ class VisitController extends CommonController
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
$all = request()->all();
|
|
|
|
|
$list = Visit::with('accompany.department','gateLogs', 'visitTime', 'admin', 'visitArea', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department', 'audit.auditAdmin')->where(function ($query) use ($all) {
|
|
|
|
|
$is_auth = request('is_auth', 1);
|
|
|
|
|
$list = Visit::with('accompany.department', 'gateLogs', 'visitTime', 'admin', 'visitArea', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department', 'audit.auditAdmin')->where(function ($query) use ($all, $is_auth) {
|
|
|
|
|
if (isset($all['keyword'])) {
|
|
|
|
|
$query->where('name', 'like', '%' . $all['keyword'] . '%');
|
|
|
|
|
}
|
|
|
|
|
@ -70,29 +72,31 @@ class VisitController extends CommonController
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// 权限设置
|
|
|
|
|
$user = $this->getUser();
|
|
|
|
|
$adminIds = Admin::roleAllowAdminIds($user, $departmentIds);
|
|
|
|
|
$query->where(function ($qry) use ($adminIds, $departmentIds, $user) {
|
|
|
|
|
$qry->whereIn('accpet_department_id', $departmentIds)->orWhere(function ($qry) use ($adminIds) {
|
|
|
|
|
$qry->whereIn('accept_admin_id', $adminIds);
|
|
|
|
|
if ($is_auth) {
|
|
|
|
|
$user = $this->getUser();
|
|
|
|
|
$adminIds = Admin::roleAllowAdminIds($user, $departmentIds);
|
|
|
|
|
$query->where(function ($qry) use ($adminIds, $departmentIds, $user) {
|
|
|
|
|
$qry->whereIn('accpet_department_id', $departmentIds)->orWhere(function ($qry) use ($adminIds) {
|
|
|
|
|
$qry->whereIn('accept_admin_id', $adminIds);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
})->orderBy($all['sort_name'] ?? 'id', $all['sort_type'] ?? 'desc');
|
|
|
|
|
if (isset($all['is_export']) && !empty($all['is_export'])) {
|
|
|
|
|
return (new FastExcel($list->limit(5000)->get()->toArray()))->download('访问记录' . date('YmdHis') . '.csv', function ($info) {
|
|
|
|
|
return [
|
|
|
|
|
'姓名' => $info['name']??'',
|
|
|
|
|
'类型' => $info['type_text']??'',
|
|
|
|
|
'审核状态' => $info['audit_status_text']??'',
|
|
|
|
|
'姓名' => $info['name'] ?? '',
|
|
|
|
|
'类型' => $info['type_text'] ?? '',
|
|
|
|
|
'审核状态' => $info['audit_status_text'] ?? '',
|
|
|
|
|
'是否随访' => empty($info['follw_people']) ? '否' : '是',
|
|
|
|
|
'预约时间' => $info['date']??'',
|
|
|
|
|
'证件号' => $info['idcard']??'',
|
|
|
|
|
'预约时间' => $info['date'] ?? '',
|
|
|
|
|
'证件号' => $info['idcard'] ?? '',
|
|
|
|
|
'证件类型' => $info['credent'] == 1 ? '身份证' : '护照',
|
|
|
|
|
'单位名称' => $info['company_name']??'',
|
|
|
|
|
'手机号' => $info['mobile']??'',
|
|
|
|
|
'单位名称' => $info['company_name'] ?? '',
|
|
|
|
|
'手机号' => $info['mobile'] ?? '',
|
|
|
|
|
'访问时间' => ($info['visit_time']['start_time']) ?? '',
|
|
|
|
|
'结束时间' => ($info['visit_time']['end_time']) ?? '',
|
|
|
|
|
'创建时间' => $info['created_at']??'',
|
|
|
|
|
'创建时间' => $info['created_at'] ?? '',
|
|
|
|
|
];
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
@ -127,7 +131,7 @@ class VisitController extends CommonController
|
|
|
|
|
if ($validator->fails()) {
|
|
|
|
|
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
|
|
|
|
|
}
|
|
|
|
|
$detail = Visit::with('accompany.department','logs.admin', 'logs.user', 'audit.auditAdmin', 'visitTime', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department', 'visitArea', 'audit.auditAdmin')->find($all['id']);
|
|
|
|
|
$detail = Visit::with('accompany.department', 'logs.admin', 'logs.user', 'audit.auditAdmin', 'visitTime', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department', 'visitArea', 'audit.auditAdmin')->find($all['id']);
|
|
|
|
|
return $this->success($detail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|