From 24f0083d78bbcbbdaae3d275d193669367179771 Mon Sep 17 00:00:00 2001 From: pqhuy1987 Date: Tue, 23 Jun 2026 13:42:50 +0700 Subject: [PATCH] =?UTF-8?q?[CLAUDE]=20PurchaseEvaluation:=20form=20t?= =?UTF-8?q?=E1=BA=A1o=20phi=E1=BA=BFu=20=E2=80=94=20=E1=BA=A9n=20m?= =?UTF-8?q?=E1=BB=A5c=203/4/5=20+=20auto-ch=E1=BB=8Dn=20quy=20tr=C3=ACnh?= =?UTF-8?q?=20duy=E1=BB=87t=20(anh=20Ki=E1=BB=87t=20FDC=20UAT=20R1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit D1 — ẩn mục 3 (NCC tham gia) / 4 (Hạng mục + Báo giá) / 5 (Ý kiến) + dòng 2a placeholder khỏi form TẠO (chỉ là "Lưu phiếu trước", gây rối) — mở khóa đầy đủ ở Detail tabs sau khi tạo. D5 — auto-chọn quy trình duyệt khi danh sách chỉ có 1 lựa chọn (hết nhầm "chưa chọn quy trình"; prod PE type-1 có đúng 1 workflow IsUserSelectable). Gỡ FormRow/LockedHint/Lock unused (TS6133). FE 2 app SHA-identical. Both build PASS. Co-Authored-By: Claude Opus 4.8 --- .../components/pe/PeWorkspaceCreateView.tsx | 54 +++++-------------- .../components/pe/PeWorkspaceCreateView.tsx | 54 +++++-------------- 2 files changed, 26 insertions(+), 82 deletions(-) diff --git a/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx b/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx index f11eaf4..f42518e 100644 --- a/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx +++ b/fe-admin/src/components/pe/PeWorkspaceCreateView.tsx @@ -6,10 +6,9 @@ // // Pattern user 2026-05-07: "Thêm mới list ra hết trường dữ liệu giống chỉnh // sửa nhưng trống, mở rộng từng phần. Save header xong mới cho nhập chi tiết." -import { useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { toast } from 'sonner' -import { Lock } from 'lucide-react' import { Button } from '@/components/ui/Button' import { Input } from '@/components/ui/Input' import { Label } from '@/components/ui/Label' @@ -103,6 +102,15 @@ export function PeWorkspaceCreateView({ }, }) + // [D5 anh Kiệt FDC] Auto-chọn quy trình khi danh sách chỉ có 1 lựa chọn → hết nhầm + // "chưa chọn quy trình" (chỉ set khi user chưa tự chọn, giữ lựa chọn thủ công nếu có). + useEffect(() => { + const list = approvalWorkflows.data + if (list && list.length === 1 && !form.approvalWorkflowId) { + setForm(f => ({ ...f, approvalWorkflowId: list[0].id })) + } + }, [approvalWorkflows.data, form.approvalWorkflowId]) + const budgetPayload = { budgetPeriodAmount: form.budgetPeriodAmount > 0 ? form.budgetPeriodAmount : null, } @@ -242,11 +250,6 @@ export function PeWorkspaceCreateView({ {/* Section 2 — Chọn NCC/TP (chỉ Ngân sách editable, còn lại sẽ unlock sau create) */}
- — (sau khi thêm NCC tham gia + chốt winner)} - /> - {/* [S61 Mig 50] b. Ngân sách kỳ này — ô đơn thay picker Budget cũ + toggle nhập tay (module Budget xóa hẳn). Số phân bổ cho RIÊNG phiếu này (row 3 bảng "Tổng hợp ngân sách trình ký"). */} @@ -290,22 +293,9 @@ export function PeWorkspaceCreateView({
- {/* Section 3 — NCC tham gia (locked) */} -
- -
- - {/* Section 4 — Hạng mục + Báo giá (locked) */} -
- -
- - {/* Section 5 — Ý kiến 4 phòng ban (locked + amber hint per Q5 user) */} -
-
- Ý kiến + chữ ký nhập khi duyệt phiếu — vào menu “Duyệt” để ký. -
-
+ {/* [D1 anh Kiệt FDC] Mục 3 (NCC tham gia) / 4 (Hạng mục + Báo giá) / 5 (Ý kiến) ẨN + khỏi form TẠO — chỉ là placeholder "Lưu phiếu trước", gây rối. Mở khóa đầy đủ + ở Detail tabs sau khi tạo phiếu. */} {/* Action bar */} @@ -334,21 +324,3 @@ function Section({ title, children }: { title: string; children: React.ReactNode ) } - -function FormRow({ label, value }: { label: string; value: React.ReactNode }) { - return ( -
- {label} -
{value}
-
- ) -} - -function LockedHint({ text }: { text: string }) { - return ( -
- - {text} -
- ) -} diff --git a/fe-user/src/components/pe/PeWorkspaceCreateView.tsx b/fe-user/src/components/pe/PeWorkspaceCreateView.tsx index f11eaf4..f42518e 100644 --- a/fe-user/src/components/pe/PeWorkspaceCreateView.tsx +++ b/fe-user/src/components/pe/PeWorkspaceCreateView.tsx @@ -6,10 +6,9 @@ // // Pattern user 2026-05-07: "Thêm mới list ra hết trường dữ liệu giống chỉnh // sửa nhưng trống, mở rộng từng phần. Save header xong mới cho nhập chi tiết." -import { useRef, useState } from 'react' +import { useEffect, useRef, useState } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { toast } from 'sonner' -import { Lock } from 'lucide-react' import { Button } from '@/components/ui/Button' import { Input } from '@/components/ui/Input' import { Label } from '@/components/ui/Label' @@ -103,6 +102,15 @@ export function PeWorkspaceCreateView({ }, }) + // [D5 anh Kiệt FDC] Auto-chọn quy trình khi danh sách chỉ có 1 lựa chọn → hết nhầm + // "chưa chọn quy trình" (chỉ set khi user chưa tự chọn, giữ lựa chọn thủ công nếu có). + useEffect(() => { + const list = approvalWorkflows.data + if (list && list.length === 1 && !form.approvalWorkflowId) { + setForm(f => ({ ...f, approvalWorkflowId: list[0].id })) + } + }, [approvalWorkflows.data, form.approvalWorkflowId]) + const budgetPayload = { budgetPeriodAmount: form.budgetPeriodAmount > 0 ? form.budgetPeriodAmount : null, } @@ -242,11 +250,6 @@ export function PeWorkspaceCreateView({ {/* Section 2 — Chọn NCC/TP (chỉ Ngân sách editable, còn lại sẽ unlock sau create) */}
- — (sau khi thêm NCC tham gia + chốt winner)} - /> - {/* [S61 Mig 50] b. Ngân sách kỳ này — ô đơn thay picker Budget cũ + toggle nhập tay (module Budget xóa hẳn). Số phân bổ cho RIÊNG phiếu này (row 3 bảng "Tổng hợp ngân sách trình ký"). */} @@ -290,22 +293,9 @@ export function PeWorkspaceCreateView({
- {/* Section 3 — NCC tham gia (locked) */} -
- -
- - {/* Section 4 — Hạng mục + Báo giá (locked) */} -
- -
- - {/* Section 5 — Ý kiến 4 phòng ban (locked + amber hint per Q5 user) */} -
-
- Ý kiến + chữ ký nhập khi duyệt phiếu — vào menu “Duyệt” để ký. -
-
+ {/* [D1 anh Kiệt FDC] Mục 3 (NCC tham gia) / 4 (Hạng mục + Báo giá) / 5 (Ý kiến) ẨN + khỏi form TẠO — chỉ là placeholder "Lưu phiếu trước", gây rối. Mở khóa đầy đủ + ở Detail tabs sau khi tạo phiếu. */} {/* Action bar */} @@ -334,21 +324,3 @@ function Section({ title, children }: { title: string; children: React.ReactNode ) } - -function FormRow({ label, value }: { label: string; value: React.ReactNode }) { - return ( -
- {label} -
{value}
-
- ) -} - -function LockedHint({ text }: { text: string }) { - return ( -
- - {text} -
- ) -}