feat: [부서관리] 기능 보완 - 필드 확장, 검색/필터, UI 개선

- Department 타입에 code, description, isActive, sortOrder 필드 추가
- DepartmentDialog: Zod + react-hook-form 폼 검증 (5개 필드)
- DepartmentToolbar: 상태 필터(전체/활성/비활성) + 검색 기능
- DepartmentTree: 트리 필터링 (검색어 + 상태)
- DepartmentTreeItem: 코드 Badge, 부서명 볼드, 설명 표시, 체크박스 크기 조정
- convertApiToLocal에서 누락 필드 매핑 복원
This commit is contained in:
2026-03-13 00:30:09 +09:00
parent ca5a9325c6
commit 13249384e2
26 changed files with 1284 additions and 915 deletions

View File

@@ -1,6 +1,9 @@
'use client';
import { useState, useEffect } from 'react';
import { useEffect } from 'react';
import { z } from 'zod';
import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import {
Dialog,
DialogContent,
@@ -11,7 +14,19 @@ import {
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import { Label } from '@/components/ui/label';
import type { DepartmentDialogProps } from './types';
import { Switch } from '@/components/ui/switch';
import { Textarea } from '@/components/ui/textarea';
import type { DepartmentDialogProps, DepartmentFormData } from './types';
const departmentFormSchema = z.object({
code: z.string().min(1, '부서 코드를 입력하세요').max(50, '50자 이내로 입력하세요'),
name: z.string().min(1, '부서명을 입력하세요').max(100, '100자 이내로 입력하세요'),
description: z.string().max(500, '500자 이내로 입력하세요').default(''),
sortOrder: z.coerce.number().min(0, '0 이상 입력하세요').default(0),
isActive: z.boolean().default(true),
});
type FormData = z.infer<typeof departmentFormSchema>;
/**
* 부서 추가/수정 다이얼로그
@@ -22,27 +37,59 @@ export function DepartmentDialog({
mode,
parentDepartment,
department,
onSubmit
onSubmit,
}: DepartmentDialogProps) {
const [name, setName] = useState('');
const {
register,
handleSubmit,
reset,
setValue,
watch,
formState: { errors },
} = useForm<FormData>({
resolver: zodResolver(departmentFormSchema),
defaultValues: {
code: '',
name: '',
description: '',
sortOrder: 0,
isActive: true,
},
});
const isActive = watch('isActive');
// 다이얼로그 열릴 때 초기값 설정
useEffect(() => {
if (isOpen) {
if (mode === 'edit' && department) {
setName(department.name);
reset({
code: department.code || '',
name: department.name,
description: department.description || '',
sortOrder: department.sortOrder,
isActive: department.isActive,
});
} else {
setName('');
reset({
code: '',
name: '',
description: '',
sortOrder: 0,
isActive: true,
});
}
}
}, [isOpen, mode, department]);
}, [isOpen, mode, department, reset]);
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (name.trim()) {
onSubmit(name.trim());
setName('');
}
const onFormSubmit = (data: FormData) => {
onSubmit({
code: data.code,
name: data.name,
description: data.description || '',
sortOrder: data.sortOrder,
isActive: data.isActive,
} as DepartmentFormData);
};
const title = mode === 'add' ? '부서 추가' : '부서 수정';
@@ -50,12 +97,12 @@ export function DepartmentDialog({
return (
<Dialog open={isOpen} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-md">
<DialogContent className="sm:max-w-lg">
<DialogHeader>
<DialogTitle>{title}</DialogTitle>
</DialogHeader>
<form onSubmit={handleSubmit}>
<form onSubmit={handleSubmit(onFormSubmit)}>
<div className="space-y-4 py-4">
{/* 부모 부서 표시 (추가 모드일 때) */}
{mode === 'add' && parentDepartment && (
@@ -64,16 +111,78 @@ export function DepartmentDialog({
</div>
)}
{/* 부서명 입력 */}
{/* 부서 코드 */}
<div className="space-y-2">
<Label htmlFor="department-name"></Label>
<Label htmlFor="department-code">
<span className="text-destructive">*</span>
</Label>
<Input
id="department-name"
value={name}
onChange={(e) => setName(e.target.value)}
placeholder="부서명을 입력하세요"
id="department-code"
{...register('code')}
placeholder="예: DEV, SALES, HR"
autoFocus
/>
{errors.code && (
<p className="text-sm text-destructive">{errors.code.message}</p>
)}
</div>
{/* 부서명 */}
<div className="space-y-2">
<Label htmlFor="department-name">
<span className="text-destructive">*</span>
</Label>
<Input
id="department-name"
{...register('name')}
placeholder="부서명을 입력하세요"
/>
{errors.name && (
<p className="text-sm text-destructive">{errors.name.message}</p>
)}
</div>
{/* 설명 */}
<div className="space-y-2">
<Label htmlFor="department-description"></Label>
<Textarea
id="department-description"
{...register('description')}
placeholder="부서 설명을 입력하세요"
rows={3}
/>
{errors.description && (
<p className="text-sm text-destructive">{errors.description.message}</p>
)}
</div>
{/* 정렬순서 + 활성상태 (가로 배치) */}
<div className="flex items-start gap-6">
<div className="space-y-2 flex-1">
<Label htmlFor="department-sort-order"></Label>
<Input
id="department-sort-order"
type="number"
{...register('sortOrder')}
min={0}
/>
{errors.sortOrder && (
<p className="text-sm text-destructive">{errors.sortOrder.message}</p>
)}
</div>
<div className="space-y-2">
<Label> </Label>
<div className="flex items-center gap-2 h-9">
<Switch
checked={isActive}
onCheckedChange={(checked) => setValue('isActive', checked)}
/>
<span className="text-sm text-muted-foreground">
{isActive ? '활성' : '비활성'}
</span>
</div>
</div>
</div>
</div>
@@ -81,7 +190,7 @@ export function DepartmentDialog({
<Button type="button" variant="outline" onClick={() => onOpenChange(false)}>
</Button>
<Button type="submit" disabled={!name.trim()}>
<Button type="submit">
{submitText}
</Button>
</DialogFooter>
@@ -89,4 +198,4 @@ export function DepartmentDialog({
</DialogContent>
</Dialog>
);
}
}

View File

@@ -2,31 +2,58 @@
import { Input } from '@/components/ui/input';
import { Button } from '@/components/ui/button';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/select';
import { Search, Plus, Trash2 } from 'lucide-react';
import type { DepartmentToolbarProps } from './types';
/**
* 검색 + 추가/삭제 버튼 툴바
* 검색 + 필터 + 추가/삭제 버튼 툴바
*/
export function DepartmentToolbar({
totalCount,
selectedCount,
searchQuery,
onSearchChange,
statusFilter,
onStatusFilterChange,
onAdd,
onDelete
onDelete,
}: DepartmentToolbarProps) {
return (
<div className="flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between">
{/* 검색 */}
<div className="relative w-full sm:w-80">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
<Input
placeholder="부서명 검색"
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
className="pl-9"
/>
{/* 검색 + 필터 */}
<div className="flex items-center gap-2 w-full sm:w-auto">
{/* 검색창 */}
<div className="relative flex-1 sm:w-64">
<Search className="absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground" />
<Input
placeholder="부서명, 코드 검색"
value={searchQuery}
onChange={(e) => onSearchChange(e.target.value)}
className="pl-9"
/>
</div>
{/* 상태 필터 */}
<Select
value={statusFilter}
onValueChange={(value) => onStatusFilterChange(value as 'all' | 'active' | 'inactive')}
>
<SelectTrigger className="w-28 shrink-0">
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="all"></SelectItem>
<SelectItem value="active"></SelectItem>
<SelectItem value="inactive"></SelectItem>
</SelectContent>
</Select>
</div>
{/* 선택 카운트 + 버튼 */}
@@ -54,4 +81,4 @@ export function DepartmentToolbar({
</div>
</div>
);
}
}

View File

@@ -35,7 +35,7 @@ export function DepartmentTree({
onCheckedChange={onToggleSelectAll}
aria-label="전체 선택"
/>
<span className="font-medium text-sm"></span>
<span className="font-medium text-sm"> / </span>
</div>
</div>

View File

@@ -3,6 +3,7 @@
import { memo } from 'react';
import { Checkbox } from '@/components/ui/checkbox';
import { Button } from '@/components/ui/button';
import { Badge } from '@/components/ui/badge';
import { ChevronRight, ChevronDown, Plus, SquarePen, Trash2 } from 'lucide-react';
import type { DepartmentTreeItemProps } from './types';
@@ -56,11 +57,35 @@ export const DepartmentTreeItem = memo(function DepartmentTreeItem({
checked={isSelected}
onCheckedChange={() => onToggleSelect(department.id)}
aria-label={`${department.name} 선택`}
className="shrink-0"
className="shrink-0 size-[18px]"
/>
{/* 부서 코드 */}
<span
className="w-20 shrink-0 cursor-pointer"
onClick={() => onToggleSelect(department.id)}
>
{department.code && (
<Badge variant="outline" className="text-xs font-mono rounded-sm w-16 justify-center">
{department.code}
</Badge>
)}
</span>
{/* 부서명 */}
<span className="break-words">{department.name}</span>
<span className="w-20 shrink-0 font-bold truncate">{department.name}</span>
{/* 설명 */}
<span className="text-xs text-muted-foreground truncate">
{department.description || ''}
</span>
{/* 상태 뱃지 */}
{!department.isActive && (
<Badge variant="secondary" className="text-xs shrink-0">
</Badge>
)}
</div>
{/* 작업 버튼 (선택 시 부서명 아래에 표시, 데스크톱: 호버 시에도 표시) */}

View File

@@ -9,8 +9,8 @@ import { DepartmentToolbar } from './DepartmentToolbar';
import { DepartmentTree } from './DepartmentTree';
import { DepartmentDialog } from './DepartmentDialog';
import { DeleteConfirmDialog } from '@/components/ui/confirm-dialog';
import type { Department } from './types';
import { countAllDepartments, getAllDepartmentIds, findDepartmentById } from './types';
import type { Department, DepartmentFormData, StatusFilter } from './types';
import { countAllDepartments, getAllDepartmentIds, findDepartmentById, filterDepartmentTree } from './types';
import {
getDepartmentTree,
createDepartment,
@@ -27,8 +27,12 @@ import { isNextRedirectError } from '@/lib/utils/redirect-error';
function convertApiToLocal(record: DepartmentRecord): Department {
return {
id: record.id,
code: record.code,
name: record.name,
description: record.description,
parentId: record.parentId,
isActive: record.isActive,
sortOrder: record.sortOrder,
depth: record.depth,
children: record.children ? record.children.map(convertApiToLocal) : [],
};
@@ -51,6 +55,9 @@ export function DepartmentManagement() {
// 검색어
const [searchQuery, setSearchQuery] = useState('');
// 상태 필터
const [statusFilter, setStatusFilter] = useState<StatusFilter>('all');
/**
* 부서 트리 조회 API
*/
@@ -92,11 +99,20 @@ export function DepartmentManagement() {
const [departmentToDelete, setDepartmentToDelete] = useState<Department | null>(null);
const [isBulkDelete, setIsBulkDelete] = useState(false);
// 전체 부서 수 계산
// 필터링된 부서 트리
const filteredDepartments = useMemo(
() => filterDepartmentTree(departments, searchQuery, statusFilter),
[departments, searchQuery, statusFilter],
);
// 전체 부서 수 (필터 전)
const totalCount = useMemo(() => countAllDepartments(departments), [departments]);
// 모든 부서 ID
const allIds = useMemo(() => getAllDepartmentIds(departments), [departments]);
// 필터된 부서
const filteredCount = useMemo(() => countAllDepartments(filteredDepartments), [filteredDepartments]);
// 필터된 부서 ID
const filteredAllIds = useMemo(() => getAllDepartmentIds(filteredDepartments), [filteredDepartments]);
// 펼침/접힘 토글
const handleToggleExpand = (id: number) => {
@@ -124,12 +140,12 @@ export function DepartmentManagement() {
});
};
// 전체 선택/해제
// 전체 선택/해제 (필터된 부서 기준)
const handleToggleSelectAll = () => {
if (selectedIds.size === allIds.length) {
if (selectedIds.size === filteredAllIds.length) {
setSelectedIds(new Set());
} else {
setSelectedIds(new Set(allIds));
setSelectedIds(new Set(filteredAllIds));
}
};
@@ -225,18 +241,19 @@ export function DepartmentManagement() {
/**
* 부서 추가/수정 제출 핸들러 (API 연동)
* @note parentId는 현재 API에서 미지원 - 모든 부서가 최상위로 생성됨
*/
const handleDialogSubmit = useCallback(async (name: string) => {
const handleDialogSubmit = useCallback(async (formData: DepartmentFormData) => {
if (isProcessing) return;
setIsProcessing(true);
try {
if (dialogMode === 'add') {
// 새 부서 추가 API
// NOTE: parentId는 현재 API에서 지원하지 않아 최상위에만 생성됨
const result = await createDepartment({
name,
code: formData.code,
name: formData.name,
description: formData.description || undefined,
sortOrder: formData.sortOrder,
isActive: formData.isActive,
parentId: parentDepartment?.id,
});
if (result.success) {
@@ -245,8 +262,13 @@ export function DepartmentManagement() {
console.error('[DepartmentManagement] 부서 생성 실패:', result.error);
}
} else if (dialogMode === 'edit' && selectedDepartment) {
// 부서 수정 API
const result = await updateDepartment(selectedDepartment.id, { name });
const result = await updateDepartment(selectedDepartment.id, {
code: formData.code,
name: formData.name,
description: formData.description || undefined,
sortOrder: formData.sortOrder,
isActive: formData.isActive,
});
if (result.success) {
await fetchDepartments();
} else {
@@ -262,6 +284,9 @@ export function DepartmentManagement() {
}
}, [dialogMode, parentDepartment, selectedDepartment, isProcessing, fetchDepartments]);
// 필터 활성 여부
const isFiltered = searchQuery.trim() !== '' || statusFilter !== 'all';
return (
<PageLayout>
<PageHeader
@@ -274,19 +299,21 @@ export function DepartmentManagement() {
{/* 전체 부서 카운트 */}
<DepartmentStats totalCount={totalCount} />
{/* 검색 + 추가/삭제 버튼 */}
{/* 검색 + 필터 + 추가/삭제 버튼 */}
<DepartmentToolbar
totalCount={totalCount}
totalCount={isFiltered ? filteredCount : totalCount}
selectedCount={selectedIds.size}
searchQuery={searchQuery}
onSearchChange={setSearchQuery}
statusFilter={statusFilter}
onStatusFilterChange={setStatusFilter}
onAdd={handleBulkAdd}
onDelete={handleBulkDelete}
/>
{/* 트리 테이블 */}
<DepartmentTree
departments={departments}
departments={filteredDepartments}
expandedIds={expandedIds}
selectedIds={selectedIds}
onToggleExpand={handleToggleExpand}
@@ -328,4 +355,4 @@ export function DepartmentManagement() {
/>
</PageLayout>
);
}
}

View File

@@ -8,12 +8,27 @@
*/
export interface Department {
id: number;
code: string | null;
name: string;
description: string | null;
parentId: number | null;
isActive: boolean;
sortOrder: number;
depth: number; // 깊이 (0: 최상위, 1, 2, 3, ... 무제한)
children?: Department[]; // 하위 부서 (재귀 - 무제한 깊이)
}
/**
* 부서 폼 데이터
*/
export interface DepartmentFormData {
code: string;
name: string;
description: string;
sortOrder: number;
isActive: boolean;
}
/**
* 부서 추가/수정 다이얼로그 Props
*/
@@ -23,7 +38,7 @@ export interface DepartmentDialogProps {
mode: 'add' | 'edit';
parentDepartment?: Department; // 추가 시 부모 부서
department?: Department; // 수정 시 대상 부서
onSubmit: (name: string) => void;
onSubmit: (data: DepartmentFormData) => void;
}
/**
@@ -48,6 +63,11 @@ export interface DepartmentStatsProps {
totalCount: number;
}
/**
* 상태 필터 타입
*/
export type StatusFilter = 'all' | 'active' | 'inactive';
/**
* 툴바 Props
*/
@@ -56,6 +76,8 @@ export interface DepartmentToolbarProps {
selectedCount: number;
searchQuery: string;
onSearchChange: (query: string) => void;
statusFilter: StatusFilter;
onStatusFilterChange: (filter: StatusFilter) => void;
onAdd: () => void;
onDelete: () => void;
}
@@ -107,3 +129,45 @@ export const findDepartmentById = (departments: Department[], id: number): Depar
}
return null;
};
/**
* 트리 필터링 유틸리티 (재귀 — 검색/상태 필터)
* 자식이 매칭되면 부모도 유지
*/
export const filterDepartmentTree = (
departments: Department[],
searchQuery: string,
statusFilter: StatusFilter,
): Department[] => {
const query = searchQuery.trim().toLowerCase();
const filterNode = (dept: Department): Department | null => {
// 자식 먼저 필터링
const filteredChildren = dept.children
? dept.children.map(filterNode).filter(Boolean) as Department[]
: [];
// 현재 노드가 매칭되는지 확인
const matchesSearch = !query ||
dept.name.toLowerCase().includes(query) ||
(dept.code && dept.code.toLowerCase().includes(query));
const matchesStatus = statusFilter === 'all' ||
(statusFilter === 'active' && dept.isActive) ||
(statusFilter === 'inactive' && !dept.isActive);
// 자식이 매칭되면 부모도 유지
if (filteredChildren.length > 0) {
return { ...dept, children: filteredChildren };
}
// 현재 노드가 매칭되면 유지
if (matchesSearch && matchesStatus) {
return { ...dept, children: [] };
}
return null;
};
return departments.map(filterNode).filter(Boolean) as Department[];
};

View File

@@ -237,7 +237,10 @@ export function ReceivingDetail({ id, mode = 'view' }: Props) {
// 수입검사 성적서 템플릿 존재 여부 + 첨부파일 확인
if (result.data.itemId) {
const templateCheck = await checkInspectionTemplate(result.data.itemId);
setHasInspectionTemplate(templateCheck.hasTemplate);
// API 성공 시에만 값 업데이트 (실패 시 기존 값 유지 — 버튼 사라짐 방지)
if (templateCheck.success) {
setHasInspectionTemplate(templateCheck.hasTemplate);
}
if (templateCheck.attachments && templateCheck.attachments.length > 0) {
setInspectionAttachments(templateCheck.attachments);
}

View File

@@ -1256,3 +1256,14 @@ export async function getQuotesForSelect(params?: {
},
};
}
/**
* 수주서 문서용 상세 데이터 조회
* BOM 기반 products, motors, bending_parts, subsidiary_parts 포함
*/
export async function getOrderDocumentDetail(orderId: string) {
return executeServerAction({
url: buildApiUrl(`/api/v1/qms/lot-audit/documents/order/${orderId}`),
errorMessage: '수주서 문서 데이터 조회에 실패했습니다.',
});
}

View File

@@ -12,7 +12,7 @@ import { ContractDocument } from "./ContractDocument";
import { TransactionDocument } from "./TransactionDocument";
import { PurchaseOrderDocument } from "./PurchaseOrderDocument";
import { SalesOrderDocument } from "./SalesOrderDocument";
import { OrderItem } from "../actions";
import { OrderItem, getOrderDocumentDetail } from "../actions";
import { getCompanyInfo } from "@/components/settings/CompanyInfoManagement/actions";
// 문서 타입
@@ -54,6 +54,7 @@ export interface OrderDocumentData {
recipientContact?: string;
shutterCount?: number;
fee?: number;
orderId?: number;
}
interface OrderDocumentModalProps {
@@ -79,6 +80,8 @@ export function OrderDocumentModal({
data,
}: OrderDocumentModalProps) {
const [companyInfo, setCompanyInfo] = useState<CompanyInfo | null>(null);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const [orderDetail, setOrderDetail] = useState<Record<string, any> | null>(null);
// 모달이 열릴 때 회사 정보 조회
useEffect(() => {
@@ -97,6 +100,21 @@ export function OrderDocumentModal({
}
}, [open, companyInfo]);
// 수주서일 때 BOM 상세 데이터 로드
useEffect(() => {
if (!open || documentType !== 'salesOrder' || !data.orderId) {
setOrderDetail(null);
return;
}
getOrderDocumentDetail(String(data.orderId)).then((result) => {
if (result.success && result.data) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const raw = result.data as Record<string, any>;
setOrderDetail(raw?.data ?? raw);
}
});
}, [open, documentType, data.orderId]);
const getDocumentTitle = () => {
switch (documentType) {
case "contract":
@@ -186,6 +204,12 @@ export function OrderDocumentModal({
items={data.items || []}
products={data.products}
remarks={data.remarks}
productRows={orderDetail?.products || []}
motorsLeft={orderDetail?.motors?.left || []}
motorsRight={orderDetail?.motors?.right || []}
bendingParts={orderDetail?.bending_parts || []}
subsidiaryParts={orderDetail?.subsidiary_parts || []}
categoryCode={orderDetail?.category_code}
/>
);
default:

View File

@@ -14,6 +14,51 @@ import { ProductInfo } from "./OrderDocumentModal";
import { ConstructionApprovalTable } from "@/components/document-system";
import { formatNumber } from '@/lib/utils/amount';
// ===== 데이터 타입 =====
interface MotorRow {
item: string;
type: string;
spec: string;
qty: number;
}
interface BendingItem {
name: string;
spec: string;
qty: number;
}
interface BendingGroup {
group: string;
items: BendingItem[];
}
interface SubsidiaryItem {
name: string;
spec: string;
qty: number;
}
interface ProductRow {
no: number;
floor?: string;
symbol?: string;
product_name?: string;
product_type?: string;
open_width?: number | string;
open_height?: number | string;
made_width?: number | string;
made_height?: number | string;
guide_rail?: string;
shaft?: string | number;
case_inch?: string | number;
bracket?: string;
capacity?: string | number;
finish?: string;
joint_bar?: number | null;
}
interface SalesOrderDocumentProps {
documentNumber?: string;
orderNumber: string;
@@ -34,61 +79,15 @@ interface SalesOrderDocumentProps {
items?: OrderItem[];
products?: ProductInfo[];
remarks?: string;
// 실 데이터 props
productRows?: ProductRow[];
motorsLeft?: MotorRow[];
motorsRight?: MotorRow[];
bendingParts?: BendingGroup[];
subsidiaryParts?: SubsidiaryItem[];
categoryCode?: string;
}
// ===== 문서 전용 목데이터 (출고증과 동일 구조) =====
const MOCK_SCREEN_ROWS = [
{ no: 1, type: '이(마)', code: 'FA123', openW: 4300, openH: 4300, madeW: 4300, madeH: 3000, guideRail: '백면형', shaft: 5, caseInch: 5, bracket: '500X300 380X180', capacity: 300, finish: 'SUS마감' },
{ no: 2, type: '이(마)', code: 'FA123', openW: 4300, openH: 4300, madeW: 4300, madeH: 3000, guideRail: '백면형', shaft: 5, caseInch: 5, bracket: '500X300 380X180', capacity: 300, finish: 'SUS마감' },
];
const MOCK_STEEL_ROWS = [
{ no: 1, code: 'FA123', openW: 4300, openH: 3000, madeW: 4300, madeH: 3000, guideRail: '백면형', shaft: 5, jointBar: 5, caseInch: 5, bracket: '500X300 380X180', capacity: 300, finish: 'SUS마감' },
{ no: 2, code: 'FA123', openW: 4300, openH: 3000, madeW: 4300, madeH: 3000, guideRail: '백면형', shaft: 5, jointBar: 5, caseInch: 5, bracket: '500X300 380X180', capacity: 300, finish: 'SUS마감' },
];
const MOCK_MOTOR_LEFT = [
{ item: '모터', type: '380V 단상', spec: 'KD-150K', qty: 6 },
{ item: '브라켓트', type: '-', spec: '380X180', qty: 6 },
{ item: '앵글', type: '밑침통 영금', spec: '40*40*380', qty: 4 },
];
const MOCK_MOTOR_RIGHT = [
{ item: '전동개폐기', type: '릴박스', spec: '-', qty: 1 },
{ item: '전동개폐기', type: '매입', spec: '-', qty: 1 },
];
const MOCK_GUIDE_RAIL_ITEMS = [
{ name: '항목명', spec: 'L: 3,000', qty: 22 },
{ name: '하부BASE', spec: '130X80', qty: 22 },
];
const MOCK_GUIDE_SMOKE = { name: '연기차단재(W50)', spec: '2,438', qty: 4 };
const MOCK_CASE_ITEMS = [
{ name: '500X330', spec: 'L: 4,000', qty: 3 },
{ name: '500X330', spec: 'L: 5,000', qty: 4 },
{ name: '상부덮개', spec: '1219X389', qty: 55 },
{ name: '측면부 (마구리)', spec: '500X355', qty: '500X355' },
];
const MOCK_CASE_SMOKE = { name: '연기차단재(W80)', spec: '3,000', qty: 4 };
const MOCK_BOTTOM_SCREEN = [
{ name: '하단마감재', spec: '60X40', l1: 'L: 3,000', q1: 6, name2: '하단마감재', spec2: '60X40', l2: 'L: 4,000', q2: 6 },
{ name: '하단보강엘비', spec: '60X17', l1: 'L: 3,000', q1: 6, name2: '하단보강엘비', spec2: '60X17', l2: 'L: 4,000', q2: 6 },
{ name: '하단보강평철', spec: '-', l1: 'L: 3,000', q1: 6, name2: '하단보강평철', spec2: '-', l2: 'L: 4,000', q2: 6 },
{ name: '하단무게평철', spec: '50X12T', l1: 'L: 3,000', q1: 6, name2: '하단무게평철', spec2: '50X12T', l2: 'L: 4,000', q2: 6 },
];
const MOCK_BOTTOM_STEEL = { spec: '60X40', length: 'L: 3,000', qty: 22 };
const MOCK_SUBSIDIARY = [
{ leftItem: '감기사프트', leftSpec: '4인치 4500', leftQty: 6, rightItem: '각파이프', rightSpec: '6000', rightQty: 4 },
{ leftItem: '조인트바', leftSpec: '300', leftQty: 6, rightItem: '환봉', rightSpec: '3000', rightQty: 5 },
];
// ===== 공통 스타일 =====
const thBase = 'border-r border-gray-400 px-1 py-1';
const tdBase = 'border-r border-gray-300 px-1 py-1';
@@ -114,10 +113,40 @@ export function SalesOrderDocument({
items: _items = [],
products = [],
remarks,
productRows = [],
motorsLeft = [],
motorsRight = [],
bendingParts = [],
subsidiaryParts = [],
}: SalesOrderDocumentProps) {
const [bottomFinishView, setBottomFinishView] = useState<'screen' | 'steel'>('screen');
const motorRows = Math.max(MOCK_MOTOR_LEFT.length, MOCK_MOTOR_RIGHT.length);
const motorRows = Math.max(motorsLeft.length, motorsRight.length);
// 절곡물 그룹 데이터 추출
const guideRailItems = bendingParts.find(g => g.group === '가이드레일')?.items ?? [];
const caseItems = bendingParts.find(g => g.group === '케이스')?.items ?? [];
const bottomItems = bendingParts.find(g => g.group === '하단마감')?.items ?? [];
const smokeItems = bendingParts.find(g => g.group === '연기차단재')?.items ?? [];
const guideSmokeItems = smokeItems.filter(i => i.name.includes('레일') || i.name.includes('가이드'));
const caseSmokeItems = smokeItems.filter(i => i.name.includes('케이스'));
// 구분 불가한 연기차단재는 그대로 표시
const otherSmokeItems = smokeItems.filter(i =>
!i.name.includes('레일') && !i.name.includes('가이드') && !i.name.includes('케이스')
);
// 부자재 좌/우 2열 변환
const subsidiaryRows = [];
for (let i = 0; i < subsidiaryParts.length; i += 2) {
subsidiaryRows.push({
left: subsidiaryParts[i],
right: subsidiaryParts[i + 1] ?? null,
});
}
// 스크린/철재 제품 분리
const screenProducts = productRows.filter(p => p.product_type !== 'steel');
const steelProducts = productRows.filter(p => p.product_type === 'steel');
return (
<div className="bg-white p-8 min-h-full text-[11px]">
@@ -142,9 +171,9 @@ export function SalesOrderDocument({
<td className="bg-gray-100 px-2 py-1 font-medium border-r border-gray-400 whitespace-nowrap"></td>
<td className="px-2 py-1 border-r border-gray-400">{orderNumber}</td>
<td className="bg-gray-100 px-2 py-1 font-medium border-r border-gray-400 whitespace-nowrap"></td>
<td className="px-2 py-1 border-r border-gray-400">{products[0]?.productName || "-"}</td>
<td className="px-2 py-1 border-r border-gray-400">{products[0]?.productName || productRows[0]?.product_name || "-"}</td>
<td className="bg-gray-100 px-2 py-1 font-medium border-r border-gray-400 whitespace-nowrap"></td>
<td className="px-2 py-1 border-r border-gray-400">KWS01</td>
<td className="px-2 py-1 border-r border-gray-400">{productRows[0]?.product_name?.split(' ')[0] || "KWS01"}</td>
<td className="bg-gray-100 px-2 py-1 font-medium border-r border-gray-400 whitespace-nowrap"></td>
<td className="px-2 py-1">{certificationNumber}</td>
</tr>
@@ -198,7 +227,7 @@ export function SalesOrderDocument({
</tr>
<tr>
<td className="bg-gray-100 px-2 py-1 font-medium"></td>
<td className="px-2 py-1">{shutterCount}</td>
<td className="px-2 py-1">{shutterCount || productRows.length}</td>
</tr>
</tbody>
</table>
@@ -239,391 +268,383 @@ export function SalesOrderDocument({
<p className="text-[10px] mb-4"> .</p>
{/* ========== 1. 스크린 ========== */}
<div className="mb-4">
<p className="font-bold mb-2">1. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-8`} rowSpan={2}>No</th>
<th className={`${thBase} w-14`} rowSpan={2}></th>
<th className={`${thBase} w-14`} rowSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={`${thBase} w-16`} rowSpan={2}><br /></th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={thBase} colSpan={2}></th>
<th className="px-1 py-1 w-16" rowSpan={2}></th>
</tr>
<tr className="bg-gray-50 border-b border-gray-400 text-[9px]">
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}>Kg</th>
</tr>
</thead>
<tbody>
{MOCK_SCREEN_ROWS.map((row) => (
<tr key={row.no} className="border-b border-gray-300">
<td className={tdCenter}>{row.no}</td>
<td className={tdCenter}>{row.type}</td>
<td className={tdCenter}>{row.code}</td>
<td className={tdCenter}>{formatNumber(row.openW)}</td>
<td className={tdCenter}>{formatNumber(row.openH)}</td>
<td className={tdCenter}>{formatNumber(row.madeW)}</td>
<td className={tdCenter}>{formatNumber(row.madeH)}</td>
<td className={tdCenter}>{row.guideRail}</td>
<td className={tdCenter}>{row.shaft}</td>
<td className={tdCenter}>{row.caseInch}</td>
<td className={tdCenter}>{row.bracket}</td>
<td className={tdCenter}>{row.capacity}</td>
<td className="px-1 py-1 text-center">{row.finish}</td>
{screenProducts.length > 0 && (
<div className="mb-4">
<p className="font-bold mb-2">1. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-8`} rowSpan={2}>No</th>
<th className={`${thBase} w-14`} rowSpan={2}></th>
<th className={`${thBase} w-14`} rowSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={`${thBase} w-16`} rowSpan={2}><br /></th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={thBase} colSpan={2}></th>
<th className="px-1 py-1 w-16" rowSpan={2}></th>
</tr>
))}
</tbody>
</table>
<tr className="bg-gray-50 border-b border-gray-400 text-[9px]">
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}>Kg</th>
</tr>
</thead>
<tbody>
{screenProducts.map((row) => (
<tr key={row.no} className="border-b border-gray-300">
<td className={tdCenter}>{row.no}</td>
<td className={tdCenter}>{row.floor ?? '-'}</td>
<td className={tdCenter}>{row.symbol ?? '-'}</td>
<td className={tdCenter}>{row.open_width ? formatNumber(Number(row.open_width)) : '-'}</td>
<td className={tdCenter}>{row.open_height ? formatNumber(Number(row.open_height)) : '-'}</td>
<td className={tdCenter}>{row.made_width ? formatNumber(Number(row.made_width)) : '-'}</td>
<td className={tdCenter}>{row.made_height ? formatNumber(Number(row.made_height)) : '-'}</td>
<td className={tdCenter}>{row.guide_rail ?? '-'}</td>
<td className={tdCenter}>{row.shaft ?? '-'}</td>
<td className={tdCenter}>{row.case_inch ?? '-'}</td>
<td className={tdCenter}>{row.bracket ?? '-'}</td>
<td className={tdCenter}>{row.capacity ?? '-'}</td>
<td className="px-1 py-1 text-center">{row.finish ?? '-'}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
)}
{/* ========== 2. 철재 ========== */}
<div className="mb-4">
<p className="font-bold mb-2">2. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-8`} rowSpan={2}>No.</th>
<th className={`${thBase} w-14`} rowSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={`${thBase} w-16`} rowSpan={2}><br /></th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={thBase} colSpan={2}></th>
<th className="px-1 py-1 w-16" rowSpan={2}></th>
</tr>
<tr className="bg-gray-50 border-b border-gray-400 text-[9px]">
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}>Kg</th>
</tr>
</thead>
<tbody>
{MOCK_STEEL_ROWS.map((row) => (
<tr key={row.no} className="border-b border-gray-300">
<td className={tdCenter}>{row.no}</td>
<td className={tdCenter}>{row.code}</td>
<td className={tdCenter}>{formatNumber(row.openW)}</td>
<td className={tdCenter}>{formatNumber(row.openH)}</td>
<td className={tdCenter}>{formatNumber(row.madeW)}</td>
<td className={tdCenter}>{formatNumber(row.madeH)}</td>
<td className={tdCenter}>{row.guideRail}</td>
<td className={tdCenter}>{row.shaft}</td>
<td className={tdCenter}>{row.jointBar}</td>
<td className={tdCenter}>{row.caseInch}</td>
<td className={tdCenter}>{row.bracket}</td>
<td className={tdCenter}>{row.capacity}</td>
<td className="px-1 py-1 text-center">{row.finish}</td>
{steelProducts.length > 0 && (
<div className="mb-4">
<p className="font-bold mb-2">2. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-8`} rowSpan={2}>No.</th>
<th className={`${thBase} w-14`} rowSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={thBase} colSpan={2}></th>
<th className={`${thBase} w-16`} rowSpan={2}><br /></th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={`${thBase} w-14`} rowSpan={2}><br />()</th>
<th className={thBase} colSpan={2}></th>
<th className="px-1 py-1 w-16" rowSpan={2}></th>
</tr>
))}
</tbody>
</table>
<tr className="bg-gray-50 border-b border-gray-400 text-[9px]">
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}></th>
<th className={thBase}>Kg</th>
</tr>
</thead>
<tbody>
{steelProducts.map((row) => (
<tr key={row.no} className="border-b border-gray-300">
<td className={tdCenter}>{row.no}</td>
<td className={tdCenter}>{row.symbol ?? '-'}</td>
<td className={tdCenter}>{row.open_width ? formatNumber(Number(row.open_width)) : '-'}</td>
<td className={tdCenter}>{row.open_height ? formatNumber(Number(row.open_height)) : '-'}</td>
<td className={tdCenter}>{row.made_width ? formatNumber(Number(row.made_width)) : '-'}</td>
<td className={tdCenter}>{row.made_height ? formatNumber(Number(row.made_height)) : '-'}</td>
<td className={tdCenter}>{row.guide_rail ?? '-'}</td>
<td className={tdCenter}>{row.shaft ?? '-'}</td>
<td className={tdCenter}>{row.joint_bar ?? '-'}</td>
<td className={tdCenter}>{row.case_inch ?? '-'}</td>
<td className={tdCenter}>{row.bracket ?? '-'}</td>
<td className={tdCenter}>{row.capacity ?? '-'}</td>
<td className="px-1 py-1 text-center">{row.finish ?? '-'}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
)}
{/* ========== 3. 모터 ========== */}
<div className="mb-4">
<p className="font-bold mb-2">3. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-10`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-10"></th>
</tr>
</thead>
<tbody>
{Array.from({ length: motorRows }).map((_, i) => {
const left = MOCK_MOTOR_LEFT[i];
const right = MOCK_MOTOR_RIGHT[i];
return (
<tr key={i} className="border-b border-gray-300">
<td className={tdBase}>{left?.item || ''}</td>
<td className={tdBase}>{left?.type || ''}</td>
<td className={tdBase}>{left?.spec || ''}</td>
<td className={tdCenter}>{left?.qty ?? ''}</td>
<td className={tdBase}>{right?.item || ''}</td>
<td className={tdBase}>{right?.type || ''}</td>
<td className={tdBase}>{right?.spec || ''}</td>
<td className="px-1 py-1 text-center">{right?.qty ?? ''}</td>
</tr>
);
})}
</tbody>
</table>
{motorRows > 0 && (
<div className="mb-4">
<p className="font-bold mb-2">3. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-10`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-10"></th>
</tr>
</thead>
<tbody>
{Array.from({ length: motorRows }).map((_, i) => {
const left = motorsLeft[i];
const right = motorsRight[i];
return (
<tr key={i} className="border-b border-gray-300">
<td className={tdBase}>{left?.item || ''}</td>
<td className={tdBase}>{left?.type || ''}</td>
<td className={tdBase}>{left?.spec || ''}</td>
<td className={tdCenter}>{left?.qty ?? ''}</td>
<td className={tdBase}>{right?.item || ''}</td>
<td className={tdBase}>{right?.type || ''}</td>
<td className={tdBase}>{right?.spec || ''}</td>
<td className="px-1 py-1 text-center">{right?.qty ?? ''}</td>
</tr>
);
})}
</tbody>
</table>
</div>
</div>
</div>
)}
{/* ========== 4. 절곡물 ========== */}
<div className="mb-4">
<p className="font-bold mb-2">4. </p>
{bendingParts.length > 0 && (
<div className="mb-4">
<p className="font-bold mb-2">4. </p>
{/* 4-1. 가이드레일 */}
<div className="mb-3">
<p className="text-[10px] font-medium mb-1">4-1. - EGI 1.5ST + EGI 1.1ST + SUS 1.1ST</p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-32`}> (120X70)</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{MOCK_GUIDE_RAIL_ITEMS.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
{i === 0 && (
<td className={tdCenter} rowSpan={MOCK_GUIDE_RAIL_ITEMS.length}>
<div className={`${imgPlaceholder} h-20 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
{/* 연기차단재 */}
<div className="mt-1 border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-50 border-b border-gray-400 text-[10px]">
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
<tr className="border-b border-gray-300">
<td className={tdCenter}>
<div className={`${imgPlaceholder} h-14 w-full`}>IMG</div>
</td>
<td className={tdCenter}>{MOCK_GUIDE_SMOKE.name}</td>
<td className={tdCenter}>{MOCK_GUIDE_SMOKE.spec}</td>
<td className="px-1 py-1 text-center">{MOCK_GUIDE_SMOKE.qty}</td>
</tr>
</tbody>
</table>
</div>
<p className="mt-1 text-[10px]">
<span className="font-medium">* <span className="text-red-600 font-bold"></span> </span> - EGI 0.8T +
</p>
</div>
{/* 4-2. 케이스(셔터박스) */}
<div className="mb-3">
<p className="text-[10px] font-medium mb-1">4-2. () - EGI 1.5ST</p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{MOCK_CASE_ITEMS.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
{i === 0 && (
<td className={tdCenter} rowSpan={MOCK_CASE_ITEMS.length}>
<div className={`${imgPlaceholder} h-24 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
{/* 연기차단재 */}
<div className="mt-1 border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-50 border-b border-gray-400 text-[10px]">
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
<tr className="border-b border-gray-300">
<td className={tdCenter}>
<div className={`${imgPlaceholder} h-14 w-full`}>IMG</div>
</td>
<td className={tdCenter}>{MOCK_CASE_SMOKE.name}</td>
<td className={tdCenter}>{MOCK_CASE_SMOKE.spec}</td>
<td className="px-1 py-1 text-center">{MOCK_CASE_SMOKE.qty}</td>
</tr>
</tbody>
</table>
</div>
<p className="mt-1 text-[10px]">
<span className="font-medium">* , <span className="text-red-600 font-bold"></span> </span> - EGI 0.8T +
</p>
</div>
{/* 4-3. 하단마감재 (토글: 스크린 / 절재) */}
<div className="mb-3">
<div className="flex items-center gap-2 mb-2">
<button
onClick={() => setBottomFinishView('screen')}
className={`px-3 py-1 text-[10px] font-bold border rounded ${
bottomFinishView === 'screen'
? 'bg-gray-800 text-white border-gray-800'
: 'bg-white text-gray-600 border-gray-400 hover:bg-gray-100'
}`}
>
#
</button>
<button
onClick={() => setBottomFinishView('steel')}
className={`px-3 py-1 text-[10px] font-bold border rounded ${
bottomFinishView === 'steel'
? 'bg-gray-800 text-white border-gray-800'
: 'bg-white text-gray-600 border-gray-400 hover:bg-gray-100'
}`}
>
#
</button>
</div>
{bottomFinishView === 'screen' ? (
<>
<p className="text-[10px] font-medium mb-1">
4-3. - (EGI 1.5ST) + (EGI 1.5ST) + (EGI 1.1ST) + (50X12T)
</p>
{/* 4-1. 가이드레일 */}
{guideRailItems.length > 0 && (
<div className="mb-3">
<p className="text-[10px] font-medium mb-1">4-1. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-14`}></th>
<th className={`${thBase} w-16`}></th>
<th className={`${thBase} w-10`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-14`}></th>
<th className={`${thBase} w-16`}></th>
<th className="px-1 py-1 w-10"></th>
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{MOCK_BOTTOM_SCREEN.map((row, i) => (
{guideRailItems.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
<td className={tdBase}>{row.name}</td>
<td className={tdCenter}>{row.spec}</td>
<td className={tdCenter}>{row.l1}</td>
<td className={tdCenter}>{row.q1}</td>
<td className={tdBase}>{row.name2}</td>
<td className={tdCenter}>{row.spec2}</td>
<td className={tdCenter}>{row.l2}</td>
<td className="px-1 py-1 text-center">{row.q2}</td>
{i === 0 && (
<td className={tdCenter} rowSpan={guideRailItems.length}>
<div className={`${imgPlaceholder} h-20 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
</>
) : (
<>
<p className="text-[10px] font-medium mb-1">
4-3. -EGI 1.5ST
{/* 가이드레일 연기차단재 */}
{guideSmokeItems.length > 0 && (
<div className="mt-1 border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-50 border-b border-gray-400 text-[10px]">
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{guideSmokeItems.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
{i === 0 && (
<td className={tdCenter} rowSpan={guideSmokeItems.length}>
<div className={`${imgPlaceholder} h-14 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
<p className="mt-1 text-[10px]">
<span className="font-medium">* <span className="text-red-600 font-bold"></span> </span> - EGI 0.8T +
</p>
</div>
)}
{/* 4-2. 케이스(셔터박스) */}
{caseItems.length > 0 && (
<div className="mb-3">
<p className="text-[10px] font-medium mb-1">4-2. ()</p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-32`}></th>
<th className={`${thBase} w-14`}></th>
<th className={`${thBase} w-16`}></th>
<th className="px-1 py-1 w-10"></th>
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
<tr className="border-b border-gray-300">
<td className={tdCenter}>
<div className={`${imgPlaceholder} h-16 w-full`}>IMG</div>
</td>
<td className={tdCenter}>{MOCK_BOTTOM_STEEL.spec}</td>
<td className={tdCenter}>{MOCK_BOTTOM_STEEL.length}</td>
<td className="px-1 py-1 text-center">{MOCK_BOTTOM_STEEL.qty}</td>
</tr>
{caseItems.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
{i === 0 && (
<td className={tdCenter} rowSpan={caseItems.length}>
<div className={`${imgPlaceholder} h-24 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
</>
{/* 케이스 연기차단재 */}
{caseSmokeItems.length > 0 && (
<div className="mt-1 border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-50 border-b border-gray-400 text-[10px]">
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{caseSmokeItems.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
{i === 0 && (
<td className={tdCenter} rowSpan={caseSmokeItems.length}>
<div className={`${imgPlaceholder} h-14 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
<p className="mt-1 text-[10px]">
<span className="font-medium">* , <span className="text-red-600 font-bold"></span> </span> - EGI 0.8T +
</p>
</div>
)}
{/* 4-3. 하단마감재 */}
{bottomItems.length > 0 && (
<div className="mb-3">
<p className="text-[10px] font-medium mb-1">4-3. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-32`}>&nbsp;</th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{bottomItems.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
{i === 0 && (
<td className={tdCenter} rowSpan={bottomItems.length}>
<div className={`${imgPlaceholder} h-16 w-full`}>IMG</div>
</td>
)}
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
{/* 연기차단재 (구분 불가) */}
{otherSmokeItems.length > 0 && (
<div className="mb-3">
<p className="text-[10px] font-medium mb-1"></p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-50 border-b border-gray-400 text-[10px]">
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-14"></th>
</tr>
</thead>
<tbody>
{otherSmokeItems.map((item, i) => (
<tr key={i} className="border-b border-gray-300">
<td className={tdCenter}>{item.name}</td>
<td className={tdCenter}>{item.spec}</td>
<td className="px-1 py-1 text-center">{item.qty}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
)}
</div>
</div>
)}
{/* ========== 5. 부자재 ========== */}
<div className="mb-4">
<p className="font-bold mb-2">5. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-10`}></th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-10"></th>
</tr>
</thead>
<tbody>
{MOCK_SUBSIDIARY.map((row, i) => (
<tr key={i} className="border-b border-gray-300">
<td className={tdBase}>{row.leftItem}</td>
<td className={tdCenter}>{row.leftSpec}</td>
<td className={tdCenter}>{row.leftQty}</td>
<td className={tdBase}>{row.rightItem}</td>
<td className={tdCenter}>{row.rightSpec}</td>
<td className="px-1 py-1 text-center">{row.rightQty}</td>
{subsidiaryParts.length > 0 && (
<div className="mb-4">
<p className="font-bold mb-2">5. </p>
<div className="border border-gray-400">
<table className="w-full">
<thead>
<tr className="bg-gray-100 border-b border-gray-400">
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className={`${thBase} w-10`}></th>
<th className={`${thBase} w-24`}></th>
<th className={`${thBase} w-20`}></th>
<th className="px-1 py-1 w-10"></th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{subsidiaryRows.map((row, i) => (
<tr key={i} className="border-b border-gray-300">
<td className={tdBase}>{row.left?.name ?? ''}</td>
<td className={tdCenter}>{row.left?.spec ?? ''}</td>
<td className={tdCenter}>{row.left?.qty ?? ''}</td>
<td className={tdBase}>{row.right?.name ?? ''}</td>
<td className={tdCenter}>{row.right?.spec ?? ''}</td>
<td className="px-1 py-1 text-center">{row.right?.qty ?? ''}</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
</div>
)}
{/* ========== 특이사항 ========== */}
{remarks && (
@@ -636,4 +657,4 @@ export function SalesOrderDocument({
)}
</div>
);
}
}

View File

@@ -162,12 +162,7 @@ export function PricingListClient({
// 네비게이션 핸들러
const handleRegister = (item: PricingListItem) => {
// item_type_code는 품목 정보에서 자동으로 가져오므로 URL에 포함하지 않음
const params = new URLSearchParams();
params.set('mode', 'new');
if (item.itemId) params.set('itemId', item.itemId);
if (item.itemCode) params.set('itemCode', item.itemCode);
router.push(`/sales/pricing-management?${params.toString()}`);
router.push(`/sales/pricing-management/create?itemId=${item.itemId}`);
};
const handleEdit = (item: PricingListItem) => {
@@ -221,12 +216,12 @@ export function PricingListClient({
) => {
const { isSelected, onToggle } = handlers;
// 행 클릭 핸들러: 등록되지 않은 항목은 등록, 등록된 항목은 수정
// 행 클릭 핸들러: 등록되지 않은 항목은 등록, 등록된 항목은 상세 조회
const handleRowClick = () => {
if (item.status === 'not_registered') {
handleRegister(item);
} else {
handleEdit(item);
router.push(`/sales/pricing-management/${item.id}`);
}
};
@@ -310,7 +305,7 @@ export function PricingListClient({
statusBadge={renderStatusBadge(item)}
isSelected={isSelected}
onToggleSelection={onToggle}
onCardClick={() => item.status !== 'not_registered' ? handleEdit(item) : handleRegister(item)}
onCardClick={() => item.status !== 'not_registered' ? router.push(`/sales/pricing-management/${item.id}`) : handleRegister(item)}
infoGrid={
<div className="grid grid-cols-2 gap-x-4 gap-y-3">
{item.specification && (

View File

@@ -171,7 +171,7 @@ export async function getPricingById(id: string): Promise<PricingData | null> {
}
export async function getItemInfo(itemId: string): Promise<ItemInfo | null> {
interface ItemApiItem { id: number; code: string; name: string; item_type: string; specification?: string; unit?: string }
interface ItemApiItem { id: number; item_code: string; code?: string; name: string; item_type: string; specification?: string; unit?: string }
const result = await executeServerAction<ItemApiItem>({
url: `${API_URL}/api/v1/items/${itemId}`,
errorMessage: '품목 조회에 실패했습니다.',
@@ -179,7 +179,7 @@ export async function getItemInfo(itemId: string): Promise<ItemInfo | null> {
if (!result.success || !result.data) return null;
const item = result.data;
return {
id: String(item.id), itemCode: item.code, itemName: item.name,
id: String(item.id), itemCode: item.item_code || item.code || '', itemName: item.name,
itemType: item.item_type || 'PT', specification: item.specification || undefined, unit: item.unit || 'EA',
};
}
@@ -243,10 +243,17 @@ export async function finalizePricing(id: string): Promise<{ success: boolean; d
interface ItemApiData {
id: number;
item_type: string; // FG, PT, SM, RM, CS (품목 유형)
code: string;
item_code?: string;
code?: string;
name: string;
specification?: string;
unit: string;
category_id: number | null;
attributes?: {
salesPrice?: number;
purchasePrice?: number;
[key: string]: unknown;
} | null;
created_at: string;
deleted_at: string | null;
}
@@ -330,11 +337,11 @@ export async function getPricingListData(): Promise<PricingListItem[]> {
const [itemsResult, pricingResult] = await Promise.all([
executeServerAction<ItemsPaginatedResponse>({
url: `${API_URL}/api/v1/items?group_id=1&size=100`,
url: `${API_URL}/api/v1/items?group_id=1&size=10000`,
errorMessage: '품목 목록 조회에 실패했습니다.',
}),
executeServerAction<PricingPaginatedResponse>({
url: `${API_URL}/api/v1/pricing?size=100`,
url: `${API_URL}/api/v1/pricing?size=10000`,
errorMessage: '단가 목록 조회에 실패했습니다.',
}),
]);
@@ -354,10 +361,13 @@ export async function getPricingListData(): Promise<PricingListItem[]> {
const key = `${item.item_type}_${item.id}`;
const pricing = pricingMap.get(key);
const itemCode = item.item_code || item.code || '';
const specification = item.specification || undefined;
if (pricing) {
return {
id: String(pricing.id), itemId: String(item.id), itemCode: item.code, itemName: item.name,
itemType: mapItemTypeForList(item.item_type), specification: undefined, unit: item.unit || 'EA',
id: String(pricing.id), itemId: String(item.id), itemCode, itemName: item.name,
itemType: mapItemTypeForList(item.item_type), specification, unit: item.unit || 'EA',
purchasePrice: pricing.purchase_price ? parseFloat(pricing.purchase_price) : undefined,
processingCost: pricing.processing_cost ? parseFloat(pricing.processing_cost) : undefined,
salesPrice: pricing.sales_price ? parseFloat(pricing.sales_price) : undefined,
@@ -367,10 +377,15 @@ export async function getPricingListData(): Promise<PricingListItem[]> {
currentRevision: 0, isFinal: pricing.is_final, itemTypeCode: item.item_type,
};
} else {
// prices 미등록 → items.attributes에서 참고 단가 표시
const attrSalesPrice = item.attributes?.salesPrice ? Number(item.attributes.salesPrice) : undefined;
const attrPurchasePrice = item.attributes?.purchasePrice ? Number(item.attributes.purchasePrice) : undefined;
return {
id: `item_${item.id}`, itemId: String(item.id), itemCode: item.code, itemName: item.name,
itemType: mapItemTypeForList(item.item_type), specification: undefined, unit: item.unit || 'EA',
purchasePrice: undefined, processingCost: undefined, salesPrice: undefined, marginRate: undefined,
id: `item_${item.id}`, itemId: String(item.id), itemCode, itemName: item.name,
itemType: mapItemTypeForList(item.item_type), specification, unit: item.unit || 'EA',
purchasePrice: attrPurchasePrice, processingCost: undefined,
salesPrice: attrSalesPrice, marginRate: undefined,
effectiveDate: undefined, status: 'not_registered' as const,
currentRevision: 0, isFinal: false, itemTypeCode: item.item_type,
};

View File

@@ -13,3 +13,4 @@ export type { InspectionContentRef } from './ScreenInspectionContent';
// 모달
export { InspectionReportModal } from './InspectionReportModal';
export { WorkLogModal } from './WorkLogModal';