[CLAUDE] PurchaseEvaluation · FE-User · FE-Admin · Tests: PE note "Duyệt là KẾT THÚC quy trình (không trình CEO)" — 3 surface
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m58s

Phiếu mà quy trình duyệt có cấp bật AllowApproverFinalize (Mig 58) sẽ kết thúc tại cấp đó,
KHÔNG trình CEO. Hiển thị note cho MỌI NGƯỜI NẮM ở 3 surface (anh Kiệt FDC). KHÔNG migration
(cột AllowApproverFinalize đã có Mig 58, prod ở Mig 59).

BE (3 file, computed DTO):
- PurchaseEvaluationDtos.cs: +bool EndsBeforeCeo +string? FinalizeStepName +string? FinalizeLevelName
  trên DetailBundle + ListItem; flow-level +bool AllowApproverFinalize.
- PurchaseEvaluationFeatures.cs: detail compute first-reachable (Step.Order↑→Level.Order↑, dept-name
  in-memory); list + inbox projection qua 3 subquery EF-safe (lv.Step!.Name). V1 (workflowId==null) → false.
- CreateContractFromEvaluationFeatures.cs: ListApproved projection cùng DTO → +3 subquery y hệt.

FE 2-app (fe-user + fe-admin SHA-mirror component):
- PeFinalizeChip.tsx (MỚI, chip tím) ở 3 danh sách: PeListPanel + PurchaseEvaluationsListPage (cây) + InboxPage.
- PeWorkflowPanel.tsx: note callout trong phiếu, branch DaDuyet (past-tense) / đang-chạy; copy boundary-aware
  "...là KẾT THÚC, không trình CEO. Các cấp trước vẫn duyệt như thường." (tránh cấp giữa hiểu nhầm).
- UserDashboardPage.tsx (chỉ fe-user): dải "Phiếu Duyệt NCC gần đây" + chip (admin dashboard để nguyên).
- types: PeListItem/PeDetailBundle/PeApprovalFlowLevel +field.

