liyinglin 3 years ago
parent 6e0c27b0fb
commit 5052837478

@ -29,6 +29,9 @@ class VisitController extends CommonController
* @OA\Parameter(name="sort_name", in="query", @OA\Schema(type="string"), required=false, description="排序字段名字"),
* @OA\Parameter(name="sort_type", in="query", @OA\Schema(type="string"), required=false, description="排序类型"),
* @OA\Parameter(name="is_export", in="query", @OA\Schema(type="string"), required=false, description="是否导出0否1是默认0"),
* @OA\Parameter(name="my_self", in="query", @OA\Schema(type="string"), required=false, description="是否显示自己创建的0否1是默认0"),
* @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="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
* @OA\Response(
* response="200",
@ -39,7 +42,7 @@ class VisitController extends CommonController
public function index()
{
$all = request()->all();
$list = Visit::with('visitTime', 'admin','visitArea','acceptAdmin.department','acceptAdminSignFile','acceptGoodsAdmin.department')->where(function ($query) use ($all) {
$list = Visit::with('visitTime', 'admin', 'visitArea', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department')->where(function ($query) use ($all) {
if (isset($all['keyword'])) {
$query->where('name', 'like', '%' . $all['keyword'] . '%');
}
@ -49,6 +52,17 @@ class VisitController extends CommonController
if (isset($all['start_date']) && isset($all['end_date'])) {
$query->whereBetween('date', [$all['start_date'], $all['end_date']]);
}
if (isset($all['my_self']) && !empty($all['my_self'])) {
$query->where('admin_id', $this->getUserId());
}
if (isset($all['my_accept_admin']) && !empty($all['my_accept_admin'])) {
$query->where('accept_admin_id', $this->getUserId());
}
if (isset($all['my_audit']) && !empty($all['my_audit'])) {
$query->whereHas('audit', function ($q) {
$q->where('audit_admin_id', $this->getUserId());
});
}
})->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) {
@ -100,7 +114,7 @@ class VisitController extends CommonController
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = Visit::with('audit.auditAdmin','visitTime','acceptAdmin.department','acceptAdminSignFile','acceptGoodsAdmin.department','visitArea')->find($all['id']);
$detail = Visit::with('audit.auditAdmin', 'visitTime', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department', 'visitArea')->find($all['id']);
return $this->success($detail);
}

@ -161,7 +161,7 @@ class UserController extends CommonController
public function myVisit()
{
$all = request()->all();
$list = Visit::where('user_id', $this->getUserId())
$list = Visit::with('visitTime', 'admin', 'visitArea', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department')->where('user_id', $this->getUserId())
->where(function ($query) use ($all) {
if (isset($all['type'])) {
$query->where('type', $all['type']);
@ -197,7 +197,7 @@ class UserController extends CommonController
if ($validator->fails()) {
return $this->fail([ResponseCode::ERROR_PARAMETER, implode(',', $validator->errors()->all())]);
}
$detail = Visit::with('visitTime')->find($all['id']);
$detail = Visit::with('visitTime', 'admin', 'visitArea', 'acceptAdmin.department', 'acceptAdminSignFile', 'acceptGoodsAdmin.department')->find($all['id']);
return $this->success($detail);
}

Loading…
Cancel
Save