@extends('layouts.app') @section('title', '工作看板') @push('styles') @endpush @section('content') @php $allCards = $columns->flatMap(fn($c) => $c->cards)->sortBy('id'); @endphp
{{-- 工具列 --}}
@if($personalMode ?? false)

個人看板

@else

工作看板

@endif @if(($isAdmin ?? false) && !($personalMode ?? false)) @endif
@if(!($personalMode ?? false))
@endif
{{-- 統計 + 新增卡片按鈕 --}}
@if(!($personalMode ?? false))
全部 {{ $columns->sum(fn($c) => $c->cards->count()) }} 完成度 100% {{ $columns->sum(fn($c) => $c->cards->where('done_ratio', 100)->count()) }} 今日異動 {{ $columns->sum(fn($c) => $c->cards->filter(fn($card) => $card->updated_at?->isToday())->count()) }}
@else
@endif
{{-- 今日工時統計(依分類) --}} @php $keywords = ['保固', '維護', '進行']; $todayCards = $columns->flatMap(fn($c) => $c->cards)->filter(fn($c) => $c->updated_at?->isToday() && $c->work_hours > 0); $catHours = $todayCards->groupBy(fn($c) => $c->category?->name ?? '')->filter(function($cards, $name) use ($keywords) { foreach ($keywords as $kw) { if (mb_strpos($name, $kw) !== false) return true; } return false; })->map(fn($cards, $name) => [ 'name' => $name, 'color' => $cards->first()->category?->color ?? '#6c757d', 'hours' => $cards->sum('work_hours'), ])->values(); @endphp @if($catHours->isNotEmpty())
今日工時: @foreach($catHours as $r) @php $h = $r['hours']; $display = ($h == floor($h)) ? (int)$h : $h; @endphp {{ $r['name'] }} {{ $display }}小時 @endforeach @php $total = $catHours->sum('hours'); $totalDisplay = ($total == floor($total)) ? (int)$total : $total; @endphp 合計 {{ $totalDisplay }}小時
@endif
{{-- Toast --}} {{-- 看板 --}}
@foreach($columns as $col)
{{ $col->name }}
{{ $col->cards->count() }}
@foreach($col->cards as $card) @php $priClass = match($card->priority) { 'urgent' => 'pri-urgent', 'high' => 'pri-high', 'low' => 'pri-low', default => 'pri-normal' }; $priBadge = match($card->priority) { 'urgent' => ['cls' => 'bg-danger', 'txt' => '緊急'], 'high' => ['cls' => 'bg-warning text-dark', 'txt' => '高'], 'low' => ['cls' => 'bg-secondary', 'txt' => '低'], default => ['cls' => 'bg-info bg-opacity-75', 'txt' => '一般'], }; $overdue = $card->due_date && $card->due_date->isPast() && $card->done_ratio < 100; @endphp @php $assigneeIds = $card->assignees->pluck('id')->join(','); @endphp
#{{ $card->id }} @if($card->parent) #{{ $card->parent_id }} @endif @if($card->category) {{ $card->category->name }} @endif @if($card->project) {{ $card->project->name }} @endif
{{ $priBadge['txt'] }}
{{ Str::limit($card->title, 60) }}
@php $subtaskTotal = $card->subtasks->count(); $subtaskDone = $card->subtasks->where('is_done', true)->count(); $childTotal = $card->children->count(); $childDone = $card->children->where('done_ratio', 100)->count(); $soon = $card->due_date && !$overdue && $card->due_date->diffInDays(now()) <= 3 && $card->done_ratio < 100; @endphp @if($card->done_ratio > 0 || $subtaskTotal > 0 || $childTotal > 0)
@if($card->done_ratio > 0)
@endif @if($subtaskTotal > 0)
@endif @if($childTotal > 0)
@endif
@endif
@php $assigneeNames = $card->assignees->pluck('name')->join('、') @endphp {{ $assigneeNames ?: '未指派' }} @if($subtaskTotal > 0) {{ $subtaskDone }}/{{ $subtaskTotal }} @endif @if($childTotal > 0) {{ $childDone }}/{{ $childTotal }} @endif @if($card->work_hours) {{ $card->work_hours }}小時 @endif
@if($card->due_date) @php $dueCls = $overdue ? 'text-danger fw-bold' : ($soon ? 'fw-semibold' : 'text-muted'); $dueStyle = $soon && !$overdue ? 'color:#d97706;' : ''; @endphp {{ $card->due_date->format('Y-m-d') }} @endif
@endforeach
{{-- 泳道新增按鈕 --}}
@endforeach {{-- 新增欄位按鈕 --}}
{{-- ── Modals ─────────────────────────────────────────────── --}} {{-- 新增/編輯欄位 --}} {{-- 新增卡片 --}} {{-- 編輯卡片 --}} {{-- 管理分類 --}} {{-- 成員管理 --}} @if($isAdmin ?? false) @endif {{-- 通知設定 --}} {{-- ── 一鍵填寫 Modal ──────────────────────────────────────── --}} @endsection @push('scripts') @endpush