49956f7afa
사용자 보고: "품명/3D 컬럼이 좁아서 겹쳐 보임 + 폴더 모양(파랑/투명)으로 표시해줘"
운영판 wace 견적현황·partMng 폴더 아이콘 패턴 1:1 적용:
- 값 > 0 → 파란 폴더 (fill-[#1a73e8])
- 값 = 0 → 흰색 폴더 (투명 효과, fill-white + muted text)
수정:
- app/(main)/COMPANY_16/development/part-regist/page.tsx — 3D/2D/PDF (60→70px, center, folder)
- app/(main)/COMPANY_16/development/part-search/page.tsx — 3D/2D/PDF (60→70px, center, folder)
- app/(main)/COMPANY_16/development/ebom-search/page.tsx — 3D/2D/PDF (60→70px width 통일)
- components/development/BomReportTreeDialog.tsx — "Y/공백" → FolderCell
- components/production/MbomDetailDialog.tsx — "Y/공백" → FolderCell
sales/{order,sale,revenue}.tsx 의 cu01_cnt 는 "주문서첨부" clip 아이콘이라 별 의미라 미수정.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
247 lines
10 KiB
TypeScript
247 lines
10 KiB
TypeScript
"use client";
|
|
|
|
// 개발관리 > PART 등록 (M1) — wace partMngTempList.jsp 1:1
|
|
// 그리드: status != 'release' 인 PART 23셀
|
|
// 액션: 등록 / 수정 / 삭제 / 확정 / 조회
|
|
// 참조: docs/migration/development/01-part.md
|
|
|
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
import { Button } from "@/components/ui/button";
|
|
import { PageHeader } from "@/components/common/PageHeader";
|
|
import { CompactFilterBar, CompactFilterField } from "@/components/common/CompactFilterBar";
|
|
import {
|
|
Plus, Pencil, Trash2, CheckSquare, FileSpreadsheet,
|
|
} from "lucide-react";
|
|
import { toast } from "sonner";
|
|
import { DataGrid, DataGridColumn } from "@/components/common/DataGrid";
|
|
import { devPartApi, PartListFilter, PartRow } from "@/lib/api/devPart";
|
|
import { PartFormDialog } from "@/components/development/PartFormDialog";
|
|
import { PartDetailDialog } from "@/components/development/PartDetailDialog";
|
|
import { PartExcelImportDialog } from "@/components/development/PartExcelImportDialog";
|
|
import { PartDrawingMultiUploadButton } from "@/components/development/PartDrawingMultiUploadButton";
|
|
import { DevPartSelect } from "@/components/development/DevPartSelect";
|
|
|
|
// wace 23셀 + 부속 (PARENT_PART_INFO/PARTNER_TITLE/Q_QTY)
|
|
const GRID_COLUMNS: DataGridColumn[] = [
|
|
{ key: "part_no", label: "품번", width: "w-[140px]", frozen: true },
|
|
{ key: "part_name", label: "품명", minWidth: "min-w-[220px]" },
|
|
{ key: "cu01_cnt", label: "3D", width: "w-[70px]", align: "center", renderType: "folder" },
|
|
{ key: "cu02_cnt", label: "2D", width: "w-[70px]", align: "center", renderType: "folder" },
|
|
{ key: "cu03_cnt", label: "PDF", width: "w-[70px]", align: "center", renderType: "folder" },
|
|
{ key: "material", label: "재료", width: "w-[100px]" },
|
|
{ key: "heat_treatment_hardness", label: "열처리경도", width: "w-[110px]" },
|
|
{ key: "heat_treatment_method", label: "열처리방법", width: "w-[110px]" },
|
|
{ key: "surface_treatment", label: "표면처리", width: "w-[100px]" },
|
|
{ key: "maker", label: "메이커", width: "w-[100px]" },
|
|
{ key: "part_type_title", label: "범주", width: "w-[100px]" },
|
|
{ key: "spec", label: "규격", width: "w-[140px]" },
|
|
{ key: "acctfg_nm", label: "계정구분", width: "w-[80px]", align: "center" },
|
|
{ key: "odrfg_nm", label: "조달구분", width: "w-[80px]", align: "center" },
|
|
{ key: "unit_dc_nm", label: "재고단위", width: "w-[80px]", align: "center" },
|
|
{ key: "unitmang_dc_nm", label: "관리단위", width: "w-[80px]", align: "center" },
|
|
{ key: "unitchng_nb", label: "환산수량", width: "w-[90px]", align: "right", formatNumber: true },
|
|
{ key: "lot_fg_nm", label: "LOT구분", width: "w-[80px]", align: "center" },
|
|
{ key: "use_yn_nm", label: "사용여부", width: "w-[80px]", align: "center" },
|
|
{ key: "qc_fg_nm", label: "검사여부", width: "w-[80px]", align: "center" },
|
|
{ key: "setitem_fg_nm", label: "SET품여부", width: "w-[90px]", align: "center" },
|
|
{ key: "req_fg_nm", label: "의뢰여부", width: "w-[80px]", align: "center" },
|
|
{ key: "unit_length", label: "개당길이", width: "w-[90px]", align: "right" },
|
|
{ key: "unit_qty", label: "개당수량", width: "w-[90px]", align: "right" },
|
|
// M1 부속
|
|
{ key: "partner_title", label: "공급업체(시퀀스)", minWidth: "min-w-[180px]" },
|
|
{ key: "parent_part_info", label: "상위 품번", width: "w-[120px]" },
|
|
{ key: "q_qty", label: "수량(BOM)", width: "w-[90px]", align: "right" },
|
|
{ key: "revision", label: "REV", width: "w-[60px]", align: "center" },
|
|
{ key: "status", label: "상태", width: "w-[80px]", align: "center" },
|
|
];
|
|
|
|
const EMPTY_FILTER: PartListFilter = {
|
|
search_part_no: "", search_part_name: "",
|
|
page: 1, page_size: 50,
|
|
};
|
|
|
|
export default function PartRegistPage() {
|
|
const [rows, setRows] = useState<PartRow[]>([]);
|
|
const [total, setTotal] = useState(0);
|
|
const [loading, setLoading] = useState(false);
|
|
const [filter, setFilter] = useState<PartListFilter>(EMPTY_FILTER);
|
|
const [checkedIds, setCheckedIds] = useState<string[]>([]);
|
|
|
|
// 다이얼로그 상태
|
|
const [formOpen, setFormOpen] = useState(false);
|
|
const [formMode, setFormMode] = useState<"create" | "edit">("create");
|
|
const [formObjid, setFormObjid] = useState<string | null>(null);
|
|
const [detailOpen, setDetailOpen] = useState(false);
|
|
const [detailObjid, setDetailObjid] = useState<string | null>(null);
|
|
const [excelOpen, setExcelOpen] = useState(false);
|
|
|
|
const fetchList = useCallback(async (override?: Partial<PartListFilter>) => {
|
|
setLoading(true);
|
|
try {
|
|
const f = { ...filter, ...override };
|
|
const res = await devPartApi.listTemp(f);
|
|
setRows(res.rows ?? []);
|
|
setTotal(res.total ?? 0);
|
|
setCheckedIds([]);
|
|
} catch (e: any) {
|
|
toast.error(e?.response?.data?.message ?? e?.message ?? "조회 실패");
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
}, [filter]);
|
|
|
|
useEffect(() => { fetchList(); /* eslint-disable-next-line */ }, []);
|
|
|
|
// 행 더블클릭 → 상세 다이얼로그
|
|
const columns = useMemo(
|
|
() => GRID_COLUMNS.map((c) =>
|
|
c.key === "part_no"
|
|
? { ...c, onClick: (row: any) => { setDetailObjid(row.objid); setDetailOpen(true); } }
|
|
: c,
|
|
),
|
|
[],
|
|
);
|
|
|
|
// DataGrid 는 row.id 를 키로 사용 — backend 응답은 row.objid 이므로 매핑
|
|
const gridRows = useMemo(() => rows.map((r) => ({ ...r, id: r.objid })), [rows]);
|
|
|
|
// 등록
|
|
const handleCreate = () => {
|
|
setFormMode("create");
|
|
setFormObjid(null);
|
|
setFormOpen(true);
|
|
};
|
|
|
|
// 수정 (단일 선택 필요)
|
|
const handleEdit = () => {
|
|
if (checkedIds.length !== 1) return toast.error("수정할 행 1개를 선택하세요.");
|
|
setFormMode("edit");
|
|
setFormObjid(checkedIds[0]);
|
|
setFormOpen(true);
|
|
};
|
|
|
|
// 삭제 (다중)
|
|
const handleDelete = async () => {
|
|
if (checkedIds.length === 0) return toast.error("선택된 행이 없습니다.");
|
|
if (!confirm(`${checkedIds.length}건을 삭제하시겠습니까?`)) return;
|
|
try {
|
|
const res = await devPartApi.remove(checkedIds);
|
|
toast.success(res?.message ?? "삭제되었습니다.");
|
|
fetchList();
|
|
} catch (e: any) {
|
|
toast.error(e?.response?.data?.message ?? e?.message ?? "삭제 실패");
|
|
}
|
|
};
|
|
|
|
// 확정 (M1 → M2): EO_NO 채번 + part_mng_history 이력
|
|
const handleDeploy = async () => {
|
|
if (checkedIds.length === 0) return toast.error("확정할 행을 선택하세요.");
|
|
if (!confirm(`${checkedIds.length}건을 확정하시겠습니까? (M1 → M2)`)) return;
|
|
try {
|
|
const res = await devPartApi.deploy(checkedIds);
|
|
toast.success(`${res.deployed}건이 확정되었습니다.`);
|
|
fetchList();
|
|
} catch (e: any) {
|
|
toast.error(e?.response?.data?.message ?? e?.message ?? "확정 실패");
|
|
}
|
|
};
|
|
|
|
// 상세 → 수정 전환
|
|
const handleEditFromDetail = (objid: string) => {
|
|
setDetailOpen(false);
|
|
setFormMode("edit");
|
|
setFormObjid(objid);
|
|
setFormOpen(true);
|
|
};
|
|
|
|
return (
|
|
<div className="flex h-full flex-col gap-2 p-2">
|
|
<PageHeader
|
|
loading={loading}
|
|
onSearch={() => fetchList()}
|
|
onReset={() => { setFilter(EMPTY_FILTER); fetchList(EMPTY_FILTER); }}
|
|
actions={
|
|
<>
|
|
<Button size="sm" className="h-8 gap-1 text-xs" onClick={handleCreate}>
|
|
<Plus className="h-3.5 w-3.5" />등록
|
|
</Button>
|
|
<Button size="sm" variant="secondary" className="h-8 gap-1 text-xs" onClick={handleEdit}
|
|
disabled={checkedIds.length !== 1}>
|
|
<Pencil className="h-3.5 w-3.5" />수정
|
|
</Button>
|
|
<Button size="sm" variant="destructive" className="h-8 gap-1 text-xs" onClick={handleDelete}
|
|
disabled={checkedIds.length === 0}>
|
|
<Trash2 className="h-3.5 w-3.5" />삭제
|
|
</Button>
|
|
<Button size="sm" variant="outline" className="h-8 gap-1 text-xs" onClick={() => setExcelOpen(true)}>
|
|
<FileSpreadsheet className="h-3.5 w-3.5" />Excel Upload
|
|
</Button>
|
|
<PartDrawingMultiUploadButton
|
|
partNoList={rows.map((r) => r.part_no).filter(Boolean) as string[]}
|
|
onUploaded={() => fetchList()}
|
|
/>
|
|
<Button size="sm" onClick={handleDeploy}
|
|
disabled={checkedIds.length === 0}
|
|
className="h-8 gap-1 bg-emerald-600 hover:bg-emerald-700 text-white text-xs">
|
|
<CheckSquare className="h-3.5 w-3.5" />확정
|
|
</Button>
|
|
</>
|
|
} />
|
|
|
|
<CompactFilterBar totalText={<>총 {total.toLocaleString()}건 (M1: status ≠ 'release')</>}>
|
|
<CompactFilterField label="품번" width={220}>
|
|
<DevPartSelect mode="partNo"
|
|
value={filter.search_part_no ?? ""}
|
|
onValueChange={(v, row) => setFilter((prev) => ({
|
|
...prev,
|
|
search_part_no: v,
|
|
search_part_name: row?.part_name ?? prev.search_part_name,
|
|
}))} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="품명" width={220}>
|
|
<DevPartSelect mode="partName"
|
|
value={filter.search_part_name ?? ""}
|
|
onValueChange={(v, row) => setFilter((prev) => ({
|
|
...prev,
|
|
search_part_name: v,
|
|
search_part_no: row?.part_no ?? prev.search_part_no,
|
|
}))} />
|
|
</CompactFilterField>
|
|
</CompactFilterBar>
|
|
|
|
<div className="min-h-0 flex-1">
|
|
<DataGrid
|
|
columns={columns}
|
|
data={gridRows}
|
|
loading={loading}
|
|
showRowNumber
|
|
showCheckbox
|
|
checkedIds={checkedIds}
|
|
onCheckedChange={setCheckedIds}
|
|
emptyMessage="조건에 맞는 PART가 없습니다."
|
|
gridId="development-part-regist"
|
|
/>
|
|
</div>
|
|
|
|
<PartFormDialog
|
|
open={formOpen}
|
|
onOpenChange={setFormOpen}
|
|
mode={formMode}
|
|
editObjid={formObjid}
|
|
onSaved={fetchList}
|
|
/>
|
|
<PartDetailDialog
|
|
open={detailOpen}
|
|
onOpenChange={setDetailOpen}
|
|
objid={detailObjid}
|
|
onEdit={handleEditFromDetail}
|
|
/>
|
|
<PartExcelImportDialog
|
|
open={excelOpen}
|
|
onOpenChange={setExcelOpen}
|
|
onSaved={fetchList}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|