diff --git a/app/Http/Controllers/Business/SystemizationTodos.php b/app/Http/Controllers/Business/SystemizationTodos.php index 45a54d5b..607c60d7 100644 --- a/app/Http/Controllers/Business/SystemizationTodos.php +++ b/app/Http/Controllers/Business/SystemizationTodos.php @@ -19,6 +19,13 @@ use Throwable; class SystemizationTodos extends Controller { private const OVERDUE_FILTER = '__overdue__'; + private const REMINDER_OPTIONS = [ + 'overdue' => '已逾期', + 'today' => '今天到期', + 'upcoming' => '剩余天数', + 'pending' => '时间待定', + 'none' => '无提醒', + ]; public function page(): array { @@ -36,6 +43,24 @@ class SystemizationTodos extends Controller } elseif ($filters['status'] === SystemizationTodo::STATUS_COMPLETED) { $query->where('status', $filters['status']); } + if ($filters['reminder'] !== '') { + if ($filters['reminder'] === 'overdue') { + $query->where('status', '<>', SystemizationTodo::STATUS_COMPLETED) + ->whereNotNull('due_date') + ->whereDate('due_date', '<', today()); + } elseif ($filters['reminder'] === 'today') { + $query->where('status', '<>', SystemizationTodo::STATUS_COMPLETED) + ->whereDate('due_date', today()); + } elseif ($filters['reminder'] === 'upcoming') { + $query->where('status', '<>', SystemizationTodo::STATUS_COMPLETED) + ->whereDate('due_date', '>', today()); + } elseif ($filters['reminder'] === 'pending') { + $query->where('status', '<>', SystemizationTodo::STATUS_COMPLETED) + ->whereNull('due_date'); + } elseif ($filters['reminder'] === 'none') { + $query->where('status', SystemizationTodo::STATUS_COMPLETED); + } + } if ($filters['category'] !== '') { $query->where('category', $filters['category']); } @@ -150,6 +175,12 @@ class SystemizationTodos extends Controller 'todoAssignees' => $this->peopleOptions('assignee'), 'todoStatuses' => SystemizationTodo::STATUSES, 'todoStatusOptions' => $statusOptions, + 'todoReminderOptions' => collect(self::REMINDER_OPTIONS) + ->map(static fn (string $label, string $value): array => [ + 'value' => $value, + 'label' => $label, + ]) + ->values(), 'todoReturnFilters' => base64_encode(json_encode( $filters, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES, @@ -602,6 +633,7 @@ class SystemizationTodos extends Controller { return [ 'status' => $this->normalizeStatusValue(request('status')), + 'reminder' => $this->normalizeReminderValue(request('reminder')), 'category' => trim((string) request('category', '')), 'owners' => $this->peopleFilter('owner'), 'assignees' => $this->peopleFilter('assignee'), @@ -624,6 +656,13 @@ class SystemizationTodos extends Controller : ''; } + private function normalizeReminderValue(mixed $value): string + { + $reminder = trim((string) $value); + + return array_key_exists($reminder, self::REMINDER_OPTIONS) ? $reminder : ''; + } + private function peopleFilter(string $key): array { return collect((array) request($key, [])) @@ -818,6 +857,7 @@ class SystemizationTodos extends Controller return array_filter([ 'status' => $this->normalizeStatusValue($filters['status'] ?? null), + 'reminder' => $this->normalizeReminderValue($filters['reminder'] ?? null), 'category' => $category, 'owner' => $owners, 'assignee' => $assignees, diff --git a/resources/views/business/pages/systemization-todos.blade.php b/resources/views/business/pages/systemization-todos.blade.php index 7b12efff..d2d4eb7d 100644 --- a/resources/views/business/pages/systemization-todos.blade.php +++ b/resources/views/business/pages/systemization-todos.blade.php @@ -264,6 +264,12 @@ @endforeach + @php $selectedOwners = $todoOwners->filter( static fn (string $owner): bool => in_array($owner, $todoFilters['owners'], true) @@ -595,7 +601,7 @@
-