c74e742b6f
Build and Push Images / build-and-push (push) Has been cancelled
수입검사 요청 (incoming-request): - 필터 12종 (품의서/발주서/프로젝트/품번/품명/공급업체/입고결과/제품구분/ 검사여부/요청현황/요청자/요청일범위) - 그리드 12컬럼 (proposal_no, purchase_order_no, project_no, product_name, part_no, part_name, partner_name, delivery_status, request_date, request_user_name, inspection_yn, request_status) - 백엔드: purchase_order_master + incoming_inspection_detail LEFT JOIN + sales_request_master + contract_mgmt + part_mng + user_info 수입검사 진행 (incoming-mgmt): - 필터 11종 (수입요청과 유사 + 검사일범위 + 검사현황) - 그리드 19컬럼 (검사일/검사자/품의서/발주서/프로젝트/제품구분/품명모델/ 부품품번/부품명/공급업체/입고일/입고수량/입고결과/검사수량/불량수량/ 불량률/검사현황/검사성적서) - SUM(defect_qty) 서브쿼리로 불량률 자동 계산 - 하단 요약: 총 입고수량/검사수량/불량수량 공정검사 관리 (process-inspection): - 필터 10종 (프로젝트/제품구분/품번/품명/작업환경/측정기/검사일범위/ 검사자/검사결과/진행공정) - 그리드 9컬럼 (검사일/검사자/프로젝트/제품구분/품번/품명/검사수량합계/ 검사결과/첨부파일) - master/detail 집계 + EXISTS 필터로 wace 1:1 반제품검사 관리 (semi-product-inspection): - 필터 8종 (모델명/작업지시번호/부품품번/부품명/검사일범위/검사자/ 불량유형/귀책부서) - 그리드 14컬럼 (검사일/검사자/제품구분/모델명/작업지시번호/부품품번/ 부품명/입고수량/양품수량/불량수량/불량률/재생수량/최종양품수량) - data_type='GOOD' 마스터 + 동일 inspection_group_id 의 'DEFECT' SUM - 재생수량(disposition_type='수정완료') + 최종양품수량 자동 산정 - 하단 요약: 5개 합계 카드 frontend/lib/api/quality.ts 타입 1:1 정합, 모든 필터 파라미터 직렬화.
185 lines
9.3 KiB
TypeScript
185 lines
9.3 KiB
TypeScript
"use client";
|
|
|
|
/**
|
|
* 수입검사 진행 — wace_plm 의 incomingInspectionProgressList.jsp 1:1 이식.
|
|
* 필터 11종, 그리드 19컬럼 (불량률 자동산정, 검사현황 컬러표시).
|
|
*/
|
|
import React, { useCallback, useEffect, useState } from "react";
|
|
import { Plus } from "lucide-react";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
import { toast } from "sonner";
|
|
import { useAuth } from "@/hooks/useAuth";
|
|
import { DataGrid, DataGridColumn } from "@/components/common/DataGrid";
|
|
import { PageHeader } from "@/components/common/PageHeader";
|
|
import { CompactFilterBar, CompactFilterField, CompactDateRange } from "@/components/common/CompactFilterBar";
|
|
import { qualityApi, IncomingMgmtRow } from "@/lib/api/quality";
|
|
import { exportToExcel } from "@/lib/utils/excelExport";
|
|
|
|
// wace_plm incomingInspectionProgressList.jsp 그리드 1:1
|
|
const GRID_COLUMNS: DataGridColumn[] = [
|
|
{ key: "inspection_date", label: "검사일", width: "w-[110px]", align: "center", frozen: true },
|
|
{ key: "inspector_name", label: "검사자", width: "w-[90px]", align: "center" },
|
|
{ key: "proposal_no", label: "품의서 No", width: "w-[120px]", align: "center" },
|
|
{ key: "purchase_order_no", label: "발주서 No", width: "w-[120px]", align: "center" },
|
|
{ key: "project_no", label: "프로젝트번호", width: "w-[140px]", align: "center" },
|
|
{ key: "product_name", label: "제품구분", width: "w-[100px]", align: "center" },
|
|
{ key: "model_name", label: "품명(모델명)", width: "w-[150px]" },
|
|
{ key: "part_no", label: "부품품번", width: "w-[140px]" },
|
|
{ key: "part_name", label: "부품명", width: "w-[150px]" },
|
|
{ key: "partner_name", label: "공급업체", width: "w-[150px]" },
|
|
{ key: "delivery_date", label: "입고일", width: "w-[110px]", align: "center" },
|
|
{ key: "delivery_qty", label: "입고수량", width: "w-[100px]", align: "right", formatNumber: true },
|
|
{ key: "delivery_status", label: "입고결과", width: "w-[90px]", align: "center" },
|
|
{ key: "inspection_qty", label: "검사수량", width: "w-[100px]", align: "right", formatNumber: true },
|
|
{ key: "defect_qty_sum", label: "불량수량", width: "w-[100px]", align: "right", formatNumber: true },
|
|
{ key: "defect_rate", label: "불량률(%)", width: "w-[100px]", align: "right" },
|
|
{ key: "inspection_result", label: "검사현황", width: "w-[100px]", align: "center" },
|
|
{ key: "inspection_file_cnt", label: "검사성적서", width: "w-[100px]", align: "center", renderType: "clip" },
|
|
];
|
|
|
|
const INSPECTION_STATUS_OPTIONS = ["전체", "완료", "진행중"];
|
|
const DELIVERY_STATUS_OPTIONS = ["전체", "입고중", "입고완료", "지연"];
|
|
|
|
export default function IncomingMgmtPage() {
|
|
const { user } = useAuth();
|
|
const [rows, setRows] = useState<IncomingMgmtRow[]>([]);
|
|
const [loading, setLoading] = useState(false);
|
|
const [selectedId, setSelectedId] = useState<string | null>(null);
|
|
|
|
const [search, setSearch] = useState({
|
|
search_proposal_no: "",
|
|
search_purchase_order_no: "",
|
|
project_no: "",
|
|
search_part_no: "",
|
|
search_part_name: "",
|
|
search_partner: "",
|
|
search_delivery_status: "",
|
|
search_product_cd: "",
|
|
inspector_id: "",
|
|
inspection_start_date: "",
|
|
inspection_end_date: "",
|
|
search_inspection_status: "",
|
|
});
|
|
|
|
const fetchList = useCallback(async () => {
|
|
if (!user) return;
|
|
setLoading(true);
|
|
try {
|
|
const res = await qualityApi.incomingMgmt(search);
|
|
setRows(res.list.map((r) => ({ ...r, id: r.objid } as any)));
|
|
setSelectedId(null);
|
|
} catch { toast.error("수입검사 진행 목록 조회 실패"); }
|
|
finally { setLoading(false); }
|
|
}, [user, search]);
|
|
|
|
useEffect(() => { fetchList(); }, [fetchList]);
|
|
|
|
const handleReset = () => setSearch({
|
|
search_proposal_no: "", search_purchase_order_no: "", project_no: "",
|
|
search_part_no: "", search_part_name: "", search_partner: "",
|
|
search_delivery_status: "", search_product_cd: "",
|
|
inspector_id: "", inspection_start_date: "", inspection_end_date: "",
|
|
search_inspection_status: "",
|
|
});
|
|
|
|
const summary = (() => {
|
|
const fmt = (n: number) => n.toLocaleString();
|
|
return [
|
|
{ label: "총 입고수량", value: fmt(rows.reduce((a, r) => a + Number(r.delivery_qty || 0), 0)) },
|
|
{ label: "총 검사수량", value: fmt(rows.reduce((a, r) => a + Number(r.inspection_qty || 0), 0)) },
|
|
{ label: "총 불량수량", value: fmt(rows.reduce((a, r) => a + Number(r.defect_qty_sum || 0), 0)) },
|
|
];
|
|
})();
|
|
|
|
const HardcodedSelect = ({ value, onChange, options }: { value: string; onChange: (v: string) => void; options: string[] }) => (
|
|
<Select value={value || "all"} onValueChange={(v) => onChange(v === "all" || v === "전체" ? "" : v)}>
|
|
<SelectTrigger className="h-7 text-xs"><SelectValue placeholder="전체" /></SelectTrigger>
|
|
<SelectContent>
|
|
{options.map((o) => <SelectItem key={o} value={o === "전체" ? "all" : o}>{o}</SelectItem>)}
|
|
</SelectContent>
|
|
</Select>
|
|
);
|
|
|
|
return (
|
|
<div className="flex h-full flex-col overflow-hidden p-2 gap-2">
|
|
<PageHeader
|
|
loading={loading}
|
|
onSearch={fetchList}
|
|
onReset={handleReset}
|
|
actions={
|
|
<Button size="sm" className="h-8 gap-1 text-xs" disabled>
|
|
<Plus className="h-3.5 w-3.5" />수입검사 진행
|
|
</Button>
|
|
}
|
|
/>
|
|
<CompactFilterBar totalText={<>총 {rows.length.toLocaleString()}건</>}>
|
|
<CompactFilterField label="품의서 No" width={130}>
|
|
<Input value={search.search_proposal_no} onChange={(e) => setSearch({ ...search, search_proposal_no: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="발주서 No" width={130}>
|
|
<Input value={search.search_purchase_order_no} onChange={(e) => setSearch({ ...search, search_purchase_order_no: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="프로젝트번호" width={150}>
|
|
<Input value={search.project_no} onChange={(e) => setSearch({ ...search, project_no: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="품번" width={140}>
|
|
<Input value={search.search_part_no} onChange={(e) => setSearch({ ...search, search_part_no: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="품명" width={160}>
|
|
<Input value={search.search_part_name} onChange={(e) => setSearch({ ...search, search_part_name: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="공급업체 ID" width={140}>
|
|
<Input value={search.search_partner} onChange={(e) => setSearch({ ...search, search_partner: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="입고결과" width={120}>
|
|
<HardcodedSelect value={search.search_delivery_status} onChange={(v) => setSearch({ ...search, search_delivery_status: v })} options={DELIVERY_STATUS_OPTIONS} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="제품구분 ID" width={120}>
|
|
<Input value={search.search_product_cd} onChange={(e) => setSearch({ ...search, search_product_cd: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="검사자 ID" width={120}>
|
|
<Input value={search.inspector_id} onChange={(e) => setSearch({ ...search, inspector_id: e.target.value })} />
|
|
</CompactFilterField>
|
|
<CompactFilterField label="검사일" width={280}>
|
|
<CompactDateRange
|
|
from={search.inspection_start_date} setFrom={(v) => setSearch({ ...search, inspection_start_date: v })}
|
|
to={search.inspection_end_date} setTo={(v) => setSearch({ ...search, inspection_end_date: v })}
|
|
/>
|
|
</CompactFilterField>
|
|
<CompactFilterField label="검사현황" width={110}>
|
|
<HardcodedSelect value={search.search_inspection_status} onChange={(v) => setSearch({ ...search, search_inspection_status: v })} options={INSPECTION_STATUS_OPTIONS} />
|
|
</CompactFilterField>
|
|
</CompactFilterBar>
|
|
<DataGrid
|
|
gridId="quality-incoming-mgmt"
|
|
columns={GRID_COLUMNS}
|
|
data={rows}
|
|
loading={loading}
|
|
showCheckbox
|
|
checkedIds={selectedId ? [selectedId] : []}
|
|
onCheckedChange={(ids) => setSelectedId(ids.length ? ids[ids.length - 1] : null)}
|
|
selectedId={selectedId}
|
|
onSelect={setSelectedId}
|
|
emptyMessage="조회된 수입검사 진행 내역이 없습니다."
|
|
summaryStats={summary}
|
|
showColumnSettings
|
|
paginationStyle="range"
|
|
pageSizeOptions={[10, 15, 20, 50, 100]}
|
|
showChart
|
|
onRefresh={fetchList}
|
|
onDownload={() => {
|
|
if (rows.length === 0) { toast.info("내보낼 데이터가 없습니다."); return; }
|
|
const exportRows = rows.map((r) => {
|
|
const out: Record<string, any> = {};
|
|
GRID_COLUMNS.forEach((c) => { out[c.label] = (r as any)[c.key] ?? ""; });
|
|
return out;
|
|
});
|
|
exportToExcel(exportRows, "수입검사관리.xlsx", "수입검사관리");
|
|
}}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|