master
cody 1 year ago
parent f80aa0d83d
commit 4458739f33

@ -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,13 +72,15 @@ 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) {

Loading…
Cancel
Save