summaryrefslogtreecommitdiff
path: root/lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx
diff options
context:
space:
mode:
authordujinkim <dujin.kim@dtsolution.co.kr>2025-08-11 09:00:38 +0000
committerdujinkim <dujin.kim@dtsolution.co.kr>2025-08-11 09:00:38 +0000
commiteb654f88214095f71be142b989e620fd28db3f69 (patch)
treeaaad3074de4a6422a880b35f9e577d489b0a6c91 /lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx
parenta383fd2a30f60360ebc0c1b897b3d43cbae178fa (diff)
(최겸) 기술영업 변경사항 반영, PQ/실사 변경사항 반영
Diffstat (limited to 'lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx')
-rw-r--r--lib/pq/pq-review-table-new/vendors-table-toolbar-actions.tsx59
1 files changed, 33 insertions, 26 deletions
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>