From c0c19c0425df426eccf71519470ab8babe4013f0 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 22 Jul 2025 14:32:25 +0900 Subject: [PATCH] =?UTF-8?q?=EB=A7=A4=EC=B9=AD=EC=99=84=EB=A3=8C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wr/app/matMng/coMat/ruseRvwHstry/page.tsx | 111 +++++++++--------- apps/wr/app/store/matDmd/coMatRvw/type.tsx | 3 +- .../store/matDmd/ruseRvwHstry/headList.tsx | 1 + .../app/store/matDmd/ruseRvwHstry/index.tsx | 8 +- apps/wr/public/locales/ko/message.json | 7 +- 5 files changed, 69 insertions(+), 61 deletions(-) diff --git a/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx b/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx index 75fd6825f..1c034ac89 100644 --- a/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx +++ b/apps/wr/app/matMng/coMat/ruseRvwHstry/page.tsx @@ -1,12 +1,9 @@ "use client"; import { useWrStore } from "@/app/store"; +import { type RvwHistTableType } from "@/app/store/matDmd/coMatRvw/type"; import { - DmdCoReqSchema, - type DmdCoReqType, - type RvwHistTableType, -} from "@/app/store/matDmd/coMatRvw/type"; -import { + confirmToast, formatPhoneNumber, getCity, getdmdMatFlag, @@ -27,11 +24,10 @@ import { } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Label } from "@common/components/ui"; -import { zodResolver } from "@hookform/resolvers/zod"; import moment from "moment"; import { useCallback, useEffect, useState } from "react"; -import { useForm } from "react-hook-form"; import toast, { Toaster } from "react-hot-toast"; +import { useTranslation } from "react-i18next"; export default function RuseRvwHstry() { const { code, @@ -51,6 +47,7 @@ export default function RuseRvwHstry() { sgg: "", city: "", }); + const { t } = useTranslation('base'); const [fromDate, setFromDate] = useState( String(new Date().getFullYear()) @@ -116,53 +113,65 @@ export default function RuseRvwHstry() { } }; - const form = useForm({ - resolver: zodResolver(DmdCoReqSchema), - mode: "onChange", - }); - const TableCellClick = useCallback( - (index: number | undefined) => { - if ( - index !== undefined && - index >= 0 && - rvwHistRes && - rvwHistRes[index] - ) { - form.reset(rvwHistRes[index]); + (index: number | undefined, headId: string) => { + if (index !== undefined && index >= 0) { + const selectedData = rvwHistData; + if (selectedData && selectedData.length > 0) { + if ( + selectedData[index]?.splyFcltFlg === "검토완료" && + headId === "completeYn" + ) { + setRvwHistData([...selectedData]); + } else if ( + selectedData[index]?.splyFcltFlg === "매칭완료" && + headId === "completeYn" + ) { + toast.error(t("canNotChangeMatStateMsg")); + return; + } + } } }, - [rvwHistRes, form] + [rvwHistData] ); const confrirmToast = () => { const completeData = rvwHistData ?.map((item) => { - form.clearErrors(); - if (item?.completeYn) { + if (item?.completeYn.chk && item.splyFcltFlg === "검토완료") { return Number(item.dmdInfoSn); } }) .filter((item) => item !== undefined); - if (form.formState.isDirty) { - toast((t) => ( - - 표준공사비 정보가 변경되었습니다. 검토 완료 진행시 입력한 정보는 - 초기화 됩니다. -
- 진행하시겠습니까? - - -
- )); + + if (completeData && completeData?.length > 0) { + confirmToast(t('isMatchFinishMsg'), () => ruseRvwComplete(completeData as number[])); + + // const handleConfirm = async () => { + // ruseRvwComplete(completeData as number[]); + // }; + // toast((t) => ( + // + // 매칭완료를 진행하시겠습니까? + //
+ //
+ // + // + //
+ //
+ // )); } else { - ruseRvwComplete(completeData as number[]); + toast.error( t('isNotMatchFinishMsg')); } }; useEffect(() => { @@ -203,11 +212,10 @@ export default function RuseRvwHstry() { rvwCmptnYmd: formatDate(item.demandMatching?.rvwCmptnYmd), mtchnCmptnYmd: formatDate(item.demandMatching?.mtchnCmptnYmd), - ruseUtztnFcltNm: item.ruseUtztnFcltNm, dmndQty: item.dmndQty, splyFcltFlg: flag, - completeYn: false, + completeYn: {chk:flag=="매칭완료", readonly:flag=="매칭완료"}, } as unknown as RvwHistTableType; }); @@ -215,9 +223,6 @@ export default function RuseRvwHstry() { } }, [rvwHistRes]); - useEffect(() => { - console.log("변경여부 ", form.formState.isDirty); - }, [form.formState]); return ( @@ -301,7 +306,7 @@ export default function RuseRvwHstry() { 조회 @@ -319,18 +324,14 @@ export default function RuseRvwHstry() { headlist={ruseHistHeadList} pageSize={20} total={rvwHistCount} - cellClick={(index: number | undefined) => { - TableCellClick(index); + cellClick={(index: number | undefined, headId: string) => { + console.log("테이블 클릭", index); + TableCellClick(index, headId); }} onPageChange={(page) => { setPageNatiion(page); }} > - {/*
-

- 수요신청 상세현황 -

- */} diff --git a/apps/wr/app/store/matDmd/coMatRvw/type.tsx b/apps/wr/app/store/matDmd/coMatRvw/type.tsx index 719071188..b1eee267f 100644 --- a/apps/wr/app/store/matDmd/coMatRvw/type.tsx +++ b/apps/wr/app/store/matDmd/coMatRvw/type.tsx @@ -1,3 +1,4 @@ +import type { ChkClass } from "@common/business_components/ui"; import { z } from "zod"; const DemandInfoSchema = z.object({ @@ -130,7 +131,7 @@ export type RvwHistTableType = { dmndQty: string; useUsgCd: string; splyFcltFlg: string; - completeYn: boolean; + completeYn: ChkClass; dmdInfoSn: string; }; diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx index d80747264..e2873d573 100644 --- a/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx @@ -6,6 +6,7 @@ export const ruseHstryHeadListExport:TableUpperProps[]= [ id: "cityText", title: "시도", visible: true, + }, { id: "sggText", diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx index 65f2d2730..c490dc399 100644 --- a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx @@ -130,7 +130,7 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( toast.success("매칭 계산 저장이 완료입니다."); const rvwHistRes = await irvwHistInit( 1, - 10, + 13, new Date().getFullYear().toString(), new Date().getFullYear().toString(), ); @@ -217,10 +217,10 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( fetchType.WR ); if (complet.status === 200) { - toast.success("완료 처리가 완료되었습니다."); + toast.success("매칭완료가 완료되었습니다."); const rvwHistRes = await irvwHistInit( 1, - 10, + 13, new Date().getFullYear().toString(), new Date().getFullYear().toString(), ); @@ -236,7 +236,7 @@ export const ruseHstryActionsExport: (set: any) => ruseHstryActions = ( } } catch (e) { console.log(" error ", e); - toast.error("완료 처리 중 오류가 발생했습니다."); + toast.error("매칭 완료 처리 중 오류가 발생했습니다."); } }, }; diff --git a/apps/wr/public/locales/ko/message.json b/apps/wr/public/locales/ko/message.json index 2258d80d6..d3c55de5e 100644 --- a/apps/wr/public/locales/ko/message.json +++ b/apps/wr/public/locales/ko/message.json @@ -12,8 +12,13 @@ "isUpdateMsg": "수정한 정보를 저장하시겠습니까?", "isInsertMsg": "등록하시겠습니까?", "isUpdatetMsg": "수정하시겠습니까?", - + "matchFinishMsg" : "{{name}}이(가) 완료되었습니다.", "excelDownErrMsg": "다운로드할 데이터가 없습니다.", + "isMatchFinishMsg":" 매칭완료를 진행하시겠습니까?", + "isNotMatchFinishMsg":"검토완료중 매칭완료 여부를 체크한 항목이 없습니다.", + "canNotChangeMatStateMsg":"매칭완료된 항목은 상태를 변경할 수 없습니다.", + + "alreadyInsertedErrMsg": "사업자번호 {{num}}(은)는 이미 등록되었습니다. 다시 등록해주세요.", "saveRowErrMsg": "수정을 원하는 행을 선택하고 저장버튼을 눌러주세요.",