summaryrefslogtreecommitdiff
path: root/lib/pq
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pq')
-rw-r--r--lib/pq/pq-review-table-new/request-investigation-dialog.tsx39
-rw-r--r--lib/pq/pq-review-table-new/site-visit-dialog.tsx21
-rw-r--r--lib/pq/pq-review-table-new/vendors-table-columns.tsx69
-rw-r--r--lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx59
-rw-r--r--lib/pq/pq-review-table-new/vendors-table.tsx7
5 files changed, 72 insertions, 123 deletions
diff --git a/lib/pq/pq-review-table-new/request-investigation-dialog.tsx b/lib/pq/pq-review-table-new/request-investigation-dialog.tsx
index 6cbb885f..b9648e74 100644
--- a/lib/pq/pq-review-table-new/request-investigation-dialog.tsx
+++ b/lib/pq/pq-review-table-new/request-investigation-dialog.tsx
@@ -51,14 +51,6 @@ interface QMUser {
}
const requestInvestigationFormSchema = z.object({
- evaluationType: z.enum([
- "PURCHASE_SELF_EVAL", // 구매자체평가
- "DOCUMENT_EVAL", // 서류평가
- // "PRODUCT_INSPECTION", // 제품검사평가
- // "SITE_VISIT_EVAL" // 방문실사평가
- ], {
- required_error: "평가 유형을 선택해주세요.",
- }),
qmManagerId: z.number({
required_error: "QM 담당자를 선택해주세요.",
}),
@@ -76,7 +68,6 @@ interface RequestInvestigationDialogProps {
isOpen: boolean
onClose: () => void
onSubmit: (data: {
- evaluationType: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL",
qmManagerId: number,
forecastedAt: Date,
investigationAddress: string,
@@ -86,7 +77,6 @@ interface RequestInvestigationDialogProps {
selectedCount: number
// 선택된 행에서 가져온 초기값
initialData?: {
- evaluationType?: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL",
qmManagerId?: number,
forecastedAt?: Date,
investigationAddress?: string,
@@ -110,7 +100,6 @@ export function RequestInvestigationDialog({
const form = useForm<RequestInvestigationFormValues>({
resolver: zodResolver(requestInvestigationFormSchema),
defaultValues: {
- evaluationType: initialData?.evaluationType || "PURCHASE_SELF_EVAL",
qmManagerId: initialData?.qmManagerId || undefined,
forecastedAt: initialData?.forecastedAt || undefined,
investigationAddress: initialData?.investigationAddress || "",
@@ -123,7 +112,6 @@ export function RequestInvestigationDialog({
React.useEffect(() => {
if (isOpen) {
form.reset({
- evaluationType: initialData?.evaluationType || "PURCHASE_SELF_EVAL",
qmManagerId: initialData?.qmManagerId || undefined,
forecastedAt: initialData?.forecastedAt || undefined,
investigationAddress: initialData?.investigationAddress || "",
@@ -175,33 +163,6 @@ export function RequestInvestigationDialog({
</DialogHeader>
<Form {...form}>
<form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-4">
- <FormField
- control={form.control}
- name="evaluationType"
- render={({ field }) => (
- <FormItem>
- <FormLabel>평가 유형</FormLabel>
- <Select
- onValueChange={field.onChange}
- defaultValue={field.value}
- disabled={isPending}
- >
- <FormControl>
- <SelectTrigger>
- <SelectValue placeholder="평가 유형을 선택하세요" />
- </SelectTrigger>
- </FormControl>
- <SelectContent>
- <SelectItem value="PURCHASE_SELF_EVAL">구매자체평가</SelectItem>
- <SelectItem value="DOCUMENT_EVAL">서류평가</SelectItem>
- {/* <SelectItem value="PRODUCT_INSPECTION">제품검사평가</SelectItem> */}
- {/* <SelectItem value="SITE_VISIT_EVAL">방문실사평가</SelectItem> */}
- </SelectContent>
- </Select>
- <FormMessage />
- </FormItem>
- )}
- />
<FormField
control={form.control}
diff --git a/lib/pq/pq-review-table-new/site-visit-dialog.tsx b/lib/pq/pq-review-table-new/site-visit-dialog.tsx
index 63390cb1..b6bd3624 100644
--- a/lib/pq/pq-review-table-new/site-visit-dialog.tsx
+++ b/lib/pq/pq-review-table-new/site-visit-dialog.tsx
@@ -131,8 +131,7 @@ interface SiteVisitDialogProps {
onSubmit: (data: SiteVisitRequestFormValues, attachments?: File[]) => Promise<void>
investigation: {
id: number
- evaluationType: "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL"
- investigationMethod?: string
+ investigationMethod?: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL"
investigationAddress?: string
vendorName: string
vendorCode: string
@@ -275,17 +274,6 @@ export function SiteVisitDialog({
setSelectedFiles(prev => prev.filter((_, i) => i !== index))
}
- const getEvaluationTypeLabel = (type: string) => {
- switch (type) {
- case "PRODUCT_INSPECTION":
- return "제품검사평가"
- case "SITE_VISIT_EVAL":
- return "방문실사평가"
- default:
- return type
- }
- }
-
const getInvestigationMethodLabel = (method: string) => {
switch (method) {
case "PURCHASE_SELF_EVAL":
@@ -338,13 +326,8 @@ export function SiteVisitDialog({
<FormLabel className="text-sm font-medium">실사방법</FormLabel>
<div className="mt-1 p-3 bg-muted rounded-md">
<Badge variant="outline">
- {getEvaluationTypeLabel(investigation.evaluationType)}
+ {getInvestigationMethodLabel(investigation.investigationMethod || "")}
</Badge>
- {investigation.investigationMethod && (
- <div className="mt-2 text-sm text-muted-foreground">
- {getInvestigationMethodLabel(investigation.investigationMethod)}
- </div>
- )}
</div>
</div>
diff --git a/lib/pq/pq-review-table-new/vendors-table-columns.tsx b/lib/pq/pq-review-table-new/vendors-table-columns.tsx
index d99f201e..d3fada0d 100644
--- a/lib/pq/pq-review-table-new/vendors-table-columns.tsx
+++ b/lib/pq/pq-review-table-new/vendors-table-columns.tsx
@@ -65,7 +65,6 @@ export interface PQSubmission {
id: number
investigationStatus: string
requesterName: string | null // 실사 요청자 이름
- evaluationType: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL" | null
qmManagerId: number | null
qmManagerName: string | null // QM 담당자 이름
qmManagerEmail: string | null // QM 담당자 이메일
@@ -301,37 +300,38 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef
}
}
- const evaluationTypeColumn: ColumnDef<PQSubmission> = {
- accessorKey: "evaluationType",
- header: ({ column }) => (
- <DataTableColumnHeaderSimple column={column} title="평가 유형" />
- ),
- cell: ({ row }) => {
- const investigation = row.original.investigation;
-
- if (!investigation || !investigation.evaluationType) {
- return <span className="text-muted-foreground">-</span>;
- }
-
- switch (investigation.evaluationType) {
- case "PURCHASE_SELF_EVAL":
- return <Badge variant="outline">구매자체평가</Badge>;
- case "DOCUMENT_EVAL":
- return <Badge variant="secondary">서류평가</Badge>;
- case "PRODUCT_INSPECTION":
- return <Badge variant="default">제품검사평가</Badge>;
- case "SITE_VISIT_EVAL":
- return <Badge variant="destructive">방문실사평가</Badge>;
- default:
- return <span>{investigation.evaluationType}</span>;
- }
- },
- filterFn: (row, id, value) => {
- const investigation = row.original.investigation;
- if (!investigation || !investigation.evaluationType) return value.includes("null");
- return value.includes(investigation.evaluationType);
- },
- };
+ // 평가유형 컬럼 (QM실사방법으로 교체됨)
+ // const evaluationTypeColumn: ColumnDef<PQSubmission> = {
+ // accessorKey: "evaluationType",
+ // header: ({ column }) => (
+ // <DataTableColumnHeaderSimple column={column} title="평가 유형" />
+ // ),
+ // cell: ({ row }) => {
+ // const investigation = row.original.investigation;
+
+ // if (!investigation || !investigation.evaluationType) {
+ // return <span className="text-muted-foreground">-</span>;
+ // }
+
+ // switch (investigation.evaluationType) {
+ // case "PURCHASE_SELF_EVAL":
+ // return <Badge variant="outline">구매자체평가</Badge>;
+ // case "DOCUMENT_EVAL":
+ // return <Badge variant="secondary">서류평가</Badge>;
+ // case "PRODUCT_INSPECTION":
+ // return <Badge variant="default">제품검사평가</Badge>;
+ // case "SITE_VISIT_EVAL":
+ // return <Badge variant="destructive">방문실사평가</Badge>;
+ // default:
+ // return <span>{investigation.evaluationType}</span>;
+ // }
+ // },
+ // filterFn: (row, id, value) => {
+ // const investigation = row.original.investigation;
+ // if (!investigation || !investigation.evaluationType) return value.includes("null");
+ // return value.includes(investigation.evaluationType);
+ // },
+ // };
const evaluationResultColumn: ColumnDef<PQSubmission> = {
@@ -387,7 +387,7 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef
cell: ({ row }) => {
const investigation = row.original.investigation;
- if (!investigation || !investigation.evaluationType) {
+ if (!investigation || !investigation.investigationAddress) {
return <span className="text-muted-foreground">-</span>;
}
@@ -675,7 +675,7 @@ export function getColumns({ setRowAction, router }: GetColumnsProps): ColumnDef
e.preventDefault();
// 실사 정보 수정 다이얼로그 열기 로직
setRowAction({
- type: "edit-investigation",
+ type: "update",
row: row.original
});
}}
@@ -772,7 +772,6 @@ const qmManagerColumn: ColumnDef<PQSubmission> = {
submittedAtColumn,
approvalDateColumn,
answerCountColumn,
- evaluationTypeColumn, // 평가 유형 컬럼
investigationMethodColumn,
investigationForecastedAtColumn,
investigationRequestedAtColumn,
diff --git a/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx b/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx
index 48aeb552..f731a922 100644
--- a/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx
+++ b/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx
@@ -23,7 +23,7 @@ interface VendorsTableToolbarActionsProps {
}
interface InvestigationInitialData {
- evaluationType?: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL";
+ investigationMethod?: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL";
qmManagerId?: number;
forecastedAt?: Date;
createdAt?: Date;
@@ -91,7 +91,7 @@ const handleOpenRequestDialog = async () => {
})[0].investigation;
if (latestInvestigation) {
- initialData.evaluationType = latestInvestigation.evaluationType || "SITE_VISIT_EVAL";
+ initialData.investigationMethod = latestInvestigation.investigationMethod || undefined;
initialData.qmManagerId = latestInvestigation.qmManagerId || undefined;
initialData.investigationAddress = defaultAddress; // Factory Location 사용
@@ -102,7 +102,7 @@ const handleOpenRequestDialog = async () => {
}
} else {
// 기본값 설정
- initialData.evaluationType = "SITE_VISIT_EVAL";
+ initialData.investigationMethod = undefined;
const futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 14); // 기본값으로 2주 후
initialData.forecastedAt = futureDate;
@@ -110,14 +110,14 @@ const handleOpenRequestDialog = async () => {
}
}
// 실사가 이미 있고 수정하는 경우
- else if (row.investigation) {
- initialData.evaluationType = row.investigation.evaluationType || "SITE_VISIT_EVAL";
- initialData.qmManagerId = row.investigation.qmManagerId !== null ?
- row.investigation.qmManagerId : undefined;
- initialData.forecastedAt = row.investigation.forecastedAt || new Date();
- initialData.investigationAddress = row.investigation.investigationAddress || "";
- initialData.investigationNotes = row.investigation.investigationNotes || "";
- }
+ // else if (row.investigation) {
+ // initialData.investigationMethod = row.investigation.investigationMethod || undefined;
+ // initialData.qmManagerId = row.investigation.qmManagerId !== null ?
+ // row.investigation.qmManagerId : undefined;
+ // initialData.forecastedAt = row.investigation.forecastedAt || new Date();
+ // initialData.investigationAddress = row.investigation.investigationAddress || "";
+ // initialData.investigationNotes = row.investigation.investigationNotes || "";
+ // }
}
} catch (error) {
console.error("초기 데이터 로드 중 오류:", error);
@@ -132,22 +132,26 @@ const handleOpenRequestDialog = async () => {
};
// 실사 의뢰 요청 처리
const handleRequestInvestigation = async (formData: {
- evaluationType: "PURCHASE_SELF_EVAL" | "DOCUMENT_EVAL" | "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL",
qmManagerId: number,
forecastedAt: Date,
investigationAddress: string,
- investigationMethod?: string,
investigationNotes?: string
}) => {
setIsLoading(true)
try {
- // 승인된 PQ 제출만 필터링
+ // 승인된 PQ 제출만 필터링 (미실사 PQ 제외)
const approvedPQs = selectedRows.filter(row =>
- row.original.status === "APPROVED" && !row.original.investigation
+ row.original.status === "APPROVED" &&
+ !row.original.investigation &&
+ row.original.type !== "NON_INSPECTION"
)
if (approvedPQs.length === 0) {
- toast.error("실사를 의뢰할 수 있는 업체가 없습니다. 승인된 PQ 제출만 실사 의뢰가 가능합니다.")
+ if (hasNonInspectionPQ) {
+ toast.error("미실사 PQ는 실사 의뢰할 수 없습니다. 미실사 PQ를 제외하고 선택해주세요.")
+ } else {
+ toast.error("실사를 의뢰할 수 있는 업체가 없습니다. 승인된 PQ 제출만 실사 의뢰가 가능합니다.")
+ }
return
}
@@ -158,13 +162,8 @@ const handleOpenRequestDialog = async () => {
)
if (result.success) {
- const evaluationTypeLabels = {
- "PURCHASE_SELF_EVAL": "구매자체평가",
- "DOCUMENT_EVAL": "서류평가",
- "PRODUCT_INSPECTION": "제품검사평가",
- "SITE_VISIT_EVAL": "방문실사평가"
- };
- toast.success(`${result.count}개 업체에 대한 ${evaluationTypeLabels[formData.evaluationType]}가 의뢰되었습니다.`)
+
+ toast.success(`${result.count}개 업체에 대해 실사가 의뢰되었습니다.`)
window.location.reload()
} else {
toast.error(result.error || "실사 의뢰 처리 중 오류가 발생했습니다.")
@@ -258,9 +257,11 @@ const handleOpenRequestDialog = async () => {
}
}
- // 승인된 업체 수 확인
+ // 승인된 업체 수 확인 (미실사 PQ 제외)
const approvedPQsCount = selectedRows.filter(row =>
- row.original.status === "APPROVED" && !row.original.investigation
+ row.original.status === "APPROVED" &&
+ !row.original.investigation &&
+ row.original.type !== "NON_INSPECTION"
).length
// 계획 상태 실사 수 확인
@@ -276,6 +277,11 @@ const handleOpenRequestDialog = async () => {
row.original.investigation.evaluationResult === "APPROVED"
).length
+ // 미실사 PQ가 선택되었는지 확인
+ const hasNonInspectionPQ = selectedRows.some(row =>
+ row.original.type === "NON_INSPECTION"
+ )
+
// 실사 방법 라벨 변환 함수
const getInvestigationMethodLabel = (method: string): string => {
switch (method) {
@@ -328,8 +334,9 @@ const handleOpenRequestDialog = async () => {
variant="outline"
size="sm"
onClick={handleOpenRequestDialog} // 여기를 수정: 새로운 핸들러 함수 사용
- disabled={isLoading || selectedRows.length === 0}
+ disabled={isLoading || selectedRows.length === 0 || hasNonInspectionPQ}
className="gap-2"
+ title={hasNonInspectionPQ ? "미실사 PQ는 실사 의뢰할 수 없습니다." : undefined}
>
<ClipboardCheck className="size-4" aria-hidden="true" />
<span className="hidden sm:inline">실사 의뢰</span>
diff --git a/lib/pq/pq-review-table-new/vendors-table.tsx b/lib/pq/pq-review-table-new/vendors-table.tsx
index c2712611..191c8bfa 100644
--- a/lib/pq/pq-review-table-new/vendors-table.tsx
+++ b/lib/pq/pq-review-table-new/vendors-table.tsx
@@ -192,7 +192,7 @@ export function PQSubmissionsTable({ promises, className }: PQSubmissionsTablePr
setSelectedSiteVisitRequestId(rowAction.row.siteVisitRequestId || null)
setIsVendorInfoViewDialogOpen(true)
setRowAction(null)
- } else if (rowAction?.type === "edit-investigation") {
+ } else if (rowAction?.type === "update") {
// 실사 정보 수정 다이얼로그 열기
setSelectedInvestigationForEdit(rowAction.row)
setIsEditInvestigationDialogOpen(true)
@@ -432,9 +432,8 @@ export function PQSubmissionsTable({ promises, className }: PQSubmissionsTablePr
onSubmit={handleSiteVisitRequest}
investigation={{
id: selectedInvestigation.investigation?.id || 0,
- evaluationType: selectedInvestigation.investigation?.evaluationType as "PRODUCT_INSPECTION" | "SITE_VISIT_EVAL",
- investigationMethod: selectedInvestigation.investigation?.investigationMethod,
- investigationAddress: selectedInvestigation.investigation?.investigationAddress,
+ investigationMethod: selectedInvestigation.investigation?.investigationMethod || "",
+ investigationAddress: selectedInvestigation.investigation?.investigationAddress || "",
vendorName: selectedInvestigation.vendorName,
vendorCode: selectedInvestigation.vendorCode,
projectName: selectedInvestigation.projectName || undefined,