diff --git a/fe-admin/src/pages/contracts/ContractCreatePage.tsx b/fe-admin/src/pages/contracts/ContractCreatePage.tsx index fadd205..afdf556 100644 --- a/fe-admin/src/pages/contracts/ContractCreatePage.tsx +++ b/fe-admin/src/pages/contracts/ContractCreatePage.tsx @@ -13,7 +13,7 @@ import { useState, useMemo, type FormEvent, useEffect } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { useSearchParams } from 'react-router-dom' -import { FileText, Plus, Search, Save, Pencil, Trash2 } from 'lucide-react' +import { FileText, Plus, Search, Save, Pencil, Trash2, Lock } from 'lucide-react' import { toast } from 'sonner' import { ContractDetailsTab } from '@/components/contracts/ContractDetailsTab' import { PhaseBadge } from '@/components/PhaseBadge' @@ -379,13 +379,75 @@ function ContractHeaderForm({ -
- Chi tiết HĐ (line items) sẽ hiện ở đây sau khi tạo Header xong. -
+ ) } +// Preview section cho create mode — render structure thật của Chi tiết +// (table headers + add button) nhưng disabled, để user thấy trước phần +// nhập liệu sẽ unlock sau khi tạo Header xong. +function ContractDetailsPreview({ type }: { type: number }) { + const headers = HEADERS_BY_TYPE[type] ?? [] + const typeLabel = ContractTypeLabel[type] ?? '—' + + return ( +
+

+ + Chi tiết ({typeLabel}) + + 🔒 Cần tạo Header trước + +

+ +
+ + + + + {headers.map(h => )} + + + + + + + + +
#{h}
+
+ + Tạo Header xong sẽ thêm được hạng mục chi tiết +
+
+
+ + +
+ ) +} + +// Headers per ContractType — sync với ContractDetailsTab.tsx để preview +// trùng với Chi tiết thật khi unlock. +const HEADERS_BY_TYPE: Record = { + 1: ['Hạng mục', 'ĐVT', 'Khối lượng', 'Đơn giá', 'Thành tiền', 'Hoàn thành', 'Ghi chú'], + 2: ['Mã CV', 'Tên công việc', 'ĐVT', 'KL', 'Đơn giá', 'Thành tiền', 'Hoàn thành'], + 3: ['Mã SP', 'Tên SP', 'ĐVT', 'SL', 'Đơn giá', 'Thành tiền', 'Giao hàng'], + 4: ['Mã DV', 'Tên DV', 'ĐVT', 'Thời gian', 'Đơn giá', 'Thành tiền'], + 5: ['Mã SP', 'Tên SP', 'ĐVT', 'SL', 'Đơn giá', 'VAT (%)', 'Thành tiền'], + 6: ['Nhóm SP', 'Tên SP', 'ĐVT', 'Giá min', 'Giá max', 'Điều kiện thanh toán'], + 7: ['Loại DV', 'Tên DV', 'ĐVT', 'Giá min', 'Giá max', 'SLA'], +} + function ContractEditForm({ contract, onSaved, diff --git a/fe-user/src/pages/contracts/ContractCreatePage.tsx b/fe-user/src/pages/contracts/ContractCreatePage.tsx index fadd205..afdf556 100644 --- a/fe-user/src/pages/contracts/ContractCreatePage.tsx +++ b/fe-user/src/pages/contracts/ContractCreatePage.tsx @@ -13,7 +13,7 @@ import { useState, useMemo, type FormEvent, useEffect } from 'react' import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query' import { useSearchParams } from 'react-router-dom' -import { FileText, Plus, Search, Save, Pencil, Trash2 } from 'lucide-react' +import { FileText, Plus, Search, Save, Pencil, Trash2, Lock } from 'lucide-react' import { toast } from 'sonner' import { ContractDetailsTab } from '@/components/contracts/ContractDetailsTab' import { PhaseBadge } from '@/components/PhaseBadge' @@ -379,13 +379,75 @@ function ContractHeaderForm({ -
- Chi tiết HĐ (line items) sẽ hiện ở đây sau khi tạo Header xong. -
+ ) } +// Preview section cho create mode — render structure thật của Chi tiết +// (table headers + add button) nhưng disabled, để user thấy trước phần +// nhập liệu sẽ unlock sau khi tạo Header xong. +function ContractDetailsPreview({ type }: { type: number }) { + const headers = HEADERS_BY_TYPE[type] ?? [] + const typeLabel = ContractTypeLabel[type] ?? '—' + + return ( +
+

+ + Chi tiết ({typeLabel}) + + 🔒 Cần tạo Header trước + +

+ +
+ + + + + {headers.map(h => )} + + + + + + + + +
#{h}
+
+ + Tạo Header xong sẽ thêm được hạng mục chi tiết +
+
+
+ + +
+ ) +} + +// Headers per ContractType — sync với ContractDetailsTab.tsx để preview +// trùng với Chi tiết thật khi unlock. +const HEADERS_BY_TYPE: Record = { + 1: ['Hạng mục', 'ĐVT', 'Khối lượng', 'Đơn giá', 'Thành tiền', 'Hoàn thành', 'Ghi chú'], + 2: ['Mã CV', 'Tên công việc', 'ĐVT', 'KL', 'Đơn giá', 'Thành tiền', 'Hoàn thành'], + 3: ['Mã SP', 'Tên SP', 'ĐVT', 'SL', 'Đơn giá', 'Thành tiền', 'Giao hàng'], + 4: ['Mã DV', 'Tên DV', 'ĐVT', 'Thời gian', 'Đơn giá', 'Thành tiền'], + 5: ['Mã SP', 'Tên SP', 'ĐVT', 'SL', 'Đơn giá', 'VAT (%)', 'Thành tiền'], + 6: ['Nhóm SP', 'Tên SP', 'ĐVT', 'Giá min', 'Giá max', 'Điều kiện thanh toán'], + 7: ['Loại DV', 'Tên DV', 'ĐVT', 'Giá min', 'Giá max', 'SLA'], +} + function ContractEditForm({ contract, onSaved,