Files
wace_rps/frontend/lib/api/devBom.ts
T
hjjeong 20a429eecb 개발관리>E-BOM 화면 운영판 1:1 정정 다수 — 검색폼·상태변경·체크박스·STATUS 표시
사용자 검증으로 발견된 5가지 함정 일괄 정정.

(1) ebom-search 검색폼 운영판 1:1 — wace structureAscendingList.jsp 노출 필드만:
   - 제거: 프로젝트 OBJID (raw input), UNIT_CODE (raw input)
     운영판도 고객사/프로젝트번호/유닛명 모두 주석 처리되어 노출 안 됨
   - 유지: 품번 / 품명 / 표시 레벨 (1~5 select)
   - BomTreeFilter.search_level 추가 + ascending/descending CTE 에 T.lev <= $search_level::int

(2) 품번/품명 자동완성 (wace select2-part 1:1):
   - 영업관리 PartSelect 는 item_info 마스터 기반 → 개발관리(part_mng)용 별도 컴포넌트 신설
   - backend GET /api/development/part/options : IS_LAST='1' part_mng 전체 (영업관리 sales/parts 패턴)
   - frontend DevPartSelect.tsx : SmartSelect 캐시 + mode partNo/partName 분리
   - ebom-search 페이지 단순 Input → DevPartSelect 교체
   - 품번 선택 시 품명 자동 채움 / 품명 선택 시 품번 자동 채움 (운영판 select2-part 1:1)

(3) BomReportStatusDialog 운영판 1:1 재작성 — wace structureStatusChangePopup.jsp:
   - 잘못된 점: read-only 박스 + 상태 select(create/changeDesign/deploy 3옵션)
   - 정정: 5필드 모두 편집 가능 (CommCodeSelect 제품구분 / 품번 input / 품명 input /
           Version input / 상태 Y/N 라디오) — 운영 매퍼 updateStructureStatus 5컬럼 UPDATE 1:1
   - 헤더 파란 바 + 4컬럼 테이블(25%/75%) + 저장/닫기 중앙 배치 (운영판 스타일 1:1)

(4) DataGrid id 매핑 — 체크박스 ID 키 불일치 함정:
   - DataGrid 는 row.id 로 체크박스 ID 관리, 백엔드 응답은 row.objid (postgres lowercase)
   - 결과: checkedIds[0] 가 undefined → 상태변경/수정/삭제 다이얼로그가 objid=undefined 로 열려
     detail 호출 안 됨 → 빈 폼 표시 (사용자 지적 "기본 정보 표시 안됨")
   - 일괄 수정 (3 페이지) : ebom-regist / part-regist / part-search
     gridRows = useMemo(() => rows.map(r => ({ ...r, id: r.objid })), [rows])
     영업관리 페이지 동일 패턴 1:1

(5) STATUS_TITLE 매핑 운영판 1:1 — 운영 그리드는 'Y'/'N' 글자 그대로 표시:
   CASE UPPER(T.STATUS)
     WHEN 'CREATE' THEN '등록중'
     WHEN 'CHANGEDESIGN' THEN '설계변경미배포'
     WHEN 'DEPLOY' THEN '배포완료'
     ELSE COALESCE(T.STATUS, '') END AS STATUS_TITLE
   - 운영 매퍼는 ELSE '' 이지만 RPS 는 raw fallback (사용자 화면에서 식별 가능)
   - 'Y'/'N' 매핑 라벨 추가 → 운영 스크린샷 확인 후 제거 (운영판은 raw)

미해결 (별 작업):
- 확정일 (DEPLOY_DATE) 표시 — 운영판은 별도 "배포" 액션 (deployBomReport 매퍼) 으로 채움.
  RPS ebom-regist 에 배포 버튼 미구현 → 신규 BOM 확정일 빈값. 별 PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 11:43:29 +09:00

305 lines
9.0 KiB
TypeScript