Tests: +PeFinalizeProjectionTests (EF-translate smoke 3 subquery + first-reachable + V1-false). Full suite 421→422.
em-main self-gate sau workflow (impl-frontend return rỗng #53 → mirror fe-admin + verify 5 site recover-disk).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-06-25 14:58:54 +07:00
parent a71753bde8
commit f0bca7737c
16 changed files with 417 additions and 6 deletions

View File

@ -0,0 +1,23 @@
// PE — chip "Quy trình kết thúc tại cấp này" (không trình CEO). Hiện khi quy
// trình của phiếu có cấp bật AllowApproverFinalize (Mig 58, anh Kiệt FDC S89).
// SINGLE SOURCE OF TRUTH cho pill này dùng ở MỌI danh sách phiếu (cây danh sách
// + picker workspace/chờ-duyệt + inbox) để mọi người NẮM ngay "phiếu này duyệt
// đến đây là xong, không lên CEO" mà KHÔNG cần mở phiếu. Shape khớp PeUrgentChips.
export function PeFinalizeChip({
endsBeforeCeo,
finalizeStepName,
}: {
endsBeforeCeo: boolean
finalizeStepName: string | null
}) {
if (!endsBeforeCeo) return null
return (
<span
className="inline-flex shrink-0 items-center rounded bg-violet-100 px-1.5 py-0.5 text-[11px] font-semibold text-violet-800"
title={`Quy trình kết thúc tại ${finalizeStepName ?? 'cấp này'} — không trình CEO`}
>
{finalizeStepName ? `⚑ Kết thúc · ${finalizeStepName}` : '⚑ Không lên CEO'}
</span>
)
}

View File

@ -26,6 +26,7 @@ import {
type PeListItem,
} from '@/types/purchaseEvaluation'
import { PeUrgentChips } from '@/components/pe/PeUrgentChips'
import { PeFinalizeChip } from '@/components/pe/PeFinalizeChip'
export function PeListPanel({
typeFilter,
@ -158,6 +159,7 @@ export function PeListPanel({
<div className="min-w-0 flex-1">
<div className="flex min-w-0 items-center gap-1 text-[13px] font-medium text-slate-900">
<PeUrgentChips isUrgentByPro={p.isUrgentByPro} isUrgentByCcm={p.isUrgentByCcm} />
<PeFinalizeChip endsBeforeCeo={p.endsBeforeCeo} finalizeStepName={p.finalizeStepName} />
<span className="truncate">{p.tenGoiThau}</span>
</div>
<div className="mt-0.5 flex items-center gap-1.5 text-[11px] text-slate-500">

View File

@ -251,6 +251,29 @@ export function PeWorkflowPanel({
)}
</div>
{/* [Mig 58 AllowApproverFinalize — anh Kiệt FDC, S89] NOTE cho MỌI người NẮM:
quy trình của phiếu này có cấp được cấu hình "Duyệt là KẾT THÚC" (không
trình CEO). Branch theo phase: đang chạy = callout xanh-lá báo trước /
Đã duyệt = xác nhận đã kết thúc tại đâu. */}
{evaluation.endsBeforeCeo && (
<div className="rounded-md border border-emerald-300 bg-emerald-50 px-3 py-2 text-[12px] text-emerald-800">
{evaluation.phase === PurchaseEvaluationPhase.DaDuyet ? (
<span>
Phiếu đã kết thúc tại{' '}
<span className="font-semibold">{evaluation.finalizeStepName ?? 'cấp duyệt'}</span>
{evaluation.finalizeLevelName ? <> · {evaluation.finalizeLevelName}</> : null} không qua CEO.
</span>
) : (
<span>
Quy trình rút gọn: duyệt đến{' '}
<span className="font-semibold">{evaluation.finalizeStepName ?? 'cấp này'}</span>
{evaluation.finalizeLevelName ? <> · {evaluation.finalizeLevelName}</> : null} KẾT THÚC,
không trình CEO. Các cấp trước vẫn duyệt như thường.
</span>
)}
</div>
)}
{/* Mig 24 V2 — Flow render Bước → Cấp → NV thay phase cards.
Status: Done (✓ emerald) / Current (● brand) / Pending (○ slate) */}
{flow && flow.steps.length > 0 && (

View File

@ -27,6 +27,7 @@ import {
} from '@/types/purchaseEvaluation'
import { PeDetailTabs } from '@/components/pe/PeDetailTabs'
import { PeUrgentChips } from '@/components/pe/PeUrgentChips'
import { PeFinalizeChip } from '@/components/pe/PeFinalizeChip'
import { PeWorkflowPanel } from '@/components/pe/PeWorkflowPanel'
export function PurchaseEvaluationsListPage() {
@ -487,6 +488,7 @@ export function PurchaseEvaluationsListPage() {
<div className="flex min-w-0 flex-1 items-center gap-1 truncate text-[13px] font-medium text-slate-900">
{/* S77 — cờ gấp PILL đồng bộ mọi danh sách: 🔴 GẤP (PRO) / 🟢 GẤP (CCM). */}
<PeUrgentChips isUrgentByPro={p.isUrgentByPro} isUrgentByCcm={p.isUrgentByCcm} />
<PeFinalizeChip endsBeforeCeo={p.endsBeforeCeo} finalizeStepName={p.finalizeStepName} />
<span className="truncate">{p.tenGoiThau}</span>
</div>
<span

View File

@ -141,6 +141,12 @@ export type PeListItem = {
// null selectedSupplierName khi joint ≥2 winner → list card ưu tiên field này,
// fallback selectedSupplierName cho phiếu 1-winner cũ.
winnerSupplierNames: string[]
// [Mig 58 AllowApproverFinalize — anh Kiệt FDC, S89] Quy trình có cấp bật "Duyệt là
// KẾT THÚC" (không trình CEO). BE first-reachable finalize theo Step.Order↑ → Level.Order↑.
// V1 (approvalWorkflowId==null) → endsBeforeCeo=false + names null. FE render PeFinalizeChip.
endsBeforeCeo: boolean
finalizeStepName: string | null
finalizeLevelName: string | null
}
export type PeSupplier = {
@ -263,6 +269,8 @@ export type PeApprovalFlowLevel = {
name: string | null
approvers: PeCurrentApprovalLevelApprover[]
status: 'Done' | 'Current' | 'Pending'
// [Mig 58 — anh Kiệt FDC, S89] Cấp này bật "Duyệt là KẾT THÚC quy trình" (không trình CEO).
allowApproverFinalize: boolean
}
export type PeApprovalFlowStep = {
@ -491,6 +499,12 @@ export type PeDetailBundle = {
currentApproval: PeCurrentApproval | null
// Mig 24 — full flow snapshot (Bước → Cấp → NV) với Status per level
approvalFlow: PeApprovalFlow | null
// [Mig 58 AllowApproverFinalize — anh Kiệt FDC, S89] Quy trình có cấp bật "Duyệt là KẾT
// THÚC" (không trình CEO). BE first-reachable finalize theo Step.Order↑ → Level.Order↑
// (dùng nơi flow THỰC kết thúc). V1 (approvalWorkflowId==null) → endsBeforeCeo=false, names null.
endsBeforeCeo: boolean
finalizeStepName: string | null
finalizeLevelName: string | null
suppliers: PeSupplier[]
details: PeDetailRow[]
approvals: PeApproval[]