구매관리 7메뉴 신규 + M-BOM PR-B3·B5 + 발주관리 DataGrid 통일 + 생산계획&실적 라우트
구매관리 (wace 1:1) - backend: services/purchaseService.ts (7 list + 옵션 3종) + controllers/purchaseController.ts + routes/purchaseRoutes.ts (/api/purchase 마운트) - frontend: lib/api/purchase.ts + 7 page.tsx (list/quote-request/proposal/inbound/inbound-by-item/inbound-by-date/project-status) - 영업관리 4메뉴 DataGrid 패턴 통일 — pageSizeOptions=[10,15,20,50,100], emptyMessage, showColumnSettings/summaryStats/onRefresh/onDownload/showChart - 마스터단독 데이터(sales_request_master, project_mgmt+mbom_detail) 노출, detail/part 누락 테이블 의존은 빈 그리드 + UI 발주관리 (purchase/order/page.tsx) - EDataTable → DataGrid 교체 + logicstudio 6종 props + 날짜/숫자 pre-format M-BOM PR-B3 — 구매리스트 생성 (wace createPurchaseListFromMBom.do 1:1) - mbomService.createSalesRequest + controller + route POST /api/production/mbom/sales-request - 단건 체크 + 1:1 강제 + R-YYYYMMDD-NNN 채번 + sales_request_master 단건 INSERT - production/mbom/page.tsx 에 [구매리스트 생성] 버튼 M-BOM PR-B5 — BOM 할당 (mBomEbomSelectPopup.do) - mbomService.searchAssignableEboms/assignBom + controller + routes - MbomAssignDialog 신규, MbomDetailDialog 통합 생산관리 4메뉴 라우트 (생산계획&실적, 소요량) - prodPlanResultService/Controller + productionPlanResultRoutes (planResult/mbomReq) - mbomRequirementService + 4 page.tsx (prod-plan-result, prod-plan-result-equip, raw-material-requirement, semi-product-requirement) - lib/api/prodPlanResult.ts Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,190 @@
|
||||
"use client";
|
||||
|
||||
// 구매관리 > 견적요청서관리 — wace salesMng/quotationRequestList.jsp 1:1
|
||||
// 검색: 년도 / 프로젝트번호 / 견적요청서No / 공급업체 / 메일발송 / 작성자 / 제품구분
|
||||
// 그리드: 13컬럼 (견적번호 / 요청번호 / 구매유형 / 프로젝트번호 / 주문유형 / 제품구분 / 품번 / 품명 / 공급업체 / 견적요청서(파일) / 메일발송 / 수신견적서 / 작성자)
|
||||
// 액션: 메일발송 / 삭제 / 조회
|
||||
// ⚠️ 백엔드 quotation_request_master 미존재 → 빈 그리드 (UI 만 제공)
|
||||
|
||||
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Mail, Trash2 } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { DataGrid, DataGridColumn } from "@/components/common/DataGrid";
|
||||
import { SmartSelect, SmartSelectOption } from "@/components/common/SmartSelect";
|
||||
import { CompactFilterBar, CompactFilterField } from "@/components/common/CompactFilterBar";
|
||||
import { PageHeader } from "@/components/common/PageHeader";
|
||||
import { apiClient } from "@/lib/api/client";
|
||||
import { purchaseApi, PurchaseListFilter, OptionItem, getYearOptions } from "@/lib/api/purchase";
|
||||
import { exportToExcel } from "@/lib/utils/excelExport";
|
||||
|
||||
const PARENT_PRODUCT = "0000001";
|
||||
|
||||
const MAIL_SEND_OPTS: SmartSelectOption[] = [
|
||||
{ code: "N", label: "미발송" },
|
||||
{ code: "Y", label: "발송" },
|
||||
];
|
||||
|
||||
const EMPTY_FILTER: PurchaseListFilter = {
|
||||
year: String(new Date().getFullYear()),
|
||||
project_no: "", proposal_no: "", partner_objid: "",
|
||||
mail_send_yn: "", writer: "", product_cd: "",
|
||||
page: 1, page_size: 50,
|
||||
};
|
||||
|
||||
export default function QuoteRequestPage() {
|
||||
const [rows, setRows] = useState<any[]>([]);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [filter, setFilter] = useState<PurchaseListFilter>(EMPTY_FILTER);
|
||||
const [checkedIds, setCheckedIds] = useState<string[]>([]);
|
||||
|
||||
const [productOpts, setProductOpts] = useState<SmartSelectOption[]>([]);
|
||||
const [supplierOpts, setSupplierOpts] = useState<OptionItem[]>([]);
|
||||
const [userOpts, setUserOpts] = useState<OptionItem[]>([]);
|
||||
|
||||
const yearOpts = useMemo(() => getYearOptions(), []);
|
||||
|
||||
const fetchList = useCallback(async (override?: Partial<PurchaseListFilter>) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const f = { ...filter, ...override };
|
||||
const res = await purchaseApi.listQuotationRequest(f);
|
||||
setRows(res.rows ?? []);
|
||||
setTotal(res.totalCount ?? 0);
|
||||
} catch (e: any) {
|
||||
toast.error(e?.response?.data?.message ?? e?.message ?? "조회 실패");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
}, [filter]);
|
||||
|
||||
useEffect(() => {
|
||||
let dead = false;
|
||||
(async () => {
|
||||
try {
|
||||
const [p, s, u] = await Promise.all([
|
||||
apiClient.get(`/sales/codes/${PARENT_PRODUCT}`),
|
||||
purchaseApi.listSuppliers(),
|
||||
purchaseApi.listUsers(),
|
||||
]);
|
||||
if (dead) return;
|
||||
setProductOpts(p.data?.data ?? []);
|
||||
setSupplierOpts(s);
|
||||
setUserOpts(u);
|
||||
} catch { /* skip */ }
|
||||
})();
|
||||
fetchList(EMPTY_FILTER);
|
||||
return () => { dead = true; };
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const gridRows = useMemo(() => rows.map((r, i) => ({ ...r, id: r.objid ?? `q_${i}` })), [rows]);
|
||||
|
||||
const GRID_COLUMNS: DataGridColumn[] = useMemo(() => ([
|
||||
{ key: "quotation_request_no", label: "견적번호", width: "w-[140px]", align: "center" },
|
||||
{ key: "request_mng_no", label: "요청번호", width: "w-[140px]", align: "center" },
|
||||
{ key: "purchase_type_name", label: "구매유형", width: "w-[115px]", align: "center" },
|
||||
{ key: "project_number", label: "프로젝트번호", width: "w-[140px]", align: "center" },
|
||||
{ key: "order_type_name", label: "주문유형", width: "w-[115px]", align: "center" },
|
||||
{ key: "product_name_title", label: "제품구분", width: "w-[115px]", align: "center" },
|
||||
{ key: "part_no", label: "품번", width: "w-[150px]" },
|
||||
{ key: "part_name", label: "품명", minWidth: "min-w-[180px]" },
|
||||
{ key: "vendor_name", label: "공급업체", minWidth: "min-w-[150px]" },
|
||||
{ key: "quotation_file", label: "견적요청서", width: "w-[115px]", align: "center", renderType: "clip" },
|
||||
{ key: "mail_send_date_title", label: "메일발송", width: "w-[125px]", align: "center" },
|
||||
{ key: "attach_file_cnt", label: "수신견적서", width: "w-[115px]", align: "center" },
|
||||
{ key: "writer_name", label: "작성자", width: "w-[115px]", align: "center" },
|
||||
]), []);
|
||||
|
||||
const summary = useMemo(() => [
|
||||
{ label: "전체 건수", value: total.toLocaleString(), suffix: "건" },
|
||||
{ label: "선택", value: checkedIds.length.toLocaleString(), suffix: "건" },
|
||||
], [total, checkedIds]);
|
||||
|
||||
const handleSearch = () => { setFilter(f => ({ ...f, page: 1 })); fetchList({ page: 1 }); };
|
||||
const handleReset = () => { setFilter(EMPTY_FILTER); fetchList(EMPTY_FILTER); };
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col overflow-hidden p-2 gap-2">
|
||||
<PageHeader
|
||||
loading={loading} onSearch={handleSearch} onReset={handleReset}
|
||||
actions={<>
|
||||
<Button size="sm" variant="outline" className="h-8 gap-1 px-2 text-xs"
|
||||
disabled={checkedIds.length === 0}
|
||||
onClick={() => toast.info("메일발송 — 운영DB quotation_request_master 신설 후 활성")}>
|
||||
<Mail className="h-3.5 w-3.5" /> 메일발송
|
||||
</Button>
|
||||
<Button size="sm" variant="destructive" className="h-8 gap-1 px-2 text-xs"
|
||||
disabled={checkedIds.length === 0}
|
||||
onClick={() => toast.info("삭제 — 운영DB quotation_request_master 신설 후 활성")}>
|
||||
<Trash2 className="h-3.5 w-3.5" /> 삭제
|
||||
</Button>
|
||||
</>}
|
||||
/>
|
||||
<CompactFilterBar totalText={<>총 {total.toLocaleString()}건</>}>
|
||||
<CompactFilterField label="년도" width={100}>
|
||||
<SmartSelect options={yearOpts} value={filter.year ?? ""}
|
||||
onValueChange={(v) => setFilter({ ...filter, year: v })} />
|
||||
</CompactFilterField>
|
||||
<CompactFilterField label="프로젝트번호" width={170}>
|
||||
<Input value={filter.project_no ?? ""}
|
||||
onChange={(e) => setFilter({ ...filter, project_no: e.target.value })} />
|
||||
</CompactFilterField>
|
||||
<CompactFilterField label="견적요청서No" width={150}>
|
||||
<Input value={filter.proposal_no ?? ""}
|
||||
onChange={(e) => setFilter({ ...filter, proposal_no: e.target.value })} />
|
||||
</CompactFilterField>
|
||||
<CompactFilterField label="공급업체" width={180}>
|
||||
<SmartSelect options={supplierOpts} value={filter.partner_objid ?? ""}
|
||||
onValueChange={(v) => setFilter({ ...filter, partner_objid: v })} />
|
||||
</CompactFilterField>
|
||||
<CompactFilterField label="메일발송" width={120}>
|
||||
<SmartSelect options={MAIL_SEND_OPTS} value={filter.mail_send_yn ?? ""}
|
||||
onValueChange={(v) => setFilter({ ...filter, mail_send_yn: v })} />
|
||||
</CompactFilterField>
|
||||
<CompactFilterField label="작성자" width={150}>
|
||||
<SmartSelect options={userOpts} value={filter.writer ?? ""}
|
||||
onValueChange={(v) => setFilter({ ...filter, writer: v })} />
|
||||
</CompactFilterField>
|
||||
<CompactFilterField label="제품구분" width={130}>
|
||||
<SmartSelect options={productOpts} value={filter.product_cd ?? ""}
|
||||
onValueChange={(v) => setFilter({ ...filter, product_cd: v })} />
|
||||
</CompactFilterField>
|
||||
</CompactFilterBar>
|
||||
|
||||
<DataGrid
|
||||
columns={GRID_COLUMNS}
|
||||
data={gridRows}
|
||||
loading={loading}
|
||||
showCheckbox
|
||||
checkedIds={checkedIds}
|
||||
onCheckedChange={setCheckedIds}
|
||||
emptyMessage={loading ? "조회 중..." : "데이터가 없습니다"}
|
||||
gridId="purchase-quote-request"
|
||||
pageSizeOptions={[10, 15, 20, 50, 100]}
|
||||
paginationStyle="range"
|
||||
serverPaging
|
||||
serverPage={filter.page ?? 1}
|
||||
serverPageSize={filter.page_size ?? 50}
|
||||
serverTotalItems={total}
|
||||
onPageChange={(p) => { setFilter(f => ({ ...f, page: p })); fetchList({ page: p }); }}
|
||||
onPageSizeChange={(n) => { setFilter(f => ({ ...f, page: 1, page_size: n })); fetchList({ page: 1, page_size: n }); }}
|
||||
showColumnSettings
|
||||
summaryStats={summary}
|
||||
onRefresh={() => fetchList()}
|
||||
onDownload={() => {
|
||||
if (gridRows.length === 0) { toast.info("내보낼 데이터가 없습니다."); return; }
|
||||
const exportRows = gridRows.map((r: any) => {
|
||||
const out: Record<string, any> = {};
|
||||
GRID_COLUMNS.forEach((c) => { out[c.label] = r[c.key] ?? ""; });
|
||||
return out;
|
||||
});
|
||||
exportToExcel(exportRows, "견적요청서관리.xlsx", "견적요청서");
|
||||
}}
|
||||
showChart
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user