import { apiClient } from "./client";
// Content-Disposition 의 filename / filename* 파싱 (UTF-8 인코딩 우선)
function extractFileName(cd: string | undefined): string | null {
if (!cd) return null;
const utf8 = /filename\*=UTF-8''([^;]+)/i.exec(cd);
if (utf8 && utf8[1]) {
try { return decodeURIComponent(utf8[1]); } catch { /* fallthrough */ }
}
const plain = /filename="?([^";]+)"?/i.exec(cd);
if (plain && plain[1]) {
try { return decodeURIComponent(plain[1]); } catch { return plain[1]; }
}
return null;
}
// ============================================================
// 개발관리 E-BOM (M3 등록 / M4 조회) — wace partMng.xml 1:1
// 라우트: /api/development/ebom/*, /api/development/ebom-tree/*
// ============================================================
export interface BomReportListFilter {
customer_cd?: string;
project_name?: string;
unit_code?: string;
search_unit_name?: string;
search_writer?: string;
product_cd?: string;
search_part_no?: string;
search_part_name?: string;
search_from_date?: string;
search_to_date?: string;
status?: string;
page?: number;
page_size?: number;
}
export interface BomReportRow {
num: number | string;
objid: string;
customer_objid: string | null;
customer_name: string | null;
contract_objid: string | null;
customer_project_name: string | null;
project_no: string | null;
unit_code: string | null;
unit_name: string | null;
status: string | null;
status_title: string | null;
writer: string | null;
dept_name: string | null;
user_name: string | null;
dept_user_name: string | null;
regdate: string | null;
reg_date: string | null;
deploy_date: string | null;
revision: string | null;
eo_no: string | null;
eo_date: string | null;
note: string | null;
multi_yn: string | null;
multi_master_yn: string | null;
multi_break_yn: string | null;
multi_master_objid: string | null;
bom_cnt: number | string | null;
product_cd: string | null;
product_name: string | null;
part_no: string | null;
part_name: string | null;
}
export interface BomReportListResponse {
rows: BomReportRow[];
total: number;
page: number;
pageSize: number;
}
export interface BomReportStatusBody {
product_cd?: string;
part_no?: string;
part_name?: string;
version?: string;
status: string;
}
export interface BomTreeFilter {
bom_report_objid?: string;
project_name?: string;
unit_code?: string;
search_part_no?: string;
search_part_name?: string;
search_level?: string | number; // wace 1:1 — 1~5 표시 레벨
}
export interface BomTreeRow {
bom_report_objid: string | null;
objid: string;
parent_objid: string | null;
child_objid: string | null;
part_no: string | null; // bom_part_qty.part_no (= part_mng.objid)
qty: string | null;
seq: number | string | null;
status: string | null;
lev: number;
path: string[] | null;
// part_mng JOIN
pm_part_no: string | null;
pm_part_name: string | null;
spec: string | null;
material: string | null;
weight: string | null;
remark: string | null;
edit_date: string | null;
eo_no: string | null;
revision: string | null;
cu01_cnt: number | string | null;
cu02_cnt: number | string | null;
cu03_cnt: number | string | null;
max_level: number | string | null;
}
export interface BomTreeResponse {
rows: BomTreeRow[];
max_level: number;
}
// 트리 풀 컬럼 (ascendingForExcel 1:1) — BomReportTreeDialog 용
export interface BomTreeFullRow {
lev: number | string;
pm_part_no: string | null;
pm_part_name: string | null;
qty: string | number | null;
p_qty: string | number | null;
material: string | null;
remark: string | null;
heat_treatment_hardness: string | null;
heat_treatment_method: string | null;
surface_treatment: string | null;
maker: string | null;
part_type: string | null;
part_type_title: string | null;
cu01_cnt: number | string | null;
cu02_cnt: number | string | null;
cu03_cnt: number | string | null;
}
export interface BomTreeFullResponse {
rows: BomTreeFullRow[];
max_level: number;
}
// ─── API ─────────────────────────────────────────────────
export const devBomApi = {
// M3 그리드
async list(filter: BomReportListFilter = {}): Promise<BomReportListResponse> {
const res = await apiClient.get("/development/ebom/list", { params: filter });
return res.data?.data as BomReportListResponse;
},
async detail(objid: string): Promise<BomReportRow | null> {
const res = await apiClient.get(`/development/ebom/${objid}`);
return res.data?.data ?? null;
},
async updateStatus(objid: string, body: BomReportStatusBody) {
return (await apiClient.put(`/development/ebom/${objid}/status`, body)).data;
},
async remove(objids: string[]) {
const res = await apiClient.delete("/development/ebom", { data: { objids } });
return res.data;
},
// M4
async ascending(filter: BomTreeFilter): Promise<BomTreeResponse> {
const res = await apiClient.get("/development/ebom-tree/ascending", { params: filter });
return res.data?.data as BomTreeResponse;
},
async descending(filter: BomTreeFilter): Promise<BomTreeResponse> {
const res = await apiClient.get("/development/ebom-tree/descending", { params: filter });
return res.data?.data as BomTreeResponse;
},
// E-BOM 트리 (풀 컬럼) — M3 그리드 행 클릭 → BomReportTreeDialog
async treeFull(filter: BomTreeFilter): Promise<BomTreeFullResponse> {
const res = await apiClient.get("/development/ebom-tree/full", { params: filter });
return res.data?.data as BomTreeFullResponse;
},
// M4 엑셀 다운로드 (정/역전개) — wace 1:1
async excelAscending(filter: BomTreeFilter): Promise<{ blob: Blob; fileName: string }> {
const res = await apiClient.get("/development/ebom-tree/ascending/excel", {
params: filter, responseType: "blob",
});
return { blob: res.data as Blob, fileName: extractFileName(res.headers?.["content-disposition"]) ?? "BOM_ascending.xlsx" };
},
async excelDescending(filter: BomTreeFilter): Promise<{ blob: Blob; fileName: string }> {
const res = await apiClient.get("/development/ebom-tree/descending/excel", {
params: filter, responseType: "blob",
});
return { blob: res.data as Blob, fileName: extractFileName(res.headers?.["content-disposition"]) ?? "BOM_descending.xlsx" };
},
// Excel Import
async excelParse(file: File): Promise<BomExcelParseResponse> {
const fd = new FormData();
fd.append("file", file);
const res = await apiClient.post("/development/ebom/excel-parse", fd, {
headers: { "Content-Type": "multipart/form-data" },
});
return res.data?.data as BomExcelParseResponse;
},
async excelCheckDuplicate(partNo: string, exclude?: string): Promise<boolean> {
const res = await apiClient.get("/development/ebom/excel-check-duplicate", {
params: { partNo, exclude },
});
return !!res.data?.data?.isDuplicate;
},
async excelCopySource(productCd?: string): Promise<BomCopySourceRow[]> {
const res = await apiClient.get("/development/ebom/excel-copy-source", {
params: productCd ? { productCd } : undefined,
});
return (res.data?.data as BomCopySourceRow[]) ?? [];
},
async excelCopy(objid: string): Promise<BomCsvRow[]> {
const res = await apiClient.get(`/development/ebom/excel-copy/${objid}`);
return ((res.data?.data?.rows as BomCsvRow[]) ?? []);
},
async excelSave(input: BomExcelSaveInput): Promise<BomExcelSaveResult> {
const res = await apiClient.post("/development/ebom/excel-save", input);
return res.data?.data as BomExcelSaveResult;
},
};
// ─── CSV Import 타입 (wace parsingCsvFile 1:1) ─────────────
export interface BomCsvRow {
NOTE: string;
LEVEL: string;
PARENT_PART_NO: string;
PART_NO: string;
PART_NAME: string;
QTY: string;
ITEM_QTY: string;
MATERIAL: string;
HEAT_TREATMENT_HARDNESS: string;
HEAT_TREATMENT_METHOD: string;
SURFACE_TREATMENT: string;
MAKER: string;
PART_TYPE: string;
PART_TYPE_NAME: string;
ACCTFG: string;
ODRFG: string;
UNIT_DC: string;
UNITMANG_DC: string;
UNITCHNG_NB: string;
LOT_FG: string;
USE_YN: string;
QC_FG: string;
SETITEM_FG: string;
REQ_FG: string;
}
// 기존 코드 호환용 별칭 (필요 시 마이그레이션)
export type BomExcelRow = BomCsvRow;
export interface BomExcelParseResponse {
rows: BomCsvRow[];
hasError: boolean;
firstLevel: { part_no: string; part_name: string } | null;
encoding: string;
}
export interface BomCopySourceRow {
objid: string;
part_no: string;
part_name: string;
revision: string | null;
product_cd: string | null;
regdate: string | null;
}
export interface BomExcelSaveInput {
bomReportObjid?: string;
productCd: string;
partNo: string;
partName: string;
version?: string;
rows: BomCsvRow[];
}
export interface BomExcelSaveResult {
bomReportObjid: string;
insertedParts: number;
updatedParts: number;
bomRows: number;
mode: "create" | "update";
}