[CLAUDE] PurchaseEvaluation: co gap GAN=NV chuc nang / GO=chi Truong phong (DeptManager) bat doi xung
All checks were successful
Deploy SOLUTION_ERP / build-deploy (push) Successful in 4m48s

Tra Sol + anh Kiet (Zalo chot 14:25): tranh NV khac lo tay go co cua nguoi da gan. Handler SetPurchaseEvaluationUrgent gate BAT DOI XUNG theo IsUrgent: GAN (true) = role chuc nang (Procurement->do / CostControl->xanh / Admin->ca 2); GO (false) = role chuc nang + DeptManager (Truong phong) hoac Admin. FE PeDetailTabs nut toggle gate theo trang thai hien tai (da gap->can quyen GO; chua gap->can quyen GAN) → an nut GO voi NV thuong. Test PeUrgentToggleAuthzTests rewrite asymmetric (354 PASS 0 fail). FE 2 app SHA256-identical. Build slnx 0-err.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
pqhuy1987
2026-06-19 14:42:08 +07:00
parent e29391ec9e
commit b5aa72d005
4 changed files with 188 additions and 79 deletions

View File

@ -126,8 +126,16 @@ export function PeDetailTabs({
// BE chặn Forbidden role khác → FE chỉ ẩn nút (UX), không phải security.
const isPro = currentUser?.roles?.includes('Procurement') ?? false
const isCcm = currentUser?.roles?.includes('CostControl') ?? false
const canToggleProUrgent = isAdmin || isPro
const canToggleCcmUrgent = isAdmin || isCcm
// [S77 Tra Sol/anh Kiệt — chốt] BẤT ĐỐI XỨNG: GẮN = NV chức năng (ai làm nấy gắn);
// GỠ = chỉ Trưởng phòng (DeptManager)/Admin (tránh NV khác lỡ tay gỡ). Nút phụ thuộc
// trạng thái hiện tại: đã gấp → cần quyền GỠ; chưa gấp → cần quyền GẮN.
const isDeptManager = currentUser?.roles?.includes('DeptManager') ?? false
const canToggleProUrgent = evaluation.isUrgentByPro
? (isAdmin || (isPro && isDeptManager))
: (isAdmin || isPro)
const canToggleCcmUrgent = evaluation.isUrgentByCcm
? (isAdmin || (isCcm && isDeptManager))
: (isAdmin || isCcm)
const v2Approvers = evaluation.currentApproval?.approvers ?? []
const actorMatchesLevel = isAdmin
|| (currentUser?.id != null && v2Approvers.some(a => a.userId === currentUser.id))