filter-review-by-month + scroll-review-detail-pane + show-help-by-role: review page card-month filter (default earliest month, tab counts and cap summaries follow the month, kept across tabs and views, bare ?id= picks the case month); detail pane in the review workbench is sticky and scrolls on its own; help page shows manager/admin sections only to non-employee roles
CI / build (push) Successful in 5m30s
CI / build (push) Successful in 5m30s
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
27c898005f
commit
62e41c5efe
@@ -161,7 +161,8 @@ If Playwright's browser download fails (CDN returns 403 on this machine), set `P
|
||||
- Return and reject use `ReasonDialog`; reject adds its `confirmStep`.
|
||||
- Rows can be ticked for batch approve. 「已勾選 N 筆」 and 「批次核准」 sit top-left, on the checkbox side.
|
||||
- `DataTable sticky={{ first, last }}` pins the checkbox + 申請人 columns left and the 操作 column right while scrolling sideways (view-only tabs pin 申請人 only).
|
||||
- `?view=detail`: the two-column workbench, where `?id=` selects a case. A bare `?id=` also opens it.
|
||||
- `?view=detail`: the two-column workbench, where `?id=` selects a case. A bare `?id=` also opens it. The right detail pane is sticky under the top bar and scrolls on its own (keyed by the case id, so it resets to the top).
|
||||
- Card-month filter `?month=YYYY-MM|all` (`reviewQueueMonths`; `listReviewQueue` / `reviewQueueCounts` take the month): default is the earliest month with cases in the current tab, or the case's month for a bare `?id=`; tab counts, list, batch approve and cap summaries follow the month; links keep it.
|
||||
- Narrow screens: a card list, plus `/department/review/:id`.
|
||||
- Above the lists, and in the detail: 部門額度試算 per (department, card month).
|
||||
- `reviewCapPreview` / `reviewCapPreviews` cover pending + approved + pending-settlement cases, using the settlement calculation (equal share, current adjustments) with the current params (read-only; creates a missing snapshot for started months).
|
||||
@@ -297,6 +298,7 @@ If Playwright's browser download fails (CDN returns 403 on this machine), set `P
|
||||
- Decorative images:
|
||||
- Cropped from the mockups by `scripts/crop-mockup-images.ts` into `public/images/`, shown via `Illustration`. To upgrade, replace the files with higher-resolution ones under the same names.
|
||||
- `public/images/` is excluded from the login redirect in `src/proxy.ts`. The Dockerfile copies `public/` into the runtime image (standalone output doesn't).
|
||||
- `/help` renders the 主管 / 管理端 sections only for users with any role besides employee (show-help-by-role).
|
||||
- Login, dev login and 403 pages use `AuthShell` (`src/components/auth-shell.tsx`).
|
||||
- Component tests: `// @vitest-environment jsdom` + Testing Library.
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
## 1. 服務
|
||||
|
||||
- [ ] 1.1 `listReviewQueue`、`reviewQueueCounts` 接受選填月份(D3);新增 `reviewQueueMonths`(目前分頁各月份筆數,由舊到新)。測試:9 月 5 筆、10 月 18 筆時的清單、筆數與月份列表;他部門案件不計入
|
||||
- [x] 1.1 `listReviewQueue`、`reviewQueueCounts` 接受選填月份(D3);新增 `reviewQueueMonths`(目前分頁各月份筆數,由舊到新)。測試:9 月 5 筆、10 月 18 筆時的清單、筆數與月份列表;他部門案件不計入
|
||||
|
||||
## 2. 頁面
|
||||
|
||||
- [ ] 2.1 `page.tsx` 解析 `?month=`(`YYYY-MM`/`all`),依 D2 決定預設(`?id=` 取案件月份、否則最早月份、沒有案件為全部);狀態分頁筆數、清單、試算摘要依所選月份
|
||||
- [ ] 2.2 「刷卡月份」膠囊選擇(全部+各月份與筆數,所選月份即使 0 筆也保留);狀態分頁、檢視切換與逐筆檢視的案件連結(`review-queue.tsx`、`review-table.tsx`)帶上 `month`
|
||||
- [ ] 2.3 CLAUDE.md「Review UI」補上月份選擇與預設規則
|
||||
- [x] 2.1 `page.tsx` 解析 `?month=`(`YYYY-MM`/`all`),依 D2 決定預設(`?id=` 取案件月份、否則最早月份、沒有案件為全部);狀態分頁筆數、清單、試算摘要依所選月份
|
||||
- [x] 2.2 「刷卡月份」膠囊選擇(全部+各月份與筆數,所選月份即使 0 筆也保留);狀態分頁、檢視切換與逐筆檢視的案件連結(`review-queue.tsx`、`review-table.tsx`)帶上 `month`
|
||||
- [x] 2.3 CLAUDE.md「Review UI」補上月份選擇與預設規則
|
||||
|
||||
## 3. 驗證
|
||||
|
||||
- [ ] 3.1 e2e:兩個月份的待審案件 → 預設最早月份、摘要只有該月、切換月份與「全部」的清單與筆數、切換分頁保留月份、批次核准只含所選月份、首頁 `?id=` 連結自動選月份
|
||||
- [ ] 3.2 `npm run lint`、`npm run format:check`、`npm run typecheck`、`npm test` 全過;`npm run test:e2e:prepare` 後 e2e 全過
|
||||
- [x] 3.1 e2e:兩個月份的待審案件 → 預設最早月份、摘要只有該月、切換月份與「全部」的清單與筆數、切換分頁保留月份、批次核准只含所選月份、首頁 `?id=` 連結自動選月份
|
||||
- [x] 3.2 `npm run lint`、`npm run format:check`、`npm run typecheck`、`npm test` 全過;`npm run test:e2e:prepare` 後 e2e 全過
|
||||
- [ ] 3.3 使用者授權後 push 部署;使用者驗收:正式站審核頁依月份檢視
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
## 1. 版面
|
||||
|
||||
- [ ] 1.1 逐筆檢視右側詳情 sticky、限制高度、獨立捲動(D1),系統時間提示列存在時的偏移
|
||||
- [ ] 1.2 切換案件時詳情捲回頂端(D2)
|
||||
- [x] 1.1 逐筆檢視右側詳情 sticky、限制高度、獨立捲動(D1),系統時間提示列存在時的偏移
|
||||
- [x] 1.2 切換案件時詳情捲回頂端(D2)
|
||||
|
||||
## 2. 驗證
|
||||
|
||||
- [ ] 2.1 e2e(1440×900,案件詳情夠長):捲動詳情時左側清單 `scrollY`/位置不變;捲動頁面時詳情仍在可視範圍;捲到底後點另一筆,詳情 `scrollTop` 為 0;條列檢視不受影響
|
||||
- [ ] 2.2 `npm run lint`、`npm run format:check`、`npm run typecheck`、`npm test` 全過;`npm run test:e2e:prepare` 後 e2e 全過
|
||||
- [x] 2.1 e2e(1440×900,案件詳情夠長):捲動詳情時左側清單 `scrollY`/位置不變;捲動頁面時詳情仍在可視範圍;捲到底後點另一筆,詳情 `scrollTop` 為 0;條列檢視不受影響
|
||||
- [x] 2.2 `npm run lint`、`npm run format:check`、`npm run typecheck`、`npm test` 全過;`npm run test:e2e:prepare` 後 e2e 全過
|
||||
- [ ] 2.3 使用者授權後 push 部署;使用者驗收
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
## 1. 頁面
|
||||
|
||||
- [ ] 1.1 `help/page.tsx` 依 D1 判斷角色,「部門月結(主管)」「核定與發放(管理端)」「更正與發放失敗(管理端)」只對主管、管理者、系統管理員輸出(D2)
|
||||
- [x] 1.1 `help/page.tsx` 依 D1 判斷角色,「部門月結(主管)」「核定與發放(管理端)」「更正與發放失敗(管理端)」只對主管、管理者、系統管理員輸出(D2)
|
||||
|
||||
## 2. 驗證
|
||||
|
||||
- [ ] 2.1 e2e:員工開啟使用說明看得到申請流程、補助怎麼算、截止日,看不到三個主管端/管理端段落;主管、管理者、系統管理員看得到全部
|
||||
- [ ] 2.2 `npm run lint`、`npm run format:check`、`npm run typecheck`、`npm test` 全過;`npm run test:e2e:prepare` 後 e2e 全過
|
||||
- [x] 2.1 e2e:員工開啟使用說明看得到申請流程、補助怎麼算、截止日,看不到三個主管端/管理端段落;主管、管理者、系統管理員看得到全部
|
||||
- [x] 2.2 `npm run lint`、`npm run format:check`、`npm run typecheck`、`npm test` 全過;`npm run test:e2e:prepare` 後 e2e 全過
|
||||
- [ ] 2.3 使用者授權後 push 部署;使用者驗收:以員工與主管帳號分別開啟使用說明
|
||||
|
||||
@@ -2,12 +2,14 @@ import Link from "next/link";
|
||||
import { PageHeader } from "@/components/page-header";
|
||||
import { pillClass } from "@/components/ui/button";
|
||||
import { EmptyState } from "@/components/ui/empty-state";
|
||||
import { formatMonth } from "@/lib/format";
|
||||
import {
|
||||
REVIEW_FILTERS,
|
||||
listReviewQueue,
|
||||
parseReviewFilter,
|
||||
reviewCapPreviews,
|
||||
reviewQueueCounts,
|
||||
reviewQueueMonths,
|
||||
returnBlockedReason,
|
||||
type ReviewCapPreview,
|
||||
type ReviewFilter,
|
||||
@@ -33,6 +35,8 @@ type ReviewView = "list" | "detail";
|
||||
|
||||
const VIEW_LABELS: Record<ReviewView, string> = { list: "條列檢視", detail: "逐筆檢視" };
|
||||
|
||||
const MONTH_PATTERN = /^\d{4}-(0[1-9]|1[0-2])$/;
|
||||
|
||||
/** 案件的部門額度試算(月結提交後為最終補助);不在試算範圍或沒有快照時為 null。 */
|
||||
function subsidyFor(previews: readonly ReviewCapPreview[], row: ReviewQueueRow) {
|
||||
const preview = previews.find(
|
||||
@@ -54,7 +58,7 @@ function subsidyFor(previews: readonly ReviewCapPreview[], row: ReviewQueueRow)
|
||||
export default async function DepartmentReviewPage({
|
||||
searchParams,
|
||||
}: {
|
||||
searchParams: Promise<{ status?: string; id?: string; view?: string }>;
|
||||
searchParams: Promise<{ status?: string; id?: string; view?: string; month?: string }>;
|
||||
}) {
|
||||
const user = await requireRouteAccess("/department/review");
|
||||
const params = await searchParams;
|
||||
@@ -64,8 +68,27 @@ export default async function DepartmentReviewPage({
|
||||
params.view === "detail" || (params.view === undefined && params.id) ? "detail" : "list";
|
||||
const db = getDb();
|
||||
const timeZone = getEnv().TZ_APP;
|
||||
const rows = listReviewQueue(db, user, filter);
|
||||
const counts = reviewQueueCounts(db, user);
|
||||
const linkedId = /^\d+$/.test(params.id ?? "") ? Number(params.id) : null;
|
||||
const linked = linkedId === null ? null : loadReviewable(user, linkedId);
|
||||
|
||||
// 刷卡月份(filter-review-by-month):`?month=YYYY-MM`/`all`;沒有時,只帶 `?id=` 的連結取該案件的月份,
|
||||
// 否則取目前分頁最早有案件的月份,沒有案件時為全部。
|
||||
const monthsInTab = reviewQueueMonths(db, user, filter);
|
||||
const month: string | null =
|
||||
params.month === "all"
|
||||
? null
|
||||
: params.month && MONTH_PATTERN.test(params.month)
|
||||
? params.month
|
||||
: (linked?.app.applicationMonth ?? monthsInTab[0]?.month ?? null);
|
||||
const monthKey = month ?? "all";
|
||||
const monthOptions =
|
||||
month && !monthsInTab.some((m) => m.month === month)
|
||||
? [...monthsInTab, { month, count: 0 }].sort((a, b) => a.month.localeCompare(b.month))
|
||||
: monthsInTab;
|
||||
const tabTotal = monthsInTab.reduce((sum, m) => sum + m.count, 0);
|
||||
|
||||
const rows = listReviewQueue(db, user, filter, month);
|
||||
const counts = reviewQueueCounts(db, user, month);
|
||||
const audit = await auditContextFor(user);
|
||||
const previews = reviewCapPreviews(db, audit, rows, timeZone);
|
||||
// 申請截止後不可退回補件:同一刷卡月份只算一次。
|
||||
@@ -81,10 +104,10 @@ export default async function DepartmentReviewPage({
|
||||
subsidy: subsidyFor(previews, row),
|
||||
returnBlocked: returnBlocked(row.applicationMonth),
|
||||
}));
|
||||
const selectedId = view === "detail" && /^\d+$/.test(params.id ?? "") ? Number(params.id) : null;
|
||||
const selected = selectedId === null ? null : loadReviewable(user, selectedId);
|
||||
const href = (next: { status?: ReviewFilter; view?: ReviewView }) =>
|
||||
`/department/review?view=${next.view ?? view}&status=${next.status ?? filter}`;
|
||||
const selectedId = view === "detail" ? linkedId : null;
|
||||
const selected = selectedId === null ? null : linked;
|
||||
const href = (next: { status?: ReviewFilter; view?: ReviewView; month?: string }) =>
|
||||
`/department/review?view=${next.view ?? view}&status=${next.status ?? filter}&month=${next.month ?? monthKey}`;
|
||||
|
||||
const summaries =
|
||||
previews.length > 0 ? (
|
||||
@@ -130,6 +153,31 @@ export default async function DepartmentReviewPage({
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
<nav
|
||||
aria-label="刷卡月份"
|
||||
className="-mt-2 flex flex-wrap items-center gap-2"
|
||||
data-testid="month-filter"
|
||||
>
|
||||
<span className="text-sm text-muted">刷卡月份</span>
|
||||
<Link
|
||||
href={href({ month: "all" })}
|
||||
aria-current={month === null ? "page" : undefined}
|
||||
className={pillClass(month === null)}
|
||||
>
|
||||
全部({tabTotal})
|
||||
</Link>
|
||||
{monthOptions.map((m) => (
|
||||
<Link
|
||||
key={m.month}
|
||||
href={href({ month: m.month })}
|
||||
aria-current={m.month === month ? "page" : undefined}
|
||||
className={pillClass(m.month === month)}
|
||||
>
|
||||
{formatMonth(m.month)}({m.count})
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
|
||||
{view === "list" ? (
|
||||
<>
|
||||
{summaries}
|
||||
@@ -140,6 +188,7 @@ export default async function DepartmentReviewPage({
|
||||
reviewable={filter === "pending"}
|
||||
timeZone={timeZone}
|
||||
filter={filter}
|
||||
month={monthKey}
|
||||
empty={empty}
|
||||
/>
|
||||
</section>
|
||||
@@ -147,6 +196,7 @@ export default async function DepartmentReviewPage({
|
||||
<ReviewQueue
|
||||
items={items}
|
||||
filter={filter}
|
||||
month={monthKey}
|
||||
selectedId={null}
|
||||
batch={filter === "pending"}
|
||||
link="page"
|
||||
@@ -161,12 +211,19 @@ export default async function DepartmentReviewPage({
|
||||
<ReviewQueue
|
||||
items={items}
|
||||
filter={filter}
|
||||
month={monthKey}
|
||||
selectedId={selectedId}
|
||||
batch={filter === "pending"}
|
||||
empty={empty}
|
||||
/>
|
||||
</section>
|
||||
<section aria-label="案件詳情" className="hidden min-w-0 lg:block">
|
||||
{/* 詳情固定在頂部列下方、在區塊內獨立捲動;換案件時以 key 重建,捲回頂端(scroll-review-detail-pane)。 */}
|
||||
<section
|
||||
key={selectedId ?? "none"}
|
||||
aria-label="案件詳情"
|
||||
data-testid="detail-pane"
|
||||
className="hidden min-w-0 self-start overscroll-contain lg:sticky lg:top-[calc(var(--spacing-topbar)+1rem)] lg:block lg:max-h-[calc(100dvh-var(--spacing-topbar)-2rem)] lg:overflow-y-auto"
|
||||
>
|
||||
{selected ? (
|
||||
<ReviewDetail data={selected} preview={await loadCapPreview(user, selected.app)} />
|
||||
) : (
|
||||
|
||||
@@ -37,6 +37,7 @@ type BatchResult = Awaited<ReturnType<typeof batchApproveAction>>;
|
||||
export function ReviewQueue({
|
||||
items,
|
||||
filter,
|
||||
month,
|
||||
selectedId,
|
||||
batch,
|
||||
link = "pane",
|
||||
@@ -44,6 +45,8 @@ export function ReviewQueue({
|
||||
}: {
|
||||
items: QueueItem[];
|
||||
filter: string;
|
||||
/** 目前的刷卡月份選擇(`YYYY-MM` 或 `all`),逐筆檢視的連結帶上以保留選擇。 */
|
||||
month: string;
|
||||
selectedId: number | null;
|
||||
batch: boolean;
|
||||
link?: "pane" | "page";
|
||||
@@ -153,7 +156,7 @@ export function ReviewQueue({
|
||||
)}
|
||||
{link === "pane" && (
|
||||
<Link
|
||||
href={`/department/review?view=detail&status=${filter}&id=${item.id}`}
|
||||
href={`/department/review?view=detail&status=${filter}&month=${month}&id=${item.id}`}
|
||||
scroll={false}
|
||||
className={`${linkClass} hidden lg:block`}
|
||||
aria-current={item.id === selectedId ? "true" : undefined}
|
||||
|
||||
@@ -75,6 +75,7 @@ export function ReviewTable({
|
||||
reviewable,
|
||||
timeZone,
|
||||
filter,
|
||||
month,
|
||||
empty,
|
||||
}: {
|
||||
items: ReviewTableItem[];
|
||||
@@ -82,6 +83,8 @@ export function ReviewTable({
|
||||
reviewable: boolean;
|
||||
timeZone: string;
|
||||
filter: string;
|
||||
/** 目前的刷卡月份選擇(`YYYY-MM` 或 `all`),逐筆檢視的連結帶上以保留選擇。 */
|
||||
month: string;
|
||||
/** 沒有案件時的空狀態;清單在元件內切換,批次核准把清單清空後結果訊息仍保留。 */
|
||||
empty: React.ReactNode;
|
||||
}) {
|
||||
@@ -275,7 +278,7 @@ export function ReviewTable({
|
||||
expansion={{
|
||||
isExpanded: (r) => r.id === expanded,
|
||||
onToggle: (r) => setExpanded((current) => (current === r.id ? null : r.id)),
|
||||
render: (r) => <RowDetail item={r} filter={filter} />,
|
||||
render: (r) => <RowDetail item={r} filter={filter} month={month} />,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
@@ -285,7 +288,15 @@ export function ReviewTable({
|
||||
}
|
||||
|
||||
/** 展開內容:完整用途、成果產出、原幣金額、最近一次退回意見與附件預覽。 */
|
||||
function RowDetail({ item, filter }: { item: ReviewTableItem; filter: string }) {
|
||||
function RowDetail({
|
||||
item,
|
||||
filter,
|
||||
month,
|
||||
}: {
|
||||
item: ReviewTableItem;
|
||||
filter: string;
|
||||
month: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className="grid gap-4 rounded-control bg-surface p-4 md:grid-cols-2"
|
||||
@@ -321,7 +332,7 @@ function RowDetail({ item, filter }: { item: ReviewTableItem; filter: string })
|
||||
/>
|
||||
))}
|
||||
<Link
|
||||
href={`/department/review?view=detail&status=${filter}&id=${item.id}`}
|
||||
href={`/department/review?view=detail&status=${filter}&month=${month}&id=${item.id}`}
|
||||
className={buttonClass("ghost", "sm")}
|
||||
>
|
||||
開啟完整詳情
|
||||
|
||||
+76
-69
@@ -17,7 +17,9 @@ const STEPS = [
|
||||
] as const;
|
||||
|
||||
export default async function HelpPage() {
|
||||
await requireRouteAccess("/help");
|
||||
const user = await requireRouteAccess("/help");
|
||||
// 一般員工(只有員工角色)只看申請相關段落;有主管、管理者或系統管理員角色看全部。
|
||||
const showStaffSections = user.roles.some((role) => role !== "employee");
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<PageHeader title="使用說明" description="從申請到發放的流程與重要規則。" />
|
||||
@@ -76,74 +78,79 @@ export default async function HelpPage() {
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
<Card title="部門月結(主管)">
|
||||
<ul className="list-disc space-y-2 pl-5 text-ink/90">
|
||||
<li>
|
||||
員工申請截止後,當月「已通過」的申請會自動轉為「待月結」;截止後才核准的申請直接成為待月結。
|
||||
</li>
|
||||
<li>支付金額=同一人當月已通過申請的台幣金額合計(多筆加總)。</li>
|
||||
<li>個人上限=同一人當月每筆已通過申請台幣金額的 50%(不足 1 元捨去)加總。</li>
|
||||
<li>
|
||||
部門月上限=當月人數快照 ×
|
||||
部門類型每人額度。個人上限合計未超過月上限時,每人照個人上限發放。
|
||||
</li>
|
||||
<li>
|
||||
超過上限時,主管調整過的人照調整金額,其餘申請人平分剩下的額度;個人上限比平分額少的人只拿自己的個人上限,多出來的再由其他人平分。
|
||||
{REMAINDER_RULE_TEXT}重算結果一致。
|
||||
</li>
|
||||
<li>主管調整的個人可補助不能超過該員工的個人上限,調整金額合計不能超過月上限。</li>
|
||||
<li>
|
||||
提交前須沒有「待審核」與「待補件」的案件;申請截止後仍待補件的案件可在月結頁「逾期不核准」。
|
||||
截止前只能檢視試算,不能提交。
|
||||
</li>
|
||||
<li>
|
||||
提交時以最新資料與參數重新計算並保存參數快照,之後參數或人數變更不影響已提交的月結。超過主管提交截止仍可提交,但會標示「逾期提交」。
|
||||
</li>
|
||||
<li>
|
||||
提交後名單鎖定,主管與員工都不能再修改、重新計算或變更審核結果;如需更正,請聯絡管理端退回月結。
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
<Card title="核定與發放(管理端)">
|
||||
<ul className="list-disc space-y-2 pl-5 text-ink/90">
|
||||
<li>
|
||||
全公司月結頁依月份列出各部門的計算人數、月上限、最終補助、狀態與提交時間,並標示逾期未提交、逾期提交與缺人數快照。
|
||||
</li>
|
||||
<li>
|
||||
部長提交後,管理者檢視名單、參數快照與案件附件,執行「最終核定」或「退回月結」,兩者都需確認;退回必須填寫原因。
|
||||
</li>
|
||||
<li>
|
||||
退回後月結回到部長可編輯的狀態、案件回到待月結;原提交版本與退回紀錄都會保留,部長重新提交會產生新版本。已最終核定的月結不能退回。
|
||||
</li>
|
||||
<li>
|
||||
最終核定時,為最終補助大於 0 的申請人建立待發放紀錄:發放月份為刷卡月份後第 2 個月(例如
|
||||
10 月刷卡於 12 月發放),薪資名目固定「{PAY_ITEM}」。
|
||||
</li>
|
||||
<li>
|
||||
發放管理可匯出 Excel 或 CSV,欄位固定為:
|
||||
{PAYOUT_EXPORT_COLUMNS.map((c) => c.header).join("、")};補助金額為整數元數值。
|
||||
</li>
|
||||
<li>
|
||||
發放後勾選紀錄並「標記已發放」(確認視窗顯示筆數與金額);部門所有紀錄都已發放時月結變為已發放。已發放不可改回,如有錯誤需透過更正流程處理。
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
<Card title="更正與發放失敗(管理端)">
|
||||
<ul className="list-disc space-y-2 pl-5 text-ink/90">
|
||||
<li>
|
||||
已最終核定或已發放的月結不重算、不覆寫,事後變動都在月結詳情的「更正」以更正紀錄處理,每筆都必填原因並留在操作紀錄。申請人可在案件詳情看到更正與原因。
|
||||
</li>
|
||||
<li>
|
||||
補發:金額為正整數,排入本月起任一發放月份;補發後部門更正後合計不可超過該月結的月上限。未發放前可取消(需填原因)。
|
||||
</li>
|
||||
<li>
|
||||
撤銷補助:只限尚未發放;撤銷後該人的待發放項目變為已撤銷,撤銷不可取消。已發放的補助不可撤銷,也沒有追回。
|
||||
</li>
|
||||
<li>
|
||||
發放失敗:在發放管理對待發放項目「標記發放失敗」並填原因,該筆不計入合計;再按「改期」同額排入下一個發放月份(不可任選)。改期項目發放後,月結才會變為已發放。
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
{/* 主管端與管理端段落只對主管、管理者、系統管理員輸出(show-help-by-role)。 */}
|
||||
{showStaffSections && (
|
||||
<>
|
||||
<Card title="部門月結(主管)">
|
||||
<ul className="list-disc space-y-2 pl-5 text-ink/90">
|
||||
<li>
|
||||
員工申請截止後,當月「已通過」的申請會自動轉為「待月結」;截止後才核准的申請直接成為待月結。
|
||||
</li>
|
||||
<li>支付金額=同一人當月已通過申請的台幣金額合計(多筆加總)。</li>
|
||||
<li>個人上限=同一人當月每筆已通過申請台幣金額的 50%(不足 1 元捨去)加總。</li>
|
||||
<li>
|
||||
部門月上限=當月人數快照 ×
|
||||
部門類型每人額度。個人上限合計未超過月上限時,每人照個人上限發放。
|
||||
</li>
|
||||
<li>
|
||||
超過上限時,主管調整過的人照調整金額,其餘申請人平分剩下的額度;個人上限比平分額少的人只拿自己的個人上限,多出來的再由其他人平分。
|
||||
{REMAINDER_RULE_TEXT}重算結果一致。
|
||||
</li>
|
||||
<li>主管調整的個人可補助不能超過該員工的個人上限,調整金額合計不能超過月上限。</li>
|
||||
<li>
|
||||
提交前須沒有「待審核」與「待補件」的案件;申請截止後仍待補件的案件可在月結頁「逾期不核准」。
|
||||
截止前只能檢視試算,不能提交。
|
||||
</li>
|
||||
<li>
|
||||
提交時以最新資料與參數重新計算並保存參數快照,之後參數或人數變更不影響已提交的月結。超過主管提交截止仍可提交,但會標示「逾期提交」。
|
||||
</li>
|
||||
<li>
|
||||
提交後名單鎖定,主管與員工都不能再修改、重新計算或變更審核結果;如需更正,請聯絡管理端退回月結。
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
<Card title="核定與發放(管理端)">
|
||||
<ul className="list-disc space-y-2 pl-5 text-ink/90">
|
||||
<li>
|
||||
全公司月結頁依月份列出各部門的計算人數、月上限、最終補助、狀態與提交時間,並標示逾期未提交、逾期提交與缺人數快照。
|
||||
</li>
|
||||
<li>
|
||||
部長提交後,管理者檢視名單、參數快照與案件附件,執行「最終核定」或「退回月結」,兩者都需確認;退回必須填寫原因。
|
||||
</li>
|
||||
<li>
|
||||
退回後月結回到部長可編輯的狀態、案件回到待月結;原提交版本與退回紀錄都會保留,部長重新提交會產生新版本。已最終核定的月結不能退回。
|
||||
</li>
|
||||
<li>
|
||||
最終核定時,為最終補助大於 0 的申請人建立待發放紀錄:發放月份為刷卡月份後第 2
|
||||
個月(例如 10 月刷卡於 12 月發放),薪資名目固定「{PAY_ITEM}」。
|
||||
</li>
|
||||
<li>
|
||||
發放管理可匯出 Excel 或 CSV,欄位固定為:
|
||||
{PAYOUT_EXPORT_COLUMNS.map((c) => c.header).join("、")};補助金額為整數元數值。
|
||||
</li>
|
||||
<li>
|
||||
發放後勾選紀錄並「標記已發放」(確認視窗顯示筆數與金額);部門所有紀錄都已發放時月結變為已發放。已發放不可改回,如有錯誤需透過更正流程處理。
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
<Card title="更正與發放失敗(管理端)">
|
||||
<ul className="list-disc space-y-2 pl-5 text-ink/90">
|
||||
<li>
|
||||
已最終核定或已發放的月結不重算、不覆寫,事後變動都在月結詳情的「更正」以更正紀錄處理,每筆都必填原因並留在操作紀錄。申請人可在案件詳情看到更正與原因。
|
||||
</li>
|
||||
<li>
|
||||
補發:金額為正整數,排入本月起任一發放月份;補發後部門更正後合計不可超過該月結的月上限。未發放前可取消(需填原因)。
|
||||
</li>
|
||||
<li>
|
||||
撤銷補助:只限尚未發放;撤銷後該人的待發放項目變為已撤銷,撤銷不可取消。已發放的補助不可撤銷,也沒有追回。
|
||||
</li>
|
||||
<li>
|
||||
發放失敗:在發放管理對待發放項目「標記發放失敗」並填原因,該筆不計入合計;再按「改期」同額排入下一個發放月份(不可任選)。改期項目發放後,月結才會變為已發放。
|
||||
</li>
|
||||
</ul>
|
||||
</Card>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import {
|
||||
reviewCapPreview,
|
||||
reviewCapPreviews,
|
||||
reviewQueueCounts,
|
||||
reviewQueueMonths,
|
||||
returnBlockedReason,
|
||||
} from "./review";
|
||||
import { resolveReviewers, reviewDecision } from "./reviewer";
|
||||
@@ -497,6 +498,35 @@ describe("部門額度試算", () => {
|
||||
.run();
|
||||
}
|
||||
|
||||
it("依刷卡月份:清單、分頁筆數與各月份筆數;他部門不計入", () => {
|
||||
const sep = [
|
||||
caseIn(f.applicant, 100, "pending_review", "2026-09"),
|
||||
caseIn(f.colleague, 200, "pending_review", "2026-09"),
|
||||
];
|
||||
const oct = caseIn(f.applicant, 300, "pending_review");
|
||||
caseIn(f.colleague, 400, "approved");
|
||||
caseIn(f.rndManager, 500, "pending_review", "2026-09");
|
||||
expect(reviewQueueMonths(t.db, f.designManager, "pending")).toEqual([
|
||||
{ month: "2026-09", count: 2 },
|
||||
{ month: "2026-10", count: 1 },
|
||||
]);
|
||||
expect(listReviewQueue(t.db, f.designManager, "pending", "2026-09").map((r) => r.id)).toEqual(
|
||||
sep,
|
||||
);
|
||||
expect(listReviewQueue(t.db, f.designManager, "pending", "2026-10").map((r) => r.id)).toEqual([
|
||||
oct,
|
||||
]);
|
||||
expect(listReviewQueue(t.db, f.designManager, "pending")).toHaveLength(3);
|
||||
expect(reviewQueueCounts(t.db, f.designManager, "2026-10")).toMatchObject({
|
||||
pending: 1,
|
||||
approved: 1,
|
||||
});
|
||||
expect(reviewQueueCounts(t.db, f.designManager, "2026-09")).toMatchObject({
|
||||
pending: 2,
|
||||
approved: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it("未超出:摘要的已核准、待審與合計以每筆 50% 計算;每筆試算等於該筆 50%,加總等於合計", () => {
|
||||
snapshot(4);
|
||||
const approved = caseIn(f.applicant, 901, "approved");
|
||||
|
||||
@@ -97,11 +97,13 @@ export interface ReviewQueueRow {
|
||||
* 審核清單:只有操作者主管的部門(與 `canReview` 同一份資料),不含其他部門,
|
||||
* 也不含部門未設定主管的案件(等待指派,見 `listUnassignedReviewDepartments`)。
|
||||
* 待審核依送出時間由舊到新(先送先審),其餘依最後更新由新到舊。
|
||||
* `month`(`YYYY-MM`)有值時只列該刷卡月份(filter-review-by-month)。
|
||||
*/
|
||||
export function listReviewQueue(
|
||||
db: Db,
|
||||
actor: { id: number; roles: readonly Role[] },
|
||||
filter: ReviewFilter,
|
||||
month?: string | null,
|
||||
): ReviewQueueRow[] {
|
||||
const departmentIds = managedDepartmentIds(db, actor);
|
||||
if (departmentIds.length === 0) return [];
|
||||
@@ -115,6 +117,7 @@ export function listReviewQueue(
|
||||
inArray(applications.departmentId, departmentIds),
|
||||
eq(applications.status, status),
|
||||
isNull(applications.deletedAt),
|
||||
month ? eq(applications.applicationMonth, month) : undefined,
|
||||
),
|
||||
)
|
||||
.orderBy(
|
||||
@@ -391,6 +394,7 @@ export function previewAmountFor(
|
||||
export function reviewQueueCounts(
|
||||
db: Db,
|
||||
actor: { id: number; roles: readonly Role[] },
|
||||
month?: string | null,
|
||||
): Record<ReviewFilter, number> {
|
||||
const counts = { pending: 0, needs_revision: 0, approved: 0, rejected: 0 };
|
||||
const departmentIds = managedDepartmentIds(db, actor);
|
||||
@@ -398,7 +402,13 @@ export function reviewQueueCounts(
|
||||
const rows = db
|
||||
.select({ status: applications.status, n: count() })
|
||||
.from(applications)
|
||||
.where(and(inArray(applications.departmentId, departmentIds), isNull(applications.deletedAt)))
|
||||
.where(
|
||||
and(
|
||||
inArray(applications.departmentId, departmentIds),
|
||||
isNull(applications.deletedAt),
|
||||
month ? eq(applications.applicationMonth, month) : undefined,
|
||||
),
|
||||
)
|
||||
.groupBy(applications.status)
|
||||
.all();
|
||||
for (const key of Object.keys(REVIEW_FILTERS) as ReviewFilter[]) {
|
||||
@@ -407,6 +417,33 @@ export function reviewQueueCounts(
|
||||
return counts;
|
||||
}
|
||||
|
||||
/**
|
||||
* 目前狀態分頁中各刷卡月份的筆數(由舊到新),供部門審核頁的月份選擇與預設月份(filter-review-by-month)。
|
||||
*/
|
||||
export function reviewQueueMonths(
|
||||
db: Db,
|
||||
actor: { id: number; roles: readonly Role[] },
|
||||
filter: ReviewFilter,
|
||||
): { month: string; count: number }[] {
|
||||
const departmentIds = managedDepartmentIds(db, actor);
|
||||
if (departmentIds.length === 0) return [];
|
||||
return db
|
||||
.select({ month: applications.applicationMonth, count: count() })
|
||||
.from(applications)
|
||||
.where(
|
||||
and(
|
||||
inArray(applications.departmentId, departmentIds),
|
||||
eq(applications.status, REVIEW_FILTERS[filter].status),
|
||||
isNull(applications.deletedAt),
|
||||
isNotNull(applications.applicationMonth),
|
||||
),
|
||||
)
|
||||
.groupBy(applications.applicationMonth)
|
||||
.orderBy(asc(applications.applicationMonth))
|
||||
.all()
|
||||
.map((r) => ({ month: r.month!, count: r.count }));
|
||||
}
|
||||
|
||||
/** 有待審案件、卻沒有主管可審的部門(部門管理頁提示系統管理員指派主管)。 */
|
||||
export function listUnassignedReviewDepartments(
|
||||
db: Db,
|
||||
|
||||
@@ -227,7 +227,7 @@ test("申請截止後只能核准或不核准:條列與逐筆檢視都沒有
|
||||
cardDate: `${monthsAgo(2)}-05`,
|
||||
});
|
||||
const current = insertPendingApplication(team.member("截止乙"));
|
||||
await loginAs(page, team.managerNo!, "/department/review");
|
||||
await loginAs(page, team.managerNo!, "/department/review?month=all");
|
||||
|
||||
await expect(row(page, late).getByRole("button", { name: /^核准 / })).toBeVisible();
|
||||
await expect(row(page, late).getByRole("button", { name: /^不核准 / })).toBeVisible();
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
import { expect, test, type Page } from "@playwright/test";
|
||||
import { applicationStatus, createTeam, insertPendingApplication, monthsAgo } from "./db";
|
||||
import { DEMO, loginAs } from "./helpers";
|
||||
|
||||
// 第四批:部門審核依刷卡月份檢視(filter-review-by-month)、逐筆檢視的詳情獨立捲動
|
||||
// (scroll-review-detail-pane)、使用說明依角色顯示(show-help-by-role)。
|
||||
|
||||
const display = (month: string) => month.replace("-", "/");
|
||||
const tab = (page: Page, label: RegExp) =>
|
||||
page.getByRole("navigation", { name: "審核狀態" }).getByRole("link", { name: label });
|
||||
const monthPill = (page: Page, label: RegExp) =>
|
||||
page.getByRole("navigation", { name: "刷卡月份" }).getByRole("link", { name: label });
|
||||
|
||||
/** 上個月 2 筆、本月 3 筆待審核,另有本月 1 筆已通過。 */
|
||||
function twoMonthTeam() {
|
||||
const team = createTeam({ managerName: "月份主管" });
|
||||
const prev = monthsAgo(1);
|
||||
const older = [1, 2].map((i) =>
|
||||
insertPendingApplication(team.member(`上月${i}`), { cardDate: `${prev}-0${i}` }),
|
||||
);
|
||||
const current = [1, 2, 3].map((i) => insertPendingApplication(team.member(`本月${i}`)));
|
||||
insertPendingApplication(team.member("本月已通過"), { status: "approved" });
|
||||
return { team, prev, older, current };
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await page.setViewportSize({ width: 1440, height: 900 });
|
||||
});
|
||||
|
||||
test("預設最早月份;切換月份與全部;分頁筆數跟著月份;切換分頁保留月份", async ({ page }) => {
|
||||
const { team, prev, older, current } = twoMonthTeam();
|
||||
const now = monthsAgo(0);
|
||||
await loginAs(page, team.managerNo!, "/department/review");
|
||||
|
||||
await expect(monthPill(page, new RegExp(`^${display(prev)}(2)$`))).toHaveAttribute(
|
||||
"aria-current",
|
||||
"page",
|
||||
);
|
||||
await expect(monthPill(page, /^全部(5)$/)).toBeVisible();
|
||||
await expect(monthPill(page, new RegExp(`^${display(now)}(3)$`))).toBeVisible();
|
||||
await expect(tab(page, /^待審核(2)$/)).toBeVisible();
|
||||
for (const id of older) await expect(page.getByTestId(`review-row-${id}`)).toBeVisible();
|
||||
await expect(page.getByTestId(`review-row-${current[0]}`)).toHaveCount(0);
|
||||
await expect(page.getByTestId("cap-summary")).toHaveCount(1);
|
||||
await expect(page.getByTestId("cap-summary")).toHaveAttribute("data-month", prev);
|
||||
|
||||
await monthPill(page, new RegExp(`^${display(now)}`)).click();
|
||||
await expect(tab(page, /^待審核(3)$/)).toBeVisible();
|
||||
await expect(tab(page, /^已通過(1)$/)).toBeVisible();
|
||||
for (const id of current) await expect(page.getByTestId(`review-row-${id}`)).toBeVisible();
|
||||
await expect(page.getByTestId(`review-row-${older[0]}`)).toHaveCount(0);
|
||||
|
||||
await tab(page, /^已通過/).click();
|
||||
await expect(page).toHaveURL(new RegExp(`status=approved&month=${now}`));
|
||||
await expect(monthPill(page, new RegExp(`^${display(now)}`))).toHaveAttribute(
|
||||
"aria-current",
|
||||
"page",
|
||||
);
|
||||
|
||||
await page.goto("/department/review?month=all");
|
||||
await expect(tab(page, /^待審核(5)$/)).toBeVisible();
|
||||
await expect(page.getByTestId("cap-summary")).toHaveCount(2);
|
||||
});
|
||||
|
||||
test("批次核准只含所選月份;首頁 ?id= 連結自動選該案件的月份", async ({ page }) => {
|
||||
const { team, prev, older, current } = twoMonthTeam();
|
||||
await loginAs(page, team.managerNo!, `/department/review?month=${prev}`);
|
||||
const table = page.getByTestId("review-table");
|
||||
await expect(table.getByRole("checkbox", { name: /選取/ })).toHaveCount(2);
|
||||
await table.getByRole("checkbox", { name: /選取/ }).first().check();
|
||||
await table.getByRole("checkbox", { name: /選取/ }).nth(1).check();
|
||||
await page.getByRole("button", { name: "批次核准" }).click();
|
||||
await expect(page.getByText("已核准 2 筆")).toBeVisible();
|
||||
expect(older.map(applicationStatus)).toEqual(["approved", "approved"]);
|
||||
expect(current.map(applicationStatus)).toEqual([
|
||||
"pending_review",
|
||||
"pending_review",
|
||||
"pending_review",
|
||||
]);
|
||||
|
||||
await page.goto(`/department/review?id=${current[1]}`);
|
||||
await expect(monthPill(page, new RegExp(`^${display(monthsAgo(0))}`))).toHaveAttribute(
|
||||
"aria-current",
|
||||
"page",
|
||||
);
|
||||
await expect(page.getByTestId(`queue-item-${current[1]}`)).toBeVisible();
|
||||
});
|
||||
|
||||
test("逐筆檢視:右側詳情獨立捲動,捲動頁面時詳情仍在畫面中;換案件後回到頂端", async ({ page }) => {
|
||||
const { team, current } = twoMonthTeam();
|
||||
await page.setViewportSize({ width: 1440, height: 700 });
|
||||
await loginAs(
|
||||
page,
|
||||
team.managerNo!,
|
||||
`/department/review?view=detail&status=pending&month=all&id=${current[0]}`,
|
||||
);
|
||||
const pane = page.getByTestId("detail-pane");
|
||||
await expect(pane.getByTestId("review-detail")).toBeVisible();
|
||||
const scrollable = await pane.evaluate((el) => el.scrollHeight > el.clientHeight);
|
||||
expect(scrollable).toBe(true);
|
||||
|
||||
await pane.evaluate((el) => el.scrollTo({ top: el.scrollHeight }));
|
||||
expect(await page.evaluate(() => window.scrollY)).toBe(0); // 只有詳情捲動
|
||||
expect(await pane.evaluate((el) => el.scrollTop)).toBeGreaterThan(0);
|
||||
|
||||
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight));
|
||||
const box = (await pane.boundingBox())!;
|
||||
expect(box.y).toBeGreaterThanOrEqual(0);
|
||||
expect(box.y).toBeLessThan(200); // 仍貼在頂部列下方
|
||||
|
||||
await page.getByTestId(`queue-item-${current[1]}`).getByRole("link").first().click();
|
||||
await expect(page).toHaveURL(new RegExp(`id=${current[1]}`));
|
||||
await expect(pane.getByTestId("review-detail")).toBeVisible();
|
||||
expect(await pane.evaluate((el) => el.scrollTop)).toBe(0);
|
||||
});
|
||||
|
||||
test("使用說明:員工看不到主管端與管理端段落,主管、管理者、系統管理員看得到", async ({ page }) => {
|
||||
const staffSections = ["部門月結(主管)", "核定與發放(管理端)", "更正與發放失敗(管理端)"];
|
||||
await loginAs(page, DEMO.employee, "/help");
|
||||
await expect(page.getByRole("heading", { name: "補助怎麼算" })).toBeVisible();
|
||||
await expect(page.getByRole("heading", { name: "截止日" })).toBeVisible();
|
||||
for (const title of staffSections) {
|
||||
await expect(page.getByRole("heading", { name: title })).toHaveCount(0);
|
||||
}
|
||||
// 管理端段落的內容不送到員工的瀏覽器(含 RSC 資料)。
|
||||
expect(await page.content()).not.toContain("發放管理可匯出");
|
||||
|
||||
for (const user of [DEMO.manager, DEMO.admin, DEMO.sysadmin]) {
|
||||
await loginAs(page, user, "/help");
|
||||
for (const title of staffSections) {
|
||||
await expect(page.getByRole("heading", { name: title })).toBeVisible();
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user