From d283c4e6ab510241bdb7bff5ecedcfdaf272160e Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Sun, 25 Oct 2026 19:02:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=B3=BB=E7=BB=9F=E5=8C=96?= =?UTF-8?q?=E5=BE=85=E5=8A=9E=E5=88=97=E8=A1=A8=E6=93=8D=E4=BD=9C=E4=BD=93?= =?UTF-8?q?=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/SystemizationTodos.php | 51 +++ .../pages/systemization-todos.blade.php | 304 ++++++++++++++---- .../Business/SystemizationTodosTest.php | 70 +++- 3 files changed, 366 insertions(+), 59 deletions(-) diff --git a/app/Http/Controllers/Business/SystemizationTodos.php b/app/Http/Controllers/Business/SystemizationTodos.php index b48f1929..35a51209 100644 --- a/app/Http/Controllers/Business/SystemizationTodos.php +++ b/app/Http/Controllers/Business/SystemizationTodos.php @@ -19,6 +19,17 @@ class SystemizationTodos extends Controller public function page(): array { $filters = $this->filters(); + if ( + $filters['date_from'] !== '' + && $filters['date_to'] !== '' + && $filters['date_from'] > $filters['date_to'] + ) { + [$filters['date_from'], $filters['date_to']] = [ + $filters['date_to'], + $filters['date_from'], + ]; + } + $query = SystemizationTodo::query() ->with('attachments') ->withCount('attachments'); @@ -35,6 +46,12 @@ class SystemizationTodos extends Controller ->orWhere('assignee', $filters['owner']); }); } + if ($filters['date_from'] !== '') { + $query->whereDate($filters['date_scope'], '>=', $filters['date_from']); + } + if ($filters['date_to'] !== '') { + $query->whereDate($filters['date_scope'], '<=', $filters['date_to']); + } if ($filters['keyword'] !== '') { $like = '%' . addcslashes($filters['keyword'], '%_\\') . '%'; $query->where(function ($builder) use ($like): void { @@ -50,6 +67,10 @@ class SystemizationTodos extends Controller $items = $query ->orderByRaw("CASE WHEN status = '已完成' THEN 1 ELSE 0 END") + ->orderByRaw("CASE WHEN category IS NULL OR category = '' THEN 1 ELSE 0 END") + ->orderBy('category') + ->orderByRaw("CASE WHEN section IS NULL OR section = '' THEN 1 ELSE 0 END") + ->orderBy('section') ->orderByRaw('CASE WHEN due_date IS NULL THEN 1 ELSE 0 END') ->orderBy('due_date') ->orderBy('sort_order') @@ -88,6 +109,7 @@ class SystemizationTodos extends Controller 'todoCategories' => $categories, 'todoOwners' => $owners, 'todoStatuses' => SystemizationTodo::STATUSES, + 'todoDateScopes' => $this->dateScopes(), 'todoSummary' => [ 'total' => (clone $base)->count(), 'pending' => (clone $base)->where('status', SystemizationTodo::STATUS_PENDING)->count(), @@ -207,6 +229,9 @@ class SystemizationTodos extends Controller private function filters(): array { + $dateScopes = $this->dateScopes(); + $dateScope = (string) request('date_scope', 'due_date'); + return [ 'status' => in_array(request('status'), SystemizationTodo::STATUSES, true) ? (string) request('status') @@ -214,9 +239,35 @@ class SystemizationTodos extends Controller 'category' => trim((string) request('category', '')), 'owner' => trim((string) request('owner', '')), 'keyword' => trim((string) request('keyword', '')), + 'date_scope' => array_key_exists($dateScope, $dateScopes) ? $dateScope : 'due_date', + 'date_from' => $this->normalizeDateFilter(request('date_from')), + 'date_to' => $this->normalizeDateFilter(request('date_to')), ]; } + private function dateScopes(): array + { + return [ + 'due_date' => '完成时间', + 'start_date' => '开始时间', + 'created_at' => '新增时间', + ]; + } + + private function normalizeDateFilter(mixed $value): string + { + $value = trim((string) $value); + if ($value === '') { + return ''; + } + + $date = \DateTimeImmutable::createFromFormat('!Y-m-d', $value); + + return $date instanceof \DateTimeImmutable && $date->format('Y-m-d') === $value + ? $value + : ''; + } + private function validated(Request $request): array { return $request->validate([ diff --git a/resources/views/business/pages/systemization-todos.blade.php b/resources/views/business/pages/systemization-todos.blade.php index 1659e857..2f3847f4 100644 --- a/resources/views/business/pages/systemization-todos.blade.php +++ b/resources/views/business/pages/systemization-todos.blade.php @@ -11,34 +11,54 @@ .sys-todo-page__button--primary:hover { background:#6a5129; color:#fff; } .sys-todo-page__button .material-icons-outlined { font-size:1rem; } .sys-todo-page__intro { margin:.35rem 0 0; color:var(--sys-muted); font-size:.75rem; line-height:1.6; } - .sys-todo-summary { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:.75rem; margin:1rem 0; } - .sys-todo-summary__item { padding:.75rem .85rem; border:1px solid #e6dfd2; border-radius:.6rem; background:#fffdf9; } + .sys-todo-summary { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:.55rem; margin:.8rem 0; } + .sys-todo-summary__item { display:flex; align-items:center; justify-content:space-between; gap:.6rem; padding:.5rem .7rem; border:1px solid #e6dfd2; border-radius:.5rem; background:#fffdf9; } .sys-todo-summary__label { color:var(--sys-muted); font-size:.72rem; } - .sys-todo-summary__value { margin-top:.15rem; color:#171717; font-size:1.25rem; font-weight:700; font-variant-numeric:tabular-nums; } + .sys-todo-summary__value { color:#171717; font-size:1rem; font-weight:700; font-variant-numeric:tabular-nums; } .sys-todo-summary__item.is-warning .sys-todo-summary__value { color:#935f07; } .sys-todo-summary__item.is-success .sys-todo-summary__value { color:#53793e; } - .sys-todo-filter { display:grid; grid-template-columns:minmax(8rem,.8fr) minmax(10rem,1fr) minmax(10rem,1fr) minmax(18rem,2fr) auto; gap:.65rem .75rem; align-items:end; margin:0 0 1rem; padding:.85rem; border:1px solid #e6dfd2; border-radius:.65rem; background:#fcfaf5; } - .sys-todo-filter label { display:grid; gap:.3rem; color:#595959; font-size:.75rem; } + .sys-todo-filter { display:flex; flex-wrap:wrap; gap:.65rem .55rem; align-items:end; margin:0 0 .85rem; padding:.7rem; border:1px solid #e6dfd2; border-radius:.65rem; background:#fcfaf5; } + .sys-todo-filter label { display:grid; flex:1 1 7.4rem; gap:.25rem; min-width:0; color:#595959; font-size:.72rem; } + .sys-todo-filter label.sys-todo-filter__keyword { flex:2.2 1 16rem; } .sys-todo-filter input, .sys-todo-filter select { width:100%; height:2.125rem; padding:0 .6rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; color:#171717; font:inherit; font-size:.8125rem; } - .sys-todo-filter__actions { display:flex; gap:.45rem; } + .sys-todo-filter__actions { display:flex; flex:0 0 auto; gap:.45rem; } .sys-todo-table-wrap { overflow:auto; border:1px solid var(--sys-border); border-radius:.65rem; background:#fff; } - .sys-todo-table { width:100%; min-width:94rem; border-collapse:collapse; font-size:.78rem; } - .sys-todo-table th { position:sticky; top:0; z-index:1; padding:.65rem .55rem; border-bottom:1px solid var(--sys-border); background:#f3ece0; color:#3d3a35; text-align:left; white-space:nowrap; } - .sys-todo-table td { padding:.6rem .55rem; border-bottom:1px solid #eee7da; color:#2f2a23; vertical-align:top; } - .sys-todo-table tbody tr:hover { background:#fdfbf6; } - .sys-todo-table__title, .sys-todo-table__progress, .sys-todo-table__notes { min-width:14rem; max-width:28rem; white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.55; } - .sys-todo-table__title { min-width:24rem; font-weight:600; } + .sys-todo-table-wrap { max-height:clamp(24rem,58vh,46rem); overscroll-behavior:contain; scrollbar-gutter:stable; } + .sys-todo-table { width:100%; min-width:88rem; border-collapse:separate; border-spacing:0; font-size:.75rem; } + .sys-todo-table th { position:sticky; top:0; z-index:4; padding:.55rem .48rem; border-bottom:1px solid var(--sys-border); background:#f3ece0; color:#3d3a35; text-align:left; white-space:nowrap; } + .sys-todo-table td { padding:.45rem .48rem; border-bottom:1px solid #eee7da; background:#fff; color:#2f2a23; vertical-align:top; } + .sys-todo-table tbody tr { cursor:pointer; } + .sys-todo-table tbody tr:hover td { background:#fdfbf6; } + .sys-todo-table tbody tr:focus-visible { outline:2px solid var(--sys-gold); outline-offset:-2px; } + .sys-todo-table th:first-child, .sys-todo-table td:first-child { position:sticky; left:0; z-index:3; width:4rem; min-width:4rem; text-align:center; box-shadow:1px 0 0 #e5ddcf; } + .sys-todo-table th:first-child { z-index:6; background:#f3ece0; } + .sys-todo-table th:last-child, .sys-todo-table td:last-child { position:sticky; right:0; z-index:3; width:5.8rem; min-width:5.8rem; background:#fff; box-shadow:-1px 0 0 #e5ddcf; } + .sys-todo-table th:last-child { z-index:6; background:#f3ece0; } + .sys-todo-table tbody tr:hover td:first-child, .sys-todo-table tbody tr:hover td:last-child { background:#fdfbf6; } + .sys-todo-table__index { color:#6d5630; font-weight:600; font-variant-numeric:tabular-nums; white-space:nowrap; } + .sys-todo-table__group { vertical-align:middle; background:#fcfaf5; font-weight:600; } + .sys-todo-table__section { min-width:14rem; max-width:20rem; } + .sys-todo-table__title, .sys-todo-table__progress, .sys-todo-table__notes { line-height:1.45; white-space:pre-line; overflow-wrap:anywhere; } + .sys-todo-table__title { min-width:20rem; max-width:27rem; font-weight:600; } + .sys-todo-table__progress { min-width:15rem; max-width:23rem; } + .sys-todo-table__notes { min-width:11rem; max-width:18rem; } + .sys-todo-table__clamp { display:-webkit-box; overflow:hidden; -webkit-box-orient:vertical; -webkit-line-clamp:3; } + .sys-todo-table__section .sys-todo-table__clamp { -webkit-line-clamp:2; } .sys-todo-badge { display:inline-flex; align-items:center; padding:.1rem .45rem; border:1px solid #dfd6c5; border-radius:999px; background:#faf6ee; color:#51483c; white-space:nowrap; } .sys-todo-badge--progress { border-color:#dbbf7a; background:#fff7df; color:#935f07; } .sys-todo-badge--completed { border-color:#bad0ac; background:#f2f8ed; color:#53793e; } .sys-todo-badge--delayed { border-color:#e7c3c3; background:#fff3f3; color:#b80000; } .sys-todo-badge--overdue { border-color:#e7c3c3; color:#b80000; } .sys-todo-shots { display:flex; flex-wrap:wrap; gap:.3rem; max-width:13rem; } - .sys-todo-shots a { display:block; width:4.25rem; height:3.2rem; border:1px solid #ddd4c4; border-radius:.35rem; overflow:hidden; background:#faf8f3; } + .sys-todo-shots button { display:block; width:4.25rem; height:3.2rem; padding:0; border:1px solid #ddd4c4; border-radius:.35rem; overflow:hidden; background:#faf8f3; cursor:zoom-in; } .sys-todo-shots img { width:100%; height:100%; object-fit:cover; } .sys-todo-row-actions { display:flex; flex-wrap:wrap; gap:.35rem; } .sys-todo-row-actions button, .sys-todo-row-actions a { padding:.2rem .45rem; border:1px solid var(--sys-border); border-radius:.35rem; background:#fff; color:#51483c; font:inherit; font-size:.72rem; text-decoration:none; cursor:pointer; } .sys-todo-row-actions button:hover, .sys-todo-row-actions a:hover { border-color:#c7b687; background:var(--sys-gold-soft); } + .sys-todo-table__add { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.65rem; margin-top:.6rem; padding:.55rem .7rem; border:1px dashed #d8cdb8; border-radius:.55rem; background:#fcfaf5; color:#666; font-size:.72rem; } + .sys-todo-table__add button { display:inline-flex; align-items:center; gap:.25rem; min-height:2rem; padding:0 .7rem; border:1px solid var(--sys-border); border-radius:.4rem; background:#fff; color:#51483c; font:inherit; font-size:.76rem; cursor:pointer; } + .sys-todo-table__add button:hover { border-color:#c7b687; background:var(--sys-gold-soft); } + .sys-todo-table__add .material-icons-outlined { font-size:1rem; } .sys-todo-empty { padding:2rem 1rem; color:#777; text-align:center; } .sys-todo-pagination { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.75rem; padding:.85rem 0 0; color:#595959; font-size:.75rem; } .sys-todo-pagination__actions { display:flex; gap:.5rem; } @@ -65,18 +85,32 @@ .sys-todo-field input, .sys-todo-field select, .sys-todo-field textarea { width:100%; padding:.5rem .6rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; color:#171717; font:inherit; font-size:.8125rem; } .sys-todo-field input, .sys-todo-field select { min-height:2.15rem; } .sys-todo-field textarea { min-height:5.5rem; resize:vertical; line-height:1.55; } - .sys-todo-field input[type="file"] { padding:.35rem; } - .sys-todo-upload-note { color:#777; font-size:.72rem; } + .sys-todo-upload-zone { display:flex; flex-wrap:wrap; align-items:center; gap:.45rem .65rem; min-height:4.5rem; padding:.7rem; border:1px dashed #cfc3ad; border-radius:.55rem; background:#fcfaf5; } + .sys-todo-upload-zone input[type="file"] { position:absolute; width:1px; height:1px; padding:0; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; } + .sys-todo-upload-button { display:inline-flex; align-items:center; justify-content:center; min-height:2rem; padding:0 .75rem; border:1px solid var(--sys-gold); border-radius:.4rem; background:var(--sys-gold); color:#fff; font-size:.78rem; cursor:pointer; } + .sys-todo-upload-button:hover { background:#6a5129; } + .sys-todo-upload-note { flex:1 1 15rem; color:#666; font-size:.72rem; line-height:1.5; } .sys-todo-field.is-dragging { outline:2px dashed var(--sys-gold); outline-offset:3px; border-radius:.55rem; background:var(--sys-gold-soft); } .sys-todo-existing { display:flex; flex-wrap:wrap; gap:.55rem; margin-top:.45rem; } - .sys-todo-existing__item { display:grid; gap:.25rem; width:8rem; padding:.4rem; border:1px solid #e4dccd; border-radius:.45rem; background:#fcfaf5; font-size:.7rem; } - .sys-todo-existing__item img { width:100%; height:5rem; object-fit:cover; border-radius:.3rem; background:#fff; } + .sys-todo-existing__item { display:grid; gap:.25rem; width:8.5rem; padding:.4rem; border:1px solid #e4dccd; border-radius:.45rem; background:#fcfaf5; font-size:.7rem; } + .sys-todo-existing__item button { display:block; width:100%; padding:0; border:0; border-radius:.3rem; background:#fff; cursor:zoom-in; overflow:hidden; } + .sys-todo-existing__item img { display:block; width:100%; height:5rem; object-fit:cover; background:#fff; } .sys-todo-existing__item label { display:flex; align-items:center; gap:.25rem; color:#b80000; } .sys-todo-dialog__foot { display:flex; justify-content:flex-end; gap:.5rem; padding:.75rem 1.25rem; border-top:1px solid #e8e0d2; background:#fcfaf5; } .sys-todo-dialog__foot button { min-height:2.1rem; padding:0 .9rem; border:1px solid var(--sys-border); border-radius:.45rem; background:#fff; font:inherit; font-size:.8125rem; cursor:pointer; } .sys-todo-dialog__foot button[type="submit"] { border-color:var(--sys-gold); background:var(--sys-gold); color:#fff; } - @media (max-width:1100px) { .sys-todo-summary { grid-template-columns:repeat(3,minmax(0,1fr)); } .sys-todo-filter { grid-template-columns:repeat(2,minmax(0,1fr)); } .sys-todo-filter__actions { justify-self:end; } } - @media (max-width:720px) { .sys-todo-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } .sys-todo-filter { grid-template-columns:1fr; } .sys-todo-filter__actions { justify-self:stretch; } .sys-todo-filter__actions .sys-todo-page__button { flex:1; } .sys-todo-field--3,.sys-todo-field--4,.sys-todo-field--6 { grid-column:span 12; } } + .sys-todo-image-dialog { width:min(72rem,calc(100vw - 2rem)); max-height:92vh; padding:0; border:1px solid var(--sys-border); border-radius:.8rem; background:#111; color:#fff; overflow:hidden; } + .sys-todo-image-dialog::backdrop { background:rgba(5,5,6,.78); } + .sys-todo-image-dialog__head { display:flex; align-items:center; gap:1rem; padding:.65rem .85rem; background:#1d1d1f; } + .sys-todo-image-dialog__head h2 { margin:0; min-width:0; overflow:hidden; font-size:.82rem; text-overflow:ellipsis; white-space:nowrap; } + .sys-todo-image-dialog__head button { margin-left:auto; width:2rem; height:2rem; border:1px solid #5a554d; border-radius:999px; background:#2a2927; color:#fff; cursor:pointer; } + .sys-todo-image-dialog__body { display:grid; place-items:center; height:calc(92vh - 7rem); padding:.75rem; background:#111; overflow:auto; } + .sys-todo-image-dialog__body img { max-width:100%; max-height:100%; object-fit:contain; } + .sys-todo-image-dialog__foot { display:flex; justify-content:flex-end; padding:.55rem .85rem; background:#1d1d1f; } + .sys-todo-image-dialog__foot a { color:#f0e4bf; font-size:.75rem; } + @media (max-width:1300px) { .sys-todo-summary { grid-template-columns:repeat(3,minmax(0,1fr)); } } + @media (max-width:900px) { .sys-todo-filter label, .sys-todo-filter label.sys-todo-filter__keyword { flex-basis:9rem; } .sys-todo-filter__actions { width:100%; } .sys-todo-filter__actions .sys-todo-page__button { flex:1; } } + @media (max-width:720px) { .sys-todo-summary { grid-template-columns:repeat(2,minmax(0,1fr)); } .sys-todo-filter label, .sys-todo-filter label.sys-todo-filter__keyword { flex-basis:10rem; } .sys-todo-field--3,.sys-todo-field--4,.sys-todo-field--6 { grid-column:span 12; } .sys-todo-table-wrap { max-height:65vh; } }
| 序号 | 类型 | 内容 | 待办事项 | 总负责人 | 责任人 | -开始时间 | 完成时间 | 状态 | 完成情况 | 完成截图 | 备注 | 操作 | +序号 | 类型 | 内容 | 待办事项 | 总负责人 | 责任人 | +开始时间 | 完成时间 | 状态 | 完成情况 | 完成截图 | 备注 | 操作 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $items->firstItem() + $loop->index }} | -{{ $item->category ?: '—' }} | -{{ $item->section ?: '—' }} | -{!! nl2br(e($item->title)) !!} | +||||||||||||||||||||||
| {{ $item->sort_order ?: $item->id }} | + @if ($categorySpan !== 0) +1) rowspan="{{ $categorySpan }}" @endif>{{ $item->category ?: '—' }} | + @endif + @if ($sectionSpan !== 0) + 1) rowspan="{{ $sectionSpan }}" @endif>
+ {{ $item->section ?: '—' }}
+ |
+ @endif
+ {{ $item->title }} |
{{ $item->owner ?: '—' }} | {{ $item->assignee ?: '—' }} | {{ $item->start_date?->format('Y-m-d') ?: ($item->start_note ?: '—') }} | @@ -202,26 +288,31 @@ @if ($isOverdue){{ $item->status }} | -{!! nl2br(e($item->progress ?: '—')) !!} | +{{ $item->progress ?: '—' }} |
@if ($item->attachments->isNotEmpty())
@foreach ($item->attachments as $attachment)
-
+ @php
+ $attachmentUrl = route('business.systemization-todos.attachments.show', [
+ 'todo' => $item->id,
+ 'attachment' => $attachment->id,
+ ]);
+ @endphp
+
+
@endforeach
@else
—
@endif
|
- {!! nl2br(e($item->notes ?: '—')) !!} | +{{ $item->notes ?: '—' }} |
-
+
|