From 584bd9b432952b4f37fa56a9cf7b91763615e5ec Mon Sep 17 00:00:00 2001 From: leedj312 Date: Fri, 23 May 2025 15:03:25 +0900 Subject: [PATCH 01/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EC=98=88=EC=8B=9C=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=A0=84=EB=8B=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 13 +++++++++---- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 17 +++++++++++++++++ .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 2 ++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 8994e46c1..4a7da579d 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -19,7 +19,7 @@ import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRe import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; export default function PublicReuseFaciltyInsert() { - const { code, pbnst, pubHasuInit } = useWrStore((state) => state); + const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); const { pubFacHeadList,pbnstHasuRes } = pbnst; @@ -31,11 +31,12 @@ export default function PublicReuseFaciltyInsert() { useEffect(() => { - if (!pbnst.isInit) { + if (!pbnst.isInit ) { pubHasuInit(undefined); - } - }, [pbnst.isInit, pubHasuInit]); + pbnstRegInit( '41'); + } + }, [pbnst.isInit, pubHasuInit,pbnstRegInit]); useEffect(() => { if (code.sggCd.length > 0) { @@ -43,6 +44,10 @@ useEffect(() => { } }, [code, pbnstHasuRes]); + useEffect(() => { + console.log("/pbnstRes ", pbnstRes) + }, [pbnstRes]); + const onSelectValue = (val: string) => { console.log(val); diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index f24d33ad3..ac33f48ac 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -22,6 +22,15 @@ export const pubMngUpHeadListExport: TableUpperProps[] = [ { id: "startDay", title: "시작일", upName: "upChangeRe", upSequnce: 1 }, { id: "endDay", title: "종료일", upName: "upChangeRe", upSequnce: 2 }, ]; + + +export const pubOrgwtHeadListExport: TableUpperProps[] = [ + { id: "ruseUtztnFcltNm", title: "운영방식" }, + { id: "orgwtWtritQnt", title: "원수취수량" }, + { id: "tmsYn", title: "하수처리량TMS 전후", }, + { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​", }, + { id: "dtlPstnExpln", title: "상세위치 설명", }, +]; const date = new Date(); export const pubMngNmExport: chHeadType[] = [ @@ -73,4 +82,12 @@ export const businessSttnInfo:formDetailType[]=[ {id:'bizMthdCd' , lable:'사업방식'}, {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , +] + + +export const ruseFcltIntakeList:formDetailType[]=[ + {id:'seCd' , lable:'구분'}, + {id:'bizMthdCd' , lable:'사업방식'}, + {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, + {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , ] \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 912d9dc77..0c9aa6bef 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -58,6 +58,8 @@ export function PbnstBuseForm() { useEffect(() => { if (getBizCycle ) { console.log("getBizCycle", getBizCycle); + + form.reset() } }, [getBizCycle]); From bf6ad4ee79a3ec2ba6cbb501a3f84cd135a3f9d2 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Fri, 23 May 2025 17:37:46 +0900 Subject: [PATCH 02/62] =?UTF-8?q?=EA=B3=B5=EA=B3=B5=20=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 6 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 31 ++++++---- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 62 +++++++++++-------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 34 ++-------- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 28 +++++++-- 5 files changed, 84 insertions(+), 77 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index ac33f48ac..8aa75fd28 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -16,7 +16,7 @@ export const pubFacHeadListExport: TableUpperProps[] = [ { id: "authoDay", title: "등록여부" }, ]; -export const pubMngUpHeadListExport: TableUpperProps[] = [ +export const pbnstMngUpHeadListExport: TableUpperProps[] = [ { id: "mng", title: "운영방식" }, { id: "subCo", title: "대행업체" }, { id: "startDay", title: "시작일", upName: "upChangeRe", upSequnce: 1 }, @@ -24,7 +24,7 @@ export const pubMngUpHeadListExport: TableUpperProps[] = [ ]; -export const pubOrgwtHeadListExport: TableUpperProps[] = [ +export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "ruseUtztnFcltNm", title: "운영방식" }, { id: "orgwtWtritQnt", title: "원수취수량" }, { id: "tmsYn", title: "하수처리량TMS 전후", }, @@ -33,7 +33,7 @@ export const pubOrgwtHeadListExport: TableUpperProps[] = [ ]; const date = new Date(); -export const pubMngNmExport: chHeadType[] = [ +export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index b8e3a00ea..a4ee07a95 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -2,34 +2,36 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; import { getFetch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; -import { pubFacHeadListExport, pubMngNmExport, pubMngUpHeadListExport } from "./headList"; import { exampleData, fcBizSchema, type customPbnst, type pubHasuType } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; +import { pbnstMngUpHeadListExport, pbnstOrgwtHeadListRxport, pbnstMngNmExport, pubFacHeadListExport } from "./headList"; const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }]; const pubFacHeadList= pubFacHeadListExport; -const pubMngUpHeadList = pubMngUpHeadListExport -const pubMngNm= pubMngNmExport; +const pbnstMngUpHeadList = pbnstMngUpHeadListExport +const pbnstOrgwtHeadList =pbnstOrgwtHeadListRxport +const pbnstMngNm= pbnstMngNmExport; export type pubFacState = { pbnst: { isInit: boolean; pubFacHeadList: TableUpperProps[]; - pubMngUpHeadList: TableUpperProps[]; - pubMngNm: chHeadType[]; + pbnstMngUpHeadList: TableUpperProps[]; + pbnstMngNm: chHeadType[]; pbnstHasuRes: pubHasuType[] - selectLabel: SelectDataType[]; pbnstRes: customPbnst[]; pbnstBizCycle: SelectDataType[]; + selectLabel: SelectDataType[]; + pbnstOrgwtHeadList:TableUpperProps[] }; }; type pubFacActions = { + pubHasuInit: (txt: string | undefined) => void; pbnstRegInit: (sgg: string) => void; pbnstRegSearch: (txt: string | undefined, sgg: string) => void; pbnstReg: (txt: string | undefined) => void; - pubHasuInit: (txt: string | undefined) => void; }; export type pubFacType = pubFacState & pubFacActions; @@ -38,12 +40,13 @@ export const pubFacStateExport: pubFacState = { pbnst: { isInit: false, pubFacHeadList: pubFacHeadList, - pubMngUpHeadList: pubMngUpHeadList, - selectLabel: selectLabel, - pubMngNm: pubMngNm, + pbnstMngUpHeadList: pbnstMngUpHeadList, + pbnstMngNm: pbnstMngNm, + pbnstOrgwtHeadList:pbnstOrgwtHeadList, pbnstHasuRes: [], pbnstRes: [], - pbnstBizCycle:[] + pbnstBizCycle:[{text:'없음', val:'1'}], + selectLabel: selectLabel, }, }; @@ -55,13 +58,14 @@ const initFetch = async (txt: string | undefined) => { return rainRes; }; -const getBizCycle = async (fcBizs: z.infer[] ) => { +const getBizCycle = (fcBizs: z.infer[] ) => { const pbnstBizCycle =fcBizs.map((item: z.infer) => { return { - text: `${item.cycl}차수`, + text: `${item.cycl}차`, val: item.cycl, }; }); + return pbnstBizCycle; } export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { @@ -92,6 +96,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { const pbnstRes = exampleData; const pbnstBizCycle = getBizCycle(pbnstRes?.fcBizs); + return set((state: pubFacState) => ({ ...state, pbnst: { diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 0c9aa6bef..d566fec8f 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -1,9 +1,7 @@ "use client"; import { SelectBox } from "@common/business_components"; -import { - FormUi, -} from "@common/business_components/ui"; +import { FormUi } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -28,18 +26,16 @@ import { ruseFcltinfo, wasteWaterFcltINfo, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; -import { pbnstRegZod } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; - +import { pbnstRegZod } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; export function PbnstBuseForm() { const { code, pbnst } = useWrStore((state) => state); - const { pubMngUpHeadList,pbnstBizCycle } = pbnst; - const [getBizCycle, setBizCycle] = useState(''); - + const { pbnstBizCycle } = pbnst; + const [getBizCycle, setBizCycle] = useState([{ text: "없음", val: "1" }]); const form = useForm>({ resolver: zodResolver(pbnstRegZod), - }); // 2. Define a submit handler. @@ -56,13 +52,16 @@ export function PbnstBuseForm() { const [bizCmcnDate, setBizCmcnDate] = useState(new Date()); const [files, setFiles] = useState(null); useEffect(() => { - if (getBizCycle ) { - console.log("getBizCycle", getBizCycle); - - form.reset() + console.log("getBizCycle", getBizCycle); + if (getBizCycle) { + form.reset(); } }, [getBizCycle]); + useEffect(() => { + console.log("pbnstBizCycle", pbnstBizCycle); + }, [pbnstBizCycle]); + return (
{/* 차수별 등록 현황 폼 */} @@ -76,18 +75,22 @@ export function PbnstBuseForm() {

등록차수

- - 0 && pbnstBizCycle[0]? pbnstBizCycle[0].val : ""} - className={""} - selectClass={selectClass} - onSelectValue={(val) => {setBizCycle}} - > - - + 0 && pbnstBizCycle[0] + ? pbnstBizCycle[0].val + : "" + } + className={""} + selectClass={selectClass} + onSelectValue={(val) => { + setBizCycle; + }} + > +
@@ -98,7 +101,7 @@ export function PbnstBuseForm() { moClass="grid grid-cols-12 gap-4" sonClass="col-span-4" /> - +

재이용 원수취수 현황

+
+ + +
diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index dc18ebd4a..699a687e9 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -37,7 +37,7 @@ const formSchema = z.object({ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { const { pbnst } = useWrStore((state) => state); - const { pubMngUpHeadList, isInit } = pbnst; + const { pbnstMngUpHeadList, isInit } = pbnst; const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); const [relationfiles, setRelationFiles] = useState(null); @@ -114,33 +114,7 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { // handleSuccess: setUpload, // }) }, [relationfiles]); - const headMakeColSpan = (upHeadList: TableUpperProps[]) => { - return ( - <> - - {upHeadList.map((head: TableUpperProps) => - !head.upSequnce ? ( - - {head.title} - - ) : head.upName === "upChangeRe" && head.upSequnce === 1 ? ( - - {"운영대행기간"} - - ) : null - )} - - - {upHeadList.map((head: TableUpperProps) => - head.upName === "upChangeRe" ? ( - {head.title} - ) : null - )} - - - ); - }; - const nodeList = headMakeColSpan(pubMngUpHeadList); + return (
@@ -186,8 +160,8 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) {
diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 6ba5739db..121ad80f4 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -1,7 +1,15 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { Input, Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components/ui"; +import { + Input, + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@common/components/ui"; export default function RuseMngTable({ tableData, @@ -10,13 +18,23 @@ export default function RuseMngTable({ }: { tableData: any[]; headList: TableUpperProps[]; - upHeadList: chHeadType[]; + upHeadList?: chHeadType[]; }) { return ( <> - {headMakeprfmnc(headList, upHeadList)} + {upHeadList ? ( + headMakeprfmnc(headList, upHeadList) + ) : ( + + {headList.map((head) => ( + + {head.title} + + ))} + + )} @@ -32,9 +50,7 @@ export default function RuseMngTable({ { - ; - }} + onChange={(e) => {}} value={item[head.id] || ""} /> ) : ( From 1aea094798beb4329ae2099356266b79f13db047 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Mon, 26 May 2025 09:27:07 +0900 Subject: [PATCH 03/62] =?UTF-8?q?build=20=EC=97=90=EB=9F=AC=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/fo/next-env.d.ts | 5 ++ .../src/ui/chart/BarChart.tsx | 6 +- .../src/ui/chart/LineChart.tsx | 17 ++--- .../src/ui/excel/excelStyle.tsx | 11 ++-- .../src/ui/excel/index.tsx | 63 ++++++++----------- .../src/ui/search_base_form/index.tsx | 2 + .../src/ui/search_form_left/index.tsx | 4 +- .../business_components/src/ui/tab/index.tsx | 54 ++++++++-------- .../src/ui/table/index.tsx | 2 + 9 files changed, 86 insertions(+), 78 deletions(-) create mode 100644 apps/fo/next-env.d.ts diff --git a/apps/fo/next-env.d.ts b/apps/fo/next-env.d.ts new file mode 100644 index 000000000..1b3be0840 --- /dev/null +++ b/apps/fo/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index cdc88075b..0802a72e4 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -64,10 +64,10 @@ const CustomLegend = (props: any) => { const { payload } = props; return (
- {payload.map((entry, index: number) => ( + {payload.map((entry: unknown, index: number) => (
-
- {entry.value} +
+ {(entry as {value: string}).value}
))}
diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index a689af8ca..4014702b6 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -113,20 +113,21 @@ export default function Linechart({ }, []); // 데이터의 최대값 계산 - const getMaxValue = (data: ChartDataType, keyPrefix: string) => { - return Math.max(...Object.values(data).map(item => - Object.keys(item) - .filter(key => key.includes(keyPrefix)) - .map(key => item[key] as unknown as number) - ).flat()); + const getMaxValue = (data: ChartDataType): number => { + return Math.max(...Object.values(data).flatMap(dataset => + dataset.map(entry => { + const val = parseFloat(entry.val); + return isNaN(val) ? 0 : val; + }) + )); }; - const lineMaxValue = getMaxValue(chartData, 'lineVal'); + const lineMaxValue = getMaxValue(chartData); return (
{chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( -
+
{chartTitle}
) : null} diff --git a/packages/common/business_components/src/ui/excel/excelStyle.tsx b/packages/common/business_components/src/ui/excel/excelStyle.tsx index 1c6b2b0e2..3c8f8d219 100644 --- a/packages/common/business_components/src/ui/excel/excelStyle.tsx +++ b/packages/common/business_components/src/ui/excel/excelStyle.tsx @@ -1,5 +1,6 @@ -import type { sheetParameter } from '@/index'; +// import type { sheetParameter } from '@/index'; import * as XlsxPopulate from '@xlsx/xlsx-populate'; +import type { SheetParameter } from './index'; @@ -38,13 +39,13 @@ export const excelStyle = async (data: ArrayBuffer, range: string = "A1:V3", fil } -export const excelArrayStyle = async (data: ArrayBuffer, range: Array, fileNm:string) => { +export const excelArrayStyle = async (data: ArrayBuffer, range: SheetParameter[], fileNm: string) => { const workbook = await XlsxPopulate.Workbook.fromData(data); - if(range){ - range.forEach((item , index)=>{ + if (range) { + range.forEach((item, index) => { const rangeCells = workbook.activeSheet(index)?.sheet(index)?.range(item.headerRange); console.log(rangeCells); - rangeCells?.style((styleQ)=>{ + rangeCells?.style((styleQ) => { makeCellStyle(styleQ) }); diff --git a/packages/common/business_components/src/ui/excel/index.tsx b/packages/common/business_components/src/ui/excel/index.tsx index 76b4ba2f9..96f3b3e5d 100644 --- a/packages/common/business_components/src/ui/excel/index.tsx +++ b/packages/common/business_components/src/ui/excel/index.tsx @@ -5,7 +5,7 @@ type ExcelDownloadProps = { data: JSON | JSON[]; fileName: string; sheetNameArray: string[]; - headerRange: string; + headerRange?: string; } export const downloadExcel = ({ data, fileName = new Date().getTime().toString() + '.xlsx', sheetNameArray = ["Sheet1"], headerRange='A1:V3'}: ExcelDownloadProps) => { @@ -15,17 +15,21 @@ export const downloadExcel = ({ data, fileName = new Date().getTime().toString() excelStyle(XLSX.write(workbook, { bookType: "xlsx", type: "buffer" }), headerRange, fileName); }; -export const sheetParameter ={ - data:[[]], headerNum:0, headerRange:'A1:V3', sheetName:'Sheet1', startCol:0 -} +export type SheetParameter = { + data: any[][]; + headerNum: number; + headerRange: string; + sheetName: string; + startCol?: string; +}; -export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: Array): Promise => { +export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: SheetParameter[]): Promise => { const workbook = XLSX.utils.book_new(); for (let i = 0; i < sheetArray.length; i++) { // Create a new worksheet for each sheet const worksheet = XLSX.utils.aoa_to_sheet(sheetArray[i]?.data || [[]]); // Add data to the worksheet starting from the specified header number - if (sheetArray&&sheetArray[i]?.headerNum) { + if (sheetArray && sheetArray[i]?.headerNum) { XLSX.utils.sheet_add_aoa(worksheet, sheetArray[i]?.data || [[]], { origin: `A${sheetArray[i]?.headerNum}` }); } // Append the worksheet to the workbook with the specified sheet name @@ -37,7 +41,6 @@ export const downloadMultipleExcel = (fileName = new Date().getTime().toString() return Promise.resolve(undefined); }; - export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):Promise =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -80,8 +83,6 @@ export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):P }); } - - export const filePickedArray=(oFile: File, headerNum:number=0):Promise =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -123,8 +124,6 @@ export const filePickedArray=(oFile: File, headerNum:number=0):Promise =>{ // Create A File Reader HTML5 return new Promise(() => { // Ready The Event For When A File Gets Selected @@ -149,28 +148,20 @@ export const filePickedBlob=(oFile: ArrayBuffer, data:[][],fileNm:string, header }); } - export const filePickedBlobArray= (oFile: ArrayBuffer,fileNm:string, sheetArray: [typeof sheetParameter]):Promise =>{ // Create A File Reader HTML5 - return new Promise (async () => { - // Ready The Event For When A File Gets Selected - const wb = XLSX.read(oFile, { type: 'binary' }); - // Loop Over Each Sheet - wb.SheetNames.forEach( function (sheetName, index) { - // Obtain The Current Row As CSV - if(sheetArray[index]){ - const sheet = wb.Sheets[sheetName]; - if (sheet) { - //오리진 확인 test 필요 - // const sheet = XLSX.utils.json_to_sheet(data); - const startCol = sheetArray[index].startCol?sheetArray[index].startCol.toString():'A'; - XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol+sheetArray[index].headerNum }); - // XLSX.utils.book_append_sheet(wb, sheet, 'test'); - } else { - console.error(`Sheet "${sheetName}" is undefined.`); - } - } - }); - - - await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) - }); - } \ No newline at end of file +export const filePickedBlobArray = (oFile: ArrayBuffer, fileNm: string, sheetArray: SheetParameter[]): Promise => { + return new Promise(async () => { + const wb = XLSX.read(oFile, { type: 'binary' }); + wb.SheetNames.forEach(function (sheetName, index) { + if (sheetArray[index]) { + const sheet = wb.Sheets[sheetName]; + if (sheet) { + const startCol = sheetArray[index].startCol ? sheetArray[index].startCol : 'A'; + XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol + sheetArray[index].headerNum }); + } else { + console.error(`Sheet "${sheetName}" is undefined.`); + } + } + }); + await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) + }); +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/search_base_form/index.tsx b/packages/common/business_components/src/ui/search_base_form/index.tsx index 9dc1bf735..b8d8355ae 100644 --- a/packages/common/business_components/src/ui/search_base_form/index.tsx +++ b/packages/common/business_components/src/ui/search_base_form/index.tsx @@ -1,3 +1,5 @@ +"use client" + import { Button } from "@common/components/ui"; import { useCallback, useEffect, useState } from "react"; import { SearchFormLeft, type EnvPartSelectDataType } from "../search_form_left"; diff --git a/packages/common/business_components/src/ui/search_form_left/index.tsx b/packages/common/business_components/src/ui/search_form_left/index.tsx index ec9e814f5..02112f084 100644 --- a/packages/common/business_components/src/ui/search_form_left/index.tsx +++ b/packages/common/business_components/src/ui/search_form_left/index.tsx @@ -1,4 +1,6 @@ -import React, { useEffect, useState } from 'react'; +"use client" + +import React, { useEffect, useState } from 'react'; import type { SelectDataType } from '../search_input_select'; import { SelectBox } from '../select'; diff --git a/packages/common/business_components/src/ui/tab/index.tsx b/packages/common/business_components/src/ui/tab/index.tsx index 4fb305830..aee969460 100644 --- a/packages/common/business_components/src/ui/tab/index.tsx +++ b/packages/common/business_components/src/ui/tab/index.tsx @@ -6,37 +6,41 @@ interface TabItem { label: string; } -interface UITabProps extends React.HTMLAttributes { +interface UITabProps extends Omit, 'dir'> { defaultValue?: string; tabList: TabItem[]; children: React.ReactNode; onValueChange?: (value: string) => void; } -const UITab = React.forwardRef< +const UITab = React.forwardRef< HTMLDivElement, UITabProps ->(({defaultValue, tabList, children, onValueChange})=>{ - // Exclude 'dir' if it exists and is not of the correct type - return ( - - - {tabList.map((tab) => ( - - {tab.label} - - ))} - - {children} - - ) -}) +>(({defaultValue, tabList, children, onValueChange, ...props}, ref) => { + return ( + + + {tabList.map((tab) => ( + + {tab.label} + + ))} + + {children} + + ); +}); + +UITab.displayName = 'UITab'; + export { UITab }; diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index 791eddffe..48f4deb62 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,3 +1,5 @@ +"use client" + import { Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components"; import { useEffect, useState } from "react"; import { HeadMakeColSpan } from "./HeadMakeColSpan"; From 93beaa7a67351249695269d73b35a6a861985bd0 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 26 May 2025 09:59:07 +0900 Subject: [PATCH 04/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=82=AC=EC=97=85=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 15 ++- .../ruseFcltMng/fcltSttn/pbnstSttn/page.tsx | 4 +- .../prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx | 6 +- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 35 ++++- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 19 ++- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 50 ++++++-- .../ruseFcltMng/fcltSttn/pbnstSttn/index.tsx | 2 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 120 +++++++++++++----- .../mngRegFormDetail/mngRegFormDetail.tsx | 23 ++-- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 2 +- 10 files changed, 212 insertions(+), 64 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 4a7da579d..57f77dfff 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -14,9 +14,10 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; import { useEffect, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; import { tableData } from "@/components/lib/func/commom"; -import type { customPbnst, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { customPbnst, fcBizSchema, fcBizType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; +import { z } from "zod"; export default function PublicReuseFaciltyInsert() { const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); @@ -26,6 +27,8 @@ export default function PublicReuseFaciltyInsert() { const {pbnstRes} = pbnst const [currentTab, setCurrentTab] = useState("mng"); const [fcltMng, setFcltMng] = useState(); + const [pbnstBiz, setPbnstBiz] = useState(); + const [searchTxt, setSearchTxt] = useState(); const [bdstTable, setbdstTable] = useState(); @@ -53,8 +56,9 @@ useEffect(() => { console.log(val); }; const cellClick = (val: number | undefined) => { - if (val === undefined) return; + + setPbnstBiz(pbnstRes?.fcBizs) setFcltMng([]); }; const resetContents = () => { @@ -65,6 +69,11 @@ useEffect(() => { setCurrentTab(value); }; + useEffect(() => { + + console.log("pbnstBiz", pbnstBiz); + },[pbnstBiz]) + return ( <> @@ -129,7 +138,7 @@ useEffect(() => { - + diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index c294bdf93..a662ffb7a 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -14,7 +14,7 @@ import { Button } from "@common/components/ui"; import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal"; import { useCallback, useEffect, useRef, useState } from "react"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; -import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg"; +import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; export default function PbnstSttn() { const { code, pbnstSttn } = useWrStore( @@ -26,10 +26,8 @@ export default function PbnstSttn() { const [pageNation, setPageNation] = useState(1); const [isChHead, setIsChHead] = useState(false); const [bdstTable, setBdstTable] = useState(); - // const nodeList = headMakeprfmnc(pbnstSttn.pbnSttHeadList, pbnstSttn.pbnSttHeadNm); const excelClick = useCallback(() => { - // if (codeData) pbnstSttnSearch(1, "10000", codeData); }, []); return ( diff --git a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx index 110c684bf..c6737b31e 100644 --- a/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx +++ b/apps/wr/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/index.tsx @@ -66,7 +66,11 @@ export const rswtChkgdnStateExport: rswtChkgdnState = { rswtChkHeadList: rswtChkHeadList, rswtDetailHeadList: rswtDetailHeadList, rswtHeadNm: rswtHeadNm, - excelList: [{ data: [[]], headerNum: 0, headerRange: "A1:V3" }], + excelList: [{ + data: [[]], headerNum: 0, headerRange: "A1:V3", + sheetName: "", + startCol: 0 + }], rswtChkRes: [], rswtChkPolGuide: [], isInit: false, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 8aa75fd28..d3a0e5f0e 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -24,6 +24,24 @@ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ ]; +export const pplInstlsHeadListExport: TableUpperProps[] = [ + { id: "ppMqlt", title: "관재질", }, + { id: "pdmt", title: "관경" }, + { id: "cpct", title: "연장", }, +]; + + +export const pbnstDemandHeadListExport: TableUpperProps[] = [ + { id: "dmdCoNm", title: "수요처명" }, + { id: "daddr", title: "위치(주소)" }, + { id: "useUsgCd", title: "사용용도", }, + { id: "splyBgngDay", title: "공급시작일", }, + { id: "splyEndDay", title: "공급종료일", }, + { id: "splyCpct", title: "공급량(m³/일)", }, + { id: "splyFmYon", title: "공급유량계 유무", }, +]; + + export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "ruseUtztnFcltNm", title: "운영방식" }, { id: "orgwtWtritQnt", title: "원수취수량" }, @@ -31,7 +49,6 @@ export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​", }, { id: "dtlPstnExpln", title: "상세위치 설명", }, ]; -const date = new Date(); export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, @@ -72,7 +89,7 @@ export const businessMoneyInfo:formDetailType[]=[ {id:'gvsbs' , lable:'국고'}, {id:'lcep' , lable:'지방비'}, {id:'username' , lable:'민간투자비'}, - {id:'cusr_alotm' , lable:'원인자부담금'}, + {id:'cusrAlotm' , lable:'원인자부담금'}, {id:'etc' , lable:'기타'}, {id:'totalMoney' , lable:'합계'}, ] @@ -90,4 +107,18 @@ export const ruseFcltIntakeList:formDetailType[]=[ {id:'bizMthdCd' , lable:'사업방식'}, {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , +] + +export const ruseWaterQulityList:formDetailType[]=[ + {id:'bod' , lable:'BOD(mg/L)'}, + {id:'grssClfg' , lable:'총대장균군수(개/mg)'}, + {id:'combResdch' , lable:'결합잔류염소(mh/L)'}, + {id:'trbt' , lable:'탁도(NTU)'}, + {id:'smll' , lable:'냄새'}, + {id:'crmty' , lable:'색도'}, + {id:'tn' , lable:'총질소(mg/L)'}, + {id:'tph' , lable:'총인(mg/L)'}, + {id:'ph' , lable:'수소이온농도'}, + {id:'clIonQnt' , lable:'염화물(mg/L)'}, + {id:'cdtnv' , lable:'전기전도도(μs/cm)​'}, ] \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index a4ee07a95..d69adc713 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -4,7 +4,7 @@ import { getFetch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, fcBizSchema, type customPbnst, type pubHasuType } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; -import { pbnstMngUpHeadListExport, pbnstOrgwtHeadListRxport, pbnstMngNmExport, pubFacHeadListExport } from "./headList"; +import { pbnstMngUpHeadListExport, pbnstOrgwtHeadListRxport, pbnstMngNmExport, pubFacHeadListExport, pplInstlsHeadListExport, pbnstDemandHeadListExport } from "./headList"; const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }]; @@ -12,6 +12,8 @@ const pubFacHeadList= pubFacHeadListExport; const pbnstMngUpHeadList = pbnstMngUpHeadListExport const pbnstOrgwtHeadList =pbnstOrgwtHeadListRxport const pbnstMngNm= pbnstMngNmExport; +const pplInstlsHeadLisat =pplInstlsHeadListExport +const pbnstDemandHeadList= pbnstDemandHeadListExport export type pubFacState = { @@ -21,10 +23,12 @@ export type pubFacState = { pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; pbnstHasuRes: pubHasuType[] - pbnstRes: customPbnst[]; + pbnstRes: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경 pbnstBizCycle: SelectDataType[]; selectLabel: SelectDataType[]; pbnstOrgwtHeadList:TableUpperProps[] + pplInstlsHeadLisat:TableUpperProps[] + pbnstDemandHeadList:TableUpperProps[] }; }; type pubFacActions = { @@ -44,9 +48,11 @@ export const pubFacStateExport: pubFacState = { pbnstMngNm: pbnstMngNm, pbnstOrgwtHeadList:pbnstOrgwtHeadList, pbnstHasuRes: [], - pbnstRes: [], + pbnstRes: null, // 초기값을 null로 변경 pbnstBizCycle:[{text:'없음', val:'1'}], selectLabel: selectLabel, + pplInstlsHeadLisat:pplInstlsHeadLisat, + pbnstDemandHeadList:pbnstDemandHeadList, }, }; @@ -95,7 +101,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { const pbnstRes = exampleData; - const pbnstBizCycle = getBizCycle(pbnstRes?.fcBizs); + const pbnstBizCycle = pbnstRes ? getBizCycle(pbnstRes.fcBizs) : []; // pbnstRes가 null일 수 있으므로 체크 return set((state: pubFacState) => ({ ...state, @@ -116,7 +122,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { "wr", `/api/v1/reuseFc/pubFc` + (txt ? `/${txt}` : "") + `/${sgg}` ); - const pbnstBizCycle = getBizCycle(pbnstRes.fcBizs); + // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 + const pbnstBizCycle = pbnstRes && pbnstRes.fcBizs ? getBizCycle(pbnstRes.fcBizs) : []; + + return set((state: pubFacState) => ({ ...state, pbnst: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 1a8f1479f..043c8fedf 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -45,6 +45,12 @@ export type ruseFcltType = { splyExtraCpct: number; }; +export type fcBizType = z.infer; +export type fcOrgwtType = z.infer; +export type ppInstlType = z.infer; + +export type operType = z.infer; + const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), pdmt: z.string(), @@ -185,18 +191,18 @@ export const fcBizSchema = z.object({ export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.number().default(0), - swtrmtFcltFk: z.string(), - ruseUtztnFcltNm: z.string(), - fcltCpct: z.string(), - ruseCpct: z.string(), - splyExtraCpct: z.string(), + swtrmtFcltFk: z.string().default(""), + ruseUtztnFcltNm: z.string().default(""), + fcltCpct: z.string().default(""), + ruseCpct: z.string().default(""), + splyExtraCpct: z.string().default(""), regDt: z.date().default(new Date()), rgtr: z.string().default("test"), mdfcnDt: z.date().default(new Date()), mdfr: z.string().default("test"), - fcFiles: z.array(fcFileSchema), - fcBizs: z.array(fcBizSchema), - fcOpers: z.array(fcOperSchema), + fcFiles: z.array(fcFileSchema).default([]), + fcBizs: z.array(fcBizSchema).default([]), + fcOpers: z.array(fcOperSchema).default([]), }); const pubHasuZod = z.object({ @@ -286,6 +292,20 @@ export const exampleData = { archCstClcln: "380", pplCstClcln: "290", ruseFcltCstClcln: "4800", + pplInstls:[ + { + ruseFcltBizFk: "10", + pdmt: "관경", + ppMqlt: "1", + cpct: "100", + }, + { + ruseFcltBizFk: "10", + pdmt: "관경", + ppMqlt: "2", + cpct: "200", + }, + ], fcOrgwts: [ { pbnstRuseFcltBizFk: 10, @@ -380,6 +400,20 @@ export const exampleData = { archCstClcln: "380", pplCstClcln: "290", ruseFcltCstClcln: "4800", + pplInstls:[ + { + ruseFcltBizFk: "11", + pdmt: "관경", + ppMqlt: "1", + cpct: "100", + }, + { + ruseFcltBizFk: "11", + pdmt: "관경", + ppMqlt: "2", + cpct: "200", + }, + ], fcOrgwts: [ { pbnstRuseFcltBizFk: 11, diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index 09b5a0cad..e1a60d921 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -1,5 +1,4 @@ import type { CommonTableProps } from "@/app/store/common/type/headder"; -import type { customPbnst } from "../../fcltReg/pbnstReg"; import type { z } from "zod"; import { pbnSttHeadListExport, @@ -8,6 +7,7 @@ import { import { fetchType, getFetch } from "@/components/lib/api"; import { controlHeadView } from "../rainSttn"; import type { sttnHeadListType } from "../rainSttn/headList"; +import type { customPbnst } from "../../fcltReg/pbnstReg/type"; const pbnstSttHeadList = pbnSttHeadListExport; const pbnstSttNodeList = pbnstSttNodeListExport; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index d566fec8f..7e7adb03d 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -3,10 +3,10 @@ import { SelectBox } from "@common/business_components"; import { FormUi } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; -import { Button, Input, TableHead, TableRow } from "@common/components"; +import { Button, Input, Label, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { use, useEffect, useState } from "react"; -import { useForm } from "react-hook-form"; +import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; import { useWrStore } from "@/app/store"; import { @@ -24,43 +24,57 @@ import { businessSttnInfo, concentratedWaterInfo, ruseFcltinfo, + ruseWaterQulityList, wasteWaterFcltINfo, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; -import { pbnstRegZod } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { fcBizSchema, pbnstRegZod, type fcBizType, type fcOrgwtType, type ppInstlType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; -export function PbnstBuseForm() { +export function PbnstBuseForm({data} :{data: fcBizType[]} ) { const { code, pbnst } = useWrStore((state) => state); - const { pbnstBizCycle } = pbnst; - const [getBizCycle, setBizCycle] = useState([{ text: "없음", val: "1" }]); + const { pbnstBizCycle, pbnstRes + } = pbnst; + const [getBizCycle, setBizCycle] = useState('1'); + const [orgwtData ,setOrgwtData] = useState([]); + const [ppistlData ,setPpistlData] = useState([]); - const form = useForm>({ - resolver: zodResolver(pbnstRegZod), + const [ppiYn, setPpiYn] = useState("Y"); + const form = useForm({ + resolver: zodResolver(fcBizSchema), }); - + // 2. Define a submit handler. - function onSubmit(values: z.infer) { - // Do something with the form values. - // ✅ This will be type-safe and validated. + function onSubmit(values: fcBizType) { console.log(values); } const onSelectValue = (val: string) => { console.log(val); }; - const [instlAprvDate, setInstlAprvDate] = useState(new Date()); - const [bizCmcnDate, setBizCmcnDate] = useState(new Date()); - const [files, setFiles] = useState(null); + + const { fields: fcOrgwtFiled } = useFieldArray({ + control: form.control, + name: "fcOrgwts", + }); + + const { fields: pplInstls } = useFieldArray({ + control: form.control, + name: "pplInstls", + }); useEffect(() => { - console.log("getBizCycle", getBizCycle); - if (getBizCycle) { - form.reset(); + if(data){ + + const index = Number(getBizCycle) -1 + form.reset(data[index]); } - }, [getBizCycle]); + + }, [ getBizCycle,data]); useEffect(() => { - console.log("pbnstBizCycle", pbnstBizCycle); }, [pbnstBizCycle]); + useEffect(() => { + console.log("form errors:", form.formState.errors); + }, [form.formState.errors]); return (
@@ -80,14 +94,13 @@ export function PbnstBuseForm() { label="" selectArray={pbnstBizCycle} value={ - pbnstBizCycle.length > 0 && pbnstBizCycle[0] - ? pbnstBizCycle[0].val - : "" + getBizCycle?? pbnstBizCycle[0]?.val } className={""} selectClass={selectClass} onSelectValue={(val) => { - setBizCycle; + + setBizCycle(String(val)); }} > @@ -104,6 +117,8 @@ export function PbnstBuseForm() { 재이용 원수취수 현황
- - 추가등록 + +
+

재이용 공급관로 설치 현황

+
+ + setPpiYn(String(val))} + /> + + + + +
+ +
+ +
+ + + +

하수처리수 재이용수 수요처

+
+ +
diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 1c3a6dfb2..9edc93046 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -10,11 +10,13 @@ export default function MngRegFormDetail({ form, moClass, sonClass, + cycle, }: { formList: formDetailType[]; h1Title: string; form: any; moClass?: string; + cycle?:string sonClass?: string; }) { return ( @@ -22,11 +24,13 @@ export default function MngRegFormDetail({

{h1Title}

{formList?.map((item, index) => { + + const fieldId = cycle? `${cycle}.${item.id}`: item.id; return (
( {item.type === "select" ? ( @@ -34,17 +38,16 @@ export default function MngRegFormDetail({ ) : item.type === "date" ? ( - field.onChange(date), - }} - selectClass={"rounded-lg w-full"} - > + selected={safeDate(field.value) || new Date()} + onSelect={(date: Date | undefined) => + field.onChange(date) + } + className={"rounded-lg w-full"} + /> ) : item.type === "number" ? ( - + ) : ( - + )} )} diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 121ad80f4..0f5557821 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -29,7 +29,7 @@ export default function RuseMngTable({ ) : ( {headList.map((head) => ( - + {head.title} ))} From 06f5400569ba823225fd8c21ed98a22235be7bef Mon Sep 17 00:00:00 2001 From: jyha00 Date: Mon, 26 May 2025 16:07:08 +0900 Subject: [PATCH 05/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=EC=8B=9C=EC=84=A4=20=EB=93=B1=EB=A1=9D=20=EC=9A=B4?= =?UTF-8?q?=EC=98=81=EC=A0=95=EB=B3=B4=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EA=B0=80=EC=A0=B8=EC=98=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 16 ++-- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 10 +-- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 80 ++++++++----------- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 2 +- 4 files changed, 45 insertions(+), 63 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 57f77dfff..7585e2c32 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -21,17 +21,14 @@ import { z } from "zod"; export default function PublicReuseFaciltyInsert() { const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); - const { pubFacHeadList,pbnstHasuRes } = pbnst; - - - const {pbnstRes} = pbnst + const { pubFacHeadList,pbnstHasuRes, pbnstRes } = pbnst; const [currentTab, setCurrentTab] = useState("mng"); const [fcltMng, setFcltMng] = useState(); const [pbnstBiz, setPbnstBiz] = useState(); const [searchTxt, setSearchTxt] = useState(); const [bdstTable, setbdstTable] = useState(); - + const [selectBdst, setSelectBdst] = useState(); useEffect(() => { if (!pbnst.isInit ) { @@ -56,10 +53,9 @@ useEffect(() => { console.log(val); }; const cellClick = (val: number | undefined) => { - - - setPbnstBiz(pbnstRes?.fcBizs) - setFcltMng([]); + if (val === undefined) return; + console.log("pbnstRes", pbnstRes); + setSelectBdst(pbnstRes); }; const resetContents = () => { setFcltMng([]); // 빈 배열로 설정하여 신규 모드로 전환 @@ -135,7 +131,7 @@ useEffect(() => { 차수별정보 - + diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index d3a0e5f0e..fd1327a8b 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -17,11 +17,11 @@ export const pubFacHeadListExport: TableUpperProps[] = [ ]; export const pbnstMngUpHeadListExport: TableUpperProps[] = [ - { id: "mng", title: "운영방식" }, - { id: "subCo", title: "대행업체" }, - { id: "startDay", title: "시작일", upName: "upChangeRe", upSequnce: 1 }, - { id: "endDay", title: "종료일", upName: "upChangeRe", upSequnce: 2 }, -]; + { id: "operMthd", title: "운영방식" }, + { id: "rprtvBzenty", title: "대행업체" }, + { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1 }, + { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2 }, +]; export const pplInstlsHeadListExport: TableUpperProps[] = [ diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 699a687e9..8d1ce82b8 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -6,7 +6,7 @@ import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useState } from "react"; -import { set, useForm } from "react-hook-form"; +import { set, useFieldArray, useForm } from "react-hook-form"; import { nullable, z } from "zod"; import { useWrStore } from "@/app/store"; import { @@ -23,7 +23,7 @@ import { import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import type { Upload } from "tus-js-client"; -import type { fcltOperInfoType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { pbnstRegZod, type customPbnst, type fcltOperInfoType, type operType, type ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; const formSchema = z.object({ fcltNm: z.string().min(2).max(50), @@ -35,10 +35,11 @@ const formSchema = z.object({ splyExtraCpct: z.number(), }); -export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { +export function PbnstMngForm({ data }: { data: customPbnst }) { + console.log("data", data); const { pbnst } = useWrStore((state) => state); - const { pbnstMngUpHeadList, isInit } = pbnst; - const [ruseOperData, setRuseOperData] = useState(); + const { pbnstMngUpHeadList} = pbnst; + const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); const [relationfiles, setRelationFiles] = useState(null); @@ -53,35 +54,31 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { setProgress(Number(percentage)); }; - const form = useForm>({ - resolver: zodResolver(formSchema), - defaultValues: { - fcltNm: "", - psysScdg: "", - designScdg: "", - fcltCpct: 0, - swtrmtCpct: 0, - ruseCpct: 0, - splyExtraCpct: 0, - }, + const form = useForm>({ + resolver: zodResolver(pbnstRegZod), + defaultValues: {...data}, + }); + + const { fields: fcOpersField } = useFieldArray({ + control: form.control, + name: "fcOpers", }); - const selectOptions = data?.map((item) => ({ - text: item.fcltNm, - val: item.pbnstRuseFcltPk, - })) || [{ text: "없음", val: "1" }]; + console.log("fcOpersField", fcOpersField); + // const selectOptions = data?.map((item) => ({ + // text: item.fcltNm, + // val: item.pbnstRuseFcltPk, + // })) || [{ text: "없음", val: "1" }]; const onSelectValue = (val: string) => {}; useEffect(() => { - if (isInit) { - form.reset(); - setRuseOperData([{}] as fcltOperInfoType[]); - } - }, [isInit]); + form.reset(data); + // setRuseOperData(data.fcOpers); + }, [data]); // 2. Define a submit handler. - function onSubmit(values: z.infer) { + function onSubmit(values: z.infer) { console.log(values); } @@ -126,22 +123,7 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) {

재이용 시설명

- ( - - {}} - {...field} - /> - - )} - /> + {form.getValues("ruseUtztnFcltNm") ? ": " + form.getValues("ruseUtztnFcltNm") : ""}
@@ -159,7 +141,11 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) {
({ + ...item, + bgngDt: item.bgngDt.toLocaleDateString() || "", + endDt: item.endDt.toLocaleDateString() || "", + }))} headList={pbnst.pbnstMngUpHeadList} upHeadList={pbnst.pbnstMngNm} > @@ -174,7 +160,7 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { name="fcltCpct" render={({ field }) => ( - + )} /> @@ -185,7 +171,7 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { name="swtrmtCpct" render={({ field }) => ( - + )} /> @@ -196,7 +182,7 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { name="ruseCpct" render={({ field }) => ( - + )} /> @@ -207,7 +193,7 @@ export function PbnstMngForm({ data }: { data: ruseFcltType[] }) { name="splyExtraCpct" render={({ field }) => ( - + )} /> diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 0f5557821..121ad80f4 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -29,7 +29,7 @@ export default function RuseMngTable({ ) : ( {headList.map((head) => ( - + {head.title} ))} From 2b18aa2c4be602a4c03fd8165d612abe77d5d1ee Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 26 May 2025 16:10:34 +0900 Subject: [PATCH 06/62] =?UTF-8?q?=EB=AC=BC=20=ED=95=98=EC=88=98=EC=9E=AC?= =?UTF-8?q?=EC=9D=B4=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EC=82=AC=EC=97=85=20?= =?UTF-8?q?=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 5 +- apps/wr/app/store/common/code/index.ts | 29 ++++++++ .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 8 +-- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 41 +++++++++--- .../ruseFcltMng/fcltReg/rainReg/index.tsx | 2 + apps/wr/components/lib/api/index.ts | 8 ++- apps/wr/components/lib/config/index.ts | 3 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 67 +++++++++++-------- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 24 ++++++- 9 files changed, 139 insertions(+), 48 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 7585e2c32..8e7980481 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -39,7 +39,10 @@ useEffect(() => { }, [pbnst.isInit, pubHasuInit,pbnstRegInit]); useEffect(() => { - if (code.sggCd.length > 0) { + + + console.log("pbnstHasuRes", pbnstHasuRes); + if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { setbdstTable(tableData(pbnstHasuRes, { code })); } }, [code, pbnstHasuRes]); diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts index 86a03a120..b02918872 100644 --- a/apps/wr/app/store/common/code/index.ts +++ b/apps/wr/app/store/common/code/index.ts @@ -89,6 +89,31 @@ const chBuCd = [ { val: "개축", text: "개축" }, { val: "재축", text: "재축" }, ] + + +const pplQulity = [ + { val: "도복장강관", text: "도복장강관" }, + { val: "PE관", text: "PE관" }, + { val: "스테인레스관", text: "스테인레스관" }, + { val: "덕타일주철관", text: "덕타일주철관" }, + { val: "유리섬유복합관", text: "유리섬유복합관" }, + { val: "기타", text: "기타" }, + +] +const pplLenght = [ + { val: "D100", text: "D100" }, + { val: "D200", text: "D200" }, + { val: "D250", text: "D250" }, + { val: "D300", text: "D300" }, + { val: "D350", text: "D350" }, + { val: "D400", text: "D400" }, + { val: "D450", text: "D450" }, + { val: "D500", text: "D500" }, + { val: "D700", text: "D700" }, + { val: "D900", text: "D900" }, + { val: "D1000​", text: "D1000​" }, + +] export const buildingType = { RST:"RST", RNB:"RNB", @@ -109,6 +134,8 @@ export type comCodeState = { lclgvrnmntCd: EnvPartSelectDataType[]; orgwtKndCd: SelectDataType[]; yn: SelectDataType[]; + pplQulity: SelectDataType[]; + pplLenght: SelectDataType[]; buildingType: { RST:string, RNB:string, @@ -247,6 +274,8 @@ export const comCodeStateExport: comCodeState = { mdmbsnCd: [], lgbsnCd: [], lclgvrnmntCd: [], + pplQulity:pplQulity, + pplLenght:pplLenght, yn: yn, buildingType:buildingType, }, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index fd1327a8b..5435ef8bf 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -12,8 +12,8 @@ export const pubFacHeadListExport: TableUpperProps[] = [ { id: "addr", title: "위치" }, { id: "efflWqltStndrdNm", title: "지역구분" }, { id: "fctCpc", title: "시설용량" }, - { id: "yn", title: "재이용여부" }, - { id: "authoDay", title: "등록여부" }, + { id: "ruse", title: "재이용여부" }, + { id: "rswtrYn", title: "등록여부" }, ]; export const pbnstMngUpHeadListExport: TableUpperProps[] = [ @@ -25,8 +25,8 @@ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ export const pplInstlsHeadListExport: TableUpperProps[] = [ - { id: "ppMqlt", title: "관재질", }, - { id: "pdmt", title: "관경" }, + { id: "ppMqlt", title: "관재질", type: "select", selectData:'pplQulity' }, + { id: "pdmt", title: "관경", type: "select", selectData:'pplLenght'}, { id: "cpct", title: "연장", }, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index d69adc713..423e28c08 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -1,6 +1,6 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; -import { getFetch } from "@/components/lib/api"; +import { fetchType, getFetch, postFectch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, fcBizSchema, type customPbnst, type pubHasuType } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; @@ -56,12 +56,35 @@ export const pubFacStateExport: pubFacState = { }, }; -const initFetch = async (txt: string | undefined) => { - const rainRes = await getFetch( - "common", - `/prcsFclt/info/1/10/A/41220` + (txt ? `/${txt}` : "") + "/500" + "/1" +const checkWrRegList = async () => { + const wrRegList = await getFetch( + "wr", + `/reuseFc/pubFc` ); - return rainRes; + return wrRegList; +} + + +const hasuListFetch = async (txt: string | undefined ) => { + + const checkWrRegListRes = await checkWrRegList() + + +// prcsFclt/ruseInfo/1/20/A/11/0/1/SW + const rainRes = await postFectch( + `/prcsFclt/ruseInfo/1/10/A/11` + "/0" + "/1" +"/SW" + ,checkWrRegListRes, + fetchType.COMMON ); + + const hasuList = rainRes.data.map((item: any) => { + return { + ...item, + ruse: item.ruse===false ? 'N' : 'Y', }; + }) + + + + return hasuList; }; const getBizCycle = (fcBizs: z.infer[] ) => { @@ -79,8 +102,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pubHasuInit: async (txt: string | undefined) => { try { - const pbnstHasuRes = await initFetch(txt); + const pbnstHasuRes = await hasuListFetch(txt); + + console.log('qwe ',pbnstHasuRes) return set((state: pubFacState) => ({ ...state, @@ -141,7 +166,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, pbnstReg: async (txt: string | undefined) => { try { - const pbnstRes = await initFetch(txt); + const pbnstRes = await hasuListFetch(txt); return set((state: pubFacState) => ({ ...state, pbnst: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx index 4f6bd576c..e7e0a3653 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/rainReg/index.tsx @@ -1,6 +1,7 @@ import { getFetch, postFectch, putFectch } from "@/components/lib/api"; import { z } from "zod"; import { makeMdfr, makeRstr } from "../bdstReg"; +import type { SelectDataType } from "@common/business_components/ui"; export const TEST_UUID= '2d4b151d-1828-41e0-91d9-4cd28ea1cc7e' export const rainZod = z.object({ @@ -90,6 +91,7 @@ export type TableUpperProps = { visible?:boolean; rowSpan?: true; type?: string; + selectData ?:string; }; export const upHeadList: TableUpperProps[] = [ diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index 0ffa0d53c..6e3b9b1a8 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -20,11 +20,13 @@ export const getFetch = async( type:string , url: string) => { return res.data; } -export const postFectch = async (url: string, params: any) => { +export const postFectch = async (url: string, params: any , type?:string) => { + const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR - const response = await fetch(DEV_URL_WR+url, { + const response = await fetch(div+url, { method: "POST", headers: { + 'accept': 'application/json', "Content-Type": "application/json", }, body: JSON.stringify(params), @@ -32,7 +34,7 @@ export const postFectch = async (url: string, params: any) => { if(!response.ok) { throw new Error(`오류 발생: ${response.status}`); } - return response; + return await response.json(); } diff --git a/apps/wr/components/lib/config/index.ts b/apps/wr/components/lib/config/index.ts index 0ed7b82dd..1348c2dc1 100644 --- a/apps/wr/components/lib/config/index.ts +++ b/apps/wr/components/lib/config/index.ts @@ -6,8 +6,9 @@ const DEV_PORT_NEW="11082" export const LOCAL_URL_WR = `http://localhost:${LOCAL_PORT}/api/v1`; export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`; +// export const DEV_URL_WR = `http://192.168.0.91:8880/api/v1`; -//export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_FO}/api/v1`; +// export const DEV_URL_FO = `http://192.168.0.91:8882/api/v1`; export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 7e7adb03d..d7b8e47b7 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -1,7 +1,7 @@ "use client"; import { SelectBox } from "@common/business_components"; -import { FormUi } from "@common/business_components/ui"; +import { FormUi, type SelectDataType } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input, Label, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -27,51 +27,64 @@ import { ruseWaterQulityList, wasteWaterFcltINfo, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; -import { fcBizSchema, pbnstRegZod, type fcBizType, type fcOrgwtType, type ppInstlType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { + fcBizSchema, + pbnstRegZod, + type fcBizType, + type fcOrgwtType, + type ppInstlType, +} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; -export function PbnstBuseForm({data} :{data: fcBizType[]} ) { +export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const { code, pbnst } = useWrStore((state) => state); - const { pbnstBizCycle, pbnstRes - } = pbnst; - const [getBizCycle, setBizCycle] = useState('1'); - const [orgwtData ,setOrgwtData] = useState([]); - const [ppistlData ,setPpistlData] = useState([]); - + const { pbnstBizCycle, pbnstRes } = pbnst; + const [getBizCycle, setBizCycle] = useState("1"); + const [ppiSelectList, setPpiSelectList] = + useState<[{ name: string; val: SelectDataType[] }]>(); const [ppiYn, setPpiYn] = useState("Y"); const form = useForm({ resolver: zodResolver(fcBizSchema), }); - + // 2. Define a submit handler. function onSubmit(values: fcBizType) { console.log(values); } - const onSelectValue = (val: string) => { - console.log(val); - }; - - const { fields: fcOrgwtFiled } = useFieldArray({ + const { fields: fcOrgwtFiled } = useFieldArray({ control: form.control, name: "fcOrgwts", }); - const { fields: pplInstls } = useFieldArray({ + const { fields: pplInstls } = useFieldArray({ control: form.control, name: "pplInstls", }); useEffect(() => { - if(data){ - - const index = Number(getBizCycle) -1 + if (data) { + const index = Number(getBizCycle) - 1; form.reset(data[index]); } - - }, [ getBizCycle,data]); + }, [getBizCycle, data]); useEffect(() => { - }, [pbnstBizCycle]); + const ppl = []; + if (code.pplLenght) { + ppl.push({ name: "pplLenght", val: code.pplLenght }); + } + if (code.pplLenght) { + ppl.push({ name: "pplQulity", val: code.pplQulity }); + } + if (ppl.length > 0) { + setPpiSelectList(ppl); + } + }, [code]); + + useEffect(() => { + console.log("ppiSelectList:", ppiSelectList); + }, [ppiSelectList]); + useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -93,13 +106,10 @@ export function PbnstBuseForm({data} :{data: fcBizType[]} ) { { - setBizCycle(String(val)); }} > @@ -117,8 +127,6 @@ export function PbnstBuseForm({data} :{data: fcBizType[]} ) {
diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 121ad80f4..946470ab4 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -1,6 +1,7 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; -import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { SelectBox, type SelectDataType } from "@common/business_components/ui"; import { Input, Table, @@ -15,11 +16,16 @@ export default function RuseMngTable({ tableData, headList, upHeadList, + code = [], }: { tableData: any[]; headList: TableUpperProps[]; upHeadList?: chHeadType[]; + code?:{name:string, val:SelectDataType[] }[] }) { + + + return ( <>
@@ -53,7 +59,21 @@ export default function RuseMngTable({ onChange={(e) => {}} value={item[head.id] || ""} /> - ) : ( + ) : head.type === "select" ? ( + item.name === head.selectData)?.val ?? []} + value={ + tableData[index][item[head.id]] + } + className={""} + selectClass={selectClass} + onSelectValue={(val) => { + tableData[index][head.id] = val; + }} + > + ) + : ( `${item[head.id] || ""}` )} From eab7893c4fcbaa925e37e02367e2efc1267338c8 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 26 May 2025 16:19:00 +0900 Subject: [PATCH 07/62] =?UTF-8?q?=EC=82=AC=EC=97=85=20=EB=93=B1=EB=A1=9D?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 9 ++------- .../ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx | 2 +- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 8e7980481..c59b65e11 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -28,7 +28,7 @@ export default function PublicReuseFaciltyInsert() { const [searchTxt, setSearchTxt] = useState(); const [bdstTable, setbdstTable] = useState(); - const [selectBdst, setSelectBdst] = useState(); + const [selectBdst, setSelectBdst] = useState(null); useEffect(() => { if (!pbnst.isInit ) { @@ -47,18 +47,13 @@ useEffect(() => { } }, [code, pbnstHasuRes]); - useEffect(() => { - console.log("/pbnstRes ", pbnstRes) - }, [pbnstRes]); - - const onSelectValue = (val: string) => { console.log(val); }; const cellClick = (val: number | undefined) => { if (val === undefined) return; - console.log("pbnstRes", pbnstRes); setSelectBdst(pbnstRes); + setPbnstBiz(pbnstRes?.fcBizs) }; const resetContents = () => { setFcltMng([]); // 빈 배열로 설정하여 신규 모드로 전환 diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 946470ab4..0774f6226 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -35,7 +35,7 @@ export default function RuseMngTable({ ) : ( {headList.map((head) => ( - + {head.title} ))} From d16e09e9d9fdc82acccf545933087b2be41327f5 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 26 May 2025 16:32:23 +0900 Subject: [PATCH 08/62] =?UTF-8?q?onchange=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 2 +- .../ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index c59b65e11..f9f1ad04b 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -129,7 +129,7 @@ useEffect(() => { 차수별정보 - + diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 8d1ce82b8..f17ce757b 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -36,7 +36,6 @@ const formSchema = z.object({ }); export function PbnstMngForm({ data }: { data: customPbnst }) { - console.log("data", data); const { pbnst } = useWrStore((state) => state); const { pbnstMngUpHeadList} = pbnst; const [ruseOperData, setRuseOperData] = useState(); @@ -50,7 +49,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const handleProgress = (percentage: string) => { - console.log("handleProgress", percentage); setProgress(Number(percentage)); }; @@ -64,7 +62,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); - console.log("fcOpersField", fcOpersField); // const selectOptions = data?.map((item) => ({ // text: item.fcltNm, // val: item.pbnstRuseFcltPk, @@ -125,6 +122,9 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { {form.getValues("ruseUtztnFcltNm") ? ": " + form.getValues("ruseUtztnFcltNm") : ""} + + +
@@ -160,7 +160,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="fcltCpct" render={({ field }) => ( - + )} /> @@ -171,7 +171,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="swtrmtCpct" render={({ field }) => ( - + )} /> @@ -182,7 +182,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="ruseCpct" render={({ field }) => ( - + )} /> @@ -193,7 +193,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="splyExtraCpct" render={({ field }) => ( - + )} /> From cb5235864e89df111cf2df41101982bb8592f03c Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Mon, 26 May 2025 16:38:22 +0900 Subject: [PATCH 09/62] =?UTF-8?q?=EC=B4=9D=EC=82=AC=EC=97=85=EC=9E=90?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=EB=B2=88=ED=98=B8=20=EC=B2=B4=ED=81=AC?= =?UTF-8?q?=EB=B0=95=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/form_ui/index.tsx | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index bd9930c3c..8fab0118c 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -1,19 +1,54 @@ -import React from "react"; +import React, { useCallback, useState } from "react"; import { FormControl, FormItem, FormLabel, FormMessage } from "../form"; +import { Checkbox } from "@common/components/ui"; + +interface FormUiProps extends React.HTMLAttributes { + label?: string; + onCheckboxChange?: (checked: boolean) => void; + isDisabled?: boolean; +} + +interface FormElementProps extends React.HTMLAttributes { + disabled?: boolean; +} + +const FormUi = React.forwardRef( + ({ children, label, onCheckboxChange, isDisabled }, ref) => { + const [isChecked, setIsChecked] = useState(false); + + const handleCheckboxChange = useCallback((checked: boolean) => { + setIsChecked(checked); + onCheckboxChange?.(checked); + }, [onCheckboxChange]); -const FormUi = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & {label:string|undefined} ->(({children, label},ref)=>{ return ( - - {label?{label}:<>} - - {children} - - - - ) -}) + + {label && {label}} + {label === '종사업자등록번호' && ( +
+
+ + +
+
+ )} + + {React.isValidElement(children) && isDisabled + ? React.cloneElement(children, { + disabled: true, + ...(children.props as FormElementProps) + }) + : children} + + +
+ ); + } +); + FormUi.displayName = 'FormUi'; -export { FormUi }; +export { FormUi }; \ No newline at end of file From a77cc6a876811ca48db070fa321af835c74a1f67 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Mon, 26 May 2025 17:40:23 +0900 Subject: [PATCH 10/62] =?UTF-8?q?=EC=83=98=ED=94=8C=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 122 +++++++++++------- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 108 +++++++--------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 15 +-- 3 files changed, 123 insertions(+), 122 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 423e28c08..aaafb9ba4 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -2,19 +2,29 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; import { fetchType, getFetch, postFectch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; -import { exampleData, fcBizSchema, type customPbnst, type pubHasuType } from "./type"; +import { + exampleData, + fcBizSchema, + type customPbnst, + type pubHasuType, +} from "./type"; import type { SelectDataType } from "@common/business_components/ui"; -import { pbnstMngUpHeadListExport, pbnstOrgwtHeadListRxport, pbnstMngNmExport, pubFacHeadListExport, pplInstlsHeadListExport, pbnstDemandHeadListExport } from "./headList"; - +import { + pbnstMngUpHeadListExport, + pbnstOrgwtHeadListRxport, + pbnstMngNmExport, + pubFacHeadListExport, + pplInstlsHeadListExport, + pbnstDemandHeadListExport, +} from "./headList"; const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }]; -const pubFacHeadList= pubFacHeadListExport; -const pbnstMngUpHeadList = pbnstMngUpHeadListExport -const pbnstOrgwtHeadList =pbnstOrgwtHeadListRxport -const pbnstMngNm= pbnstMngNmExport; -const pplInstlsHeadLisat =pplInstlsHeadListExport -const pbnstDemandHeadList= pbnstDemandHeadListExport - +const pubFacHeadList = pubFacHeadListExport; +const pbnstMngUpHeadList = pbnstMngUpHeadListExport; +const pbnstOrgwtHeadList = pbnstOrgwtHeadListRxport; +const pbnstMngNm = pbnstMngNmExport; +const pplInstlsHeadLisat = pplInstlsHeadListExport; +const pbnstDemandHeadList = pbnstDemandHeadListExport; export type pubFacState = { pbnst: { @@ -22,13 +32,13 @@ export type pubFacState = { pubFacHeadList: TableUpperProps[]; pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; - pbnstHasuRes: pubHasuType[] + pbnstHasuRes: pubHasuType[]; pbnstRes: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경 pbnstBizCycle: SelectDataType[]; selectLabel: SelectDataType[]; - pbnstOrgwtHeadList:TableUpperProps[] - pplInstlsHeadLisat:TableUpperProps[] - pbnstDemandHeadList:TableUpperProps[] + pbnstOrgwtHeadList: TableUpperProps[]; + pplInstlsHeadLisat: TableUpperProps[]; + pbnstDemandHeadList: TableUpperProps[]; }; }; type pubFacActions = { @@ -36,6 +46,7 @@ type pubFacActions = { pbnstRegInit: (sgg: string) => void; pbnstRegSearch: (txt: string | undefined, sgg: string) => void; pbnstReg: (txt: string | undefined) => void; + pbnstUpdate(pbnstRes: customPbnst) : Promise; }; export type pubFacType = pubFacState & pubFacActions; @@ -46,49 +57,43 @@ export const pubFacStateExport: pubFacState = { pubFacHeadList: pubFacHeadList, pbnstMngUpHeadList: pbnstMngUpHeadList, pbnstMngNm: pbnstMngNm, - pbnstOrgwtHeadList:pbnstOrgwtHeadList, + pbnstOrgwtHeadList: pbnstOrgwtHeadList, pbnstHasuRes: [], pbnstRes: null, // 초기값을 null로 변경 - pbnstBizCycle:[{text:'없음', val:'1'}], + pbnstBizCycle: [{ text: "없음", val: "1" }], selectLabel: selectLabel, - pplInstlsHeadLisat:pplInstlsHeadLisat, - pbnstDemandHeadList:pbnstDemandHeadList, + pplInstlsHeadLisat: pplInstlsHeadLisat, + pbnstDemandHeadList: pbnstDemandHeadList, }, }; const checkWrRegList = async () => { - const wrRegList = await getFetch( - "wr", - `/reuseFc/pubFc` - ); + const wrRegList = await getFetch("wr", `/reuseFc/pubFc`); return wrRegList; -} +}; +const hasuListFetch = async (txt: string | undefined) => { + const checkWrRegListRes = await checkWrRegList(); -const hasuListFetch = async (txt: string | undefined ) => { - - const checkWrRegListRes = await checkWrRegList() - - -// prcsFclt/ruseInfo/1/20/A/11/0/1/SW + // prcsFclt/ruseInfo/1/20/A/11/0/1/SW const rainRes = await postFectch( - `/prcsFclt/ruseInfo/1/10/A/11` + "/0" + "/1" +"/SW" - ,checkWrRegListRes, - fetchType.COMMON ); + `/prcsFclt/ruseInfo/1/10/A/11` + "/0" + "/1" + "/SW", + checkWrRegListRes, + fetchType.COMMON + ); - const hasuList = rainRes.data.map((item: any) => { + const hasuList = rainRes.data.map((item: any) => { return { ...item, - ruse: item.ruse===false ? 'N' : 'Y', }; - }) - - + ruse: item.ruse === false ? "N" : "Y", + }; + }); return hasuList; }; -const getBizCycle = (fcBizs: z.infer[] ) => { - const pbnstBizCycle =fcBizs.map((item: z.infer) => { +const getBizCycle = (fcBizs: z.infer[]) => { + const pbnstBizCycle = fcBizs.map((item: z.infer) => { return { text: `${item.cycl}차`, val: item.cycl, @@ -96,22 +101,20 @@ const getBizCycle = (fcBizs: z.infer[] ) => { }); return pbnstBizCycle; -} +}; export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { return { - pubHasuInit: async (txt: string | undefined) => { try { - const pbnstHasuRes = await hasuListFetch(txt); - console.log('qwe ',pbnstHasuRes) + console.log("qwe ", pbnstHasuRes); return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, - pbnstHasuRes:pbnstHasuRes, + pbnstHasuRes: pbnstHasuRes, isInit: false, }, })); @@ -124,16 +127,16 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { try { //const pbnstRes = await initFetch(txt); - const pbnstRes = exampleData; + const pbnstRes = exampleData; - const pbnstBizCycle = pbnstRes ? getBizCycle(pbnstRes.fcBizs) : []; // pbnstRes가 null일 수 있으므로 체크 + const pbnstBizCycle = pbnstRes ? getBizCycle(pbnstRes.fcBizs) : []; // pbnstRes가 null일 수 있으므로 체크 return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, pbnstRes: pbnstRes, - pbnstBizCycle:pbnstBizCycle, + pbnstBizCycle: pbnstBizCycle, isInit: false, }, })); @@ -148,15 +151,15 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { `/api/v1/reuseFc/pubFc` + (txt ? `/${txt}` : "") + `/${sgg}` ); // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 - const pbnstBizCycle = pbnstRes && pbnstRes.fcBizs ? getBizCycle(pbnstRes.fcBizs) : []; - + const pbnstBizCycle = + pbnstRes && pbnstRes.fcBizs ? getBizCycle(pbnstRes.fcBizs) : []; return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, pbnstReg: pbnstRes, - pbnstBizCycle:pbnstBizCycle, + pbnstBizCycle: pbnstBizCycle, isInit: false, }, })); @@ -179,5 +182,24 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { console.log(errorHasu); } }, + pbnstUpdate: async (pbnstRes: customPbnst) => { + try { + const response = await postFectch( + `/reuseFc/pubFc`, + JSON.stringify(pbnstRes) + ); + + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + pbnstRes: response.data, + isInit: false, + }, + })); + } catch (error) { + console.error("Error updating pbnst:", error); + } + }, }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 043c8fedf..528f4c349 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -1,4 +1,5 @@ import { z } from "zod"; +import { TEST_UUID } from "../rainReg"; export type customPbnst = z.infer; @@ -63,9 +64,9 @@ const fcFileSchema = z.object({ filePath: z.string().default("test"), fileKnd: z.string().default("test"), regDt: z.date().default(new Date()), - rgtr: z.string().default("test"), + rgtr: z.string(), mdfcnDt: z.date().default(new Date()), - mdfr: z.string().default("test"), + mdfr: z.string(), }); const fcOperSchema = z.object({ @@ -73,11 +74,11 @@ const fcOperSchema = z.object({ pbnstRuseFcltFk: z.number().default(0), operMthd: z.string(), rprtvBzenty: z.string(), - bgngDt: z.date().default(new Date()), - endDt: z.date().default(new Date()), - regDt: z.date().default(new Date()), - rgtr: z.string().default("test"), - mdfcnDt: z.date().default(new Date()), + bgngDt: z.string(), + endDt: z.string(), + regDt: z.date().nullish(), + rgtr: z.string(), + mdfcnDt: z.date(), mdfr: z.string().default("test"), }); @@ -88,10 +89,10 @@ const fcOrgwtSchema = z.object({ tmsYn: z.string(), dschgFmYn: z.string(), dtlPstnExpln: z.string(), - regDt: z.date().default(new Date()), - rgtr: z.string().default("test"), - mdfcnDt: z.date().default(new Date()), - mdfr: z.string().default("test"), + regDt: z.date().nullish(), + rgtr: z.string(), + mdfcnDt: z.date().nullish(), + mdfr: z.string(), }); const fcPrfmncSchema = z.object({ @@ -112,10 +113,10 @@ const fcPrfmncSchema = z.object({ farmUswtr: z.string(), ugwtChr: z.string(), indstUswtr: z.string(), - regDt: z.date().default(new Date()), - rgtr: z.string().default("test"), - mdfcnDt: z.date().default(new Date()), - mdfr: z.string().default("test"), + regDt: z.date().nullish(), + rgtr: z.string(), + mdfcnDt: z.date().nullish(), + mdfr: z.string(), }); export const fcBizSchema = z.object({ @@ -183,9 +184,9 @@ export const fcBizSchema = z.object({ fcOrgwts: z.array(fcOrgwtSchema), pplInstls: z.array(pplInstlSchema), flg: z.string(), - regDt: z.string(), + regDt: z.string().nullish(), rgtr: z.string(), - mdfcnDt: z.string(), + mdfcnDt: z.string().nullish(), mdfr: z.string(), }); @@ -219,19 +220,17 @@ export type pubHasuType = z.infer; //관경 제외 export const exampleData = { pbnstRuseFcltPk: 1, - swtrmtFcltFk: "SWTRMT-001", + swtrmtFcltFk: "11000SW001R", ruseUtztnFcltNm: "재이용시설 A", fcltCpct: "100", ruseCpct: "90", splyExtraCpct: "10", - regDt: new Date("2025-05-21T11:03:26.434810"), - rgtr: "admin", - mdfr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), + rgtr: TEST_UUID, + mdfr: TEST_UUID, fcFiles: [], fcBizs: [ { - pbnstRuseFcltBizPk: 10, + pbnstRuseFcltBizPk: 1, pbnstRuseFcltFk: 1, cycl: "1", seCd: "A010", @@ -292,7 +291,7 @@ export const exampleData = { archCstClcln: "380", pplCstClcln: "290", ruseFcltCstClcln: "4800", - pplInstls:[ + pplInstls: [ { ruseFcltBizFk: "10", pdmt: "관경", @@ -308,35 +307,33 @@ export const exampleData = { ], fcOrgwts: [ { - pbnstRuseFcltBizFk: 10, - swtrmtFcltFk: 1, + pbnstRuseFcltBizFk: 1, + swtrmtFcltFk: "11000SW001R", orgwtWtritQnt: "100", tmsYn: "Y", dschgFmYn: "N", dtlPstnExpln: "배출 위치", - regDt: new Date("2025-05-21T11:03:26.434810"), + regDt: "20250221", rgtr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), + mdfcnDt: "20250321", mdfr: "admin", }, { - pbnstRuseFcltBizFk: 10, - swtrmtFcltFk: 2, + pbnstRuseFcltBizFk: 1, + swtrmtFcltFk: "11000SW001R", orgwtWtritQnt: "153", tmsYn: "Y", dschgFmYn: "N", dtlPstnExpln: "배출 위치22", - regDt: new Date("2025-05-21T11:03:26.434810"), + regDt: "20250221", rgtr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), + mdfcnDt: "20250421", mdfr: "admin", }, ], flg: "N", - regDt: "2022-01-01", - rgtr: "admin", - mdfcnDt: "2022-02-01", - mdfr: "admin", + rgtr: TEST_UUID, + mdfr: TEST_UUID, }, { pbnstRuseFcltBizPk: 11, @@ -400,7 +397,7 @@ export const exampleData = { archCstClcln: "380", pplCstClcln: "290", ruseFcltCstClcln: "4800", - pplInstls:[ + pplInstls: [ { ruseFcltBizFk: "11", pdmt: "관경", @@ -422,10 +419,8 @@ export const exampleData = { tmsYn: "Y", dschgFmYn: "N", dtlPstnExpln: "배출 위치1", - regDt: new Date("2025-05-21T11:03:26.434810"), - rgtr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), - mdfr: "admin", + rgtr: TEST_UUID, + mdfr: TEST_UUID, }, { pbnstRuseFcltBizFk: 11, @@ -434,17 +429,13 @@ export const exampleData = { tmsYn: "Y", dschgFmYn: "N", dtlPstnExpln: "배출 위치", - regDt: new Date("2025-05-21T11:03:26.434810"), - rgtr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), - mdfr: "admin", + rgtr: TEST_UUID, + mdfr: TEST_UUID, }, ], flg: "N", - regDt: "2022-01-01", - rgtr: "manager", - mdfcnDt: "2022-02-01", - mdfr: "manager", + rgtr: TEST_UUID, + mdfr: TEST_UUID, }, ], fcOpers: [ @@ -453,24 +444,19 @@ export const exampleData = { pbnstRuseFcltFk: 1, operMthd: "위탁", rprtvBzenty: "기관명", - bgngDt: new Date("2025-05-21T11:03:26.434810"), - endDt: new Date("2025-05-21T11:03:26.434810"), - regDt: new Date("2025-05-21T11:03:26.434810"), - rgtr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), - mdfr: "admin", + bgngDt: "20230930", + mdfcnDt:"20231230", + rgtr: TEST_UUID, + mdfr: TEST_UUID, }, { pbnstRuseFcltOperInfoPk: 101, pbnstRuseFcltFk: 1, operMthd: "직영", rprtvBzenty: "기관명", - bgngDt: new Date("2025-05-21T11:03:26.434810"), - endDt: new Date("2025-05-21T11:03:26.434810"), - regDt: new Date("2025-05-21T11:03:26.434810"), - rgtr: "admin", - mdfcnDt: new Date("2025-05-21T11:03:26.434810"), - mdfr: "admin", + bgngDt: "20241130", + rgtr:TEST_UUID , + mdfr: TEST_UUID, }, ], }; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index f17ce757b..247e66103 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -36,7 +36,7 @@ const formSchema = z.object({ }); export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst } = useWrStore((state) => state); + const { pbnst, pbnstUpdate } = useWrStore((state) => state); const { pbnstMngUpHeadList} = pbnst; const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); @@ -62,11 +62,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); - // const selectOptions = data?.map((item) => ({ - // text: item.fcltNm, - // val: item.pbnstRuseFcltPk, - // })) || [{ text: "없음", val: "1" }]; - const onSelectValue = (val: string) => {}; useEffect(() => { @@ -77,6 +72,8 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // 2. Define a submit handler. function onSubmit(values: z.infer) { console.log(values); + + pbnstUpdate(values); } const testFile = () => { @@ -141,11 +138,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
({ - ...item, - bgngDt: item.bgngDt.toLocaleDateString() || "", - endDt: item.endDt.toLocaleDateString() || "", - }))} + tableData={fcOpersField} headList={pbnst.pbnstMngUpHeadList} upHeadList={pbnst.pbnstMngNm} > From bc75831da21c06f6fb5292d515810891463ae3a4 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Mon, 26 May 2025 17:45:00 +0900 Subject: [PATCH 11/62] =?UTF-8?q?=EB=9D=BC=EB=B2=A8=20=ED=85=8D=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=ED=81=AC=EA=B2=8C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/business_components/src/ui/form_ui/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index 8fab0118c..1ad3afa05 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -32,7 +32,7 @@ const FormUi = React.forwardRef( checked={isChecked} onCheckedChange={handleCheckboxChange} /> - + )} From e3360999326f66db4ae66bb68484a7f29dab6983 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Mon, 26 May 2025 19:41:42 +0900 Subject: [PATCH 12/62] Co-authored-by: truthplumage --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 8 ++-- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 2 +- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 39 +++++++++++++------ apps/wr/package.json | 1 + 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 5435ef8bf..62532385f 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -17,10 +17,10 @@ export const pubFacHeadListExport: TableUpperProps[] = [ ]; export const pbnstMngUpHeadListExport: TableUpperProps[] = [ - { id: "operMthd", title: "운영방식" }, - { id: "rprtvBzenty", title: "대행업체" }, - { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1 }, - { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2 }, + { id: "operMthd", title: "운영방식", edit: true}, + { id: "rprtvBzenty", title: "대행업체", edit: true}, + { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1, type: "date"}, + { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2, type: "date"}, ]; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 247e66103..1061a1df3 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -36,7 +36,7 @@ const formSchema = z.object({ }); export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst, pbnstUpdate } = useWrStore((state) => state); + const { pbnst ,pbnstUpdate} = useWrStore((state) => state); const { pbnstMngUpHeadList} = pbnst; const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 0774f6226..5eabc06bb 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -1,7 +1,7 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { SelectBox, type SelectDataType } from "@common/business_components/ui"; +import { DatePicker, SelectBox, type SelectDataType } from "@common/business_components/ui"; import { Input, Table, @@ -11,6 +11,8 @@ import { TableHeader, TableRow, } from "@common/components/ui"; +import moment from "moment"; +import { useState } from "react"; export default function RuseMngTable({ tableData, @@ -23,8 +25,7 @@ export default function RuseMngTable({ upHeadList?: chHeadType[]; code?:{name:string, val:SelectDataType[] }[] }) { - - +const [tableState, setTableState] = useState([...tableData]); return ( <> @@ -44,11 +45,11 @@ export default function RuseMngTable({ - {tableData.map((item, index) => ( - - {headList.map((head, index) => ( + {tableState.map((item, i) => ( + + {headList.map((head, j) => ( {}} > @@ -64,16 +65,32 @@ export default function RuseMngTable({ label="" selectArray={code.find(item => item.name === head.selectData)?.val ?? []} value={ - tableData[index][item[head.id]] + item[head.id] } className={""} selectClass={selectClass} onSelectValue={(val) => { - tableData[index][head.id] = val; + setTableState((prev)=>{ + prev[i][head.id] = val + return [...prev] + }) }} > - ) - : ( + ) : head.type === "date" ? ( + { + item[head.id] = moment(date).format('yyyyMMdd'); + } + }} + selectClass={"w-full"} + /> + ) : ( `${item[head.id] || ""}` )} diff --git a/apps/wr/package.json b/apps/wr/package.json index 58a01dc42..44ba5a06b 100644 --- a/apps/wr/package.json +++ b/apps/wr/package.json @@ -17,6 +17,7 @@ "class-variance-authority": "^0.7.1", "clsx": "^2.1.1", "lucide-react": "^0.474.0", + "moment": "^2.30.1", "next": "15.1.7", "react-hook-form": "^7.54.2", "react-hot-toast": "^2.5.2", From 6dba031d8dacbb7856b8c04aa20e0d966604594d Mon Sep 17 00:00:00 2001 From: jyha00 Date: Tue, 27 May 2025 10:43:50 +0900 Subject: [PATCH 13/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=9A=B4=EC=98=81=EC=A0=95=EB=B3=B4=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EC=B6=9C=EB=A0=A5=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 20 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 12 +- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 190 ++++++++++-------- 3 files changed, 122 insertions(+), 100 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 528f4c349..8350995d9 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -28,13 +28,6 @@ export type publicReuseFacilityType = { register?: string; swtrmtFcltFk: string; }; -export type fcltOperInfoType = { - mng: string; - subCo: string; - startDay: string; - endDay: string; - pbnstRuseFcltPk: string; -}; export type ruseFcltType = { swtrmtFcltFk: string; @@ -74,8 +67,8 @@ const fcOperSchema = z.object({ pbnstRuseFcltFk: z.number().default(0), operMthd: z.string(), rprtvBzenty: z.string(), - bgngDt: z.string(), - endDt: z.string(), + bgngDt: z.date().default(new Date()), + endDt: z.date().default(new Date()), regDt: z.date().nullish(), rgtr: z.string(), mdfcnDt: z.date(), @@ -204,6 +197,7 @@ export const pbnstRegZod = z.object({ fcFiles: z.array(fcFileSchema).default([]), fcBizs: z.array(fcBizSchema).default([]), fcOpers: z.array(fcOperSchema).default([]), + hasuhasu: z.number().default(0), }); const pubHasuZod = z.object({ @@ -222,6 +216,7 @@ export const exampleData = { pbnstRuseFcltPk: 1, swtrmtFcltFk: "11000SW001R", ruseUtztnFcltNm: "재이용시설 A", + hasuhasu: 0, fcltCpct: "100", ruseCpct: "90", splyExtraCpct: "10", @@ -444,8 +439,8 @@ export const exampleData = { pbnstRuseFcltFk: 1, operMthd: "위탁", rprtvBzenty: "기관명", - bgngDt: "20230930", - mdfcnDt:"20231230", + bgngDt: new Date("2023-09-30"), + endDt: new Date("2023-12-31"), rgtr: TEST_UUID, mdfr: TEST_UUID, }, @@ -454,7 +449,8 @@ export const exampleData = { pbnstRuseFcltFk: 1, operMthd: "직영", rprtvBzenty: "기관명", - bgngDt: "20241130", + bgngDt: new Date("2024-11-30"), + endDt: new Date("2024-12-31"), rgtr:TEST_UUID , mdfr: TEST_UUID, }, diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 1061a1df3..43abc4e3f 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -5,7 +5,7 @@ import { FileUpload, FormUi, UiTable } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect, useState } from "react"; +import { use, useEffect, useRef, useState } from "react"; import { set, useFieldArray, useForm } from "react-hook-form"; import { nullable, z } from "zod"; import { useWrStore } from "@/app/store"; @@ -51,7 +51,10 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { setProgress(Number(percentage)); }; + + + const ref = useRef(data.fcOpers ?? null); const form = useForm>({ resolver: zodResolver(pbnstRegZod), defaultValues: {...data}, @@ -66,12 +69,12 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { useEffect(() => { form.reset(data); - // setRuseOperData(data.fcOpers); + setRuseOperData(data.fcOpers); }, [data]); // 2. Define a submit handler. function onSubmit(values: z.infer) { - console.log(values); + console.log("submit",values); pbnstUpdate(values); } @@ -141,6 +144,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { tableData={fcOpersField} headList={pbnst.pbnstMngUpHeadList} upHeadList={pbnst.pbnstMngNm} + ref={ref} > @@ -161,7 +165,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {
( diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index 5eabc06bb..e5733406b 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -1,5 +1,6 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import type { customPbnst, fcltOperInfoType, fcOrgwtType, operType, ppInstlType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { DatePicker, SelectBox, type SelectDataType } from "@common/business_components/ui"; import { @@ -12,93 +13,114 @@ import { TableRow, } from "@common/components/ui"; import moment from "moment"; -import { useState } from "react"; +import React, { useEffect, useState } from "react"; -export default function RuseMngTable({ - tableData, - headList, - upHeadList, - code = [], -}: { +type RuseMngTableProps = { tableData: any[]; headList: TableUpperProps[]; - upHeadList?: chHeadType[]; - code?:{name:string, val:SelectDataType[] }[] -}) { -const [tableState, setTableState] = useState([...tableData]); + upHeadList: chHeadType[]; + code?: { name: string, val: SelectDataType[] }[]; +}; - return ( - <> -
- - {upHeadList ? ( - headMakeprfmnc(headList, upHeadList) - ) : ( - - {headList.map((head) => ( - - {head.title} - - ))} - - )} - +const RuseMngTable = React.forwardRef( + ({ + tableData, + headList, + upHeadList, + code = [] + }, ref) => { + const [tableState, setTableState] = useState([...tableData]); + useEffect(() => { + if (ref && typeof ref === "object" && "current" in ref) { + ref.current = tableState; + } + }, [tableState]); - - {tableState.map((item, i) => ( - - {headList.map((head, j) => ( - {}} - > - {head.edit === true ? ( - {}} - value={item[head.id] || ""} - /> - ) : head.type === "select" ? ( - item.name === head.selectData)?.val ?? []} - value={ - item[head.id] - } - className={""} - selectClass={selectClass} - onSelectValue={(val) => { - setTableState((prev)=>{ - prev[i][head.id] = val - return [...prev] - }) - }} - > - ) : head.type === "date" ? ( - { - item[head.id] = moment(date).format('yyyyMMdd'); + useEffect(() => { + setTableState(tableData); + }, [tableData]); + return ( + <> +
+ + {upHeadList ? ( + headMakeprfmnc(headList, upHeadList) + ) : ( + + {headList.map((head) => ( + + {head.title} + + ))} + + )} + + + + {tableState.map((item, i) => ( + + {headList.map((head, j) => ( + { }} + > + {head.edit === true ? ( + { + setTableState(prev => { + const next = [...prev]; + next[i] = { ...next[i], [head.id]: txt.target.value }; + return next; + }) + }} + value={tableState[i][head.id] || ""} + /> + ) : head.type === "select" ? ( + item.name === head.selectData)?.val ?? []} + value={ + item[head.id] } - }} - selectClass={"w-full"} - /> - ) : ( - `${item[head.id] || ""}` - )} - - ))} - - ))} - -
- - ); -} + className={""} + selectClass={selectClass} + onSelectValue={(val) => { + setTableState((prev) => { + prev[i][head.id] = val + return [...prev] + }) + }} + > + ) : head.type === "date" ? ( + { + setTableState(prev => { + const next = [...prev]; + next[i] = { ...next[i], [head.id]: date }; + return next; + }) + } + } + } + selectClass={"w-full"} + /> + ) : ( + `${item[head.id] || ""}` + )} + + ))} + + ))} + + + + ); + }) +export default RuseMngTable; \ No newline at end of file From 8aaa8ae89b09df1dbb877c36ff5852f1c40d1d05 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 27 May 2025 10:44:00 +0900 Subject: [PATCH 14/62] =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 5 ++++- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 15 ++++++------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 22 ++++++++----------- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 5435ef8bf..a61b7552c 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -121,4 +121,7 @@ export const ruseWaterQulityList:formDetailType[]=[ {id:'ph' , lable:'수소이온농도'}, {id:'clIonQnt' , lable:'염화물(mg/L)'}, {id:'cdtnv' , lable:'전기전도도(μs/cm)​'}, -] \ No newline at end of file +] + + + diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 528f4c349..1aa1417e7 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -75,23 +75,23 @@ const fcOperSchema = z.object({ operMthd: z.string(), rprtvBzenty: z.string(), bgngDt: z.string(), - endDt: z.string(), + endDt: z.string().default("20250501"), regDt: z.date().nullish(), rgtr: z.string(), - mdfcnDt: z.date(), + mdfcnDt: z.date().nullish(), mdfr: z.string().default("test"), }); const fcOrgwtSchema = z.object({ pbnstRuseFcltBizFk: z.number().default(0), - swtrmtFcltFk: z.number().default(0), + swtrmtFcltFk: z.string().default(''), orgwtWtritQnt: z.string(), tmsYn: z.string(), dschgFmYn: z.string(), dtlPstnExpln: z.string(), - regDt: z.date().nullish(), + regDt: z.string().nullish(), rgtr: z.string(), - mdfcnDt: z.date().nullish(), + mdfcnDt: z.string().nullish(), mdfr: z.string(), }); @@ -414,7 +414,7 @@ export const exampleData = { fcOrgwts: [ { pbnstRuseFcltBizFk: 11, - swtrmtFcltFk: 1, + wtrmtFcltFk: "11000SW001R", orgwtWtritQnt: "152", tmsYn: "Y", dschgFmYn: "N", @@ -424,7 +424,7 @@ export const exampleData = { }, { pbnstRuseFcltBizFk: 11, - swtrmtFcltFk: 1, + wtrmtFcltFk: "11000SW001R", orgwtWtritQnt: "150", tmsYn: "Y", dschgFmYn: "N", @@ -445,7 +445,6 @@ export const exampleData = { operMthd: "위탁", rprtvBzenty: "기관명", bgngDt: "20230930", - mdfcnDt:"20231230", rgtr: TEST_UUID, mdfr: TEST_UUID, }, diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 247e66103..2028741de 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -25,16 +25,6 @@ import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import type { Upload } from "tus-js-client"; import { pbnstRegZod, type customPbnst, type fcltOperInfoType, type operType, type ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -const formSchema = z.object({ - fcltNm: z.string().min(2).max(50), - psysScdg: z.string(), - designScdg: z.string(), - fcltCpct: z.number(), - swtrmtCpct: z.number(), - ruseCpct: z.number(), - splyExtraCpct: z.number(), -}); - export function PbnstMngForm({ data }: { data: customPbnst }) { const { pbnst, pbnstUpdate } = useWrStore((state) => state); const { pbnstMngUpHeadList} = pbnst; @@ -54,7 +44,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const form = useForm>({ resolver: zodResolver(pbnstRegZod), - defaultValues: {...data}, + defaultValues: pbnstRegZod.parse({}), }); const { fields: fcOpersField } = useFieldArray({ @@ -71,7 +61,10 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // 2. Define a submit handler. function onSubmit(values: z.infer) { - console.log(values); + + + console.log("onSubmit values", values); + console.log( ' 212 ', values); pbnstUpdate(values); } @@ -93,6 +86,9 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { }, }); }; + useEffect(() => { + console.log("form errors:", form.formState.errors); + }, [form.formState.errors]); useEffect(() => { if (relationfiles && relationfiles[0]) @@ -120,7 +116,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { {form.getValues("ruseUtztnFcltNm") ? ": " + form.getValues("ruseUtztnFcltNm") : ""} - + From 7ed55d59d9ac45ef75f89005d66dde3b8bc53db3 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Tue, 27 May 2025 16:30:42 +0900 Subject: [PATCH 15/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=B6=94=EA=B0=80,=20=EC=82=AD=EC=A0=9C=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 6 ++- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 4 +- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 13 ++--- .../ui/form/fcltReg/bdstReg/bdstReg.tsx | 35 ++++--------- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 50 ++++++++++++++++--- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 48 +++++++++++++++--- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 33 ++++++++---- 7 files changed, 132 insertions(+), 57 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index f9f1ad04b..0820e5609 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -6,6 +6,7 @@ import { SearchFormLeft, SearchInput, Title, + UiModal, UiTable, } from "@common/business_components"; import { Button, Input } from "@common/components"; @@ -18,6 +19,7 @@ import type { customPbnst, fcBizSchema, fcBizType, ruseFcltType } from "@/app/st import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { z } from "zod"; +import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; export default function PublicReuseFaciltyInsert() { const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); @@ -25,6 +27,7 @@ export default function PublicReuseFaciltyInsert() { const [currentTab, setCurrentTab] = useState("mng"); const [fcltMng, setFcltMng] = useState(); const [pbnstBiz, setPbnstBiz] = useState(); + const [issNewReg, setIsNewReg] = useState(false); const [searchTxt, setSearchTxt] = useState(); const [bdstTable, setbdstTable] = useState(); @@ -96,7 +99,7 @@ useEffect(() => { @@ -137,6 +140,7 @@ useEffect(() => { + diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 4f35c813c..659aa714d 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -17,6 +17,7 @@ export const pubFacHeadListExport: TableUpperProps[] = [ ]; export const pbnstMngUpHeadListExport: TableUpperProps[] = [ + { id: "choose", title: "선택", type: "checkbox" }, { id: "operMthd", title: "운영방식", edit: true}, { id: "rprtvBzenty", title: "대행업체", edit: true}, { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1, type: "date"}, @@ -25,9 +26,10 @@ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ export const pplInstlsHeadListExport: TableUpperProps[] = [ + { id: "choose", title: "선택", type: "checkbox" }, { id: "ppMqlt", title: "관재질", type: "select", selectData:'pplQulity' }, { id: "pdmt", title: "관경", type: "select", selectData:'pplLenght'}, - { id: "cpct", title: "연장", }, + { id: "cpct", title: "연장", edit: true, type: "number" }, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index d84a5b3e6..29bec52b9 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -73,6 +73,7 @@ const fcOperSchema = z.object({ rgtr: z.string(), mdfcnDt: z.date().nullish(), mdfr: z.string().default("test"), + choose: z.boolean().default(false), }); const fcOrgwtSchema = z.object({ @@ -289,15 +290,15 @@ export const exampleData = { pplInstls: [ { ruseFcltBizFk: "10", - pdmt: "관경", - ppMqlt: "1", - cpct: "100", + pdmt: "D200", + ppMqlt: "도복장강관", + cpct: "1", }, { ruseFcltBizFk: "10", - pdmt: "관경", - ppMqlt: "2", - cpct: "200", + pdmt: "D100", + ppMqlt: "PE관", + cpct: "2", }, ], fcOrgwts: [ diff --git a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx index 638f45915..5ab5edf98 100644 --- a/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx +++ b/apps/wr/components/ui/form/fcltReg/bdstReg/bdstReg.tsx @@ -15,7 +15,8 @@ import { SelectBox, type SelectDataType, } from "@common/business_components"; -import { Button, Input } from "@common/components"; +import { Button, Checkbox, Input } from "@common/components"; +import { Check } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { useFieldArray } from "react-hook-form"; @@ -42,18 +43,15 @@ export default function BdstReg({ form }: { form: any }) { // remove(fields.length - 1); // } // }; -// 이건 삭제해도되는거 const removeSelected = () => { - // fields 배열에서 selectedIds 에 포함된 field.id 의 인덱스만 골라내기 const idxsToRemove = fields - .map((f, i) => selectedIds.includes(f.id) ? i : -1) - .filter(i => i > -1) - // 내림차순 정렬: 인덱스 뒤쪽부터 제거해야 안전합니다. - .sort((a,b) => b - a); + .map((item, idx) => selectedIds.includes(item.id) ? idx : -1) + .filter(index => index > -1) + .sort((prevIndex, nextIndex) => nextIndex - prevIndex); - remove(idxsToRemove); - setSelectedIds([]); -}; + remove(idxsToRemove); + setSelectedIds([]); + }; const [selectSgg, setSelectSgg] = useState(); @@ -89,9 +87,6 @@ export default function BdstReg({ form }: { form: any }) { return () => subscription?.unsubscribe(); }, [form.form]); - - - // 여기서부터는 자유롭게 삭제 가능 const [selectedIds, setSelectedIds] = useState([]); const toggleSelect = (id: string) => { @@ -280,19 +275,13 @@ export default function BdstReg({ form }: { form: any }) { {fields.map((field, index) => ( - //여기서부터 자유롭게 삭제 가능
- {/* 1) 체크박스 */}
- toggleSelect(field.id)} - className="h-6 w-6" + onCheckedChange={() => toggleSelect(field.id)} />
- - {/* 2) 구분 */}
- - {/* 3) 허가일 */}
- - {/* 4) 면적 */}
(data[0]?.pplInstls ?? null); const { code, pbnst } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [getBizCycle, setBizCycle] = useState("1"); @@ -57,14 +58,36 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { name: "fcOrgwts", }); - const { fields: pplInstls } = useFieldArray({ + const { fields: pplInstls, append, remove } = useFieldArray({ control: form.control, name: "pplInstls", }); + + const plusHist = () => { + append({ + choose: false, + ppMqlt: "", + pdmt: "", + cpct: "", + }); + }; + + const removeSelected = () => { + if(!ref.current) return; + const selectedIdxs = ref.current + .map((item, idx) => (item.choose ? idx : -1)) + .filter((idx) => idx !== -1); + selectedIdxs.reverse().forEach((idx) => remove(idx)); + }; + useEffect(() => { if (data) { const index = Number(getBizCycle) - 1; form.reset(data[index]); + ref.current = data[index]?.pplInstls ?? null; + console.log("form reset with data:", data[index]); + + } }, [getBizCycle, data]); @@ -180,10 +203,22 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { readOnly className="w-32 border-gray-300 rounded pr-8 " /> - - + +
@@ -191,7 +226,8 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { tableData={pplInstls} headList={pbnst.pplInstlsHeadLisat} code={ppiSelectList ?? []} - /> + ref={ref} + upHeadList={[]} />
{ + append({ + choose: false, + rgtr: "", + mdfr: "", + pbnstRuseFcltFk: 0, + pbnstRuseFcltOperInfoPk: 0, + operMthd: "", + rprtvBzenty: "", + bgngDt: new Date(), + endDt: new Date(), + }); + }; + + const removeSelected = () => { + console.log("ref", ref.current); + console.log("fcOpersField", fcOpersField); + if(!ref.current) return; + const selectedIdxs = ref.current + .map((item, idx) => (item.choose ? idx : -1)) + .filter(idx => idx !== -1); + selectedIdxs.reverse().forEach(idx => remove(idx)); + }; + const onSelectValue = (val: string) => {}; useEffect(() => { @@ -64,8 +88,8 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // 2. Define a submit handler. function onSubmit(values: z.infer) { - console.log("submit",values); - + values.fcOpers = ref.current || []; + console.log("form values:", values); pbnstUpdate(values); } @@ -77,7 +101,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { }, handleProgress, handleResponse: (req, res) => { - console.log(" handleResponse req", req); + console.log("handleResponse req", req); console.log("handleResponse res", res); }, handleSuccess: (a) => { @@ -116,22 +140,32 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { {form.getValues("ruseUtztnFcltNm") ? ": " + form.getValues("ruseUtztnFcltNm") : ""}
- +
-
+
재이용시설 운영정보 +
+ +
( }, ref) => { const [tableState, setTableState] = useState([...tableData]); useEffect(() => { + console.log("tableState", tableState); if (ref && typeof ref === "object" && "current" in ref) { ref.current = tableState; } @@ -71,11 +71,11 @@ const RuseMngTable = React.forwardRef( type={head.type} onChange={(txt) => { setTableState(prev => { - const next = [...prev]; - next[i] = { ...next[i], [head.id]: txt.target.value }; - return next; - }) - }} + const next = [...prev]; + next[i] = { ...next[i], [head.id]: txt.target.value }; + return next; + }) + }} value={tableState[i][head.id] || ""} /> ) : head.type === "select" ? ( @@ -83,7 +83,7 @@ const RuseMngTable = React.forwardRef( label="" selectArray={code.find(item => item.name === head.selectData)?.val ?? []} value={ - item[head.id] + tableState[i][head.id] || "" } className={""} selectClass={selectClass} @@ -99,18 +99,31 @@ const RuseMngTable = React.forwardRef( mode="single" field={{ value: - tableState[i][head.id], // Provide a default Date value + tableState[i][head.id], // Provide a default Date value onChange: (date) => { setTableState(prev => { const next = [...prev]; next[i] = { ...next[i], [head.id]: date }; return next; }) - } + } } } selectClass={"w-full"} /> + ) : head.type === "checkbox" ? ( + { + console.log("checked", checked); + setTableState((prev) => { + prev[i][head.id] = checked + return [...prev] + }) + }} + > + ) : ( `${item[head.id] || ""}` )} From beb00412c10b3395794cb6bf28124f368871fbd8 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Tue, 27 May 2025 18:03:39 +0900 Subject: [PATCH 16/62] =?UTF-8?q?=ED=9B=84=EB=B3=B4=EC=A7=80=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=EC=B9=B8=20=EB=B3=84=EB=8F=84=EC=9D=98=20=ED=8F=BC?= =?UTF-8?q?=EC=98=81=EC=97=AD=20=EC=83=9D=EC=84=B1=EC=99=84=EB=A3=8C,=20?= =?UTF-8?q?=EB=9D=BC=EB=B2=A8=20=EB=B3=80=EC=88=98=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business_components/src/ui/form_ui/index.tsx | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index 1ad3afa05..ec1854636 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -1,6 +1,9 @@ import React, { useCallback, useState } from "react"; import { FormControl, FormItem, FormLabel, FormMessage } from "../form"; -import { Checkbox } from "@common/components/ui"; +import { Button, Checkbox } from "@common/components/ui"; + +export const BZNM_TOT_NO = '총사업자등록번호'; +export const CANDIDATE = '공급처 후보지 선택(필수아님)'; interface FormUiProps extends React.HTMLAttributes { label?: string; @@ -20,11 +23,11 @@ const FormUi = React.forwardRef( setIsChecked(checked); onCheckboxChange?.(checked); }, [onCheckboxChange]); - + console.log(children); return ( {label && {label}} - {label === '종사업자등록번호' && ( + {label === BZNM_TOT_NO && (
(
)} + {label === CANDIDATE && ( + + {children} + + )} + {label !== BZNM_TOT_NO && label !== CANDIDATE && ( {React.isValidElement(children) && isDisabled ? React.cloneElement(children, { @@ -44,6 +53,7 @@ const FormUi = React.forwardRef( }) : children} + )}
); From bd1f91c72521473fb88875f33ea963e1191e8ec7 Mon Sep 17 00:00:00 2001 From: leedj312 Date: Tue, 27 May 2025 20:01:42 +0900 Subject: [PATCH 17/62] Co-authored-by: truthplumage --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 10 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 5 + apps/wr/components/lib/useTus_wr/useTusWr.tsx | 88 ++++++----- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 37 ++++- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 141 +++++++++++------- .../fcOrgwtsRegModal/fcOrgwtsRegModal.tsx | 64 ++++++++ apps/wr/middleware.ts | 7 +- 7 files changed, 253 insertions(+), 99 deletions(-) create mode 100644 apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 4f35c813c..e936ea8b7 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -43,12 +43,19 @@ export const pbnstDemandHeadListExport: TableUpperProps[] = [ export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ - { id: "ruseUtztnFcltNm", title: "운영방식" }, + { id: "ruseUtztnFcltNm", title: "운영방식" }, { id: "orgwtWtritQnt", title: "원수취수량" }, { id: "tmsYn", title: "하수처리량TMS 전후", }, { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​", }, { id: "dtlPstnExpln", title: "상세위치 설명", }, ]; +export const fcOrgwtsHeadListExport: TableUpperProps[] = [ + { id: "sido", title: "운영방식" }, + { id: "gugun", title: "원수취수량" }, + { id: "bscFctNm", title: "시설명" }, + { id: "addr", title: "상세위치 설명" }, + +] export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, @@ -124,4 +131,3 @@ export const ruseWaterQulityList:formDetailType[]=[ ] - diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index aaafb9ba4..661925e46 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -16,6 +16,7 @@ import { pubFacHeadListExport, pplInstlsHeadListExport, pbnstDemandHeadListExport, + fcOrgwtsHeadListExport, } from "./headList"; const selectLabel: SelectDataType[] = [{ text: "test", val: "1" }]; @@ -25,6 +26,8 @@ const pbnstOrgwtHeadList = pbnstOrgwtHeadListRxport; const pbnstMngNm = pbnstMngNmExport; const pplInstlsHeadLisat = pplInstlsHeadListExport; const pbnstDemandHeadList = pbnstDemandHeadListExport; +const fcOrgwtsHeadList=fcOrgwtsHeadListExport + export type pubFacState = { pbnst: { @@ -39,6 +42,7 @@ export type pubFacState = { pbnstOrgwtHeadList: TableUpperProps[]; pplInstlsHeadLisat: TableUpperProps[]; pbnstDemandHeadList: TableUpperProps[]; + fcOrgwtsHeadList: TableUpperProps[]; }; }; type pubFacActions = { @@ -64,6 +68,7 @@ export const pubFacStateExport: pubFacState = { selectLabel: selectLabel, pplInstlsHeadLisat: pplInstlsHeadLisat, pbnstDemandHeadList: pbnstDemandHeadList, + fcOrgwtsHeadList: fcOrgwtsHeadList, }, }; diff --git a/apps/wr/components/lib/useTus_wr/useTusWr.tsx b/apps/wr/components/lib/useTus_wr/useTusWr.tsx index 4aedb71d3..f11578245 100644 --- a/apps/wr/components/lib/useTus_wr/useTusWr.tsx +++ b/apps/wr/components/lib/useTus_wr/useTusWr.tsx @@ -1,53 +1,63 @@ import { Upload, type HttpRequest, type HttpResponse, type OnSuccessPayload } from "tus-js-client"; import { CS_TUS_UPLOAD, CS_URL } from "../config"; +import type { FilesType } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; type UploadOptions = { handleUploadStart?: (upload: Upload) => void; handleProgress?: (percentage: string) => void; handleSuccess?: (payload :OnSuccessPayload) => void; - handleResponse?: (req:HttpRequest, res: HttpResponse) => void; + handleResponse?: (req:HttpRequest, res: ReturnFileType) => void; }; +export type ReturnFileType={ + atflCd:String, + atflSn:number, + atflId:String, + physFileNm:String +} +export const TusClientUpload = (oFile: FilesType, options?: UploadOptions): Promise => { + return new Promise((resolve, reject) => { + const Authorization = "Authorization"; + const AUTH_USER_ID = "token-id"; -export function TusClientUpload(oFile: File, setUpload: (upload: Upload) => void, options?: UploadOptions) { - const Authorization = "Authorization"; - const AUTH_USER_ID = "token-id"; + //CS_URL + const uploader = new Upload(oFile.file, { + endpoint: 'http://localhost:3001' + CS_TUS_UPLOAD, + chunkSize: 10 * 1024 * 1024, + headers: { + Authorization: "", + AUTH_USER_ID: "", + }, + metadata: { + filename: oFile.file.name, + filetype: oFile.file.type, + }, + onError(error) { + console.error(`Failed because: ${error}`); + reject(error); + }, + onProgress(bytesUploaded, bytesTotal) { + const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2); - //CS_URL - const uploader = new Upload(oFile, { - endpoint: 'http://localhost:3001' + CS_TUS_UPLOAD, - chunkSize: 10* 1024 * 1024, - headers: { - Authorization: "", - AUTH_USER_ID: "", - }, - metadata: { - filename: oFile.name, - filetype: oFile.type, - }, - onError(error) { - console.error(`Failed because: ${error}`); - }, - onProgress(bytesUploaded, bytesTotal) { - const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2); - options?.handleProgress?.(percentage); - }, - onAfterResponse(req, res) { - const fileInfo = res.getHeader("X-File-Info"); - if (fileInfo === undefined || fileInfo === null) return; + console.log(`Uploaded ${bytesUploaded} of ${bytesTotal} bytes (${percentage}%)`); + options?.handleProgress?.(percentage); + }, + onAfterResponse(req, res: HttpResponse) { + const fileInfo = res.getHeader("X-File-Info"); + if (fileInfo === undefined || fileInfo === null) return; + console.log("onAfterResponse fileInfo", fileInfo); + resolve(JSON.parse(fileInfo) as ReturnFileType); + }, + onSuccess(payload: OnSuccessPayload) { + options?.handleSuccess?.(payload); + }, + }); - options?.handleResponse?.(res); - }, - onSuccess(payload :OnSuccessPayload) { - options?.handleSuccess?.(payload); - }, + options?.handleUploadStart?.(uploader); + uploader.start(); + console.log("upload start >>>>>", uploader); + + // setUpload(uploader); }); - uploader.start(); - - options?.handleUploadStart?.(uploader); - - console.log("upload start >>>>>", uploader); - - - // setUpload(uploader); } // +// diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index d7b8e47b7..7b5073718 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -1,12 +1,16 @@ "use client"; import { SelectBox } from "@common/business_components"; -import { FormUi, type SelectDataType } from "@common/business_components/ui"; +import { + FormUi, + UiModal, + type SelectDataType, +} from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input, Label, TableHead, TableRow } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { use, useEffect, useState } from "react"; -import { useFieldArray, useForm } from "react-hook-form"; +import { set, useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; import { useWrStore } from "@/app/store"; import { @@ -35,6 +39,7 @@ import { type ppInstlType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; +import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal"; export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const { code, pbnst } = useWrStore((state) => state); @@ -43,6 +48,10 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const [ppiSelectList, setPpiSelectList] = useState<[{ name: string; val: SelectDataType[] }]>(); const [ppiYn, setPpiYn] = useState("Y"); +const [ isFcOrgwts, setIsFcOrgwts] = useState(false); + + + const form = useForm({ resolver: zodResolver(fcBizSchema), }); @@ -61,6 +70,19 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { control: form.control, name: "pplInstls", }); + + + const fcOrgwtsReg = () =>{ + + + console.log("fcOrgwtsReg"); +//ref로바꿔야함 + setFcOrgwts({isOpen:true , data:fcOrgwtFiled as fcOrgwtType[]}); + + + } + + useEffect(() => { if (data) { const index = Number(getBizCycle) - 1; @@ -114,7 +136,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }} > - +
재이용 원수취수 현황
- +
+ + setIsFcOrgwts(open)} + bodyClass={"w-[68vw] max-w-none h-[60vh]"} + body={} + >
); } diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index e46390be5..0af436964 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -23,33 +23,37 @@ import { import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import type { Upload } from "tus-js-client"; -import { pbnstRegZod, type customPbnst, type operType, type ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; - +import { + pbnstRegZod, + type customPbnst, + type operType, + type ruseFcltType, +} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +export type FilesType = { + atflCd: String; + file: File; +}; export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst ,pbnstUpdate} = useWrStore((state) => state); - const { pbnstMngUpHeadList} = pbnst; + const { pbnst, pbnstUpdate } = useWrStore((state) => state); + const { pbnstMngUpHeadList } = pbnst; const [ruseOperData, setRuseOperData] = useState(); const [planFiles, setPlanFiles] = useState(null); - const [relationfiles, setRelationFiles] = useState(null); - + const [relationfiles, setRelationFiles] = useState(null); const [isModalOpen, setIsModalOpen] = useState(false); const [upload, setUpload] = useState(null); const [progress, setProgress] = useState(0); const handleProgress = (percentage: string) => { - setProgress(Number(percentage)); }; - - const ref = useRef(data.fcOpers ?? null); const form = useForm>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), }); - + const { fields: fcOpersField } = useFieldArray({ control: form.control, name: "fcOpers", @@ -58,51 +62,56 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const onSelectValue = (val: string) => {}; useEffect(() => { - form.reset(data); - setRuseOperData(data.fcOpers); + form.reset(data); + setRuseOperData(data.fcOpers); }, [data]); // 2. Define a submit handler. function onSubmit(values: z.infer) { - console.log("submit",values); - - pbnstUpdate(values); + console.log("submit", values); + testFile; + // pbnstUpdate(values); } - + const fileHandler = (files:File[]) => { + const setReFiles = [...(relationfiles || [])]; + if (files && (!relationfiles || files?.length > relationfiles?.length)) { + files?.forEach( async (item) => { + if ( + relationfiles && + relationfiles?.filter((reFile) => reFile.file.name == item.name) + ?.length > 0 + ) { + return; + } else { + const tusFile= await TusClientUpload({ atflCd: "", file: item }) + setReFiles.push({ atflCd: tusFile.atflCd, file: item }); + } + }); + } else if ( + relationfiles && + (!files || relationfiles.length > files.length) + ) { + if (!files) { + setReFiles.length = 0; + } else { + relationfiles?.forEach((item, index) => { + const idx = files?.indexOf(item.file); + if (idx < 0) { + setReFiles.slice(index); + } + }); + } + } + setRelationFiles(setReFiles); + }; const testFile = () => { if (relationfiles && relationfiles[0]) - TusClientUpload(relationfiles[0], setUpload, { - handleUploadStart: () => { - console.log("handleUploadStart"); - }, - handleProgress, - handleResponse: (req, res) => { - console.log(" handleResponse req", req); - console.log("handleResponse res", res); - }, - handleSuccess: (a) => { - console.log("req", a); - - }, - }); + TusClientUpload(relationfiles[0], setUpload); }; useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); - useEffect(() => { - if (relationfiles && relationfiles[0]) - console.log("relationfiles ", relationfiles[0]); - - // TusClientUpload( - // relationfiles[0],{ - // handleUploadStart: setUpload, - // handleProgress, - // handleSuccess: setUpload, - // }) - }, [relationfiles]); - - return (
@@ -113,11 +122,16 @@ export function PbnstMngForm({ data }: { data: customPbnst }) {

재이용 시설명

- {form.getValues("ruseUtztnFcltNm") ? ": " + form.getValues("ruseUtztnFcltNm") : ""} + + {form.getValues("ruseUtztnFcltNm") + ? ": " + form.getValues("ruseUtztnFcltNm") + : ""} +
- - +
@@ -150,7 +164,12 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="fcltCpct" render={({ field }) => ( - + )} /> @@ -161,7 +180,12 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="hasuhasu" render={({ field }) => ( - + )} /> @@ -172,7 +196,12 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="ruseCpct" render={({ field }) => ( - + )} /> @@ -183,7 +212,12 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name="splyExtraCpct" render={({ field }) => ( - + )} /> @@ -200,8 +234,11 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { render={({}) => ( item.file) || []} + setFiles={ + (files: File[] | null) => { + if(files)fileHandler(files) + } } fileTypes="PDF" > diff --git a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx new file mode 100644 index 000000000..dc4144073 --- /dev/null +++ b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx @@ -0,0 +1,64 @@ +"use client"; +import { useWrStore } from "@/app/store"; +import { Title, UiTable } from "@common/business_components/ui"; +import { ArrowLeft, ArrowRight } from "lucide-react"; +import { useEffect, useState } from "react"; + +export default function FcOrgwtsRegModal() { + const { code, pbnst } = useWrStore((state) => state); + const { fcOrgwtsHeadList } = pbnst; + + const [isFcOrgwtsData, setIsFcOrgwtsData] = useState(false); + + useEffect(() => { + console.log("isFcOrgwtsData", isFcOrgwtsData); + }, [isFcOrgwtsData]); + return ( + <> +
+
+ + </div> + <div className="flex flex-row flex-grow gap-4 mt-4"> + <div className="w-3/7"> + <UiTable + headName={"공공하수처리시설 목록"} + tableData={[]} + headlist={fcOrgwtsHeadList} + pageSize={0} + total={0} + cellClick={undefined} + onPageChange={function (page: number): void { + throw new Error("Function not implemented."); + }} + ></UiTable> + </div> + <div className="flex flex-col items-center justify-center w-1/7 gap-2"> + <ArrowRight + type="button" + onClick={() => { + setIsFcOrgwtsData(!isFcOrgwtsData); + }} + className="w-12 h-12 text-gray-500" + /> + <ArrowLeft className="w-12 h-12 text-gray-500" /> + </div> + {/* Right Table container: Takes 2/5 of the width */} + <div className="w-3/7"> + <UiTable + headName={"취수하수처리장 목록"} + tableData={[]} + headlist={fcOrgwtsHeadList} + pageSize={0} + total={0} + cellClick={undefined} + onPageChange={function (page: number): void { + throw new Error("Function not implemented."); + }} + ></UiTable> + </div> + </div> + </div> + </> + ); +} diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index 3ac0d64ed..ca8cdd6e4 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -21,16 +21,18 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJpYXQiOjE3NDc4MTM2MDksImV4cCI6MTc0NzgxMzkwOX0.XGiDHC-ljuEdN6M638q0nDet6XRQcO8o66LKvZZ07r4rGykn2ba8yagC_-8LVpVjrkPzIVZnW10I2fQWgAGT5Q" - const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0'; + const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDgzNTA2NjV9.fzXqA7vfeOp9z7AC33urbh_hZqNPyadmrp0LAs62Ay5PcP2SiFX3smRTdLH6xQSYNtV5MNgKPvebU2VgPuhHIw" + const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; const newUrl = `${serverApiUrl}${pathname}`; console.log("serverApiUrl ", serverApiUrl); console.log("pathname ", pathname); + //wr:dev: pathname /attach-service/api/v1/tus/upload/5e60b70a-956e-40c3-be5a-cdd3100bf8ad + //http://dev.onasys.co.kr:8000/attach-service/api/v1/tus/upload/5e60b70a-956e-40c3-be5a-cdd3100bf8ad if (token) requestHeaders.set(CLAIM_NAME, token); if (userId) requestHeaders.set(AUTH_USER_ID, userId); @@ -48,3 +50,4 @@ export function middleware(req: NextRequest) { export const config = { matcher: ["/server/:path*", "/attach-service/:path*"], }; + From 66df8b21b3939af172a66f8a562faad2dadbca49 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 28 May 2025 09:10:43 +0900 Subject: [PATCH 18/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=A0=EA=B7=9C=EB=93=B1=EB=A1=9D=20=ED=8C=9D?= =?UTF-8?q?=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 13 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 5 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 38 +++--- .../mngRegFormDetail/mngRegFormDetail.tsx | 2 +- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 121 ++++++++++++++++++ 5 files changed, 152 insertions(+), 27 deletions(-) create mode 100644 apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 0820e5609..1aec73e63 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -19,7 +19,7 @@ import type { customPbnst, fcBizSchema, fcBizType, ruseFcltType } from "@/app/st import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { z } from "zod"; -import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; +import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal"; export default function PublicReuseFaciltyInsert() { const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); @@ -99,7 +99,7 @@ useEffect(() => { <Button size={"sm"} className="" - onClick={() =>{} } + onClick={() => setIsNewReg(!issNewReg) } > 신규등록 </Button> @@ -140,7 +140,14 @@ useEffect(() => { </Tabs> </ScrollArea> </ListDiv> - + <UiModal + body={<PbnstRegModal></PbnstRegModal>} + bodyClass="w-[68vw] max-w-none h-[90vh]" + open={issNewReg} + onOpenChange={(open) => { + setIsNewReg(open); + }} + /> </div> </ContentsDiv> </> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 731f32e1d..e9ec31965 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -37,7 +37,10 @@ import { import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; export function PbnstBuseForm({ data }: { data: fcBizType[] }) { - const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null); + // const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null); + const ref = useRef<ppInstlType[] | null>( + Array.isArray(data) && data.length > 0 ? data[0]?.pplInstls ?? null : null + ); const { code, pbnst } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [getBizCycle, setBizCycle] = useState("1"); diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 1786b5f2e..3d37a8832 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -1,29 +1,23 @@ "use client"; -import { SelectBox } from "@common/business_components"; -import { FileUpload, FormUi, UiTable } from "@common/business_components/ui"; -import { Form, FormField } from "@common/business_components/ui/form"; -import { Button, Input, TableHead, TableRow } from "@common/components"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { use, useEffect, useRef, useState } from "react"; -import { set, useFieldArray, useForm } from "react-hook-form"; -import { nullable, z } from "zod"; import { useWrStore } from "@/app/store"; -import { - selectClass, - type TableUpperProps, -} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { FileUpload, FormUi } from "@common/business_components/ui"; +import { Form, FormField } from "@common/business_components/ui/form"; +import { Button, Input } from "@common/components"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useEffect, useRef, useState } from "react"; +import { useFieldArray, useForm } from "react-hook-form"; +import { z } from "zod"; +import { pbnstRegZod, type customPbnst, type operType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { commonButonSize, formH1Class, - formH2Class, - formTableName, + formTableName } from "@/components/lib/class/comClass"; -import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; +import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import type { Upload } from "tus-js-client"; -import { pbnstRegZod, type customPbnst, type operType, type ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; export function PbnstMngForm({ data }: { data: customPbnst }) { const { pbnst ,pbnstUpdate} = useWrStore((state) => state); @@ -44,7 +38,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { - const ref = useRef<operType[] | null>(data.fcOpers ?? null); + const ref = useRef<operType[] | null>(data?.fcOpers ?? null); const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), @@ -83,7 +77,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { useEffect(() => { form.reset(data); - setRuseOperData(data.fcOpers); + setRuseOperData(data?.fcOpers); }, [data]); // 2. Define a submit handler. @@ -178,7 +172,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { <div> <h1 className={formH1Class}>재이용수 공급 가능량</h1> <div className="grid grid-cols-12 gap-4"> - <div className="col-span-3"> + <div className="col-span-3 mt-4"> <FormField control={form.control} name="fcltCpct" @@ -189,7 +183,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { )} /> </div> - <div className="col-span-3"> + <div className="col-span-3 mt-4"> <FormField control={form.control} name="hasuhasu" @@ -200,7 +194,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { )} /> </div> - <div className="col-span-3"> + <div className="col-span-3 mt-4"> <FormField control={form.control} name="ruseCpct" @@ -211,7 +205,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { )} /> </div> - <div className="col-span-3"> + <div className="col-span-3 mt-4"> <FormField control={form.control} name="splyExtraCpct" diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 9edc93046..21b3f7ce0 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -42,7 +42,7 @@ export default function MngRegFormDetail({ onSelect={(date: Date | undefined) => field.onChange(date) } - className={"rounded-lg w-full"} + className={"rounded-lg !w-full"} /> ) : item.type === "number" ? ( <Input placeholder="" type="number" value={field.value??0} onChange={field.onChange} /> diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx new file mode 100644 index 000000000..3d33d3e92 --- /dev/null +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -0,0 +1,121 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +import type { customPbnst, fcBizType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { getCity } from "@/components/lib/func/commom"; +import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; +import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components"; +import { Button, Input, Label, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components/ui"; +import { useState } from "react"; +import type { objSearchType } from "../bdstRegModal/bdstRegModal"; +import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; + +export function PbnstRegModal() { + const {code, pbnst} = useWrStore((state) => { + return state; + }); + const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; + const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>() + const [objSearch, setObjSearch] = useState<objSearchType>({sgg:"",city:""}); + const [searchTxt, setSearchTxt] = useState<string>() + const [bdstTable, setbdstTable] = useState<customPbnst[]>(); + const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); + const [pbnstBiz, setPbnstBiz] = useState<fcBizType[]>(); + const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>({} as customPbnst); + const [currentTab, setCurrentTab] = useState<string>("mng"); + // const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList); + const getSelCity = (val: string | number) => { + const cityValue = String(val); + const data = getCity(cityValue, code.sggCd); + setSelectSgg(data); + setObjSearch({ city: cityValue, sgg: '' }); + }; + const getSgg = (val: string | number) => { + console.log(val); + setObjSearch({...objSearch,sgg: String(val)}) + }; + const tableClick: (val: number | undefined , headId:string) => void = (val ,headId) => { + // if(val!==undefined && bdst?.bdstBase.length>0){ + // const data:BdstTypeMap[T] =bdst?.bdstBase[val] + // if (data) { + // setRainBdstForm(data); + // } + // } + } + const handleTabChange = (value: string) => { + setCurrentTab(value); + }; + + return ( + <> + <div className="grid grid-cols-12 gap-4 mt-4 items-center"> + <SelectBox + className="col-span-3 h-full" + label={"시도"} + selectClass={selectClass} + selectArray={code.cityCd || []} + onSelectValue={getSelCity} + > + {""} + </SelectBox> + <SelectBox + className="col-span-3 h-full" + label={"시군구"} + selectClass={selectClass} + selectArray={selectSgg || []} + onSelectValue={getSgg} + > + {" "} + </SelectBox> + <Label className="w-full text-xl text-gray-600 text-right">시설명</Label> + <Input className="w-full h-full !text-xl col-span-2 col-start-8" type="text" value={searchTxt || ''} onChange={()=>{}}/> + <Button className="" size={"sm"} onClick={()=>{}}>조회</Button> + </div> + <div className="border-t border-gray-300 my-4"></div> + <div className="h-auto"> + <h1 className="text-2xl font-medium text-label pl-8">공공 하수처리시설 목록</h1> + <ScrollArea className="h-[30vh]"> + <div> + <UiTable + tableData={bdstTable || []} + headlist={pbnst.pubFacHeadList} + pageSize={-10} + total={-1} + headName={undefined} + cellClick={(idx, headId) => (tableClick(idx, headId || ""))} + onPageChange={function (page: number): void { + throw new Error("Function not implemented."); + }}> + {/* {nodeList} */} + </UiTable> + </div> + </ScrollArea> + <div className="border-t border-gray-300 my-4"></div> + <ScrollArea className="h-[40vh]"> + <Tabs defaultValue="mng" onValueChange={handleTabChange}> + <TabsList className=""> + <TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger> + <TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger> + </TabsList> + <TabsContent className="max-h-full" value="mng"> + <PbnstMngForm mngForm={pbnstBdstForm as customPbnst} isModal={true} /> + </TabsContent> + <TabsContent className="max-h-full" value="buse"> + <PbnstBuseForm buseForm={pbnstBdstForm as customPbnst} isModal={true} /> + </TabsContent> + </Tabs> + <div> + + + + + </div> + </ScrollArea> + </div> + </> + + ) +} + + From 98decab51282bccbd5d0f4b8522fd1d2ed0f9f8b Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 28 May 2025 13:07:46 +0900 Subject: [PATCH 19/62] =?UTF-8?q?=EC=8B=A0=EA=B7=9C=EB=93=B1=EB=A1=9D=20?= =?UTF-8?q?=ED=8C=9D=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 13 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 8 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 4 +- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 123 +++++------------- 4 files changed, 51 insertions(+), 97 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 1aec73e63..95666f8ca 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -20,6 +20,7 @@ import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRe import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { z } from "zod"; import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal"; +import { Toaster } from "react-hot-toast"; export default function PublicReuseFaciltyInsert() { const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); @@ -32,6 +33,7 @@ export default function PublicReuseFaciltyInsert() { const [searchTxt, setSearchTxt] = useState<string>(); const [bdstTable, setbdstTable] = useState<customPbnst[]>(); const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); + const [selectedRow, setSelectedRow] = useState<customPbnst | null>(null); useEffect(() => { if (!pbnst.isInit ) { @@ -55,6 +57,14 @@ useEffect(() => { }; const cellClick = (val: number | undefined) => { if (val === undefined) return; + console.log("pbnstRes", pbnstRes) + const selectRow = pbnstHasuRes?.[val]; + setSelectedRow(selectRow); + console.log("아제발", selectRow) + if (pbnstRes === null){ + alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.") + return; + } setSelectBdst(pbnstRes); setPbnstBiz(pbnstRes?.fcBizs) }; @@ -141,7 +151,7 @@ useEffect(() => { </ScrollArea> </ListDiv> <UiModal - body={<PbnstRegModal></PbnstRegModal>} + body={<PbnstRegModal data={selectedRow || []}></PbnstRegModal>} bodyClass="w-[68vw] max-w-none h-[90vh]" open={issNewReg} onOpenChange={(open) => { @@ -149,6 +159,7 @@ useEffect(() => { }} /> </div> + <Toaster position="top-center" /> </ContentsDiv> </> ); diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index aaafb9ba4..29af7285a 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -102,6 +102,12 @@ const getBizCycle = (fcBizs: z.infer<typeof fcBizSchema>[]) => { return pbnstBizCycle; }; + +const initFetch = async (code:string|undefined) => { + const pbnstRes =await getFetch("wr", `${code}`); + return pbnstRes; +}; + export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { return { pubHasuInit: async (txt: string | undefined) => { @@ -125,7 +131,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnstRegInit: async (txt: string | undefined) => { try { - //const pbnstRes = await initFetch(txt); + // const pbnstRes = await initFetch(txt); const pbnstRes = exampleData; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 3d37a8832..4ffae932d 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -76,8 +76,8 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const onSelectValue = (val: string) => {}; useEffect(() => { - form.reset(data); - setRuseOperData(data?.fcOpers); + form.reset(data); + setRuseOperData(data.fcOpers); }, [data]); // 2. Define a submit handler. diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index 3d33d3e92..b46bd028e 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -7,114 +7,51 @@ import { getCity } from "@/components/lib/func/commom"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components"; import { Button, Input, Label, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components/ui"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import type { objSearchType } from "../bdstRegModal/bdstRegModal"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; -export function PbnstRegModal() { - const {code, pbnst} = useWrStore((state) => { + +export function PbnstRegModal({ data }: { data: customPbnst }) { + + const { code, pbnst } = useWrStore((state) => { return state; }); const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; - const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>() - const [objSearch, setObjSearch] = useState<objSearchType>({sgg:"",city:""}); - const [searchTxt, setSearchTxt] = useState<string>() - const [bdstTable, setbdstTable] = useState<customPbnst[]>(); - const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); - const [pbnstBiz, setPbnstBiz] = useState<fcBizType[]>(); const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>({} as customPbnst); const [currentTab, setCurrentTab] = useState<string>("mng"); // const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList); - const getSelCity = (val: string | number) => { - const cityValue = String(val); - const data = getCity(cityValue, code.sggCd); - setSelectSgg(data); - setObjSearch({ city: cityValue, sgg: '' }); - }; - const getSgg = (val: string | number) => { - console.log(val); - setObjSearch({...objSearch,sgg: String(val)}) - }; - const tableClick: (val: number | undefined , headId:string) => void = (val ,headId) => { - // if(val!==undefined && bdst?.bdstBase.length>0){ - // const data:BdstTypeMap[T] =bdst?.bdstBase[val] - // if (data) { - // setRainBdstForm(data); - // } - // } - } + const handleTabChange = (value: string) => { setCurrentTab(value); }; - return ( - <> - <div className="grid grid-cols-12 gap-4 mt-4 items-center"> - <SelectBox - className="col-span-3 h-full" - label={"시도"} - selectClass={selectClass} - selectArray={code.cityCd || []} - onSelectValue={getSelCity} - > - {""} - </SelectBox> - <SelectBox - className="col-span-3 h-full" - label={"시군구"} - selectClass={selectClass} - selectArray={selectSgg || []} - onSelectValue={getSgg} - > - {" "} - </SelectBox> - <Label className="w-full text-xl text-gray-600 text-right">시설명</Label> - <Input className="w-full h-full !text-xl col-span-2 col-start-8" type="text" value={searchTxt || ''} onChange={()=>{}}/> - <Button className="" size={"sm"} onClick={()=>{}}>조회</Button> - </div> - <div className="border-t border-gray-300 my-4"></div> - <div className="h-auto"> - <h1 className="text-2xl font-medium text-label pl-8">공공 하수처리시설 목록</h1> - <ScrollArea className="h-[30vh]"> - <div> - <UiTable - tableData={bdstTable || []} - headlist={pbnst.pubFacHeadList} - pageSize={-10} - total={-1} - headName={undefined} - cellClick={(idx, headId) => (tableClick(idx, headId || ""))} - onPageChange={function (page: number): void { - throw new Error("Function not implemented."); - }}> - {/* {nodeList} */} - </UiTable> - </div> - </ScrollArea> - <div className="border-t border-gray-300 my-4"></div> - <ScrollArea className="h-[40vh]"> - <Tabs defaultValue="mng" onValueChange={handleTabChange}> - <TabsList className=""> - <TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger> - <TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger> - </TabsList> - <TabsContent className="max-h-full" value="mng"> - <PbnstMngForm mngForm={pbnstBdstForm as customPbnst} isModal={true} /> - </TabsContent> - <TabsContent className="max-h-full" value="buse"> - <PbnstBuseForm buseForm={pbnstBdstForm as customPbnst} isModal={true} /> - </TabsContent> - </Tabs> - <div> - - + useEffect(() => { + if (!data) return; + console.log("데이터", data) + }, [data]); - - </div> - </ScrollArea> - </div> + return ( + <> + <h1 className="text-2xl font-medium text-label pl-8">하수재이용 시설 신규등록</h1> + + <div className="border-t border-gray-300 my-4"></div> + <ScrollArea className="h-[75vh]"> + <Tabs defaultValue="mng" onValueChange={handleTabChange}> + <TabsList className=""> + <TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger> + <TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger> + </TabsList> + <TabsContent className="max-h-full" value="mng"> + <PbnstMngForm mngForm={pbnstBdstForm as customPbnst} isModal={true} /> + </TabsContent> + <TabsContent className="max-h-full" value="buse"> + <PbnstBuseForm buseForm={pbnstBdstForm as customPbnst} isModal={true} /> + </TabsContent> + </Tabs> + </ScrollArea> </> - + ) } From 7c920303aeea733ad77df5c8c2c510056a78cd30 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Wed, 28 May 2025 13:10:21 +0900 Subject: [PATCH 20/62] Co-authored-by: truthplumage <truthplumage@users.noreply.github.com> --- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 13 +- apps/wr/components/lib/useTus_wr/useTusWr.tsx | 117 ++++++++++-------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 100 ++++++++------- apps/wr/middleware.ts | 2 +- .../src/ui/file-upload/index.tsx | 2 +- .../src/ui/file-upload/lib/file_upload.tsx | 11 +- 6 files changed, 143 insertions(+), 102 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 661925e46..00b50d157 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -205,6 +205,17 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (error) { console.error("Error updating pbnst:", error); } - }, + },fileDelete(atflCd:string){ + try { + const response = postFectch( + `/ratfl/attachments/atflCd/${atflCd}`, + null, + fetchType.COMMON + ); + return response; + + } catch (error) { + } + } }; }; diff --git a/apps/wr/components/lib/useTus_wr/useTusWr.tsx b/apps/wr/components/lib/useTus_wr/useTusWr.tsx index f11578245..b9441e6a4 100644 --- a/apps/wr/components/lib/useTus_wr/useTusWr.tsx +++ b/apps/wr/components/lib/useTus_wr/useTusWr.tsx @@ -1,63 +1,78 @@ -import { Upload, type HttpRequest, type HttpResponse, type OnSuccessPayload } from "tus-js-client"; +import { + Upload, + type HttpRequest, + type HttpResponse, + type OnSuccessPayload, + type DetailedError, +} from "tus-js-client"; import { CS_TUS_UPLOAD, CS_URL } from "../config"; import type { FilesType } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; type UploadOptions = { handleUploadStart?: (upload: Upload) => void; handleProgress?: (percentage: string) => void; - handleSuccess?: (payload :OnSuccessPayload) => void; - handleResponse?: (req:HttpRequest, res: ReturnFileType) => void; + handleSuccess?: (payload: OnSuccessPayload) => void; + handleResponse?: (req: HttpRequest, res: ReturnFileType) => void; }; -export type ReturnFileType={ - atflCd:String, - atflSn:number, - atflId:String, - physFileNm:String -} -export const TusClientUpload = (oFile: FilesType, options?: UploadOptions): Promise<ReturnFileType> => { - return new Promise((resolve, reject) => { - const Authorization = "Authorization"; - const AUTH_USER_ID = "token-id"; - - //CS_URL - const uploader = new Upload(oFile.file, { - endpoint: 'http://localhost:3001' + CS_TUS_UPLOAD, - chunkSize: 10 * 1024 * 1024, - headers: { - Authorization: "", - AUTH_USER_ID: "", - }, - metadata: { - filename: oFile.file.name, - filetype: oFile.file.type, - }, - onError(error) { - console.error(`Failed because: ${error}`); - reject(error); - }, - onProgress(bytesUploaded, bytesTotal) { - const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2); - - console.log(`Uploaded ${bytesUploaded} of ${bytesTotal} bytes (${percentage}%)`); - options?.handleProgress?.(percentage); - }, - onAfterResponse(req, res: HttpResponse) { - const fileInfo = res.getHeader("X-File-Info"); - if (fileInfo === undefined || fileInfo === null) return; - console.log("onAfterResponse fileInfo", fileInfo); - resolve(JSON.parse(fileInfo) as ReturnFileType); - }, - onSuccess(payload: OnSuccessPayload) { - options?.handleSuccess?.(payload); - }, - }); - - options?.handleUploadStart?.(uploader); - uploader.start(); - console.log("upload start >>>>>", uploader); +export type ReturnFileType = { + orgnlFileNm: string; + atflFlieSz: number; + atflType: string; + dwnldNocs: number; + delYn: string; + lnkgDmnId: string | null; + lnkgDmnNm: string | null; + regDt: Date | null; + atflCd: String; + atflSn: number; + atflId: String; + physFileNm: String; +}; +export const TusClientUpload = (oFile: FilesType, options?: UploadOptions) => + new Promise<ReturnFileType>((resolve, reject) => { + try { + const Authorization = "Authorization"; + const AUTH_USER_ID = "token-id"; + let fileInfo: string | undefined; + //CS_URL + const uploader = new Upload(oFile.file, { + endpoint: CS_TUS_UPLOAD, + chunkSize: 10 * 1024 * 1024, + headers: { + Authorization: "", + AUTH_USER_ID: "", + }, + metadata: { + filename: oFile.file.name, + filetype: oFile.file.type, + }, + onError(error) { + reject(error); + }, + onProgress(bytesUploaded, bytesTotal) { + const percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2); + options?.handleProgress?.(percentage); + }, + onAfterResponse(req, res: HttpResponse) { + fileInfo = res.getHeader("X-File-Info"); + if (fileInfo === undefined || fileInfo === null) return; + }, + onSuccess(payload: OnSuccessPayload) { + options?.handleSuccess?.(payload); + if (fileInfo) { + console.log('fileInfo', fileInfo); + resolve(JSON.parse(fileInfo) as ReturnFileType); + } else reject({} as DetailedError); + }, + }); + options?.handleUploadStart?.(uploader); + uploader.start(); + } catch (e) { + console.log(e); + reject(e as DetailedError); + } // setUpload(uploader); }); -} // // diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 41d1ecdb8..6f0a1ac02 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -12,7 +12,7 @@ import { z } from "zod"; import { commonButonSize, formH1Class, - formTableName + formTableName, } from "@/components/lib/class/comClass"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; @@ -49,8 +49,11 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { defaultValues: pbnstRegZod.parse({}), }); - - const { fields: fcOpersField, append, remove } = useFieldArray({ + const { + fields: fcOpersField, + append, + remove, + } = useFieldArray({ control: form.control, name: "fcOpers", }); @@ -70,18 +73,17 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { }; const removeSelected = () => { - console.log("ref", ref.current); - console.log("fcOpersField", fcOpersField); - if(!ref.current) return; + if (!ref.current) return; const selectedIdxs = ref.current - .map((item, idx) => (item.choose ? idx : -1)) - .filter(idx => idx !== -1); - selectedIdxs.reverse().forEach(idx => remove(idx)); + .map((item, idx) => (item.choose ? idx : -1)) + .filter((idx) => idx !== -1); + selectedIdxs.reverse().forEach((idx) => remove(idx)); }; const onSelectValue = (val: string) => {}; useEffect(() => { + if (!data) return; form.reset(data); setRuseOperData(data.fcOpers); }, [data]); @@ -89,25 +91,30 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { console.log("submit", values); - testFile; // pbnstUpdate(values); values.fcOpers = ref.current || []; console.log("form values:", values); pbnstUpdate(values); } - const fileHandler = (files:File[]) => { - const setReFiles = [...(relationfiles || [])]; - if (files && (!relationfiles || files?.length > relationfiles?.length)) { - files?.forEach( async (item) => { + const fileHandler = (files: File[]) => { + console.log('fileHandler', files); + let setReFiles = [...(relationfiles || [])]; + if (files && (!relationfiles || relationfiles.length < files.length)) { + files.find((item) => { if ( - relationfiles && - relationfiles?.filter((reFile) => reFile.file.name == item.name) - ?.length > 0 + !relationfiles || + relationfiles?.findIndex((reFile) => reFile.file === item) < 0 ) { - return; - } else { - const tusFile= await TusClientUpload({ atflCd: "", file: item }) - setReFiles.push({ atflCd: tusFile.atflCd, file: item }); + TusClientUpload({ atflCd: "", file: item }) + .then((tusFile) => { + setReFiles.push({ atflCd: tusFile.atflCd, file: item }); + console.log("after async setReFiles", setReFiles); + setRelationFiles(setReFiles); + }) + .catch((e) => { + console.log(e); + }); + return item; } }); } else if ( @@ -115,8 +122,11 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { (!files || relationfiles.length > files.length) ) { if (!files) { + //TODO: 파일삭제 + setReFiles = []; setReFiles.length = 0; } else { + //TODO: 파일삭제 relationfiles?.forEach((item, index) => { const idx = files?.indexOf(item.file); if (idx < 0) { @@ -124,9 +134,14 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { } }); } + setRelationFiles(setReFiles) } - setRelationFiles(setReFiles); }; + + useEffect(() => { + console.log("relationfiles changed:", relationfiles); + }, [relationfiles]); + const testFile = () => { // if (relationfiles && relationfiles[0]) // TusClientUpload(relationfiles[0], setUpload, { @@ -140,7 +155,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // }, // handleSuccess: (a) => { // console.log("req", a); - // }, // }); }; @@ -168,7 +182,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { <Button type="submit" size={commonButonSize}> 저장 </Button> - </div> <div> @@ -176,22 +189,22 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { <div className="flex justify-between items-center mx-3 mb-3"> <span className={formTableName}>재이용시설 운영정보</span> <div> - <Button - type="button" - size={commonButonSize} - className="!text-xl" - onClick={plusHist} - > - 추가등록 - </Button> - <Button - type="button" - size={commonButonSize} - className="!text-xl !bg-red-500 !text-white ml-1" - onClick={removeSelected} - > - 삭제 - </Button> + <Button + type="button" + size={commonButonSize} + className="!text-xl" + onClick={plusHist} + > + 추가등록 + </Button> + <Button + type="button" + size={commonButonSize} + className="!text-xl !bg-red-500 !text-white ml-1" + onClick={removeSelected} + > + 삭제 + </Button> </div> </div> <RuseMngTable @@ -282,10 +295,9 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { <FormUi label="계통도"> <FileUpload files={relationfiles?.map((item) => item.file) || []} - setFiles={ - (files: File[] | null) => { - if(files)fileHandler(files) - } } + setFiles={(files: File[] | null) => { + if (files) fileHandler(files); + }} fileTypes="PDF" ></FileUpload> </FormUi> diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index ca8cdd6e4..fdd0a3c9c 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -21,7 +21,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDgzNTA2NjV9.fzXqA7vfeOp9z7AC33urbh_hZqNPyadmrp0LAs62Ay5PcP2SiFX3smRTdLH6xQSYNtV5MNgKPvebU2VgPuhHIw" + const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDgzOTk3ODl9.wbYXSIFNSvVJKyofFW0C3Yg99AZ99oLYSCMjcoRvZB6DqfxCbqxHPxUgwWyFE6oHJWYrX6q4BvMY2TdVOtzxnA" const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; diff --git a/packages/common/business_components/src/ui/file-upload/index.tsx b/packages/common/business_components/src/ui/file-upload/index.tsx index a78965954..1c70b99af 100644 --- a/packages/common/business_components/src/ui/file-upload/index.tsx +++ b/packages/common/business_components/src/ui/file-upload/index.tsx @@ -45,7 +45,7 @@ export const FileUpload = files.map((file:File, i:number) => ( <FileUploaderItem key={i} index={i}> <Paperclip className="h-4 w-4 stroke-current" /> - <span>{file.name}</span> + <span className="w-4/5 overflow-hidden">{file.name}</span> </FileUploaderItem> ))} </FileUploaderContent> diff --git a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx index 3db4bcceb..c18c3740d 100644 --- a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx +++ b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx @@ -271,7 +271,7 @@ export const FileUploaderContent = forwardRef< {...props} ref={ref} className={cn( - "flex rounded-xl gap-1", + "w-full flex rounded-xl gap-1", orientation === "horizontal" ? "flex-raw flex-wrap" : "flex-col", className, )} @@ -295,22 +295,25 @@ export const FileUploaderItem = forwardRef< ref={ref} className={cn( buttonVariants({ variant: "ghost" }), - "h-6 p-1 justify-between cursor-pointer relative", + "h-6 p-1 justify-between cursor-pointer relative w-full", className, isSelected ? "bg-muted" : "", )} {...props} + onClick={() =>{ + console.log('onclick'); + removeFileFromSet(index)}} > - <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full w-full"> + <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full !w-4/5 overflow-hidden "> {children} </div> <button type="button" className={cn( "absolute", + "!w-1/5 z-50", direction === "rtl" ? "top-1 left-1" : "top-1 right-1", )} - onClick={() => removeFileFromSet(index)} > <span className="sr-only">remove item {index}</span> <RemoveIcon className="w-4 h-4 hover:stroke-destructive duration-200 ease-in-out" /> From 889b0c5a3c4f2c6a84fd1b642830951c47bcd0af Mon Sep 17 00:00:00 2001 From: JIeunhuh <entks301@naver.com> Date: Wed, 28 May 2025 14:30:55 +0900 Subject: [PATCH 21/62] =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EC=85=98=20=ED=81=AC=EA=B8=B0=20=EC=A1=B0=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/table/lib/pagination.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/common/business_components/src/ui/table/lib/pagination.tsx b/packages/common/business_components/src/ui/table/lib/pagination.tsx index 2c17f4b45..76e3b4578 100644 --- a/packages/common/business_components/src/ui/table/lib/pagination.tsx +++ b/packages/common/business_components/src/ui/table/lib/pagination.tsx @@ -8,7 +8,7 @@ const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => ( <nav role="navigation" aria-label="pagination" - className={cn("mx-auto flex w-full justify-center", className)} + className={cn("mx-auto flex w-full justify-center text-lg mt-2", className)} {...props} /> ) @@ -42,7 +42,7 @@ type PaginationLinkProps = { const PaginationLink = ({ className, isActive, - size = "icon", + size = "default", ...props }: PaginationLinkProps) => ( <a @@ -52,6 +52,7 @@ const PaginationLink = ({ variant: isActive ? "outline" : "ghost", size, }), + "px-4 py-2 text-lg", className )} {...props} @@ -66,10 +67,10 @@ const PaginationPrevious = ({ <PaginationLink aria-label="Go to previous page" size="default" - className={cn("gap-1 pl-2.5", className)} + className={cn("gap-2 pl-4 text-lg", className)} {...props} > - <ChevronLeft className="h-4 w-4" /> + <ChevronLeft className="h-6 w-6" /> <span>Previous</span> </PaginationLink> ) @@ -82,11 +83,11 @@ const PaginationNext = ({ <PaginationLink aria-label="Go to next page" size="default" - className={cn("gap-1 pr-2.5", className)} + className={cn("gap-2 pr-4 text-lg", className)} {...props} > <span>Next</span> - <ChevronRight className="h-4 w-4" /> + <ChevronRight className="h-6 w-6" /> </PaginationLink> ) PaginationNext.displayName = "PaginationNext" @@ -97,10 +98,10 @@ const PaginationEllipsis = ({ }: React.ComponentProps<"span">) => ( <span aria-hidden - className={cn("flex h-9 w-9 items-center justify-center", className)} + className={cn("flex h-12 w-12 items-center justify-center text-lg", className)} {...props} > - <MoreHorizontal className="h-4 w-4" /> + <MoreHorizontal className="h-6 w-6" /> <span className="sr-only">More pages</span> </span> ) From 055091d64db22ad32f84c4f6f43cd6c9a123e006 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 28 May 2025 17:16:21 +0900 Subject: [PATCH 22/62] =?UTF-8?q?=EC=9B=90=EC=88=98=EC=B7=A8=EC=88=98=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 6 +- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 6 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 74 +++++++++++-------- .../fcOrgwtsRegModal/fcOrgwtsRegModal.tsx | 53 +++++++++++-- 4 files changed, 97 insertions(+), 42 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 62feda6dc..a0dce391a 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -52,10 +52,10 @@ export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "dtlPstnExpln", title: "상세위치 설명", }, ]; export const fcOrgwtsHeadListExport: TableUpperProps[] = [ - { id: "sido", title: "운영방식" }, - { id: "gugun", title: "원수취수량" }, + { id: "sido", title: "시도" }, + { id: "gugun", title: "시군구" }, { id: "bscFctNm", title: "시설명" }, - { id: "addr", title: "상세위치 설명" }, + { id: "addr", title: "위치" }, ] diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 29bec52b9..1c356019c 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -316,7 +316,7 @@ export const exampleData = { }, { pbnstRuseFcltBizFk: 1, - swtrmtFcltFk: "11000SW001R", + swtrmtFcltFk: "11200PB001R", orgwtWtritQnt: "153", tmsYn: "Y", dschgFmYn: "N", @@ -410,7 +410,7 @@ export const exampleData = { fcOrgwts: [ { pbnstRuseFcltBizFk: 11, - wtrmtFcltFk: "11000SW001R", + swtrmtFcltFk: "11000SW001R", orgwtWtritQnt: "152", tmsYn: "Y", dschgFmYn: "N", @@ -420,7 +420,7 @@ export const exampleData = { }, { pbnstRuseFcltBizFk: 11, - wtrmtFcltFk: "11000SW001R", + swtrmtFcltFk: "11200PB001R", orgwtWtritQnt: "150", tmsYn: "Y", dschgFmYn: "N", diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 1743e3b8c..60391fd18 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -1,28 +1,6 @@ "use client"; -import { SelectBox } from "@common/business_components"; -import { - FormUi, - UiModal, - type SelectDataType, -} from "@common/business_components/ui"; -import { Form, FormField } from "@common/business_components/ui/form"; -import { Button, Input, Label, TableHead, TableRow } from "@common/components"; -import { zodResolver } from "@hookform/resolvers/zod"; -import { set, useFieldArray, useForm } from "react-hook-form"; -import { use, useEffect, useRef, useState } from "react"; -import { z } from "zod"; import { useWrStore } from "@/app/store"; -import { - selectClass, - type TableUpperProps, -} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { - commonButonSize, - formH1Class, - formTableName, -} from "@/components/lib/class/comClass"; -import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; import { businessMoneyInfo, businessSttnInfo, @@ -33,13 +11,31 @@ import { } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; import { fcBizSchema, - pbnstRegZod, type fcBizType, type fcOrgwtType, - type ppInstlType, + type ppInstlType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; +import { + selectClass +} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { + commonButonSize, + formH1Class, + formTableName, +} from "@/components/lib/class/comClass"; import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal"; +import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; +import { SelectBox } from "@common/business_components"; +import { + UiModal, + type SelectDataType +} from "@common/business_components/ui"; +import { Form } from "@common/business_components/ui/form"; +import { Button, Input, Label } from "@common/components"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useEffect, useRef, useState } from "react"; +import { useFieldArray, useForm } from "react-hook-form"; +import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; export function PbnstBuseForm({ data }: { data: fcBizType[] }) { // const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null); @@ -52,7 +48,8 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const [ppiSelectList, setPpiSelectList] = useState<[{ name: string; val: SelectDataType[] }]>(); const [ppiYn, setPpiYn] = useState("Y"); -const [ isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); + const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); + const [modalData, setModalData] = useState<fcOrgwtType | null>(null); @@ -75,6 +72,12 @@ const [ isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); name: "pplInstls", }); + const buttonClick = () => { + console.log("머임?", data[0]?.fcOrgwts) + setIsFcOrgwts(true); + const moData = data[0]?.fcOrgwts; + setModalData(moData); + } const plusHist = () => { @@ -127,6 +130,7 @@ const [ isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); }, [form.formState.errors]); return ( + <> <div className=" !mx-[1.6rem] !p-0r"> {/* 차수별 등록 현황 폼 */} <div className="justify-between"> @@ -193,7 +197,18 @@ const [ isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); <h1 className={formH1Class}>재이용 원수취수 현황</h1> <div> - <Button type="button" onClick={() => {setIsFcOrgwts(true)} }size={commonButonSize}>추가등록</Button> + <Button + type="button" + onClick={ + // () => { + // setIsFcOrgwts(true) + // setModalData(modalData) + // } + buttonClick + } + size={commonButonSize}> + 추가등록 + </Button> <RuseMngTable tableData={fcOrgwtFiled} headList={pbnst.pbnstOrgwtHeadList} @@ -267,9 +282,10 @@ const [ isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); <UiModal open={isFcOrgwts} onOpenChange={(open: boolean) => setIsFcOrgwts(open)} - bodyClass={"w-[68vw] max-w-none h-[60vh]"} - body={<FcOrgwtsRegModal></FcOrgwtsRegModal>} + bodyClass={"w-[60vw] max-w-none h-[60vh]"} + body={<FcOrgwtsRegModal data={ modalData || []}></FcOrgwtsRegModal>} ></UiModal> </div> + </> ); } diff --git a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx index dc4144073..eb44fba66 100644 --- a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx @@ -1,29 +1,65 @@ "use client"; import { useWrStore } from "@/app/store"; +import type { customPbnst, fcBizType, fcOrgwtType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { tableData } from "@/components/lib/func/commom"; import { Title, UiTable } from "@common/business_components/ui"; +import { Label } from "@common/business_components/ui/form/lib/label"; +import { Button } from "@common/business_components/ui/table/lib/button"; +import { Input } from "@common/components/ui"; import { ArrowLeft, ArrowRight } from "lucide-react"; import { useEffect, useState } from "react"; -export default function FcOrgwtsRegModal() { +export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { const { code, pbnst } = useWrStore((state) => state); - const { fcOrgwtsHeadList } = pbnst; - + const { fcOrgwtsHeadList, pbnstHasuRes } = pbnst; + const [bdstTable, setbdstTable] = useState<customPbnst[]>(); const [isFcOrgwtsData, setIsFcOrgwtsData] = useState<boolean>(false); + const [pkTable, setPkTable] = useState<customPbnst[]>(); useEffect(() => { console.log("isFcOrgwtsData", isFcOrgwtsData); }, [isFcOrgwtsData]); + useEffect(() => { + // console.log("어휴", pbnstHasuRes); + if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { + setbdstTable(tableData(pbnstHasuRes, { code })); + } + }, [code, pbnstHasuRes]); + + useEffect(() => { + if (!data) return; + const findPk = data.map(element => { + const pk = pbnstHasuRes.find((item)=> String(item.bscFctCd) === element.swtrmtFcltFk) + return pk; + }); + + setPkTable(findPk); + }, [data]); + + useEffect(()=>{ + + }) + return ( <> <div className="flex flex-col h-full"> <div> <Title title={"취수하수처리장 추가"} /> + <Button className="m-2" size={"sm"} onClick={()=>{}}>저장</Button> </div> + <div className="flex flex-row flex-grow gap-4 mt-4"> <div className="w-3/7"> + <Label className="w-full text-2xl text-gray-600 text-right">공공하수처리시설 목록</Label> + <div className="flex items-center"> + <Label className="w-full text-xl text-gray-600 text-right">시설명</Label> + <Input className="w-1/3 !text-xl ml-2" type="text" value={""} onChange={(e) => {}}/> + <Button className="m-2" size={"sm"} onClick={()=>{}}>조회</Button> + </div> + <div className="border-t border-gray-300 my-4"></div> <UiTable - headName={"공공하수처리시설 목록"} - tableData={[]} + headName={""} + tableData={bdstTable || []} headlist={fcOrgwtsHeadList} pageSize={0} total={0} @@ -41,13 +77,16 @@ export default function FcOrgwtsRegModal() { }} className="w-12 h-12 text-gray-500" /> - <ArrowLeft className="w-12 h-12 text-gray-500" /> + <ArrowLeft + type="button" + onClick={() => {}} + className="w-12 h-12 text-gray-500" /> </div> {/* Right Table container: Takes 2/5 of the width */} <div className="w-3/7"> <UiTable headName={"취수하수처리장 목록"} - tableData={[]} + tableData={pkTable || []} headlist={fcOrgwtsHeadList} pageSize={0} total={0} From 103c5e05aea8923687d8264678e230160b2a6c9e Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Wed, 28 May 2025 17:18:35 +0900 Subject: [PATCH 23/62] Co-authored-by: truthplumage <truthplumage@users.noreply.github.com> --- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 43 ++++- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 14 +- apps/wr/components/lib/api/index.ts | 99 ++++++----- apps/wr/components/lib/config/index.ts | 4 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 157 ++++++++++-------- apps/wr/middleware.ts | 2 +- 6 files changed, 187 insertions(+), 132 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 00b50d157..1693dbf16 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -1,6 +1,6 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; -import { fetchType, getFetch, postFectch } from "@/components/lib/api"; +import { deleteFectch, fetchType, getFetch, postFectch } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, @@ -51,6 +51,8 @@ type pubFacActions = { pbnstRegSearch: (txt: string | undefined, sgg: string) => void; pbnstReg: (txt: string | undefined) => void; pbnstUpdate(pbnstRes: customPbnst) : Promise<void>; + fileDelete:(atflCd:string)=>void + fileDownLoad: (atflCd: string) => void }; export type pubFacType = pubFacState & pubFacActions; @@ -151,9 +153,12 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, pbnstRegSearch: async (txt: string | undefined, sgg: string) => { try { + + const pbnstRes = await getFetch( "wr", - `/api/v1/reuseFc/pubFc` + (txt ? `/${txt}` : "") + `/${sgg}` + '' + // `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}` ); // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 const pbnstBizCycle = @@ -205,16 +210,38 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (error) { console.error("Error updating pbnst:", error); } - },fileDelete(atflCd:string){ + },fileDelete: async (atflCd:string)=>{ try { - const response = postFectch( - `/ratfl/attachments/atflCd/${atflCd}`, - null, - fetchType.COMMON + const response = await deleteFectch( + `/attach-service/api/v1/atfl/attachments/atflCd//${atflCd}`, + undefined, + fetchType.CS ); - return response; + + console.log("File deleted successfully:", response); + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + isInit: false, + }, + }));; } catch (error) { + + console.error("Error deleting file:", error); + } + },fileDownLoad: async (atflCd: string) => { + + try{ + const response = await getFetch( fetchType.CS , `/api/v1/atflcd/download/${atflCd}`) + + + if (!response.ok) { + throw new Error(`Error downloading file: ${response.statusText}`); + } + }catch(error){ + console.error("Error downloading file:", error); } } }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 29bec52b9..358986465 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -44,6 +44,8 @@ export type fcOrgwtType = z.infer<typeof fcOrgwtSchema>; export type ppInstlType = z.infer<typeof pplInstlSchema>; export type operType = z.infer<typeof fcOperSchema>; +export type fcFileType = z.infer<typeof fcFileSchema>; + const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), @@ -52,13 +54,13 @@ const pplInstlSchema = z.object({ cpct: z.string(), }); const fcFileSchema = z.object({ - ruseFcltFk: z.number().default(0), - fileTkn: z.string().default("test"), - filePath: z.string().default("test"), - fileKnd: z.string().default("test"), - regDt: z.date().default(new Date()), + ruseFcltFk: z.number().default(0).nullish(), + fileTkn: z.string(), + filePath: z.string(), + fileKnd: z.string(), + regDt: z.date().default(new Date()).nullish(), rgtr: z.string(), - mdfcnDt: z.date().default(new Date()), + mdfcnDt: z.date().default(new Date()).nullish(), mdfr: z.string(), }); diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index 6e3b9b1a8..7b8507910 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -1,69 +1,84 @@ //8880 -import { DEV_URL_FO, DEV_URL_WR } from "../config/"; +import { CS_URL, DEV_URL_FO, DEV_URL_WR, LOCAL_URL } from "../config/"; -export const fetchType={COMMON: "common", WR: "wr"} +export const fetchType = { COMMON: "common", WR: "wr", LOCAL: "LOCAL" , CS: "CS" }; -export const getFetch = async( type:string , url: string) => { - const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR - const response = await fetch( div+url , { +export const getFetch = async (type: string, url: string) => { + const div = + type === fetchType.COMMON + ? DEV_URL_FO + : type === fetchType.LOCAL + ? LOCAL_URL + : type === fetchType.CS + ? '' + : DEV_URL_WR; + + const response = await fetch(div + url, { method: "GET", headers: { - accept: "application/json", + accept: "application/json", }, }); - if(!response.ok) { + if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } - const res = await response.json() + const res = await response.json(); return res.data; -} +}; -export const postFectch = async (url: string, params: any , type?:string) => { - const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR +export const postFectch = async (url: string, params: any, type?: string) => { + const div = type === fetchType.COMMON ? DEV_URL_FO : DEV_URL_WR; - const response = await fetch(div+url, { + const response = await fetch(div + url, { method: "POST", headers: { - 'accept': 'application/json', + accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(params), }); - if(!response.ok) { + if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } return await response.json(); -} - +}; export const putFectch = async (url: string, params: any) => { + const response = await fetch(DEV_URL_WR + url, { + method: "PUT", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(params), + }); + if (!response.ok) { + throw new Error(`오류 발생: ${response.status}`); + } + return response; +}; - const response = await fetch(DEV_URL_WR+url, { - method: "PUT", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(params), - }); - if(!response.ok) { - throw new Error(`오류 발생: ${response.status}`); - } - return response; - } +export const deleteFectch = async (url: string, params?: any, type?: string) => { + const div = + type === fetchType.COMMON + ? DEV_URL_FO + : type === fetchType.LOCAL + ? LOCAL_URL + : type === fetchType.CS + ? '' + : DEV_URL_WR; - -export const deleteFectch = async (url: string, params: any) => { - const response = await fetch(DEV_URL_WR+url, { - method: "DELETE", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(params), - }); - if(!response.ok) { - throw new Error(`오류 발생: ${response.status}`); - } - return response; - } \ No newline at end of file + console.log("deleteFectch url", div + url); + const response = await fetch(div + url, { + method: "DELETE", + headers: { + "Content-Type": "application/json", + }, + body: params?JSON.stringify(params):undefined, + }); + if (!response.ok) { + throw new Error(`오류 발생: ${response.status}`); + } + return await response.text(); +}; \ No newline at end of file diff --git a/apps/wr/components/lib/config/index.ts b/apps/wr/components/lib/config/index.ts index 1348c2dc1..d0e076d81 100644 --- a/apps/wr/components/lib/config/index.ts +++ b/apps/wr/components/lib/config/index.ts @@ -1,5 +1,5 @@ -const LOCAL_PORT = "3000"; +const LOCAL_PORT = "3001"; const DEV_PORT = "11080"; const DEV_PORT_NEW="11082" @@ -12,6 +12,6 @@ export const DEV_URL_WR = `http://con.mind-one.co.kr:${DEV_PORT}/api/v1`; export const DEV_URL_FO = `http://con.mind-one.co.kr:${DEV_PORT_NEW}/api/v1`; - +export const LOCAL_URL = `http://localhost:${LOCAL_PORT}`; export const CS_URL= 'http://dev.onasys.co.kr:8000' export const CS_TUS_UPLOAD= "/attach-service/api/v1/tus/upload"; \ No newline at end of file diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 6f0a1ac02..89343cb93 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -5,7 +5,7 @@ import { FileUpload, FormUi } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useEffect, useRef, useState } from "react"; +import { use, useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; @@ -20,25 +20,28 @@ import type { Upload } from "tus-js-client"; import { pbnstRegZod, type customPbnst, + type fcFileType, type operType, type ruseFcltType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; export type FilesType = { - atflCd: String; + atflCd: string; file: File; }; export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst, pbnstUpdate } = useWrStore((state) => state); + const { pbnst, pbnstUpdate, fileDelete } = useWrStore((state) => state); const { pbnstMngUpHeadList } = pbnst; const [ruseOperData, setRuseOperData] = useState<operType[]>(); - const [planFiles, setPlanFiles] = useState<File[] | null>(null); + const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null); const [isModalOpen, setIsModalOpen] = useState(false); + const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null); const [upload, setUpload] = useState<Upload | null>(null); const [progress, setProgress] = useState(0); - + //const new File([] as BlobPart[], "") 파일 다운로드 활용 const handleProgress = (percentage: string) => { setProgress(Number(percentage)); }; @@ -58,6 +61,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); + const fileDownload = (index: number) => {}; const plusHist = () => { append({ choose: false, @@ -80,8 +84,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { selectedIdxs.reverse().forEach((idx) => remove(idx)); }; - const onSelectValue = (val: string) => {}; - useEffect(() => { if (!data) return; form.reset(data); @@ -90,26 +92,37 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { - console.log("submit", values); - // pbnstUpdate(values); values.fcOpers = ref.current || []; + values.fcFiles = regFileList || []; console.log("form values:", values); pbnstUpdate(values); } - const fileHandler = (files: File[]) => { - console.log('fileHandler', files); - let setReFiles = [...(relationfiles || [])]; - if (files && (!relationfiles || relationfiles.length < files.length)) { + + const fileHandler = (files: File[], type: string) => { + console.log("fileHandler", files); + let fileList = [] as FilesType[]; + if (type === "relation" && relationfiles) { + fileList = relationfiles; + } else if (type === "plan" && planFiles) { + fileList = planFiles; + } + + let setReFiles = [...(fileList || [])]; + if (files && (!fileList || fileList.length < files.length)) { files.find((item) => { if ( - !relationfiles || - relationfiles?.findIndex((reFile) => reFile.file === item) < 0 + !fileList || + fileList?.findIndex((reFile) => reFile.file === item) < 0 ) { TusClientUpload({ atflCd: "", file: item }) .then((tusFile) => { - setReFiles.push({ atflCd: tusFile.atflCd, file: item }); - console.log("after async setReFiles", setReFiles); - setRelationFiles(setReFiles); + setReFiles.push({ + atflCd: tusFile.atflCd.toString(), + file: item, + }); + type === "relation" + ? setRelationFiles(setReFiles) + : setPlanFiles(setReFiles); }) .catch((e) => { console.log(e); @@ -117,47 +130,54 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { return item; } }); - } else if ( - relationfiles && - (!files || relationfiles.length > files.length) - ) { + } else if (fileList && (!files || fileList.length > files.length)) { if (!files) { - //TODO: 파일삭제 + fileList.forEach((file) => { + fileDelete(file.atflCd as string); + }); setReFiles = []; setReFiles.length = 0; } else { - //TODO: 파일삭제 - relationfiles?.forEach((item, index) => { + fileList?.forEach((item, index) => { const idx = files?.indexOf(item.file); if (idx < 0) { - setReFiles.slice(index); + setReFiles.splice(index); + fileDelete(item.atflCd as string); } }); } - setRelationFiles(setReFiles) + type === "relation" + ? setRelationFiles(setReFiles) + : setPlanFiles(setReFiles); } }; + const regFileFilter=(files:FilesType[], fileKnd:string, regFile:fcFileType[])=>{ + const planDatas = regFile?.filter(item=>item.fileKnd!==fileKnd) || []; + const data = files.map((item) => ({ + fileTkn: item.atflCd, + filePath: item.file.name, + fileKnd: fileKnd, + rgtr: TEST_UUID, + mdfr: TEST_UUID, + })); + return [...planDatas, ...data] + } + useEffect(() => { + console.log("relationfiles:", relationfiles); + if (relationfiles) { + setRegFileList(regFileFilter(relationfiles, "계통도", regFileList||[])); + } + }, [relationfiles]); + useEffect(() => { + if (planFiles) { + setRegFileList(regFileFilter(planFiles, "평면도", regFileList||[])); + } + }, [planFiles]); useEffect(() => { - console.log("relationfiles changed:", relationfiles); - }, [relationfiles]); + console.log("regFileList:", regFileList); + }, [regFileList]); - const testFile = () => { - // if (relationfiles && relationfiles[0]) - // TusClientUpload(relationfiles[0], setUpload, { - // handleUploadStart: () => { - // console.log("handleUploadStart"); - // }, - // handleProgress, - // handleResponse: (req, res) => { - // console.log("handleResponse req", req); - // console.log("handleResponse res", res); - // }, - // handleSuccess: (a) => { - // console.log("req", a); - // }, - // }); - }; useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -288,36 +308,27 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { </div> <div className="grid grid-cols-12 gap-4 my-4"> <div className="col-span-6"> - <FormField - control={form.control} - name="psysScdg" - render={({}) => ( - <FormUi label="계통도"> - <FileUpload - files={relationfiles?.map((item) => item.file) || []} - setFiles={(files: File[] | null) => { - if (files) fileHandler(files); - }} - fileTypes="PDF" - ></FileUpload> - </FormUi> - )} - /> + <FormUi label="계통도"> + <FileUpload + files={relationfiles?.map((item) => item.file) || []} + setFiles={(files: File[] | null) => { + if (files) fileHandler(files, "relation"); + }} + fileTypes="PDF" + onFileClick={(index) => {}} + ></FileUpload> + </FormUi> </div> <div className="col-span-6"> - <FormField - control={form.control} - name="designScdg" - render={({}) => ( - <FormUi label="평면도"> - <FileUpload - files={planFiles || []} - setFiles={setPlanFiles} - fileTypes="PDF" - ></FileUpload> - </FormUi> - )} - /> + <FormUi label="평면도"> + <FileUpload + files={planFiles?.map((item) => item.file) || []} + setFiles={(files: File[] | null) => { + if (files) fileHandler(files, "plan"); + }} + fileTypes="PDF" + ></FileUpload> + </FormUi> </div> </div> </div> diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index fdd0a3c9c..e30e04f4d 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -21,7 +21,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDgzOTk3ODl9.wbYXSIFNSvVJKyofFW0C3Yg99AZ99oLYSCMjcoRvZB6DqfxCbqxHPxUgwWyFE6oHJWYrX6q4BvMY2TdVOtzxnA" + const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0MjU0NzJ9.rABGFEzyCEDYwnuzd-6V0lPtckSGx-h77-tJBYFz00KPowmWBpwMLrSynxmHpmtmga86ksIYxuoMkiT1_aI6Sw" const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; From 89893fca9869f2827da95fc72a211ac5bc06be4d Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 28 May 2025 21:07:01 +0900 Subject: [PATCH 24/62] =?UTF-8?q?=EC=9B=90=EC=88=98=EC=B7=A8=EC=88=98=20?= =?UTF-8?q?=EC=9E=91=EC=97=85=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 1 + .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 1 + .../fcOrgwtsRegModal/fcOrgwtsRegModal.tsx | 122 ++++++++++++------ .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 6 +- 4 files changed, 90 insertions(+), 40 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index a0dce391a..686a8b420 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -52,6 +52,7 @@ export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ { id: "dtlPstnExpln", title: "상세위치 설명", }, ]; export const fcOrgwtsHeadListExport: TableUpperProps[] = [ + { id: "choose", title: "선택", type: "checkbox" }, { id: "sido", title: "시도" }, { id: "gugun", title: "시군구" }, { id: "bscFctNm", title: "시설명" }, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 1c356019c..b6a340b5e 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -185,6 +185,7 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ + choose: z.boolean().default(false), pbnstRuseFcltPk: z.number().default(0), swtrmtFcltFk: z.string().default(""), ruseUtztnFcltNm: z.string().default(""), diff --git a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx index eb44fba66..cc416a64c 100644 --- a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx @@ -1,13 +1,16 @@ "use client"; import { useWrStore } from "@/app/store"; import type { customPbnst, fcBizType, fcOrgwtType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { tableData } from "@/components/lib/func/commom"; +import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { Title, UiTable } from "@common/business_components/ui"; import { Label } from "@common/business_components/ui/form/lib/label"; import { Button } from "@common/business_components/ui/table/lib/button"; import { Input } from "@common/components/ui"; import { ArrowLeft, ArrowRight } from "lucide-react"; -import { useEffect, useState } from "react"; +import { useEffect, useRef, useState } from "react"; +import { useFieldArray } from "react-hook-form"; export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { const { code, pbnst } = useWrStore((state) => state); @@ -15,12 +18,12 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { const [bdstTable, setbdstTable] = useState<customPbnst[]>(); const [isFcOrgwtsData, setIsFcOrgwtsData] = useState<boolean>(false); const [pkTable, setPkTable] = useState<customPbnst[]>(); + const rightRef = useRef<fcOrgwtType[] | null>([] as fcOrgwtType[]); + const leftRef = useRef<fcOrgwtType[] | null>([] as fcOrgwtType[]); + const [rightData, setRightData] = useState<customPbnst[]>(); useEffect(() => { - console.log("isFcOrgwtsData", isFcOrgwtsData); - }, [isFcOrgwtsData]); - useEffect(() => { - // console.log("어휴", pbnstHasuRes); + // console.log("머지", pbnstHasuRes); if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { setbdstTable(tableData(pbnstHasuRes, { code })); } @@ -29,62 +32,105 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { useEffect(() => { if (!data) return; const findPk = data.map(element => { - const pk = pbnstHasuRes.find((item)=> String(item.bscFctCd) === element.swtrmtFcltFk) + const pk = pbnstHasuRes.find((item) => String(item.bscFctCd) === element.swtrmtFcltFk) return pk; }); - setPkTable(findPk); }, [data]); - useEffect(()=>{ - - }) - return ( <> <div className="flex flex-col h-full"> <div> <Title title={"취수하수처리장 추가"} /> - <Button className="m-2" size={"sm"} onClick={()=>{}}>저장</Button> + <Button className="m-2" size={"sm"} onClick={() => { }}>저장</Button> </div> - + <div className="flex flex-row flex-grow gap-4 mt-4"> <div className="w-3/7"> - <Label className="w-full text-2xl text-gray-600 text-right">공공하수처리시설 목록</Label> - <div className="flex items-center"> - <Label className="w-full text-xl text-gray-600 text-right">시설명</Label> - <Input className="w-1/3 !text-xl ml-2" type="text" value={""} onChange={(e) => {}}/> - <Button className="m-2" size={"sm"} onClick={()=>{}}>조회</Button> - </div> - <div className="border-t border-gray-300 my-4"></div> - <UiTable + <Label className="w-full text-2xl text-gray-600 text-right">공공하수처리시설 목록</Label> + <div className="flex items-center"> + <Label className="w-full text-xl text-gray-600 text-right">시설명</Label> + <Input className="w-1/3 !text-xl ml-2" type="text" value={""} onChange={(e) => { }} /> + <Button className="m-2" size={"sm"} onClick={() => { }}>조회</Button> + </div> + <div className="border-t border-gray-300 my-4"></div> + <RuseMngTable + tableData={bdstTable || []} + headList={fcOrgwtsHeadList} + upHeadList={[]} // TODO: Replace with actual upHeadList data if available + ref={leftRef} + /> + {/* <UiTable headName={""} tableData={bdstTable || []} headlist={fcOrgwtsHeadList} pageSize={0} total={0} - cellClick={undefined} + cellClick={cellClick} onPageChange={function (page: number): void { throw new Error("Function not implemented."); }} - ></UiTable> - </div> + ></UiTable> */} + </div> <div className="flex flex-col items-center justify-center w-1/7 gap-2"> <ArrowRight - type="button" - onClick={() => { - setIsFcOrgwtsData(!isFcOrgwtsData); - }} - className="w-12 h-12 text-gray-500" - /> - <ArrowLeft - type="button" - onClick={() => {}} - className="w-12 h-12 text-gray-500" /> - </div> + type="button" + onClick={() => { + if (leftRef && typeof leftRef === "object" && "current" in leftRef) { + const checked = leftRef.current?.filter((item) => ((item as unknown as customPbnst)?.choose)) + const unchecked = leftRef.current?.filter((item) => !(item as unknown as customPbnst)?.choose) + if (checked && checked.length > 0) { + checked.forEach(item=>(item as unknown as customPbnst).choose = false) + setRightData([...(checked as unknown as customPbnst[]), + ...((rightRef.current ?? []) as unknown as customPbnst[]) + ]) + + } + if (unchecked && unchecked.length > 0) { + setbdstTable([...(unchecked as unknown as customPbnst[])]) + }else{ + setbdstTable([]) + } + } + } + } + className="w-12 h-12 text-gray-500 cursor-pointer" + /> + <ArrowLeft + type="button" + onClick={() => { + if (rightRef && typeof rightRef === "object" && "current" in rightRef) { + const checked = rightRef.current?.filter((item) => ((item as unknown as customPbnst)?.choose)) + const unchecked = rightRef.current?.filter((item) => !(item as unknown as customPbnst)?.choose) + if (checked && checked.length > 0) { + checked.forEach(item=>(item as unknown as customPbnst).choose = false) + setbdstTable([ + ...(checked as unknown as customPbnst[]), + ...((leftRef.current ?? []) as unknown as customPbnst[]) + ]) + } + console.log("ㅇㅇ", unchecked); + if (unchecked && unchecked.length > 0) { + setRightData([...(unchecked as unknown as customPbnst[])]) + }else{ + setRightData([]) + } + } + }} + className="w-12 h-12 text-gray-500" /> + </div> {/* Right Table container: Takes 2/5 of the width */} <div className="w-3/7"> - <UiTable + <Label className="w-full text-2xl text-gray-600 text-right">취수하수처리장 목록</Label> + <div className="border-t border-gray-300 my-4"></div> + <RuseMngTable + tableData={rightData || []} + headList={fcOrgwtsHeadList} + upHeadList={[]} // TODO: Replace with actual upHeadList data if available + ref={rightRef} + /> + {/* <UiTable headName={"취수하수처리장 목록"} tableData={pkTable || []} headlist={fcOrgwtsHeadList} @@ -94,10 +140,10 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { onPageChange={function (page: number): void { throw new Error("Function not implemented."); }} - ></UiTable> + ></UiTable> */} + </div> </div> </div> - </div> </> ); } diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index d31c2efcd..c6fdea207 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -1,5 +1,7 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; +import type { customPbnst as OriginalCustomPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; + import { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { DatePicker, SelectBox, type SelectDataType } from "@common/business_components/ui"; import { @@ -21,12 +23,12 @@ type RuseMngTableProps = { code?: { name: string, val: SelectDataType[] }[]; }; -const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>( +const RuseMngTable = React.forwardRef<any, RuseMngTableProps>( ({ tableData, headList, upHeadList, - code = [] + code }, ref) => { const [tableState, setTableState] = useState([...tableData]); useEffect(() => { From 50f94aa4c2a540d484afea42c60bd479bc7ce7d4 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Wed, 28 May 2025 23:59:12 +0900 Subject: [PATCH 25/62] Co-authored-by: truthplumage <truthplumage@users.noreply.github.com> --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 21 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 74 ++-- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 5 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 351 +++++++++--------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 75 ++-- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 65 +++- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 1 - apps/wr/middleware.ts | 2 +- 8 files changed, 350 insertions(+), 244 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 95666f8ca..7c5ebdb10 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -15,7 +15,7 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; import { useEffect, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; import { tableData } from "@/components/lib/func/commom"; -import type { customPbnst, fcBizSchema, fcBizType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { customPbnst, fcBizSchema, fcBizType, pubHasuType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { z } from "zod"; @@ -31,9 +31,9 @@ export default function PublicReuseFaciltyInsert() { const [issNewReg, setIsNewReg] = useState<boolean>(false); const [searchTxt, setSearchTxt] = useState<string>(); - const [bdstTable, setbdstTable] = useState<customPbnst[]>(); + const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); - const [selectedRow, setSelectedRow] = useState<customPbnst | null>(null); + const [selectedRow, setSelectedRow] = useState<pubHasuType | null>(null); useEffect(() => { if (!pbnst.isInit ) { @@ -46,7 +46,6 @@ useEffect(() => { useEffect(() => { - console.log("pbnstHasuRes", pbnstHasuRes); if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { setbdstTable(tableData(pbnstHasuRes, { code })); } @@ -57,16 +56,14 @@ useEffect(() => { }; const cellClick = (val: number | undefined) => { if (val === undefined) return; - console.log("pbnstRes", pbnstRes) const selectRow = pbnstHasuRes?.[val]; setSelectedRow(selectRow); - console.log("아제발", selectRow) - if (pbnstRes === null){ + if (pbnstRes !== null){ alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.") return; } - setSelectBdst(pbnstRes); - setPbnstBiz(pbnstRes?.fcBizs) + // setSelectBdst(pbnstRes); + // setPbnstBiz(pbnstRes?.fcBizs) }; const resetContents = () => { setFcltMng([]); // 빈 배열로 설정하여 신규 모드로 전환 @@ -135,11 +132,17 @@ useEffect(() => { </ListDiv> </div> <ListDiv className="col-span-2 pr-6 "> + <ScrollArea className="h-[60vh]"> + + <Tabs defaultValue="mng" onValueChange={handleTabChange}> <TabsList className=""> <TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger> <TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger> + <Button size={"sm"} className="!justify-end"> + 저장 + </Button> </TabsList> <TabsContent className="max-h-full" value="mng"> <PbnstMngForm data={selectBdst || []} /> diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index e069b75f3..2d11c0e10 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -1,11 +1,17 @@ import { z } from "zod"; import type { TableUpperProps } from "../rainReg"; -import { deleteFectch, fetchType, getFetch, postFectch } from "@/components/lib/api"; +import { + deleteFectch, + fetchType, + getFetch, + postFectch, +} from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { exampleData, fcBizSchema, type customPbnst, + type fcBizType, type pubHasuType, } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; @@ -26,8 +32,7 @@ const pbnstOrgwtHeadList = pbnstOrgwtHeadListRxport; const pbnstMngNm = pbnstMngNmExport; const pplInstlsHeadLisat = pplInstlsHeadListExport; const pbnstDemandHeadList = pbnstDemandHeadListExport; -const fcOrgwtsHeadList=fcOrgwtsHeadListExport - +const fcOrgwtsHeadList = fcOrgwtsHeadListExport; export type pubFacState = { pbnst: { @@ -43,6 +48,7 @@ export type pubFacState = { pplInstlsHeadLisat: TableUpperProps[]; pbnstDemandHeadList: TableUpperProps[]; fcOrgwtsHeadList: TableUpperProps[]; + pbnstMngRegData: customPbnst[]; }; }; type pubFacActions = { @@ -50,9 +56,11 @@ type pubFacActions = { pbnstRegInit: (sgg: string) => void; pbnstRegSearch: (txt: string | undefined, sgg: string) => void; pbnstReg: (txt: string | undefined) => void; - pbnstUpdate(pbnstRes: customPbnst) : Promise<void>; - fileDelete:(atflCd:string)=>void - fileDownLoad: (atflCd: string) => void + pbnstUpdate(pbnstRes: customPbnst): Promise<void>; + fileDelete: (atflCd: string) => void; + fileDownLoad: (atflCd: string) => void; + pbnstMngData: (data: customPbnst[]) => void; + pbnstBizData(data: fcBizType): void; }; export type pubFacType = pubFacState & pubFacActions; @@ -71,6 +79,7 @@ export const pubFacStateExport: pubFacState = { pplInstlsHeadLisat: pplInstlsHeadLisat, pbnstDemandHeadList: pbnstDemandHeadList, fcOrgwtsHeadList: fcOrgwtsHeadList, + pbnstMngRegData: [], }, }; @@ -110,8 +119,8 @@ const getBizCycle = (fcBizs: z.infer<typeof fcBizSchema>[]) => { return pbnstBizCycle; }; -const initFetch = async (code:string|undefined) => { - const pbnstRes =await getFetch("wr", `${code}`); +const initFetch = async (code: string | undefined) => { + const pbnstRes = await getFetch("wr", `${code}`); return pbnstRes; }; @@ -159,12 +168,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { }, pbnstRegSearch: async (txt: string | undefined, sgg: string) => { try { - - const pbnstRes = await getFetch( "wr", - '' - // `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}` + "" + // `/api/v1/prcsFclt/ruseInfo/${pageNo}/${pageCnt}/${searchingCd}/${nameCd}/${fcltCpct}/{oprtngSttsCd}/{bscFctClsCd}/{swtrmtFcltNm}` + (txt ? `/${txt}` : "") + `/${sgg}` ); // API 응답이 pbnstRegZod 타입의 단일 객체라고 가정 const pbnstBizCycle = @@ -216,7 +223,8 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (error) { console.error("Error updating pbnst:", error); } - },fileDelete: async (atflCd:string)=>{ + }, + fileDelete: async (atflCd: string) => { try { const response = await deleteFectch( `/attach-service/api/v1/atfl/attachments/atflCd//${atflCd}`, @@ -231,24 +239,46 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { ...state.pbnst, isInit: false, }, - }));; - + })); } catch (error) { - console.error("Error deleting file:", error); } - },fileDownLoad: async (atflCd: string) => { - - try{ - const response = await getFetch( fetchType.CS , `/api/v1/atflcd/download/${atflCd}`) - + }, + fileDownLoad: async (atflCd: string) => { + try { + const response = await getFetch( + fetchType.CS, + `/api/v1/atflcd/download/${atflCd}` + ); if (!response.ok) { throw new Error(`Error downloading file: ${response.statusText}`); } - }catch(error){ + } catch (error) { console.error("Error downloading file:", error); } + }, + pbnstMngData: (data: customPbnst[]) => { + return set((state: pubFacState) => { + state.pbnst.pbnstMngRegData = data; + return state; + }); + }, + pbnstBizData:(data:fcBizType)=>{ + return set((state:pubFacState)=>{ + if(state.pbnst.pbnstMngRegData){ + const regData = state.pbnst.pbnstMngRegData.find(item=> + data.pbnstRuseFcltFk===item.pbnstRuseFcltPk + ) + if(regData){ + const bizIdx = regData.fcBizs.findIndex(item=>item.pbnstRuseFcltBizPk==data.pbnstRuseFcltBizPk) + if(bizIdx>=0){ + regData.fcBizs[bizIdx] = data; + } + } + } + return state; + }) } }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 3c39f4dbc..c04302663 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -49,6 +49,7 @@ export type fcFileType = z.infer<typeof fcFileSchema>; const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), + choose:z.boolean().default(false), pdmt: z.string(), ppMqlt: z.string(), cpct: z.string(), @@ -117,7 +118,7 @@ const fcPrfmncSchema = z.object({ export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: z.number().default(0), - pbnstRuseFcltFk: z.number().default(0), + pbnstRuseFcltFk: z.string().default(''), cycl: z.string(), seCd: z.string(), bizMthdCd: z.string(), @@ -187,7 +188,7 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ - pbnstRuseFcltPk: z.number().default(0), + pbnstRuseFcltPk: z.string().default(""), swtrmtFcltFk: z.string().default(""), ruseUtztnFcltNm: z.string().default(""), fcltCpct: z.string().default(""), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 60391fd18..3496e1140 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -13,11 +13,9 @@ import { fcBizSchema, type fcBizType, type fcOrgwtType, - type ppInstlType + type ppInstlType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -import { - selectClass -} from "@/app/store/ruseFcltMng/fcltReg/rainReg"; +import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { commonButonSize, formH1Class, @@ -26,10 +24,7 @@ import { import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { SelectBox } from "@common/business_components"; -import { - UiModal, - type SelectDataType -} from "@common/business_components/ui"; +import { UiModal, type SelectDataType } from "@common/business_components/ui"; import { Form } from "@common/business_components/ui/form"; import { Button, Input, Label } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -39,10 +34,8 @@ import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; export function PbnstBuseForm({ data }: { data: fcBizType[] }) { // const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null); - const ref = useRef<ppInstlType[] | null>( - Array.isArray(data) && data.length > 0 ? data[0]?.pplInstls ?? null : null - ); - const { code, pbnst } = useWrStore((state) => state); + const ref = useRef<ppInstlType[] |null>( null); + const { code, pbnst, pbnstBizData } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [getBizCycle, setBizCycle] = useState("1"); const [ppiSelectList, setPpiSelectList] = @@ -51,8 +44,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); const [modalData, setModalData] = useState<fcOrgwtType | null>(null); - - const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), }); @@ -67,30 +58,49 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { name: "fcOrgwts", }); - const { fields: pplInstls, append, remove } = useFieldArray({ + const { + fields: pplInstls, + append, + remove, + } = useFieldArray({ control: form.control, name: "pplInstls", }); + useEffect(() => { + pbnstBizData(form.watch() as fcBizType); + }, [form.formState]); + + useEffect(() => { + console.log("pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData); + }, [pbnst.pbnstMngRegData]); + const buttonClick = () => { - console.log("머임?", data[0]?.fcOrgwts) setIsFcOrgwts(true); - const moData = data[0]?.fcOrgwts; + const moData = data[0]?.fcOrgwts?.[0] ?? null; setModalData(moData); - } + }; - - const plusHist = () => { - append({ + const plusHist = () => { + const regData ={ + ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"", choose: false, ppMqlt: "", pdmt: "", cpct: "", + } + const currentTableDataFromRef = ref.current ? [...ref.current] : []; + const newDataForRHF = [...currentTableDataFromRef, regData]; + form.setValue("pplInstls", newDataForRHF, { + shouldValidate: true, // 필요하다면 유효성 검사 실행 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); + const latestOpers = form.getValues("pplInstls"); + ref.current = [...latestOpers]; }; const removeSelected = () => { - if(!ref.current) return; + if (!ref.current) return; const selectedIdxs = ref.current .map((item, idx) => (item.choose ? idx : -1)) .filter((idx) => idx !== -1); @@ -101,10 +111,9 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { if (data) { const index = Number(getBizCycle) - 1; form.reset(data[index]); - ref.current = data[index]?.pplInstls ?? null; + ref.current = data[index]?.pplInstls ?? []; console.log("form reset with data:", data[index]); - } }, [getBizCycle, data]); @@ -131,161 +140,165 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { return ( <> - <div className=" !mx-[1.6rem] !p-0r"> - {/* 차수별 등록 현황 폼 */} - <div className="justify-between"> - <Form {...form}> - <form - onSubmit={form.handleSubmit(onSubmit)} - className="space-y-8 mx-auto w-full mt-7" - > - <div className="flex justify-between items-center mx-3 mb-3"> - <h1 className=" text-xl"></h1> - <div className="flex items-center gap-2 mx-3"> - <h1 className={formTableName}>등록차수</h1> + <div className=" !mx-[1.6rem] !p-0r"> + {/* 차수별 등록 현황 폼 */} + <div className="justify-between"> + <Form {...form}> + <form + onSubmit={form.handleSubmit(onSubmit)} + className="space-y-8 mx-auto w-full mt-7" + > + <div className="flex justify-between items-center mx-3 mb-3"> + <h1 className=" text-xl"></h1> + <div className="flex items-center gap-2 mx-3"> + <h1 className={formTableName}>등록차수</h1> + <SelectBox + label="" + selectArray={pbnstBizCycle} + value={getBizCycle ?? pbnstBizCycle[0]?.val} + className={""} + selectClass={selectClass} + onSelectValue={(val) => { + setBizCycle(String(val)); + }} + ></SelectBox> + + <Button type="submit" size={commonButonSize}> + 저장 + </Button> + </div> + </div> + <MngRegFormDetail + formList={businessSttnInfo} + h1Title={"사업현황"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" + /> + + <MngRegFormDetail + formList={businessMoneyInfo} + h1Title={"사업비"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" + /> + <MngRegFormDetail + formList={ruseFcltinfo} + h1Title={"재처리시설"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" + /> + <MngRegFormDetail + formList={concentratedWaterInfo} + h1Title={"농축수관리"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" + /> + <MngRegFormDetail + formList={wasteWaterFcltINfo} + h1Title={"폐수배출시설 정보"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" + /> + + <h1 className={formH1Class}>재이용 원수취수 현황</h1> + <div> + <Button + type="button" + onClick={ + // () => { + // setIsFcOrgwts(true) + // setModalData(modalData) + // } + buttonClick + } + size={commonButonSize} + > + 추가등록 + </Button> + <RuseMngTable + tableData={fcOrgwtFiled} + headList={pbnst.pbnstOrgwtHeadList} + /> + </div> + <h1 className={formH1Class}>재이용 공급관로 설치 현황</h1> + <div className="flex items-center gap-4 mx-3 mb-3"> + <Label className="text-right">공급관로설치유무</Label> <SelectBox label="" - selectArray={pbnstBizCycle} - value={getBizCycle ?? pbnstBizCycle[0]?.val} - className={""} - selectClass={selectClass} - onSelectValue={(val) => { - setBizCycle(String(val)); - }} - ></SelectBox> - - <Button type ="submit" size={commonButonSize}>저장</Button> + selectArray={code.yn} + value={ppiYn} + className="w-32" + selectClass="w-full" + onSelectValue={(val) => setPpiYn(String(val))} + /> + <Label className="text-right">합계</Label> + <Input + type="text" + value={""} + readOnly + className="w-32 border-gray-300 rounded pr-8 " + /> + <Button + type="button" + size={commonButonSize} + className="!text-xl" + onClick={plusHist} + > + 추가등록 + </Button> + <Button + type="button" + size={commonButonSize} + className="!text-xl !bg-red-500 !text-white ml-1" + onClick={removeSelected} + > + 삭제 + </Button> </div> - </div> - <MngRegFormDetail - formList={businessSttnInfo} - h1Title={"사업현황"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> - <MngRegFormDetail - formList={businessMoneyInfo} - h1Title={"사업비"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> - <MngRegFormDetail - formList={ruseFcltinfo} - h1Title={"재처리시설"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> - <MngRegFormDetail - formList={concentratedWaterInfo} - h1Title={"농축수관리"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> - <MngRegFormDetail - formList={wasteWaterFcltINfo} - h1Title={"폐수배출시설 정보"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> + <div> + <RuseMngTable + tableData={pplInstls} + headList={pbnst.pplInstlsHeadLisat} + code={ppiSelectList ?? []} + ref={ref} + upHeadList={[]} + /> + </div> - <h1 className={formH1Class}>재이용 원수취수 현황</h1> - <div> - <Button - type="button" - onClick={ - // () => { - // setIsFcOrgwts(true) - // setModalData(modalData) - // } - buttonClick - } - size={commonButonSize}> - 추가등록 - </Button> - <RuseMngTable - tableData={fcOrgwtFiled} - headList={pbnst.pbnstOrgwtHeadList} + <MngRegFormDetail + formList={ruseWaterQulityList} + h1Title={"하수처리수 재이용시설 보증수질"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" /> - </div> - <h1 className={formH1Class}>재이용 공급관로 설치 현황</h1> - <div className="flex items-center gap-4 mx-3 mb-3"> - <Label className="text-right">공급관로설치유무</Label> - <SelectBox - label="" - selectArray={code.yn} - value={ppiYn} - className="w-32" - selectClass="w-full" - onSelectValue={(val) => setPpiYn(String(val))} - /> - <Label className="text-right">합계</Label> - <Input - type="text" - value={""} - readOnly - className="w-32 border-gray-300 rounded pr-8 " - /> - <Button - type="button" - size={commonButonSize} - className="!text-xl" - onClick={plusHist} - > - 추가등록 - </Button> - <Button - type="button" - size={commonButonSize} - className="!text-xl !bg-red-500 !text-white ml-1" - onClick={removeSelected} - > - 삭제 - </Button> - </div> - <div> - <RuseMngTable - tableData={pplInstls} - headList={pbnst.pplInstlsHeadLisat} - code={ppiSelectList ?? []} - ref={ref} - upHeadList={[]} /> - </div> + <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> + <div> + <Button size={commonButonSize}>수요처 추가</Button> + <RuseMngTable + tableData={[]} + headList={pbnst.pbnstDemandHeadList} + /> + </div> + </form> + </Form> + </div> - <MngRegFormDetail - formList={ruseWaterQulityList} - h1Title={"하수처리수 재이용시설 보증수질"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> - - <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> - <div> - <Button size={commonButonSize}>수요처 추가</Button> - <RuseMngTable - tableData={[]} - headList={pbnst.pbnstDemandHeadList} - /> - </div> - </form> - </Form> + <UiModal + open={isFcOrgwts} + onOpenChange={(open: boolean) => setIsFcOrgwts(open)} + bodyClass={"w-[60vw] max-w-none h-[60vh]"} + body={<FcOrgwtsRegModal data={modalData || []}></FcOrgwtsRegModal>} + ></UiModal> </div> - - <UiModal - open={isFcOrgwts} - onOpenChange={(open: boolean) => setIsFcOrgwts(open)} - bodyClass={"w-[60vw] max-w-none h-[60vh]"} - body={<FcOrgwtsRegModal data={ modalData || []}></FcOrgwtsRegModal>} - ></UiModal> - </div> </> ); } diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 89343cb93..018f9b011 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -31,7 +31,9 @@ export type FilesType = { }; export function PbnstMngForm({ data }: { data: customPbnst }) { - const { pbnst, pbnstUpdate, fileDelete } = useWrStore((state) => state); + const { pbnst, pbnstUpdate, fileDelete, pbnstMngData } = useWrStore( + (state) => state + ); const { pbnstMngUpHeadList } = pbnst; const [ruseOperData, setRuseOperData] = useState<operType[]>(); const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); @@ -50,6 +52,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), + //mode:'onChange' }); const { @@ -61,9 +64,27 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); +useEffect(() => { + console.log("ref.current", ref.current); +},[ref.current]) + useEffect(() => { + const formData = form.getValues(); + + // 기존 코드: formData.fcOpers = ref.current ? [...ref.current] : []; + // 새 코드: 상태를 유지한 채 복사 + formData.fcOpers = form.getValues("fcOpers"); // ← form 내부 상태 기준으로 복사 + formData.fcFiles = regFileList ? [...regFileList] : []; + + pbnstMngData([formData] as customPbnst[]); + }, [form.formState, regFileList]); + + useEffect(() => { + console.log(" mngRegFrom ", pbnst.pbnstMngRegData); + }, [pbnst.pbnstMngRegData]); + const fileDownload = (index: number) => {}; const plusHist = () => { - append({ + const regData = { choose: false, rgtr: "", mdfr: "", @@ -73,7 +94,15 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { rprtvBzenty: "", bgngDt: new Date(), endDt: new Date(), + }; + const currentTableDataFromRef = ref.current ? [...ref.current] : []; + const newDataForRHF = [...currentTableDataFromRef, regData]; + form.setValue("fcOpers", newDataForRHF, { + shouldValidate: true, // 필요하다면 유효성 검사 실행 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); + const latestOpers = form.getValues("fcOpers"); + ref.current = [...latestOpers]; }; const removeSelected = () => { @@ -85,9 +114,11 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { }; useEffect(() => { - if (!data) return; - form.reset(data); - setRuseOperData(data.fcOpers); + if (data) { + form.reset(data); + form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk); + ref.current = data.fcOpers || []; + } }, [data]); // 2. Define a submit handler. @@ -151,32 +182,32 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { : setPlanFiles(setReFiles); } }; - const regFileFilter=(files:FilesType[], fileKnd:string, regFile:fcFileType[])=>{ - const planDatas = regFile?.filter(item=>item.fileKnd!==fileKnd) || []; - const data = files.map((item) => ({ - fileTkn: item.atflCd, - filePath: item.file.name, - fileKnd: fileKnd, - rgtr: TEST_UUID, - mdfr: TEST_UUID, - })); - return [...planDatas, ...data] - } + const regFileFilter = ( + files: FilesType[], + fileKnd: string, + regFile: fcFileType[] + ) => { + const planDatas = regFile?.filter((item) => item.fileKnd !== fileKnd) || []; + const data = files.map((item) => ({ + fileTkn: item.atflCd, + filePath: item.file.name, + fileKnd: fileKnd, + rgtr: TEST_UUID, + mdfr: TEST_UUID, + })); + return [...planDatas, ...data]; + }; useEffect(() => { - console.log("relationfiles:", relationfiles); if (relationfiles) { - setRegFileList(regFileFilter(relationfiles, "계통도", regFileList||[])); + setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || [])); } }, [relationfiles]); useEffect(() => { if (planFiles) { - setRegFileList(regFileFilter(planFiles, "평면도", regFileList||[])); + setRegFileList(regFileFilter(planFiles, "평면도", regFileList || [])); } }, [planFiles]); - useEffect(() => { - console.log("regFileList:", regFileList); - }, [regFileList]); useEffect(() => { console.log("form errors:", form.formState.errors); diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index b46bd028e..4d2553878 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -1,24 +1,41 @@ "use client"; import { useWrStore } from "@/app/store"; -import type { customPbnst, fcBizType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { + customPbnst, + fcBizType, + pubHasuType, +} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { getCity } from "@/components/lib/func/commom"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; -import { ScrollArea, SelectBox, UiTable, type SelectDataType } from "@common/business_components"; -import { Button, Input, Label, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components/ui"; +import { + ScrollArea, + SelectBox, + UiTable, + type SelectDataType, +} from "@common/business_components"; +import { + Button, + Input, + Label, + Tabs, + TabsContent, + TabsList, + TabsTrigger, +} from "@common/components/ui"; import { useEffect, useState } from "react"; import type { objSearchType } from "../bdstRegModal/bdstRegModal"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; - -export function PbnstRegModal({ data }: { data: customPbnst }) { - +export function PbnstRegModal({ data }: { data: pubHasuType }) { const { code, pbnst } = useWrStore((state) => { return state; }); const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; - const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>({} as customPbnst); + const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>( + {} as customPbnst + ); const [currentTab, setCurrentTab] = useState<string>("mng"); // const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList); @@ -27,32 +44,44 @@ export function PbnstRegModal({ data }: { data: customPbnst }) { }; useEffect(() => { - if (!data) return; - console.log("데이터", data) + + const regData = { + pbnstRuseFcltPk: String(data.bscFctCd + "R" + "1"), + fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "R" + "1") } as unknown as fcBizType], + }; + + console.log("regData ", regData) + setPbnstBdstForm(regData as customPbnst); }, [data]); return ( <> - <h1 className="text-2xl font-medium text-label pl-8">하수재이용 시설 신규등록</h1> + <h1 className="text-2xl font-medium text-label pl-8"> + 하수재이용 시설 신규등록 + </h1> <div className="border-t border-gray-300 my-4"></div> <ScrollArea className="h-[75vh]"> <Tabs defaultValue="mng" onValueChange={handleTabChange}> <TabsList className=""> - <TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger> - <TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger> + <TabsTrigger className="!text-xl" value="mng"> + 시설정보 + </TabsTrigger> + <TabsTrigger className="!text-xl" value="buse"> + 차수별정보 + </TabsTrigger> + <Button size={"sm"} className="!justify-end"> + 저장 + </Button> </TabsList> <TabsContent className="max-h-full" value="mng"> - <PbnstMngForm mngForm={pbnstBdstForm as customPbnst} isModal={true} /> + <PbnstMngForm data={pbnstBdstForm} /> </TabsContent> <TabsContent className="max-h-full" value="buse"> - <PbnstBuseForm buseForm={pbnstBdstForm as customPbnst} isModal={true} /> + <PbnstBuseForm data={pbnstBdstForm.fcBizs} /> </TabsContent> </Tabs> </ScrollArea> </> - - ) + ); } - - diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index d31c2efcd..aba220a4c 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -30,7 +30,6 @@ const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>( }, ref) => { const [tableState, setTableState] = useState([...tableData]); useEffect(() => { - console.log("tableState", tableState); if (ref && typeof ref === "object" && "current" in ref) { ref.current = tableState; } diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index e30e04f4d..080ed30c9 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -21,7 +21,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0MjU0NzJ9.rABGFEzyCEDYwnuzd-6V0lPtckSGx-h77-tJBYFz00KPowmWBpwMLrSynxmHpmtmga86ksIYxuoMkiT1_aI6Sw" + const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0Mzc0OTF9.JM2NHEwTpgDW9nonZY3186IK_frIh667SyxMQfPwqa_lc-5mcTFNtrWXH5b72_ng39qiPSi504iF1roFEJ0c6w" const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; From cf6222011f32da9cf3a76162b0fa0707a35176cc Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Thu, 29 May 2025 14:44:26 +0900 Subject: [PATCH 26/62] =?UTF-8?q?=EC=9B=90=EC=88=98=EC=B7=A8=EC=88=98=20?= =?UTF-8?q?=EC=83=81=EC=9C=84=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EB=84=98=EA=B2=A8=EC=95=BC?= =?UTF-8?q?=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/store/common/searchCode/index.ts | 28 +++++ .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 2 +- apps/wr/app/store/store.tsx | 4 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 41 +++--- .../fcOrgwtsRegModal/fcOrgwtsRegModal.tsx | 117 +++++++++--------- 5 files changed, 115 insertions(+), 77 deletions(-) diff --git a/apps/wr/app/store/common/searchCode/index.ts b/apps/wr/app/store/common/searchCode/index.ts index e69de29bb..b1907be90 100644 --- a/apps/wr/app/store/common/searchCode/index.ts +++ b/apps/wr/app/store/common/searchCode/index.ts @@ -0,0 +1,28 @@ +import { getFetch } from "@/components/lib/api" +import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type" +export type comFcltState = { + searchFclts: pubHasuType +} +export type comFcltActions = { + getSwtrmtFcltNm: (searchNm: string) => void +} +export const searchActions: (set: any) => comFcltActions = (set: any) => { + return { + getSwtrmtFcltNm: async (searchNm: string) => { + const fcltNm = await getFetch("common", `/prcsFclt/info/1/20/${searchNm}`); + const fcltNmCd: pubHasuType[] = fcltNm.map((item: any) => ({ + bscFctCd: item.bscFctCd, + sido: item.sido, + gugun: item.gugun, + bscFctNm: item.bscFctNm, + addr: item.addr, + fctCpc: item.fctCpc + })) + return set((state: comFcltState) => ({ + ...state, + searchFclts: fcltNmCd + } + )) + } + } +} \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index b6a340b5e..b3091f97c 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -185,7 +185,6 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ - choose: z.boolean().default(false), pbnstRuseFcltPk: z.number().default(0), swtrmtFcltFk: z.string().default(""), ruseUtztnFcltNm: z.string().default(""), @@ -203,6 +202,7 @@ export const pbnstRegZod = z.object({ }); const pubHasuZod = z.object({ + choose: z.boolean().default(false), bscFctCd: z.string(), sido: z.string().default(""), gugun: z.string().default(""), diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index 5f7172c60..19c7575df 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -87,6 +87,7 @@ import { rswtChkStateExport, rswtChkSttnActionsExport, type rswtChkSttnState, ty import { pbnstSttnActionsExport, pbnstSttnStateExport, type pbnstSttnState, type pbnstSttnType } from "./ruseFcltMng/fcltSttn/pbnstSttn"; import { coSttnActionsExport, coSttnStateExport, type coSttnState, type coSttnType } from "./matDmd/coSttn"; // 옮겨야함 import { ldrmntCoSttnActionsExport, ldrmntCoSttnStateExport, type ldrmntCoSttnState, type ldrmntCoSttnType } from "./matDmd/ldrmntCoSttn"; // 옮겨야함 +import { searchActions, type comFcltActions, type comFcltState } from "./common/searchCode"; export type WrStore = comCodeType & pubFacType & @@ -103,6 +104,7 @@ export type WrStore = comCodeType & rainChkSttnType& rswtChkSttnType& pbnstSttnType& + comFcltActions&comFcltState& coSttnType& // 옮겨야함 ldrmntCoSttnType // 옮겨야함 ; @@ -125,7 +127,6 @@ export const StoreZus = ( pbnstSttnState& coSttnState& // 옮겨야함 ldrmntCoSttnState // 옮겨야함 - = { ...comCodeStateExport, ...pubFacStateExport, @@ -155,6 +156,7 @@ export const StoreZus = ( getEnvPartCd(set); return { ...initState, + ...searchActions(set), ...pubFacActionsExport(set), ...rainFacActionsExport(set), ...rswtFacActionsExport(set), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 60391fd18..de0a37b66 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -73,7 +73,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }); const buttonClick = () => { - console.log("머임?", data[0]?.fcOrgwts) setIsFcOrgwts(true); const moData = data[0]?.fcOrgwts; setModalData(moData); @@ -106,6 +105,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { } + console.log("어휴", data) }, [getBizCycle, data]); useEffect(() => { @@ -197,6 +197,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <h1 className={formH1Class}>재이용 원수취수 현황</h1> <div> + <div className="text-right mb-3"> <Button type="button" onClick={ @@ -206,9 +207,11 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { // } buttonClick } - size={commonButonSize}> + size={commonButonSize} + className=""> 추가등록 </Button> + </div> <RuseMngTable tableData={fcOrgwtFiled} headList={pbnst.pbnstOrgwtHeadList} @@ -233,21 +236,21 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { className="w-32 border-gray-300 rounded pr-8 " /> <Button - type="button" - size={commonButonSize} - className="!text-xl" - onClick={plusHist} - > - 추가등록 - </Button> - <Button - type="button" - size={commonButonSize} - className="!text-xl !bg-red-500 !text-white ml-1" - onClick={removeSelected} - > - 삭제 - </Button> + type="button" + size={commonButonSize} + className="!text-xl" + onClick={plusHist} + > + 추가등록 + </Button> + <Button + type="button" + size={commonButonSize} + className="!text-xl !bg-red-500 !text-white ml-1" + onClick={removeSelected} + > + 삭제 + </Button> </div> <div> @@ -269,7 +272,9 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> <div> + <div className="text-right mb-3"> <Button size={commonButonSize}>수요처 추가</Button> + </div> <RuseMngTable tableData={[]} headList={pbnst.pbnstDemandHeadList} @@ -282,7 +287,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <UiModal open={isFcOrgwts} onOpenChange={(open: boolean) => setIsFcOrgwts(open)} - bodyClass={"w-[60vw] max-w-none h-[60vh]"} + bodyClass={"w-[50vw] max-w-none h-[60vh]"} body={<FcOrgwtsRegModal data={ modalData || []}></FcOrgwtsRegModal>} ></UiModal> </div> diff --git a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx index cc416a64c..d904854f7 100644 --- a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx @@ -1,6 +1,6 @@ "use client"; import { useWrStore } from "@/app/store"; -import type { customPbnst, fcBizType, fcOrgwtType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { pubHasuType, fcBizType, fcOrgwtType,} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { tableData } from "@/components/lib/func/commom"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; @@ -12,16 +12,29 @@ import { ArrowLeft, ArrowRight } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { useFieldArray } from "react-hook-form"; -export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { - const { code, pbnst } = useWrStore((state) => state); +export default function FcOrgwtsRegModal({ data, onRightSet }: { data: fcOrgwtType[], onRightSet?: (rightData:fcOrgwtType[]) => {}}) { + const { code, pbnst, getSwtrmtFcltNm, searchFclts } = useWrStore((state) => state); const { fcOrgwtsHeadList, pbnstHasuRes } = pbnst; - const [bdstTable, setbdstTable] = useState<customPbnst[]>(); - const [isFcOrgwtsData, setIsFcOrgwtsData] = useState<boolean>(false); - const [pkTable, setPkTable] = useState<customPbnst[]>(); - const rightRef = useRef<fcOrgwtType[] | null>([] as fcOrgwtType[]); - const leftRef = useRef<fcOrgwtType[] | null>([] as fcOrgwtType[]); - const [rightData, setRightData] = useState<customPbnst[]>(); + const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); + const rightRef = useRef<pubHasuType[] | null>([] as pubHasuType[]); + const leftRef = useRef<pubHasuType[] | null>([] as pubHasuType[]); + const [rightData, setRightData] = useState<pubHasuType[]>(); + const [inputVal, setInputVal] = useState<string>(""); + + useEffect(()=>{ + console.log("searchFclts", searchFclts); + if(Array.isArray(searchFclts)){ + const filteredData = searchFclts.filter((item) => { + if(rightData){ + if(rightData.find(rightItem =>rightItem.bscFctCd===item.bscFctCd)) + return false; + } + return true + }) + setbdstTable(Array.isArray(filteredData) ? [...filteredData] : []) + } + }, [searchFclts]) useEffect(() => { // console.log("머지", pbnstHasuRes); if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { @@ -30,29 +43,42 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { }, [code, pbnstHasuRes]); useEffect(() => { - if (!data) return; - const findPk = data.map(element => { - const pk = pbnstHasuRes.find((item) => String(item.bscFctCd) === element.swtrmtFcltFk) - return pk; - }); - setPkTable(findPk); - }, [data]); + if(onRightSet) + onRightSet( + rightData?.map(item => ({ + pbnstRuseFcltBizFk: data[0]?.pbnstRuseFcltBizFk ?? 0, + swtrmtFcltFk: item.bscFctCd, + orgwtWtritQnt: "0", + tmsYn: "N", + dschgFmYn: "N", + dtlPstnExpln: "", + rgtr: "", + mdfr: "", + regDt: undefined, + mdfcnDt: undefined, + useYn: undefined, + })) ?? [] + ); + }, [rightData]) return ( <> <div className="flex flex-col h-full"> - <div> + <div className="flex items-center justify-between"> <Title title={"취수하수처리장 추가"} /> - <Button className="m-2" size={"sm"} onClick={() => { }}>저장</Button> + <Button className="m-2" size={"sm"} + onClick={() => { }}>저장</Button> </div> <div className="flex flex-row flex-grow gap-4 mt-4"> <div className="w-3/7"> - <Label className="w-full text-2xl text-gray-600 text-right">공공하수처리시설 목록</Label> + <div className="flex items-center justify-between"> + <Label className="w-full text-2xl text-gray-600 text-left">공공하수처리시설 목록</Label> <div className="flex items-center"> <Label className="w-full text-xl text-gray-600 text-right">시설명</Label> - <Input className="w-1/3 !text-xl ml-2" type="text" value={""} onChange={(e) => { }} /> - <Button className="m-2" size={"sm"} onClick={() => { }}>조회</Button> + <Input className="w-1/2 !text-xl ml-2" type="text" value={inputVal} onChange={(e) => {setInputVal(e.target.value)}} /> + <Button className="m-2" size={"sm"} onClick={() => getSwtrmtFcltNm(inputVal)}>조회</Button> + </div> </div> <div className="border-t border-gray-300 my-4"></div> <RuseMngTable @@ -61,34 +87,23 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { upHeadList={[]} // TODO: Replace with actual upHeadList data if available ref={leftRef} /> - {/* <UiTable - headName={""} - tableData={bdstTable || []} - headlist={fcOrgwtsHeadList} - pageSize={0} - total={0} - cellClick={cellClick} - onPageChange={function (page: number): void { - throw new Error("Function not implemented."); - }} - ></UiTable> */} </div> <div className="flex flex-col items-center justify-center w-1/7 gap-2"> <ArrowRight type="button" onClick={() => { if (leftRef && typeof leftRef === "object" && "current" in leftRef) { - const checked = leftRef.current?.filter((item) => ((item as unknown as customPbnst)?.choose)) - const unchecked = leftRef.current?.filter((item) => !(item as unknown as customPbnst)?.choose) + const checked = leftRef.current?.filter((item) => ((item as unknown as pubHasuType)?.choose)) + const unchecked = leftRef.current?.filter((item) => !(item as unknown as pubHasuType)?.choose) if (checked && checked.length > 0) { - checked.forEach(item=>(item as unknown as customPbnst).choose = false) - setRightData([...(checked as unknown as customPbnst[]), - ...((rightRef.current ?? []) as unknown as customPbnst[]) + checked.forEach(item=>(item as unknown as pubHasuType).choose = false) + setRightData([...(checked as unknown as pubHasuType[]), + ...((rightRef.current ?? []) as unknown as pubHasuType[]) ]) } if (unchecked && unchecked.length > 0) { - setbdstTable([...(unchecked as unknown as customPbnst[])]) + setbdstTable([...(unchecked as unknown as pubHasuType[])]) }else{ setbdstTable([]) } @@ -101,24 +116,23 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { type="button" onClick={() => { if (rightRef && typeof rightRef === "object" && "current" in rightRef) { - const checked = rightRef.current?.filter((item) => ((item as unknown as customPbnst)?.choose)) - const unchecked = rightRef.current?.filter((item) => !(item as unknown as customPbnst)?.choose) + const checked = rightRef.current?.filter((item) => ((item as unknown as pubHasuType)?.choose)) + const unchecked = rightRef.current?.filter((item) => !(item as unknown as pubHasuType)?.choose) if (checked && checked.length > 0) { - checked.forEach(item=>(item as unknown as customPbnst).choose = false) + checked.forEach(item=>(item as unknown as pubHasuType).choose = false) setbdstTable([ - ...(checked as unknown as customPbnst[]), - ...((leftRef.current ?? []) as unknown as customPbnst[]) + ...(checked as unknown as pubHasuType[]), + ...((leftRef.current ?? []) as unknown as pubHasuType[]) ]) } - console.log("ㅇㅇ", unchecked); if (unchecked && unchecked.length > 0) { - setRightData([...(unchecked as unknown as customPbnst[])]) + setRightData([...(unchecked as unknown as pubHasuType[])]) }else{ setRightData([]) } } }} - className="w-12 h-12 text-gray-500" /> + className="w-12 h-12 text-gray-500 cursor-pointer mt-5" /> </div> {/* Right Table container: Takes 2/5 of the width */} <div className="w-3/7"> @@ -130,17 +144,6 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) { upHeadList={[]} // TODO: Replace with actual upHeadList data if available ref={rightRef} /> - {/* <UiTable - headName={"취수하수처리장 목록"} - tableData={pkTable || []} - headlist={fcOrgwtsHeadList} - pageSize={0} - total={0} - cellClick={undefined} - onPageChange={function (page: number): void { - throw new Error("Function not implemented."); - }} - ></UiTable> */} </div> </div> </div> From 2e87e8bd3d3d5b860a93486486e538a11e4b5f2b Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Thu, 29 May 2025 16:56:10 +0900 Subject: [PATCH 27/62] =?UTF-8?q?=EC=9B=90=EC=88=98=EC=B7=A8=EC=88=98=20?= =?UTF-8?q?=EC=B5=9C=EC=A2=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index de0a37b66..0e6b2466f 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -288,7 +288,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { open={isFcOrgwts} onOpenChange={(open: boolean) => setIsFcOrgwts(open)} bodyClass={"w-[50vw] max-w-none h-[60vh]"} - body={<FcOrgwtsRegModal data={ modalData || []}></FcOrgwtsRegModal>} + body={<FcOrgwtsRegModal data={ modalData || [] } onRightSet={ (val) => { console.log("val", val); return {}; }} ></FcOrgwtsRegModal>} ></UiModal> </div> </> From fa1a9159eb50029231949467b971b787614af18c Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Thu, 29 May 2025 16:59:33 +0900 Subject: [PATCH 28/62] Co-authored-by: truthplumage <truthplumage@users.noreply.github.com> --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 6 +- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 176 ++++++++-------- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 188 ++++++++---------- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 13 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 57 +++--- .../mngRegFormDetail/mngRegFormDetail.tsx | 2 +- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 43 ++-- .../pbnstReg/ruseMngTable/ruseMngTable.tsx | 8 +- 8 files changed, 249 insertions(+), 244 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 7c5ebdb10..67f02fdb2 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -57,7 +57,9 @@ useEffect(() => { const cellClick = (val: number | undefined) => { if (val === undefined) return; const selectRow = pbnstHasuRes?.[val]; - setSelectedRow(selectRow); + if (selectRow) { + setSelectedRow(selectRow); + } if (pbnstRes !== null){ alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.") return; @@ -145,7 +147,7 @@ useEffect(() => { </Button> </TabsList> <TabsContent className="max-h-full" value="mng"> - <PbnstMngForm data={selectBdst || []} /> + <PbnstMngForm data={selectBdst || null} /> </TabsContent> <TabsContent className="max-h-full" value="buse"> <PbnstBuseForm data={pbnstBiz || []} /> diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index a0dce391a..f97a791dd 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -1,10 +1,6 @@ import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import type { TableUpperProps } from "../rainReg"; - - - - export const pubFacHeadListExport: TableUpperProps[] = [ { id: "sido", title: "시도" }, { id: "gugun", title: "시군구" }, @@ -18,118 +14,120 @@ export const pubFacHeadListExport: TableUpperProps[] = [ export const pbnstMngUpHeadListExport: TableUpperProps[] = [ { id: "choose", title: "선택", type: "checkbox" }, - { id: "operMthd", title: "운영방식", edit: true}, - { id: "rprtvBzenty", title: "대행업체", edit: true}, - { id: "bgngDt", title: "시작일", upName: "upChangeRe", upSequnce: 1, type: "date"}, - { id: "endDt", title: "종료일", upName: "upChangeRe", upSequnce: 2, type: "date"}, -]; - + { id: "operMthd", title: "운영방식", edit: true }, + { id: "rprtvBzenty", title: "대행업체", edit: true }, + { + id: "bgngDt", + title: "시작일", + upName: "upChangeRe", + upSequnce: 1, + type: "date", + }, + { + id: "endDt", + title: "종료일", + upName: "upChangeRe", + upSequnce: 2, + type: "date", + }, +]; export const pplInstlsHeadListExport: TableUpperProps[] = [ { id: "choose", title: "선택", type: "checkbox" }, - { id: "ppMqlt", title: "관재질", type: "select", selectData:'pplQulity' }, - { id: "pdmt", title: "관경", type: "select", selectData:'pplLenght'}, + { id: "ppMqlt", title: "관재질", type: "select", selectData: "pplQulity" }, + { id: "pdmt", title: "관경", type: "select", selectData: "pplLenght" }, { id: "cpct", title: "연장", edit: true, type: "number" }, ]; - export const pbnstDemandHeadListExport: TableUpperProps[] = [ { id: "dmdCoNm", title: "수요처명" }, { id: "daddr", title: "위치(주소)" }, - { id: "useUsgCd", title: "사용용도", }, - { id: "splyBgngDay", title: "공급시작일", }, - { id: "splyEndDay", title: "공급종료일", }, - { id: "splyCpct", title: "공급량(m³/일)", }, - { id: "splyFmYon", title: "공급유량계 유무", }, + { id: "useUsgCd", title: "사용용도" }, + { id: "splyBgngDay", title: "공급시작일" }, + { id: "splyEndDay", title: "공급종료일" }, + { id: "splyCpct", title: "공급량(m³/일)" }, + { id: "splyFmYon", title: "공급유량계 유무" }, ]; - export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [ - { id: "ruseUtztnFcltNm", title: "운영방식" }, + { id: "ruseUtztnFcltNm", title: "운영방식" }, { id: "orgwtWtritQnt", title: "원수취수량" }, - { id: "tmsYn", title: "하수처리량TMS 전후", }, - { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​", }, - { id: "dtlPstnExpln", title: "상세위치 설명", }, + { id: "tmsYn", title: "하수처리량TMS 전후" }, + { id: "dschgFmYn", title: "하수처리장 방류 유량계 전·후​" }, + { id: "dtlPstnExpln", title: "상세위치 설명" }, ]; export const fcOrgwtsHeadListExport: TableUpperProps[] = [ { id: "sido", title: "시도" }, - { id: "gugun", title: "시군구" }, + { id: "gugun", title: "시군구" }, { id: "bscFctNm", title: "시설명" }, { id: "addr", title: "위치" }, - -] +]; export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, ]; -export type formDetailType ={ - id:string, - lable:string - type?:string -} +export type formDetailType = { + id: string; + lable: string; + type?: string; +}; +export const wasteWaterFcltINfo: formDetailType[] = [ + { id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부" }, + { id: "tmsInstlYn", lable: "Tms설치여부" }, + { id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부" }, +]; -export const wasteWaterFcltINfo:formDetailType[]=[ - {id:'wwtEmsnFcltPrmsnYn' , lable:'폐수배출물신고 허가여부'}, - {id:'tmsInstlYn' , lable:'Tms설치여부'}, - {id:'pbnstDrngInflwExclYn' , lable:'공공하수도유입제외 허가여부'}, -] +export const concentratedWaterInfo: formDetailType[] = [ + { id: "erctWtrOcrnCpct", lable: "눙축수 발생량(m³/일)", type: "number" }, + { id: "erctUswtrLinkSpt", lable: "눙축수연계지점" }, + { id: "erctUswtrFcltCpct", lable: "시설용량(m³/일)", type: "number" }, + { id: "erctUswtrPrcsMeth", lable: "눙축수처리방식" }, + { id: "erctUswtrPrcsMsrcCd", lable: "눙축수처리공법" }, +]; -export const concentratedWaterInfo:formDetailType[]=[ -{id:'erctWtrOcrnCpct' , lable:'눙축수 발생량(m³/일)'}, -{id:'erctUswtrLinkSpt' , lable:'눙축수연계지점'}, -{id:'erctUswtrFcltCpct' , lable:'시설용량(m³/일)'}, -{id:'erctUswtrPrcsMeth' , lable:'눙축수처리방식'}, -{id:'erctUswtrPrcsMsrcCd' , lable:'눙축수처리공법'}, -] +export const ruseFcltinfo: formDetailType[] = [ + { id: "rprcsFcltCpct", lable: "시설용량(m³/일)", type: "number" }, + { id: "majorPrcsMsrcCd", lable: "주처리공법" }, + { id: "addr", lable: "위치(주소)" }, + { id: "rprcsMthdCd", lable: "재처리방식" }, + { id: "inoutYn", lable: "위치(처리장 내외)" }, // 머가 내? 외?, + { id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" }, +]; -export const ruseFcltinfo:formDetailType[]=[ - {id:'rprcsFcltCpct' , lable:'시설용량(m³/일)'}, - {id:'majorPrcsMsrcCd' , lable:'주처리공법'}, - {id:'addr' , lable:'위치(주소)'}, - {id:'rprcsMthdCd' , lable:'재처리방식'}, - {id:'inoutYn' , lable:'위치(처리장 내외)'},// 머가 내? 외?, - {id:'mainSplyPumpCpct' , lable:'메인공급펌프 용량'}, - ] - +export const businessMoneyInfo: formDetailType[] = [ + { id: "gvsbs", lable: "국고", type: "number" }, + { id: "lcep", lable: "지방비", type: "number" }, + { id: "cusrAlotm", lable: "민간투자비", type: "number" }, + { id: "etc", lable: "기타" }, + { id: "totalMoney", lable: "합계", type: "number" }, +]; -export const businessMoneyInfo:formDetailType[]=[ - {id:'gvsbs' , lable:'국고'}, - {id:'lcep' , lable:'지방비'}, - {id:'username' , lable:'민간투자비'}, - {id:'cusrAlotm' , lable:'원인자부담금'}, - {id:'etc' , lable:'기타'}, - {id:'totalMoney' , lable:'합계'}, -] - -export const businessSttnInfo:formDetailType[]=[ - {id:'seCd' , lable:'구분'}, - {id:'bizMthdCd' , lable:'사업방식'}, - {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, - {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , -] - - -export const ruseFcltIntakeList:formDetailType[]=[ - {id:'seCd' , lable:'구분'}, - {id:'bizMthdCd' , lable:'사업방식'}, - {id:'bizCmcnDay' , lable:'사업준공일' ,type:'date'}, - {id:'instlAprvSncnDt' , lable:'설치승인인가일' ,type:'date'} , -] - -export const ruseWaterQulityList:formDetailType[]=[ - {id:'bod' , lable:'BOD(mg/L)'}, - {id:'grssClfg' , lable:'총대장균군수(개/mg)'}, - {id:'combResdch' , lable:'결합잔류염소(mh/L)'}, - {id:'trbt' , lable:'탁도(NTU)'}, - {id:'smll' , lable:'냄새'}, - {id:'crmty' , lable:'색도'}, - {id:'tn' , lable:'총질소(mg/L)'}, - {id:'tph' , lable:'총인(mg/L)'}, - {id:'ph' , lable:'수소이온농도'}, - {id:'clIonQnt' , lable:'염화물(mg/L)'}, - {id:'cdtnv' , lable:'전기전도도(μs/cm)​'}, -] +export const businessSttnInfo: formDetailType[] = [ + { id: "seCd", lable: "구분" }, + { id: "bizMthdCd", lable: "사업방식" }, + { id: "bizCmcnDay", lable: "사업준공일", type: "date" }, + { id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" }, +]; +export const ruseFcltIntakeList: formDetailType[] = [ + { id: "seCd", lable: "구분" }, + { id: "bizMthdCd", lable: "사업방식" }, + { id: "bizCmcnDay", lable: "사업준공일", type: "date" }, + { id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" }, +]; +export const ruseWaterQulityList: formDetailType[] = [ + { id: "bod", lable: "BOD(mg/L)", type: "number" }, + { id: "grssClfg", lable: "총대장균군수(개/mg)", type: "number" }, + { id: "combResdch", lable: "결합잔류염소(mh/L)", type: "number" }, + { id: "trbt", lable: "탁도(NTU)", type: "number" }, + { id: "smll", lable: "냄새", type: "number" }, + { id: "crmty", lable: "색도", type: "number" }, + { id: "tn", lable: "총질소(mg/L)", type: "number" }, + { id: "tph", lable: "총인(mg/L)", type: "number" }, + { id: "ph", lable: "수소이온농도", type: "number" }, + { id: "clIonQnt", lable: "염화물(mg/L)", type: "number" }, + { id: "cdtnv", lable: "전기전도도(μs/cm)​", type: "number" }, +]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index c04302663..903fe01b9 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -50,137 +50,116 @@ export type fcFileType = z.infer<typeof fcFileSchema>; const pplInstlSchema = z.object({ ruseFcltBizFk: z.string(), choose:z.boolean().default(false), - pdmt: z.string(), - ppMqlt: z.string(), - cpct: z.string(), + pdmt: z.string().default(''), + ppMqlt: z.string().default(""), + cpct: z.number().default(0), }); const fcFileSchema = z.object({ - ruseFcltFk: z.number().default(0).nullish(), + ruseFcltFk: z.number().nullish(), fileTkn: z.string(), filePath: z.string(), fileKnd: z.string(), regDt: z.date().default(new Date()).nullish(), - rgtr: z.string(), + rgtr: z.string().nullish(), mdfcnDt: z.date().default(new Date()).nullish(), - mdfr: z.string(), + mdfr: z.string().nullish(), }); const fcOperSchema = z.object({ - pbnstRuseFcltOperInfoPk: z.number().default(0), - pbnstRuseFcltFk: z.number().default(0), + pbnstRuseFcltOperInfoPk: z.number().nullish(), + pbnstRuseFcltFk: z.number().nullish(), operMthd: z.string(), rprtvBzenty: z.string(), bgngDt: z.date().default(new Date()), endDt: z.date().default(new Date()), regDt: z.date().nullish(), - rgtr: z.string(), + rgtr: z.string().default(""), mdfcnDt: z.date().nullish(), - mdfr: z.string().default("test"), + mdfr: z.string().default(""), choose: z.boolean().default(false), }); const fcOrgwtSchema = z.object({ - pbnstRuseFcltBizFk: z.number().default(0), - swtrmtFcltFk: z.string().default(''), - orgwtWtritQnt: z.string(), - tmsYn: z.string(), - dschgFmYn: z.string(), - dtlPstnExpln: z.string(), - regDt: z.string().nullish(), - rgtr: z.string(), - mdfcnDt: z.string().nullish(), - mdfr: z.string(), + pbnstRuseFcltBizFk: z.number().nullish(), + swtrmtFcltFk: z.number().default(0), + orgwtWtritQnt: z.number(), + tmsYn: z.enum(["Y", "N"] ).default("N"), + dschgFmYn: z.enum(["Y", "N"] ).default("N"), + dtlPstnExpln: z.string().default(''), + regDt: z.date().nullish(), + rgtr: z.string().default(''), + mdfcnDt: z.date().nullish(), + mdfr: z.string().default(''), + choose: z.boolean().default(false), }); -const fcPrfmncSchema = z.object({ - pbnstRuseFcltFk: z.number().default(0), - ym: z.string(), - wshwtr: z.string(), - coolUswtr: z.string(), - cleanUswtr: z.string(), - drwtUswtr: z.string(), - dltnUswtr: z.string(), - ithlRswtr: z.string(), - ithlEtcUswtr: z.string(), - cleanToilUswtr: z.string(), - resn: z.string(), - lndwtr: z.string(), - hydUswtr: z.string(), - rvrKeepUswtr: z.string(), - farmUswtr: z.string(), - ugwtChr: z.string(), - indstUswtr: z.string(), - regDt: z.date().nullish(), - rgtr: z.string(), - mdfcnDt: z.date().nullish(), - mdfr: z.string(), -}); export const fcBizSchema = z.object({ - pbnstRuseFcltBizPk: z.number().default(0), - pbnstRuseFcltFk: z.string().default(''), - cycl: z.string(), + pbnstRuseFcltBizPk: z.number().default(1), + pbnstRuseFcltFk: z.number().nullish(), + superkey: z.string().default(""), + cycl: z.number(), seCd: z.string(), bizMthdCd: z.string(), - instlAprvSncnDt: z.string(), - bizCmcnDay: z.string(), - gvsbs: z.string(), - lcep: z.string(), - cusrAlotm: z.string(), - etc: z.string(), - totalMoney: z.string(), - rprcsFcltCpct: z.string(), + instlAprvSncnDt: z.date().nullish(), + bizCmcnDay: z.date().nullish(), + gvsbs: z.number().default(0), + lcep: z.number().default(0), + cusrAlotm: z.number().default(0), + etc: z.string().default(''), + totalMoney: z.number().default(0).nullish(), + rprcsFcltCpct: z.number(), majorPrcsMsrcCd: z.string(), addr: z.string(), rprcsMthdCd: z.string(), - inoutYn: z.string(), - mainSplyPumpCpct: z.string(), - erctWtrOcrnCpct: z.string(), - erctUswtrLinkSpt: z.string(), - erctUswtrFcltCpct: z.string(), - erctUswtrPrcsMeth: z.string(), - erctUswtrPrcsMsrcCd: z.string(), - wwtEmsnFcltPrmsnYn: z.string(), - tmsInstlYn: z.string(), - pbnstDrngInflwExclYn: z.string(), - bod: z.string(), - grssClfg: z.string(), - combResdch: z.string(), - trbt: z.string(), - clIonQnt: z.string(), - smll: z.string(), - crmty: z.string(), - tph: z.string(), - tn: z.string(), - ph: z.string(), - cdtnv: z.string(), - designCst: z.string(), - cstrnSpvsCst: z.string(), - fcltSbsdCst: z.string(), - wstCst: z.string(), - cnstCmcnCst: z.string(), - mntrgEqpmntInstlCst: z.string(), - gisDbCst: z.string(), - elpwrMtrngCst: z.string(), - mchnCst: z.string(), - archCst: z.string(), - pplCst: z.string(), - ruseFcltCst: z.string(), - designCstClcln: z.string(), - cstrnSpvsCstClcln: z.string(), - fcltSbsdCstClcln: z.string(), - wstCstClcln: z.string(), - cnstCmcnCstClcln: z.string(), - mntrgEqpmntInstlCstClcln: z.string(), - gisDbCstClcln: z.string(), - elpwrMtrngCstClcln: z.string(), - mchnCstClcln: z.string(), - archCstClcln: z.string(), - pplCstClcln: z.string(), - ruseFcltCstClcln: z.string(), + inoutYn: z.enum(["Y", "N"]), + mainSplyPumpCpct: z.number().nullish(), + erctWtrOcrnCpct: z.number().nullish(), + erctUswtrLinkSpt: z.string().nullish(), + erctUswtrFcltCpct: z.number().nullish(), + erctUswtrPrcsMeth: z.string().nullish(), + erctUswtrPrcsMsrcCd: z.string().nullish(), + wwtEmsnFcltPrmsnYn: z.enum(["Y", "N"]), + tmsInstlYn: z.enum(["Y", "N"]), + pbnstDrngInflwExclYn: z.enum(["Y", "N"]), + bod: z.number(), + grssClfg: z.number(), + combResdch: z.number(), + trbt: z.number(), + clIonQnt: z.number(), + smll: z.number(), + crmty: z.number(), + tph: z.number(), + tn: z.number(), + ph: z.number(), + cdtnv: z.number(), + designCst: z.number().nullish(), + cstrnSpvsCst: z.number().nullish(), + fcltSbsdCst: z.number().nullish(), + wstCst: z.number().nullish(), + cnstCmcnCst: z.number().nullish(), + mntrgEqpmntInstlCst: z.number().nullish(), + gisDbCst: z.number().nullish(), + elpwrMtrngCst: z.number().nullish(), + mchnCst: z.number().nullish(), + archCst: z.number().nullish(), + pplCst: z.number().nullish(), + ruseFcltCst: z.number().nullish(), + designCstClcln: z.number().nullish(), + cstrnSpvsCstClcln: z.number().nullish(), + fcltSbsdCstClcln: z.number().nullish(), + wstCstClcln: z.number().nullish(), + cnstCmcnCstClcln: z.number().nullish(), + mntrgEqpmntInstlCstClcln: z.number(), + gisDbCstClcln: z.number().nullish(), + elpwrMtrngCstClcln: z.number().nullish(), + mchnCstClcln: z.number().nullish(), + archCstClcln: z.number().nullish(), + pplCstClcln: z.number().nullish(), + ruseFcltCstClcln: z.number().nullish(), fcOrgwts: z.array(fcOrgwtSchema), pplInstls: z.array(pplInstlSchema), - flg: z.string(), + flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string(), mdfcnDt: z.string().nullish(), @@ -188,12 +167,13 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ - pbnstRuseFcltPk: z.string().default(""), + pbnstRuseFcltPk: z.number().default(1), swtrmtFcltFk: z.string().default(""), + superkey:z.string().default(""), ruseUtztnFcltNm: z.string().default(""), - fcltCpct: z.string().default(""), - ruseCpct: z.string().default(""), - splyExtraCpct: z.string().default(""), + fcltCpct: z.number().default(0), + ruseCpct: z.number().default(0), + splyExtraCpct: z.number().default(0), regDt: z.date().default(new Date()), rgtr: z.string().default("test"), mdfcnDt: z.date().default(new Date()), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 3496e1140..aa8d181e9 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -68,7 +68,13 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }); useEffect(() => { - pbnstBizData(form.watch() as fcBizType); + + const formData = form.watch() + + formData.pplInstls = ref.current? [...ref.current]:[] // ← form 내부 상태 기준으로 복사 + console.log("formData pplReg", formData) + + pbnstBizData(formData as fcBizType); }, [form.formState]); useEffect(() => { @@ -86,8 +92,8 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"", choose: false, ppMqlt: "", - pdmt: "", - cpct: "", + pdmt: '', + cpct: 0, } const currentTableDataFromRef = ref.current ? [...ref.current] : []; const newDataForRHF = [...currentTableDataFromRef, regData]; @@ -131,7 +137,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }, [code]); useEffect(() => { - console.log("ppiSelectList:", ppiSelectList); }, [ppiSelectList]); useEffect(() => { diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 018f9b011..3477c5b81 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -8,6 +8,7 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { use, useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; +import moment from "moment"; import { commonButonSize, @@ -16,7 +17,6 @@ import { } from "@/components/lib/class/comClass"; import { TusClientUpload } from "@/components/lib/useTus_wr/useTusWr"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; -import type { Upload } from "tus-js-client"; import { pbnstRegZod, type customPbnst, @@ -34,14 +34,10 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const { pbnst, pbnstUpdate, fileDelete, pbnstMngData } = useWrStore( (state) => state ); - const { pbnstMngUpHeadList } = pbnst; - const [ruseOperData, setRuseOperData] = useState<operType[]>(); + const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null); - const [isModalOpen, setIsModalOpen] = useState(false); const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null); - - const [upload, setUpload] = useState<Upload | null>(null); const [progress, setProgress] = useState(0); //const new File([] as BlobPart[], "") 파일 다운로드 활용 const handleProgress = (percentage: string) => { @@ -52,7 +48,6 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), - //mode:'onChange' }); const { @@ -64,22 +59,17 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { name: "fcOpers", }); -useEffect(() => { - console.log("ref.current", ref.current); -},[ref.current]) - useEffect(() => { - const formData = form.getValues(); - // 기존 코드: formData.fcOpers = ref.current ? [...ref.current] : []; - // 새 코드: 상태를 유지한 채 복사 - formData.fcOpers = form.getValues("fcOpers"); // ← form 내부 상태 기준으로 복사 + useEffect(() => { + const formData = form.watch(); + formData.fcOpers = ref.current ? [...ref.current] : []; formData.fcFiles = regFileList ? [...regFileList] : []; pbnstMngData([formData] as customPbnst[]); }, [form.formState, regFileList]); useEffect(() => { - console.log(" mngRegFrom ", pbnst.pbnstMngRegData); + pbnstMngData(pbnst.pbnstMngRegData); }, [pbnst.pbnstMngRegData]); const fileDownload = (index: number) => {}; @@ -88,8 +78,6 @@ useEffect(() => { choose: false, rgtr: "", mdfr: "", - pbnstRuseFcltFk: 0, - pbnstRuseFcltOperInfoPk: 0, operMthd: "", rprtvBzenty: "", bgngDt: new Date(), @@ -99,7 +87,7 @@ useEffect(() => { const newDataForRHF = [...currentTableDataFromRef, regData]; form.setValue("fcOpers", newDataForRHF, { shouldValidate: true, // 필요하다면 유효성 검사 실행 - shouldDirty: true, // 폼 상태를 dirty로 변경 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); const latestOpers = form.getValues("fcOpers"); ref.current = [...latestOpers]; @@ -115,12 +103,23 @@ useEffect(() => { useEffect(() => { if (data) { + console.log(" data ", data ) + console.log(" pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData) form.reset(data); form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk); - ref.current = data.fcOpers || []; + ref.current = data.fcOpers; } }, [data]); + // useEffect(() => { + // if (pbnst.pbnstMngRegData && !mountCheck.current) { + // console.log('pbnst.pbnstMngRegData ', pbnst.pbnstMngRegData) + // mountCheck.current=true + // // form.reset(data); + // // form.setValue("pbnstRuseFcltPk", data.pbnstRuseFcltPk); + // // ref.current = data.fcOpers || []; + // } + // }, [ ]); // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { values.fcOpers = ref.current || []; @@ -130,7 +129,6 @@ useEffect(() => { } const fileHandler = (files: File[], type: string) => { - console.log("fileHandler", files); let fileList = [] as FilesType[]; if (type === "relation" && relationfiles) { fileList = relationfiles; @@ -208,7 +206,6 @@ useEffect(() => { } }, [planFiles]); - useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -278,7 +275,9 @@ useEffect(() => { <Input placeholder="" type="number" - onChange={field.onChange} + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} value={field.value} /> </FormUi> @@ -294,7 +293,9 @@ useEffect(() => { <Input placeholder="" type="number" - onChange={field.onChange} + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} value={field.value} /> </FormUi> @@ -310,7 +311,9 @@ useEffect(() => { <Input placeholder="" type="number" - onChange={field.onChange} + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} value={field.value} /> </FormUi> @@ -326,7 +329,9 @@ useEffect(() => { <Input placeholder="" type="number" - onChange={field.onChange} + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} value={field.value} /> </FormUi> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 21b3f7ce0..0afb35206 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -45,7 +45,7 @@ export default function MngRegFormDetail({ className={"rounded-lg !w-full"} /> ) : item.type === "number" ? ( - <Input placeholder="" type="number" value={field.value??0} onChange={field.onChange} /> + <Input placeholder="" type="number" value={field.value??0} onChange={(e) =>{field.onChange(Number(e.target.value))}} /> ) : ( <Input placeholder="" type="text" value={field.value??''} onChange={field.onChange} /> )} diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index 4d2553878..e58f7b856 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -11,33 +11,33 @@ import { getCity } from "@/components/lib/func/commom"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { ScrollArea, - SelectBox, - UiTable, - type SelectDataType, } from "@common/business_components"; import { Button, - Input, - Label, Tabs, TabsContent, TabsList, TabsTrigger, } from "@common/components/ui"; import { useEffect, useState } from "react"; -import type { objSearchType } from "../bdstRegModal/bdstRegModal"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; export function PbnstRegModal({ data }: { data: pubHasuType }) { - const { code, pbnst } = useWrStore((state) => { + const { pbnst ,pbnstUpdate} = useWrStore((state) => { return state; }); - const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>( {} as customPbnst ); const [currentTab, setCurrentTab] = useState<string>("mng"); - // const nodeList = headMakeColSpan(pubFacHeadList.moUpHeadList); + +const pbnstRegTotal = ()=>{ + console.log(" pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData) + + if(pbnst.pbnstMngRegData[0]) + pbnstUpdate(pbnst.pbnstMngRegData[0]) +} + const handleTabChange = (value: string) => { setCurrentTab(value); @@ -45,15 +45,26 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) { useEffect(() => { - const regData = { - pbnstRuseFcltPk: String(data.bscFctCd + "R" + "1"), - fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "R" + "1") } as unknown as fcBizType], - }; - console.log("regData ", regData) - setPbnstBdstForm(regData as customPbnst); + if(data ){ + + let regData = { + superKey: String(data.bscFctCd + "1"), + swtrmtFcltFk: String(data.bscFctCd ), + pbnstRuseFcltPk: 1, + fcBizs: [{ pbnstRuseFcltFk: 1 ,cycl:1 } as unknown as fcBizType], + }; + + setPbnstBdstForm(regData as unknown as customPbnst); + } + }, [data]); + + useEffect(() =>{ + + console.log('pbnst.pbnstMngRegData ', pbnst.pbnstMngRegData) + },[pbnst.pbnstMngRegData]) return ( <> <h1 className="text-2xl font-medium text-label pl-8"> @@ -70,7 +81,7 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) { <TabsTrigger className="!text-xl" value="buse"> 차수별정보 </TabsTrigger> - <Button size={"sm"} className="!justify-end"> + <Button onClick={pbnstRegTotal} size={"sm"} className="!justify-end"> 저장 </Button> </TabsList> diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index aba220a4c..73add7846 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -36,6 +36,7 @@ const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>( }, [tableState]); useEffect(() => { + if(tableData) setTableState(tableData); }, [tableData]); return ( @@ -75,7 +76,9 @@ const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>( return next; }) }} - value={tableState[i][head.id] || ""} + value={head.type === "number" ? + Number(tableState[i][head.id])||0 : tableState[i][head.id] || "" + } /> ) : head.type === "select" ? ( <SelectBox @@ -123,7 +126,8 @@ const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>( }} > </Checkbox> - ) : ( + ) : + ( `${item[head.id] || ""}` )} </TableCell> From fba296d77de6c7e17cfcad234d1b0871d28a8ab6 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Thu, 29 May 2025 19:04:56 +0900 Subject: [PATCH 29/62] =?UTF-8?q?selectbox=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 3 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 4 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 46 ++++++++++++++----- 3 files changed, 38 insertions(+), 15 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 95666f8ca..19c013fc4 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -32,7 +32,7 @@ export default function PublicReuseFaciltyInsert() { const [searchTxt, setSearchTxt] = useState<string>(); const [bdstTable, setbdstTable] = useState<customPbnst[]>(); - const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); + const [selectBdst, setSelectBdst] = useState<customPbnst[] | null>(null); const [selectedRow, setSelectedRow] = useState<customPbnst | null>(null); useEffect(() => { @@ -59,6 +59,7 @@ useEffect(() => { if (val === undefined) return; console.log("pbnstRes", pbnstRes) const selectRow = pbnstHasuRes?.[val]; + setSelectedRow(selectRow); console.log("아제발", selectRow) if (pbnstRes === null){ diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 6f725870d..2e83a56ee 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -36,7 +36,7 @@ export type pubFacState = { pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; pbnstHasuRes: pubHasuType[]; - pbnstRes: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경 + pbnstRes: customPbnst[] | null; // 배열에서 단일 객체 또는 null로 변경 pbnstBizCycle: SelectDataType[]; selectLabel: SelectDataType[]; pbnstOrgwtHeadList: TableUpperProps[]; @@ -146,7 +146,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { ...state, pbnst: { ...state.pbnst, - pbnstRes: pbnstRes, + pbnstRes: [pbnstRes], pbnstBizCycle: pbnstBizCycle, isInit: false, }, diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 6f0a1ac02..68054a1e2 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -1,7 +1,7 @@ "use client"; import { useWrStore } from "@/app/store"; -import { FileUpload, FormUi } from "@common/business_components/ui"; +import { FileUpload, FormUi, SelectBox } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -22,19 +22,22 @@ import { type customPbnst, type operType, type ruseFcltType, + type selectLabel, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { Label } from "@common/business_components/ui/form/lib/label"; export type FilesType = { atflCd: String; file: File; }; -export function PbnstMngForm({ data }: { data: customPbnst }) { +export function PbnstMngForm({ data }: { data: customPbnst[] }) { const { pbnst, pbnstUpdate } = useWrStore((state) => state); const { pbnstMngUpHeadList } = pbnst; const [ruseOperData, setRuseOperData] = useState<operType[]>(); const [planFiles, setPlanFiles] = useState<File[] | null>(null); const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null); const [isModalOpen, setIsModalOpen] = useState(false); +const [fcltNm, setFcltNm] = useState<selectLabel[]>() const [upload, setUpload] = useState<Upload | null>(null); const [progress, setProgress] = useState(0); @@ -43,7 +46,7 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { setProgress(Number(percentage)); }; - const ref = useRef<operType[] | null>(data?.fcOpers ?? null); + const ref = useRef<operType[] | null>(data[0]?.fcOpers ?? null); const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), @@ -80,14 +83,21 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { selectedIdxs.reverse().forEach((idx) => remove(idx)); }; - const onSelectValue = (val: string) => {}; - useEffect(() => { if (!data) return; - form.reset(data); - setRuseOperData(data.fcOpers); + //form.reset(data); + const fcltNmList = data.map((item, index) => ({ + text: item.ruseUtztnFcltNm, + val: String(index) + })) + setFcltNm(fcltNmList) }, [data]); - +useEffect(() => { + if (!fcltNm || fcltNm.length === 0) return; + // Default to the first item in data when fcltNm changes + form.reset(data[0]); + console.log("fcltNm", fcltNm) + }, [fcltNm, data]); // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { console.log("submit", values); @@ -142,6 +152,9 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { console.log("relationfiles changed:", relationfiles); }, [relationfiles]); + + + const testFile = () => { // if (relationfiles && relationfiles[0]) // TusClientUpload(relationfiles[0], setUpload, { @@ -169,14 +182,23 @@ export function PbnstMngForm({ data }: { data: customPbnst }) { <form onSubmit={form.handleSubmit(onSubmit)}> <div className="flex justify-between items-center mx-3 mb-3"> <div className="col-span-2 flex items-top"> - <h2 className={formTableName + "pr-3 col-span-10 "}> + {/* <h2 className={formTableName + "pr-3 col-span-10 "}> 재이용 시설명 - </h2> - <span className="mt-4 ml-2"> + </h2> */} + {/* <span className="mt-4 ml-2"> {form.getValues("ruseUtztnFcltNm") ? ": " + form.getValues("ruseUtztnFcltNm") : ""} - </span> + </span> */} + <Label className={formTableName + "pr-3 col-span-2 "}>재이용 시설명</Label> + <SelectBox + label="" + className="mt-4 ml-2" + selectClass={undefined} + selectArray={fcltNm ?? []} + onSelectValue={(val) => {console.log("val", val)}} + value={""} + /> </div> <Button type="submit" size={commonButonSize}> From 644f6c0015b5b1258fc8f03763ae8f03809fe909 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Thu, 29 May 2025 19:48:44 +0900 Subject: [PATCH 30/62] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EC=97=85=EB=A1=9C?= =?UTF-8?q?=EB=93=9C=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/file-upload/index.tsx | 8 +++++--- .../src/ui/file-upload/lib/file_upload.tsx | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/packages/common/business_components/src/ui/file-upload/index.tsx b/packages/common/business_components/src/ui/file-upload/index.tsx index a78965954..22ef56820 100644 --- a/packages/common/business_components/src/ui/file-upload/index.tsx +++ b/packages/common/business_components/src/ui/file-upload/index.tsx @@ -12,10 +12,12 @@ const dropZoneConfig = { files: File[]; // 파일 배열 setFiles: (files: File[] | null) => void; // 파일 배열 세터 fileTypes?: string; // 옵션 (파일 확장자 문자열) + onFileClick?:(index:number)=> void; // 파일 클릭 핸들러 + } export const FileUpload = -({ files, setFiles, fileTypes }: FileUploadProps) => { +({ files, setFiles, fileTypes ,onFileClick}: FileUploadProps) => { return ( <FileUploader value={files} @@ -43,9 +45,9 @@ export const FileUpload = {files&& files.length > 0 && files.map((file:File, i:number) => ( - <FileUploaderItem key={i} index={i}> + <FileUploaderItem key={i} index={i} onFileClick={onFileClick }> <Paperclip className="h-4 w-4 stroke-current" /> - <span>{file.name}</span> + <span className="w-4/5 overflow-hidden">{file.name}</span> </FileUploaderItem> ))} </FileUploaderContent> diff --git a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx index 3db4bcceb..3fe1aafd8 100644 --- a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx +++ b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx @@ -286,9 +286,9 @@ FileUploaderContent.displayName = "FileUploaderContent"; export const FileUploaderItem = forwardRef< HTMLDivElement, - { index: number } & React.HTMLAttributes<HTMLDivElement> ->(({ className, index, children, ...props }, ref) => { - const { removeFileFromSet, activeIndex, direction } = useFileUpload(); + { index: number } & React.HTMLAttributes<HTMLDivElement> &{onFileClick?:(index:number)=>void} +>(({ className, index, children, onFileClick, ...props }, ref) => { + const { removeFileFromSet , activeIndex, direction } = useFileUpload(); const isSelected = index === activeIndex; return ( <div @@ -300,8 +300,13 @@ export const FileUploaderItem = forwardRef< isSelected ? "bg-muted" : "", )} {...props} + > - <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full w-full"> + <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full !w-4/5 overflow-hidden " + onClick={() =>{ + + + }}> {children} </div> <button @@ -309,8 +314,10 @@ export const FileUploaderItem = forwardRef< className={cn( "absolute", direction === "rtl" ? "top-1 left-1" : "top-1 right-1", + )} - onClick={() => removeFileFromSet(index)} + onClick={() =>{ + removeFileFromSet(index)}} > <span className="sr-only">remove item {index}</span> <RemoveIcon className="w-4 h-4 hover:stroke-destructive duration-200 ease-in-out" /> From 41df013bb382c91a18b3023e35f5e1f3f384b877 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Thu, 29 May 2025 19:56:18 +0900 Subject: [PATCH 31/62] =?UTF-8?q?=EB=B9=84=EC=A6=88=EB=8B=88=EC=8A=A4?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=97=85=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/chart/BarChart.tsx | 17 +++-- .../src/ui/chart/LineChart.tsx | 17 ++--- .../src/ui/excel/excelStyle.tsx | 11 ++-- .../src/ui/excel/index.tsx | 63 ++++++++----------- .../src/ui/file-upload/index.tsx | 8 ++- .../src/ui/file-upload/lib/file_upload.tsx | 19 +++--- .../src/ui/search_base_form/index.tsx | 2 + .../src/ui/search_form_left/index.tsx | 4 +- .../business_components/src/ui/tab/index.tsx | 54 ++++++++-------- .../src/ui/table/index.tsx | 2 + .../src/ui/table/lib/pagination.tsx | 17 ++--- 11 files changed, 117 insertions(+), 97 deletions(-) diff --git a/packages/common/business_components/src/ui/chart/BarChart.tsx b/packages/common/business_components/src/ui/chart/BarChart.tsx index b75bf373c..0802a72e4 100644 --- a/packages/common/business_components/src/ui/chart/BarChart.tsx +++ b/packages/common/business_components/src/ui/chart/BarChart.tsx @@ -64,10 +64,10 @@ const CustomLegend = (props: any) => { const { payload } = props; return ( <div style={customStyles.legendContainer}> - {payload.map((entry, index: number) => ( + {payload.map((entry: unknown, index: number) => ( <div key={`legend-${index}`} className="flex items-center gap-2"> - <div className="w-[14px] h-[14px] ml-10" style={{ backgroundColor: entry.color }}></div> - <span className="text-[12px]">{entry.value}</span> + <div className="w-[14px] h-[14px] ml-10" style={{ backgroundColor: (entry as {color: string}).color }}></div> + <span className="text-[12px]">{(entry as {value: string}).value}</span> </div> ))} </div> @@ -76,7 +76,15 @@ const CustomLegend = (props: any) => { export default function Chart({chartConfig=undefined, chartData=[], chartTitle='차트', chartClassName='w-full h-full', graphSize=40, yFieldText='', showLegend=false} : BarChartProps) { const colors = ["#FF6B6B", "#4ECDC4", "#45B7D1", "#96CEB4", "#FFEEAD", "#D4A5A5"]; + const getMaxValue = (data: any[], keyPrefix: string) => { + return Math.max(...data.map(item => + Object.keys(item) + .filter(key => key.includes(keyPrefix)) + .map(key => item[key]) + ).flat()); + }; + const barMaxValue = getMaxValue(chartData, 'barVal'); return ( <> {chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( @@ -102,7 +110,8 @@ export default function Chart({chartConfig=undefined, chartData=[], chartTitle=' axisLine={true} fontSize={12} fontWeight={500} - label={yFieldText ? { value: yFieldText, className:"text-[13px] foont-bold", position: 'top', textAnchor: 'middle', offset: 20 } : undefined} + domain={[0, Math.ceil(barMaxValue * 1)]} + label={yFieldText ? { value: yFieldText, className:"text-[13px] font-bold", position: 'insideLeft', angle: -90, offset: 20 } : undefined} /> <ChartTooltip cursor={false} content={<CustomTooltip active={undefined} payload={undefined} label={undefined} />}/> {chartData && chartData.length > 0 && ( diff --git a/packages/common/business_components/src/ui/chart/LineChart.tsx b/packages/common/business_components/src/ui/chart/LineChart.tsx index a689af8ca..4014702b6 100644 --- a/packages/common/business_components/src/ui/chart/LineChart.tsx +++ b/packages/common/business_components/src/ui/chart/LineChart.tsx @@ -113,20 +113,21 @@ export default function Linechart({ }, []); // 데이터의 최대값 계산 - const getMaxValue = (data: ChartDataType, keyPrefix: string) => { - return Math.max(...Object.values(data).map(item => - Object.keys(item) - .filter(key => key.includes(keyPrefix)) - .map(key => item[key] as unknown as number) - ).flat()); + const getMaxValue = (data: ChartDataType): number => { + return Math.max(...Object.values(data).flatMap(dataset => + dataset.map(entry => { + const val = parseFloat(entry.val); + return isNaN(val) ? 0 : val; + }) + )); }; - const lineMaxValue = getMaxValue(chartData, 'lineVal'); + const lineMaxValue = getMaxValue(chartData); return ( <div className={chartClassName}> {chartTitle && chartTitle !== "" && chartTitle !== "undefined" ? ( - <div style={{ textAlign: "left", fontSize: "13px", fontWeight: "bold", marginTop:"13px", marginBottom: "10px" }}> + <div className="text-left text-[13px] font-bold mt-[13px] mb-[10px]"> {chartTitle} </div> ) : null} diff --git a/packages/common/business_components/src/ui/excel/excelStyle.tsx b/packages/common/business_components/src/ui/excel/excelStyle.tsx index 6674720dc..3c8f8d219 100644 --- a/packages/common/business_components/src/ui/excel/excelStyle.tsx +++ b/packages/common/business_components/src/ui/excel/excelStyle.tsx @@ -1,5 +1,6 @@ -import type { sheetParameter } from '@/index'; +// import type { sheetParameter } from '@/index'; import * as XlsxPopulate from '@xlsx/xlsx-populate'; +import type { SheetParameter } from './index'; @@ -38,13 +39,13 @@ export const excelStyle = async (data: ArrayBuffer, range: string = "A1:V3", fil } -export const excelArrayStyle = async (data: ArrayBuffer, range: [typeof sheetParameter], fileNm:string) => { +export const excelArrayStyle = async (data: ArrayBuffer, range: SheetParameter[], fileNm: string) => { const workbook = await XlsxPopulate.Workbook.fromData(data); - if(range){ - range.forEach((item , index)=>{ + if (range) { + range.forEach((item, index) => { const rangeCells = workbook.activeSheet(index)?.sheet(index)?.range(item.headerRange); console.log(rangeCells); - rangeCells?.style((styleQ)=>{ + rangeCells?.style((styleQ) => { makeCellStyle(styleQ) }); diff --git a/packages/common/business_components/src/ui/excel/index.tsx b/packages/common/business_components/src/ui/excel/index.tsx index 76b4ba2f9..96f3b3e5d 100644 --- a/packages/common/business_components/src/ui/excel/index.tsx +++ b/packages/common/business_components/src/ui/excel/index.tsx @@ -5,7 +5,7 @@ type ExcelDownloadProps = { data: JSON | JSON[]; fileName: string; sheetNameArray: string[]; - headerRange: string; + headerRange?: string; } export const downloadExcel = ({ data, fileName = new Date().getTime().toString() + '.xlsx', sheetNameArray = ["Sheet1"], headerRange='A1:V3'}: ExcelDownloadProps) => { @@ -15,17 +15,21 @@ export const downloadExcel = ({ data, fileName = new Date().getTime().toString() excelStyle(XLSX.write(workbook, { bookType: "xlsx", type: "buffer" }), headerRange, fileName); }; -export const sheetParameter ={ - data:[[]], headerNum:0, headerRange:'A1:V3', sheetName:'Sheet1', startCol:0 -} +export type SheetParameter = { + data: any[][]; + headerNum: number; + headerRange: string; + sheetName: string; + startCol?: string; +}; -export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: Array<typeof sheetParameter>): Promise<JSON | undefined> => { +export const downloadMultipleExcel = (fileName = new Date().getTime().toString() + '.xlsx', sheetArray: SheetParameter[]): Promise<JSON | undefined> => { const workbook = XLSX.utils.book_new(); for (let i = 0; i < sheetArray.length; i++) { // Create a new worksheet for each sheet const worksheet = XLSX.utils.aoa_to_sheet(sheetArray[i]?.data || [[]]); // Add data to the worksheet starting from the specified header number - if (sheetArray&&sheetArray[i]?.headerNum) { + if (sheetArray && sheetArray[i]?.headerNum) { XLSX.utils.sheet_add_aoa(worksheet, sheetArray[i]?.data || [[]], { origin: `A${sheetArray[i]?.headerNum}` }); } // Append the worksheet to the workbook with the specified sheet name @@ -37,7 +41,6 @@ export const downloadMultipleExcel = (fileName = new Date().getTime().toString() return Promise.resolve(undefined); }; - export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):Promise<JSON | undefined> =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -80,8 +83,6 @@ export const filePicked=(oFile: File, headerNum:number=0, dateType="yyyymmdd"):P }); } - - export const filePickedArray=(oFile: File, headerNum:number=0):Promise<JSON[] | undefined> =>{ // Create A File Reader HTML5 const reader = new FileReader(); @@ -123,8 +124,6 @@ export const filePickedArray=(oFile: File, headerNum:number=0):Promise<JSON[] | }); } - - export const filePickedBlob=(oFile: ArrayBuffer, data:[][],fileNm:string, headerNum:number=0, headerRange='A1:V3', startCol?:number):Promise<JSON | undefined> =>{ // Create A File Reader HTML5 return new Promise<JSON | undefined>(() => { // Ready The Event For When A File Gets Selected @@ -149,28 +148,20 @@ export const filePickedBlob=(oFile: ArrayBuffer, data:[][],fileNm:string, header }); } - export const filePickedBlobArray= (oFile: ArrayBuffer,fileNm:string, sheetArray: [typeof sheetParameter]):Promise<JSON | undefined> =>{ // Create A File Reader HTML5 - return new Promise<JSON | undefined> (async () => { - // Ready The Event For When A File Gets Selected - const wb = XLSX.read(oFile, { type: 'binary' }); - // Loop Over Each Sheet - wb.SheetNames.forEach( function (sheetName, index) { - // Obtain The Current Row As CSV - if(sheetArray[index]){ - const sheet = wb.Sheets[sheetName]; - if (sheet) { - //오리진 확인 test 필요 - // const sheet = XLSX.utils.json_to_sheet(data); - const startCol = sheetArray[index].startCol?sheetArray[index].startCol.toString():'A'; - XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol+sheetArray[index].headerNum }); - // XLSX.utils.book_append_sheet(wb, sheet, 'test'); - } else { - console.error(`Sheet "${sheetName}" is undefined.`); - } - } - }); - - - await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) - }); - } \ No newline at end of file +export const filePickedBlobArray = (oFile: ArrayBuffer, fileNm: string, sheetArray: SheetParameter[]): Promise<JSON | undefined> => { + return new Promise<JSON | undefined>(async () => { + const wb = XLSX.read(oFile, { type: 'binary' }); + wb.SheetNames.forEach(function (sheetName, index) { + if (sheetArray[index]) { + const sheet = wb.Sheets[sheetName]; + if (sheet) { + const startCol = sheetArray[index].startCol ? sheetArray[index].startCol : 'A'; + XLSX.utils.sheet_add_aoa(sheet, sheetArray[index].data, { origin: startCol + sheetArray[index].headerNum }); + } else { + console.error(`Sheet "${sheetName}" is undefined.`); + } + } + }); + await excelArrayStyle(XLSX.write(wb, { bookType: "xlsx", type: "buffer" }), sheetArray, fileNm) + }); +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/file-upload/index.tsx b/packages/common/business_components/src/ui/file-upload/index.tsx index 1c70b99af..22ef56820 100644 --- a/packages/common/business_components/src/ui/file-upload/index.tsx +++ b/packages/common/business_components/src/ui/file-upload/index.tsx @@ -12,10 +12,12 @@ const dropZoneConfig = { files: File[]; // 파일 배열 setFiles: (files: File[] | null) => void; // 파일 배열 세터 fileTypes?: string; // 옵션 (파일 확장자 문자열) + onFileClick?:(index:number)=> void; // 파일 클릭 핸들러 + } export const FileUpload = -({ files, setFiles, fileTypes }: FileUploadProps) => { +({ files, setFiles, fileTypes ,onFileClick}: FileUploadProps) => { return ( <FileUploader value={files} @@ -43,9 +45,9 @@ export const FileUpload = {files&& files.length > 0 && files.map((file:File, i:number) => ( - <FileUploaderItem key={i} index={i}> + <FileUploaderItem key={i} index={i} onFileClick={onFileClick }> <Paperclip className="h-4 w-4 stroke-current" /> - <span className="w-4/5 overflow-hidden">{file.name}</span> + <span className="w-4/5 overflow-hidden">{file.name}</span> </FileUploaderItem> ))} </FileUploaderContent> diff --git a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx index c18c3740d..7b4f1995f 100644 --- a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx +++ b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx @@ -286,9 +286,9 @@ FileUploaderContent.displayName = "FileUploaderContent"; export const FileUploaderItem = forwardRef< HTMLDivElement, - { index: number } & React.HTMLAttributes<HTMLDivElement> ->(({ className, index, children, ...props }, ref) => { - const { removeFileFromSet, activeIndex, direction } = useFileUpload(); + { index: number } & React.HTMLAttributes<HTMLDivElement> &{onFileClick?:(index:number)=>void} +>(({ className, index, children, onFileClick, ...props }, ref) => { + const { removeFileFromSet , activeIndex, direction } = useFileUpload(); const isSelected = index === activeIndex; return ( <div @@ -300,11 +300,13 @@ export const FileUploaderItem = forwardRef< isSelected ? "bg-muted" : "", )} {...props} - onClick={() =>{ - console.log('onclick'); - removeFileFromSet(index)}} + > - <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full !w-4/5 overflow-hidden "> + <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full !w-4/5 overflow-hidden " + onClick={() =>{ + + + }}> {children} </div> <button @@ -313,7 +315,10 @@ export const FileUploaderItem = forwardRef< "absolute", "!w-1/5 z-50", direction === "rtl" ? "top-1 left-1" : "top-1 right-1", + )} + onClick={() =>{ + removeFileFromSet(index)}} > <span className="sr-only">remove item {index}</span> <RemoveIcon className="w-4 h-4 hover:stroke-destructive duration-200 ease-in-out" /> diff --git a/packages/common/business_components/src/ui/search_base_form/index.tsx b/packages/common/business_components/src/ui/search_base_form/index.tsx index 9dc1bf735..b8d8355ae 100644 --- a/packages/common/business_components/src/ui/search_base_form/index.tsx +++ b/packages/common/business_components/src/ui/search_base_form/index.tsx @@ -1,3 +1,5 @@ +"use client" + import { Button } from "@common/components/ui"; import { useCallback, useEffect, useState } from "react"; import { SearchFormLeft, type EnvPartSelectDataType } from "../search_form_left"; diff --git a/packages/common/business_components/src/ui/search_form_left/index.tsx b/packages/common/business_components/src/ui/search_form_left/index.tsx index ec9e814f5..02112f084 100644 --- a/packages/common/business_components/src/ui/search_form_left/index.tsx +++ b/packages/common/business_components/src/ui/search_form_left/index.tsx @@ -1,4 +1,6 @@ -import React, { useEffect, useState } from 'react'; +"use client" + +import React, { useEffect, useState } from 'react'; import type { SelectDataType } from '../search_input_select'; import { SelectBox } from '../select'; diff --git a/packages/common/business_components/src/ui/tab/index.tsx b/packages/common/business_components/src/ui/tab/index.tsx index 9dde67780..aee969460 100644 --- a/packages/common/business_components/src/ui/tab/index.tsx +++ b/packages/common/business_components/src/ui/tab/index.tsx @@ -6,37 +6,41 @@ interface TabItem { label: string; } -interface UITabProps extends React.HTMLAttributes<HTMLDivElement> { +interface UITabProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'dir'> { defaultValue?: string; tabList: TabItem[]; children: React.ReactNode; onValueChange?: (value: string) => void; } -const UITab = React.forwardRef< +const UITab = React.forwardRef< HTMLDivElement, UITabProps ->(({defaultValue, tabList, children, onValueChange, ...props}, ref)=>{ - return ( - <Tabs - defaultValue={defaultValue || tabList[0]?.value} - className={"w-full space-x-1 border-b border-gray-200"} - onValueChange={onValueChange} - {...props} - > - <TabsList className="flex space-x-1"> - {tabList.map((tab) => ( - <TabsTrigger - key={tab.value} - value={tab.value} - className="py-2 px-4 text-sm font-medium border-b-2 focus:outline-none data-[state=active]:border-blue-500 data-[state=active]:text-blue-600 data-[state=inactive]:border-transparent data-[state=inactive]:text-gray-500 hover:text-gray-700 hover:border-gray-300" - > - {tab.label} - </TabsTrigger> - ))} - </TabsList> - {children} - </Tabs> - ) -}) +>(({defaultValue, tabList, children, onValueChange, ...props}, ref) => { + return ( + <Tabs + defaultValue={defaultValue || tabList[0]?.value} + className={"w-full space-x-1 border-b border-gray-200"} + onValueChange={onValueChange} + ref={ref} + {...props} + > + <TabsList className="flex space-x-1"> + {tabList.map((tab) => ( + <TabsTrigger + key={tab.value} + value={tab.value} + className="py-2 px-4 text-sm font-medium border-b-2 focus:outline-none data-[state=active]:border-blue-500 data-[state=active]:text-blue-600 data-[state=inactive]:border-transparent data-[state=inactive]:text-gray-500 hover:text-gray-700 hover:border-gray-300" + > + {tab.label} + </TabsTrigger> + ))} + </TabsList> + {children} + </Tabs> + ); +}); + +UITab.displayName = 'UITab'; + export { UITab }; diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index 791eddffe..48f4deb62 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,3 +1,5 @@ +"use client" + import { Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components"; import { useEffect, useState } from "react"; import { HeadMakeColSpan } from "./HeadMakeColSpan"; diff --git a/packages/common/business_components/src/ui/table/lib/pagination.tsx b/packages/common/business_components/src/ui/table/lib/pagination.tsx index 2c17f4b45..76e3b4578 100644 --- a/packages/common/business_components/src/ui/table/lib/pagination.tsx +++ b/packages/common/business_components/src/ui/table/lib/pagination.tsx @@ -8,7 +8,7 @@ const Pagination = ({ className, ...props }: React.ComponentProps<"nav">) => ( <nav role="navigation" aria-label="pagination" - className={cn("mx-auto flex w-full justify-center", className)} + className={cn("mx-auto flex w-full justify-center text-lg mt-2", className)} {...props} /> ) @@ -42,7 +42,7 @@ type PaginationLinkProps = { const PaginationLink = ({ className, isActive, - size = "icon", + size = "default", ...props }: PaginationLinkProps) => ( <a @@ -52,6 +52,7 @@ const PaginationLink = ({ variant: isActive ? "outline" : "ghost", size, }), + "px-4 py-2 text-lg", className )} {...props} @@ -66,10 +67,10 @@ const PaginationPrevious = ({ <PaginationLink aria-label="Go to previous page" size="default" - className={cn("gap-1 pl-2.5", className)} + className={cn("gap-2 pl-4 text-lg", className)} {...props} > - <ChevronLeft className="h-4 w-4" /> + <ChevronLeft className="h-6 w-6" /> <span>Previous</span> </PaginationLink> ) @@ -82,11 +83,11 @@ const PaginationNext = ({ <PaginationLink aria-label="Go to next page" size="default" - className={cn("gap-1 pr-2.5", className)} + className={cn("gap-2 pr-4 text-lg", className)} {...props} > <span>Next</span> - <ChevronRight className="h-4 w-4" /> + <ChevronRight className="h-6 w-6" /> </PaginationLink> ) PaginationNext.displayName = "PaginationNext" @@ -97,10 +98,10 @@ const PaginationEllipsis = ({ }: React.ComponentProps<"span">) => ( <span aria-hidden - className={cn("flex h-9 w-9 items-center justify-center", className)} + className={cn("flex h-12 w-12 items-center justify-center text-lg", className)} {...props} > - <MoreHorizontal className="h-4 w-4" /> + <MoreHorizontal className="h-6 w-6" /> <span className="sr-only">More pages</span> </span> ) From 517cf9787765901527d04101341406b5223212e2 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Thu, 29 May 2025 20:12:11 +0900 Subject: [PATCH 32/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20input=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 0e6b2466f..426376e5e 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -88,6 +88,10 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }); }; + const plusArray = () => { + + } + const removeSelected = () => { if(!ref.current) return; const selectedIdxs = ref.current @@ -273,7 +277,13 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> <div> <div className="text-right mb-3"> - <Button size={commonButonSize}>수요처 추가</Button> + <Input + type="text" + className="!text-xl w-1/3" + onClick={plusArray} + placeholder="수요처 추가" + > + </Input> </div> <RuseMngTable tableData={[]} From a5d816e221985da6df93a4587d91c858acbbb12b Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Fri, 30 May 2025 09:17:17 +0900 Subject: [PATCH 33/62] =?UTF-8?q?=EC=9E=AC=EC=9D=B4=EC=9A=A9=EC=8B=9C?= =?UTF-8?q?=EC=84=A4=20=EB=93=B1=EB=A1=9D=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20?= =?UTF-8?q?=EA=B5=AC=EC=A1=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 13 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 88 +-- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 657 +++++++++++------- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 13 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 100 +-- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 6 +- .../src/ui/form_ui/index.tsx | 75 +- 7 files changed, 605 insertions(+), 347 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index ef2dcd2ad..e1f62c313 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -39,9 +39,9 @@ useEffect(() => { if (!pbnst.isInit ) { pubHasuInit('1','11'); - pbnstRegInit( '41'); + ///pbnstRegInit( '41'); } - }, [pbnst.isInit, pubHasuInit,pbnstRegInit]); + }, [pbnst.isInit, pubHasuInit]); useEffect(() => { @@ -60,10 +60,11 @@ useEffect(() => { if (selectRow) { setSelectedRow(selectRow); } - if (pbnstRes === null){ - alert("등록된 재이용시설 정보가 없습니다. 신규등록 하십시오.") - return; - } + + + console.log('selectRow ', selectRow) + pbnstRegInit(selectRow) + // setSelectBdst(pbnstRes); // setPbnstBiz(pbnstRes?.fcBizs) }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index a99142c64..387368827 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -42,6 +42,7 @@ export type pubFacState = { pbnstMngNm: chHeadType[]; pbnstHasuRes: pubHasuType[]; pbnstRes: customPbnst[] | null; // 배열에서 단일 객체 또는 null로 변경 + pbnstResObj: customPbnst | null; // 배열에서 단일 객체 또는 null로 변경 pbnstBizCycle: SelectDataType[]; selectLabel: SelectDataType[]; pbnstOrgwtHeadList: TableUpperProps[]; @@ -52,16 +53,15 @@ export type pubFacState = { }; }; type pubFacActions = { - pubHasuInit: (page:string, sggOrCity:string) => void; - pbnstRegInit: (sgg: string) => void; - pbnstRegSearch: (txt: string | undefined, sgg: string) => void; + pubHasuInit: (page: string, sggOrCity: string) => void; + pbnstRegInit: (pubHasuRes: pubHasuType) => void; pbnstReg: (txt: string | undefined) => void; pbnstUpdate(pbnstRes: customPbnst): Promise<void>; fileDelete: (atflCd: string) => void; fileDownLoad: (atflCd: string) => void; pbnstMngData: (data: customPbnst[]) => void; pbnstBizData(data: fcBizType): void; - + getBizCycle: (pbnstObj: customPbnst) => void; }; export type pubFacType = pubFacState & pubFacActions; @@ -74,7 +74,8 @@ export const pubFacStateExport: pubFacState = { pbnstMngNm: pbnstMngNm, pbnstOrgwtHeadList: pbnstOrgwtHeadList, pbnstHasuRes: [], - pbnstRes: null, // 초기값을 null로 변경 + pbnstResObj: null, // 초기값을 null로 변경 + pbnstRes: [], // 초기값을 null로 변경 pbnstBizCycle: [{ text: "없음", val: "1" }], selectLabel: selectLabel, pplInstlsHeadLisat: pplInstlsHeadLisat, @@ -89,11 +90,11 @@ const checkWrRegList = async () => { return wrRegList; }; -const hasuListFetch = async (page:string, sggOrCity:string) => { +const hasuListFetch = async (page: string, sggOrCity: string) => { const checkWrRegListRes = await checkWrRegList(); const rainRes = await postFectch( - `/prcsFclt/ruseInfo/${page?page:1}/10/A/${sggOrCity?sggOrCity:"11"}/0/1/SW`, + `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`, checkWrRegListRes, fetchType.COMMON ); @@ -108,18 +109,6 @@ const hasuListFetch = async (page:string, sggOrCity:string) => { return hasuList; }; -const getBizCycle = (fcBizs: z.infer<typeof fcBizSchema>[]) => { - const pbnstBizCycle = fcBizs.map((item: z.infer<typeof fcBizSchema>) => { - return { - text: `${item.cycl}차`, - val: item.cycl, - superkey: "", // Add default superkey value - }; - }); - - return pbnstBizCycle; -}; - const initFetch = async (code: string | undefined) => { const pbnstRes = await getFetch("wr", `${code}`); return pbnstRes; @@ -127,11 +116,10 @@ const initFetch = async (code: string | undefined) => { export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { return { - pubHasuInit: async (page:string, sggOrCity:string) => { + pubHasuInit: async (page: string, sggOrCity: string) => { try { const pbnstHasuRes = await hasuListFetch(page, sggOrCity); - return set((state: pubFacState) => ({ ...state, pbnst: { @@ -145,21 +133,16 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } }, - pbnstRegInit: async (txt: string | undefined) => { + pbnstRegInit: async (pubHasuRes: pubHasuType ) => { try { - // const pbnstRes = await initFetch(txt); - - const pbnstRes = [exampleData]; - - - const pbnstBizCycle = pbnstRes && pbnstRes.length > 0 ? getBizCycle(pbnstRes[0]?.fcBizs || []) : []; // pbnstRes가 null일 수 있으므로 체크 + //const pbnstRes = await initFetch(txt); + const pbnstRes = exampleData; return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, - pbnstRes: [pbnstRes], - pbnstBizCycle: pbnstBizCycle, + pbnstRes: pbnstRes, isInit: false, }, })); @@ -167,10 +150,10 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { console.log(errorHasu); } }, - + pbnstReg: async (txt: string | undefined) => { try { - const pbnstRes = await hasuListFetch(txt); + const pbnstRes = await hasuListFetch('11' , '11'); return set((state: pubFacState) => ({ ...state, pbnst: { @@ -202,6 +185,23 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { console.error("Error updating pbnst:", error); } }, + getBizCycle: async (pbnstObj: customPbnst) => { + const pbnstBizCycle = pbnstObj.fcBizs.map((item) => { + return { + text: `${item.cycl}차`, + val: item.cycl, + }; + }); + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + pbnstBizCycle: pbnstBizCycle, + pbnstResObj: pbnstObj, + isInit: false, + }, + })); + }, fileDelete: async (atflCd: string) => { try { const response = await deleteFectch( @@ -242,21 +242,23 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { return state; }); }, - pbnstBizData:(data:fcBizType)=>{ - return set((state:pubFacState)=>{ - if(state.pbnst.pbnstMngRegData){ - const regData = state.pbnst.pbnstMngRegData.find(item=> - data.pbnstRuseFcltFk===item.pbnstRuseFcltPk - ) - if(regData){ - const bizIdx = regData.fcBizs.findIndex(item=>item.pbnstRuseFcltBizPk==data.pbnstRuseFcltBizPk) - if(bizIdx>=0){ + pbnstBizData: (data: fcBizType) => { + return set((state: pubFacState) => { + if (state.pbnst.pbnstMngRegData) { + const regData = state.pbnst.pbnstMngRegData.find( + (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk + ); + if (regData) { + const bizIdx = regData.fcBizs.findIndex( + (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk + ); + if (bizIdx >= 0) { regData.fcBizs[bizIdx] = data; } } } return state; - }) - } + }); + }, }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index fbf7ec49e..daaaaab98 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -197,247 +197,434 @@ const pubHasuZod = z.object({ export type pubHasuType = z.infer<typeof pubHasuZod>; //관경 제외 -export const exampleData = { - pbnstRuseFcltPk: 1, - swtrmtFcltFk: "11000SW001R", - ruseUtztnFcltNm: "재이용시설 A", - hasuhasu: 0, - fcltCpct: "100", - ruseCpct: "90", - splyExtraCpct: "10", - rgtr: TEST_UUID, - mdfr: TEST_UUID, - fcFiles: [], - fcBizs: [ +export const exampleData = [ + { + "swtrmtFcltFk": "11000SW001R", + "pbnstRuseFcltPk": "11000SW001R1", + "ruseUtztnFcltNm":'난지', + "fcltCpct": 123, + "ruseCpct": 123, + "splyExtraCpct": 123, + "hasuhasu": 123, + "fcFiles": [], + "fcBizs": [ { - pbnstRuseFcltBizPk: 1, - pbnstRuseFcltFk: 1, - cycl: "1", - seCd: "A010", - bizMthdCd: "M02", - instlAprvSncnDt: "2022-01-01", - bizCmcnDay: "2022-02-01", - gvsbs: "정부지원", - lcep: "지자체", - cusrAlotm: "고객", - etc: "비고 없음", - totalMoney: "100000000", - rprcsFcltCpct: "50", - majorPrcsMsrcCd: "MP01", - addr: "서울시 종로구", - rprcsMthdCd: "RP01", - inoutYn: "Y", - mainSplyPumpCpct: "30", - erctWtrOcrnCpct: "5", - erctUswtrLinkSpt: "있음", - erctUswtrFcltCpct: "20", - erctUswtrPrcsMeth: "생물학적", - erctUswtrPrcsMsrcCd: "EM01", - wwtEmsnFcltPrmsnYn: "Y", - tmsInstlYn: "N", - pbnstDrngInflwExclYn: "Y", - bod: "30", - grssClfg: "양호", - combResdch: "적정", - trbt: "10", - clIonQnt: "5", - smll: "없음", - crmty: "정상", - tph: "0.2", - tn: "2", - ph: "7.2", - cdtnv: "100", - designCst: "1000", - cstrnSpvsCst: "500", - fcltSbsdCst: "200", - wstCst: "300", - cnstCmcnCst: "1000", - mntrgEqpmntInstlCst: "150", - gisDbCst: "200", - elpwrMtrngCst: "180", - mchnCst: "700", - archCst: "400", - pplCst: "300", - ruseFcltCst: "5000", - designCstClcln: "990", - cstrnSpvsCstClcln: "480", - fcltSbsdCstClcln: "190", - wstCstClcln: "280", - cnstCmcnCstClcln: "980", - mntrgEqpmntInstlCstClcln: "140", - gisDbCstClcln: "190", - elpwrMtrngCstClcln: "170", - mchnCstClcln: "680", - archCstClcln: "380", - pplCstClcln: "290", - ruseFcltCstClcln: "4800", - pplInstls: [ + "pbnstRuseFcltFk": "11000SW001R1", + "cycl": 1, + "seCd": "123", + "bizMthdCd": "123", + "gvsbs": 123, + "lcep": 123, + "cusrAlotm": 123, + "etc": "123", + "rprcsFcltCpct": 123, + "majorPrcsMsrcCd": "123", + "addr": "123", + "rprcsMthdCd": "123", + "inoutYn": "123", + "mainSplyPumpCpct": 123, + "erctWtrOcrnCpct": 123, + "erctUswtrLinkSpt": "123", + "erctUswtrFcltCpct": 123, + "erctUswtrPrcsMeth": "123", + "erctUswtrPrcsMsrcCd": "123", + "bod": 123, + "grssClfg": 123, + "combResdch": 123, + "trbt": 123, + "smll": 1230, + "crmty": 123, + "tn": 123, + "tph": 1230, + "ph": 123, + "clIonQnt": 123, + "cdtnv": 123, + "pplInstls": [ { - ruseFcltBizFk: "10", - pdmt: "D200", - ppMqlt: "도복장강관", - cpct: "1", - }, - { - ruseFcltBizFk: "10", - pdmt: "D100", - ppMqlt: "PE관", - cpct: "2", - }, - ], - fcOrgwts: [ - { - pbnstRuseFcltBizFk: 1, - swtrmtFcltFk: "11000SW001R", - orgwtWtritQnt: "100", - tmsYn: "Y", - dschgFmYn: "N", - dtlPstnExpln: "배출 위치", - regDt: "20250221", - rgtr: "admin", - mdfcnDt: "20250321", - mdfr: "admin", - }, - { - pbnstRuseFcltBizFk: 1, - swtrmtFcltFk: "11200PB001R", - orgwtWtritQnt: "153", - tmsYn: "Y", - dschgFmYn: "N", - dtlPstnExpln: "배출 위치22", - regDt: "20250221", - rgtr: "admin", - mdfcnDt: "20250421", - mdfr: "admin", - }, - ], - flg: "N", - rgtr: TEST_UUID, - mdfr: TEST_UUID, + "ruseFcltBizFk": "", + "choose": false, + "ppMqlt": "PE관", + "pdmt": "D250", + "cpct": "123", + "id": "e1472f7c-7033-44ae-a953-f69e6b90fbc1" + } + ] + + }, { - pbnstRuseFcltBizPk: 11, - pbnstRuseFcltFk: 1, - cycl: "2", - seCd: "A011", - bizMthdCd: "M02", - instlAprvSncnDt: "2022-01-01", - bizCmcnDay: "2022-02-01", - gvsbs: "민간", - lcep: "지자체", - cusrAlotm: "고객", - etc: "비고 없음", - totalMoney: "100000000", - rprcsFcltCpct: "50", - majorPrcsMsrcCd: "MP01", - addr: "부산시 해운대구", - rprcsMthdCd: "RP01", - inoutYn: "Y", - mainSplyPumpCpct: "30", - erctWtrOcrnCpct: "5", - erctUswtrLinkSpt: "있음", - erctUswtrFcltCpct: "20", - erctUswtrPrcsMeth: "생물학적", - erctUswtrPrcsMsrcCd: "EM01", - wwtEmsnFcltPrmsnYn: "Y", - tmsInstlYn: "N", - pbnstDrngInflwExclYn: "Y", - bod: "30", - grssClfg: "양호", - combResdch: "적정", - trbt: "10", - clIonQnt: "5", - smll: "없음", - crmty: "정상", - tph: "0.2", - tn: "2", - ph: "7.2", - cdtnv: "100", - designCst: "1000", - cstrnSpvsCst: "500", - fcltSbsdCst: "200", - wstCst: "300", - cnstCmcnCst: "1000", - mntrgEqpmntInstlCst: "150", - gisDbCst: "200", - elpwrMtrngCst: "180", - mchnCst: "700", - archCst: "400", - pplCst: "300", - ruseFcltCst: "5000", - designCstClcln: "990", - cstrnSpvsCstClcln: "480", - fcltSbsdCstClcln: "190", - wstCstClcln: "280", - cnstCmcnCstClcln: "980", - mntrgEqpmntInstlCstClcln: "140", - gisDbCstClcln: "190", - elpwrMtrngCstClcln: "170", - mchnCstClcln: "680", - archCstClcln: "380", - pplCstClcln: "290", - ruseFcltCstClcln: "4800", - pplInstls: [ + "pbnstRuseFcltFk": "11000SW001R1", + "cycl": 2, + "seCd": "하하", + "bizMthdCd": "호호", + "gvsbs": 12, + "lcep": 12, + "cusrAlotm": 12, + "etc": "1", + "rprcsFcltCpct": 12, + "majorPrcsMsrcCd": "12", + "addr": "12", + "rprcsMthdCd": "12", + "inoutYn": "12", + "mainSplyPumpCpct": 12, + "erctWtrOcrnCpct": 13, + "erctUswtrLinkSpt": "12", + "erctUswtrFcltCpct": 13, + "erctUswtrPrcsMeth": "12", + "erctUswtrPrcsMsrcCd": "12", + "bod": 1, + "grssClfg": 1, + "combResdch": 1, + "trbt": 1, + "smll": 1, + "crmty": 1, + "tn": 1, + "tph": 1, + "ph": 1, + "clIonQnt": 1, + "cdtnv": 1, + "pplInstls": [ { - ruseFcltBizFk: "11", - pdmt: "관경", - ppMqlt: "1", - cpct: "100", - }, - { - ruseFcltBizFk: "11", - pdmt: "관경", - ppMqlt: "2", - cpct: "200", - }, - ], - fcOrgwts: [ - { - pbnstRuseFcltBizFk: 11, - swtrmtFcltFk: "11000SW001R", - orgwtWtritQnt: "152", - tmsYn: "Y", - dschgFmYn: "N", - dtlPstnExpln: "배출 위치1", - rgtr: TEST_UUID, - mdfr: TEST_UUID, - }, - { - pbnstRuseFcltBizFk: 11, - swtrmtFcltFk: "11200PB001R", - orgwtWtritQnt: "150", - tmsYn: "Y", - dschgFmYn: "N", - dtlPstnExpln: "배출 위치", - rgtr: TEST_UUID, - mdfr: TEST_UUID, - }, - ], - flg: "N", - rgtr: TEST_UUID, - mdfr: TEST_UUID, - }, + "ruseFcltBizFk": "", + "choose": false, + "ppMqlt": "PE관", + "pdmt": "D300", + "cpct": "1", + "id": "e1472f7c-7033-44ae-a953-f69e6b90fbc1" + } + ] + } ], - fcOpers: [ + "fcOpers": [ { - pbnstRuseFcltOperInfoPk: 100, - pbnstRuseFcltFk: 1, - operMthd: "위탁", - rprtvBzenty: "기관명", - bgngDt: new Date("2023-09-30"), - endDt: new Date("2023-12-31"), - rgtr: TEST_UUID, - mdfr: TEST_UUID, - }, + "choose": false, + "rgtr": "", + "mdfr": "", + "operMthd": "1", + "rprtvBzenty": "1", + "bgngDt": "20250513", + "endDt": "20250529", + "id": "cbef8f84-33df-406b-a85f-edd2a5d3618e" + } + ] +}, +{ + "swtrmtFcltFk": "11000SW001R", + "ruseUtztnFcltNm":'난지', + "pbnstRuseFcltPk": "11000SW001R2", + "fcltCpct": 123, + "ruseCpct": 123, + "splyExtraCpct": 123, + "hasuhasu": 123, + "fcFiles": [], + "fcBizs": [ { - pbnstRuseFcltOperInfoPk: 101, - pbnstRuseFcltFk: 1, - operMthd: "직영", - rprtvBzenty: "기관명", - bgngDt: new Date("2024-11-30"), - endDt: new Date("2024-12-31"), - rgtr:TEST_UUID , - mdfr: TEST_UUID, - }, + "pbnstRuseFcltFk": "11000SW001R2", + "cycl": 1, + "seCd": "123", + "bizMthdCd": "123", + "gvsbs": 123, + "lcep": 123, + "cusrAlotm": 123, + "etc": "123", + "rprcsFcltCpct": 123, + "majorPrcsMsrcCd": "123", + "addr": "123", + "rprcsMthdCd": "123", + "inoutYn": "123", + "mainSplyPumpCpct": 123, + "erctWtrOcrnCpct": 123, + "erctUswtrLinkSpt": "123", + "erctUswtrFcltCpct": 123, + "erctUswtrPrcsMeth": "123", + "erctUswtrPrcsMsrcCd": "123", + "bod": 123, + "grssClfg": 123, + "combResdch": 123, + "trbt": 123, + "smll": 1230, + "crmty": 123, + "tn": 123, + "tph": 1230, + "ph": 123, + "clIonQnt": 123, + "cdtnv": 123, + "pplInstls": [ + { + "ruseFcltBizFk": "", + "choose": false, + "ppMqlt": "PE관", + "pdmt": "D250", + "cpct": "123", + "id": "e1472f7c-7033-44ae-a953-f69e6b90fbc1" + } + ] + } ], -}; + "fcOpers": [ + { + "choose": false, + "rgtr": "", + "mdfr": "", + "operMthd": "123", + "rprtvBzenty": "123", + "bgngDt": "20250513", + "endDt": "20250529", + "id": "cbef8f84-33df-406b-a85f-edd2a5d3618e" + } + ] +} +] + + + +// [{ +// pbnstRuseFcltPk: 1, +// swtrmtFcltFk: "11000SW001R", +// ruseUtztnFcltNm: "재이용시설 A", +// hasuhasu: 0, +// fcltCpct: "100", +// ruseCpct: "90", +// splyExtraCpct: "10", +// rgtr: TEST_UUID, +// mdfr: TEST_UUID, +// fcFiles: [], +// fcBizs: [ +// { +// pbnstRuseFcltBizPk: 1, +// pbnstRuseFcltFk: 1, +// cycl: "1", +// seCd: "A010", +// bizMthdCd: "M02", +// instlAprvSncnDt: "2022-01-01", +// bizCmcnDay: "2022-02-01", +// gvsbs: "정부지원", +// lcep: "지자체", +// cusrAlotm: "고객", +// etc: "비고 없음", +// totalMoney: "100000000", +// rprcsFcltCpct: "50", +// majorPrcsMsrcCd: "MP01", +// addr: "서울시 종로구", +// rprcsMthdCd: "RP01", +// inoutYn: "Y", +// mainSplyPumpCpct: "30", +// erctWtrOcrnCpct: "5", +// erctUswtrLinkSpt: "있음", +// erctUswtrFcltCpct: "20", +// erctUswtrPrcsMeth: "생물학적", +// erctUswtrPrcsMsrcCd: "EM01", +// wwtEmsnFcltPrmsnYn: "Y", +// tmsInstlYn: "N", +// pbnstDrngInflwExclYn: "Y", +// bod: "30", +// grssClfg: "양호", +// combResdch: "적정", +// trbt: "10", +// clIonQnt: "5", +// smll: "없음", +// crmty: "정상", +// tph: "0.2", +// tn: "2", +// ph: "7.2", +// cdtnv: "100", +// designCst: "1000", +// cstrnSpvsCst: "500", +// fcltSbsdCst: "200", +// wstCst: "300", +// cnstCmcnCst: "1000", +// mntrgEqpmntInstlCst: "150", +// gisDbCst: "200", +// elpwrMtrngCst: "180", +// mchnCst: "700", +// archCst: "400", +// pplCst: "300", +// ruseFcltCst: "5000", +// designCstClcln: "990", +// cstrnSpvsCstClcln: "480", +// fcltSbsdCstClcln: "190", +// wstCstClcln: "280", +// cnstCmcnCstClcln: "980", +// mntrgEqpmntInstlCstClcln: "140", +// gisDbCstClcln: "190", +// elpwrMtrngCstClcln: "170", +// mchnCstClcln: "680", +// archCstClcln: "380", +// pplCstClcln: "290", +// ruseFcltCstClcln: "4800", +// pplInstls: [ +// { +// ruseFcltBizFk: "10", +// pdmt: "D200", +// ppMqlt: "도복장강관", +// cpct: "1", +// }, +// { +// ruseFcltBizFk: "10", +// pdmt: "D100", +// ppMqlt: "PE관", +// cpct: "2", +// }, +// ], +// fcOrgwts: [ +// { +// pbnstRuseFcltBizFk: 1, +// swtrmtFcltFk: "11000SW001R", +// orgwtWtritQnt: "100", +// tmsYn: "Y", +// dschgFmYn: "N", +// dtlPstnExpln: "배출 위치", +// regDt: "20250221", +// rgtr: "admin", +// mdfcnDt: "20250321", +// mdfr: "admin", +// }, +// { +// pbnstRuseFcltBizFk: 1, +// swtrmtFcltFk: "11200PB001R", +// orgwtWtritQnt: "153", +// tmsYn: "Y", +// dschgFmYn: "N", +// dtlPstnExpln: "배출 위치22", +// regDt: "20250221", +// rgtr: "admin", +// mdfcnDt: "20250421", +// mdfr: "admin", +// }, +// ], +// flg: "N", +// rgtr: TEST_UUID, +// mdfr: TEST_UUID, +// }, +// { +// pbnstRuseFcltBizPk: 11, +// pbnstRuseFcltFk: 1, +// cycl: "2", +// seCd: "A011", +// bizMthdCd: "M02", +// instlAprvSncnDt: "2022-01-01", +// bizCmcnDay: "2022-02-01", +// gvsbs: "민간", +// lcep: "지자체", +// cusrAlotm: "고객", +// etc: "비고 없음", +// totalMoney: "100000000", +// rprcsFcltCpct: "50", +// majorPrcsMsrcCd: "MP01", +// addr: "부산시 해운대구", +// rprcsMthdCd: "RP01", +// inoutYn: "Y", +// mainSplyPumpCpct: "30", +// erctWtrOcrnCpct: "5", +// erctUswtrLinkSpt: "있음", +// erctUswtrFcltCpct: "20", +// erctUswtrPrcsMeth: "생물학적", +// erctUswtrPrcsMsrcCd: "EM01", +// wwtEmsnFcltPrmsnYn: "Y", +// tmsInstlYn: "N", +// pbnstDrngInflwExclYn: "Y", +// bod: "30", +// grssClfg: "양호", +// combResdch: "적정", +// trbt: "10", +// clIonQnt: "5", +// smll: "없음", +// crmty: "정상", +// tph: "0.2", +// tn: "2", +// ph: "7.2", +// cdtnv: "100", +// designCst: "1000", +// cstrnSpvsCst: "500", +// fcltSbsdCst: "200", +// wstCst: "300", +// cnstCmcnCst: "1000", +// mntrgEqpmntInstlCst: "150", +// gisDbCst: "200", +// elpwrMtrngCst: "180", +// mchnCst: "700", +// archCst: "400", +// pplCst: "300", +// ruseFcltCst: "5000", +// designCstClcln: "990", +// cstrnSpvsCstClcln: "480", +// fcltSbsdCstClcln: "190", +// wstCstClcln: "280", +// cnstCmcnCstClcln: "980", +// mntrgEqpmntInstlCstClcln: "140", +// gisDbCstClcln: "190", +// elpwrMtrngCstClcln: "170", +// mchnCstClcln: "680", +// archCstClcln: "380", +// pplCstClcln: "290", +// ruseFcltCstClcln: "4800", +// pplInstls: [ +// { +// ruseFcltBizFk: "11", +// pdmt: "관경", +// ppMqlt: "1", +// cpct: "100", +// }, +// { +// ruseFcltBizFk: "11", +// pdmt: "관경", +// ppMqlt: "2", +// cpct: "200", +// }, +// ], +// fcOrgwts: [ +// { +// pbnstRuseFcltBizFk: 11, +// swtrmtFcltFk: "11000SW001R", +// orgwtWtritQnt: "152", +// tmsYn: "Y", +// dschgFmYn: "N", +// dtlPstnExpln: "배출 위치1", +// rgtr: TEST_UUID, +// mdfr: TEST_UUID, +// }, +// { +// pbnstRuseFcltBizFk: 11, +// swtrmtFcltFk: "11200PB001R", +// orgwtWtritQnt: "150", +// tmsYn: "Y", +// dschgFmYn: "N", +// dtlPstnExpln: "배출 위치", +// rgtr: TEST_UUID, +// mdfr: TEST_UUID, +// }, +// ], +// flg: "N", +// rgtr: TEST_UUID, +// mdfr: TEST_UUID, +// }, +// ], +// fcOpers: [ +// { +// pbnstRuseFcltOperInfoPk: 100, +// pbnstRuseFcltFk: 1, +// operMthd: "위탁", +// rprtvBzenty: "기관명", +// bgngDt: new Date("2023-09-30"), +// endDt: new Date("2023-12-31"), +// rgtr: TEST_UUID, +// mdfr: TEST_UUID, +// }, +// { +// pbnstRuseFcltOperInfoPk: 101, +// pbnstRuseFcltFk: 1, +// operMthd: "직영", +// rprtvBzenty: "기관명", +// bgngDt: new Date("2024-11-30"), +// endDt: new Date("2024-12-31"), +// rgtr:TEST_UUID , +// mdfr: TEST_UUID, +// }, +// ], +// } + + + + + +// ] diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index edfa6dd96..8e096c449 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -114,13 +114,16 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }; useEffect(() => { - if (data) { - const index = Number(getBizCycle) - 1; - form.reset(data[index]); - ref.current = data[index]?.pplInstls ?? []; + + if(getBizCycle){ + + const index = Number(getBizCycle) - 1; + form.reset(pbnst.pbnstResObj?.fcBizs[index]); + ref.current = pbnst.pbnstResObj?.fcBizs[index]?.pplInstls ?? []; } - }, [getBizCycle, data]); + + }, [getBizCycle,pbnst.pbnstResObj]); useEffect(() => { const ppl = []; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 5fc30a4c7..9dcd9b5e5 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -27,30 +27,29 @@ import { } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; import { Label } from "@common/business_components/ui/form/lib/label"; +import React from "react"; export type FilesType = { atflCd: string; file: File; }; export function PbnstMngForm({ data }: { data: customPbnst[] }) { + const { pbnst, pbnstUpdate ,pbnstMngData, fileDelete,getBizCycle} = useWrStore((state) => state); + + const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null); - const { pbnst, pbnstUpdate ,pbnstMngData, fileDelete} = useWrStore((state) => state); const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null); const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null); const [progress, setProgress] = useState(0); //const new File([] as BlobPart[], "") 파일 다운로드 활용 - const handleProgress = (percentage: string) => { - setProgress(Number(percentage)); - }; const ref = useRef<operType[] | null>( null); const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), defaultValues: pbnstRegZod.parse({}), }); - const { fields: fcOpersField, append, @@ -61,18 +60,19 @@ export type FilesType = { }); - useEffect(() => { - const formData = form.watch(); - formData.fcOpers = ref.current ? [...ref.current] : []; - formData.fcFiles = regFileList ? [...regFileList] : []; - pbnstMngData([formData] as customPbnst[]); - }, [form.formState, regFileList]); + const handleProgress = (percentage: string) => { + setProgress(Number(percentage)); + }; - useEffect(() => { - pbnstMngData(pbnst.pbnstMngRegData); - }, [pbnst.pbnstMngRegData]); + const selectFclt = (val: number) => { + if (pbnst.pbnstRes && pbnst.pbnstRes[val]) { + getBizCycle(pbnst.pbnstRes[val]) + form.reset(pbnst.pbnstRes[val]) + + }; +} const fileDownload = (index: number) => {}; const plusHist = () => { const regData = { @@ -102,31 +102,6 @@ export type FilesType = { selectedIdxs.reverse().forEach((idx) => remove(idx)); }; - useEffect(() => { - if (!data) return; - //form.reset(data); - const fcltNmList = data.map((item, index) => ({ - text: item.ruseUtztnFcltNm, - val: String(index) - })) - ref.current = data[0]?.fcOpers ?? null; - setFcltNm(fcltNmList) - }, [data]) - - - -useEffect(() => { - if (!fcltNm || fcltNm.length === 0) return; - form.reset(data[0]); - }, [fcltNm, data]); - // 2. Define a submit handler. - function onSubmit(values: z.infer<typeof pbnstRegZod>) { - values.fcOpers = ref.current || []; - values.fcFiles = regFileList || []; - console.log("form values:", values); - pbnstUpdate(values); - } - const fileHandler = (files: File[], type: string) => { let fileList = [] as FilesType[]; if (type === "relation" && relationfiles) { @@ -179,6 +154,7 @@ useEffect(() => { : setPlanFiles(setReFiles); } }; + const regFileFilter = ( files: FilesType[], fileKnd: string, @@ -194,6 +170,50 @@ useEffect(() => { })); return [...planDatas, ...data]; } + + + useEffect(() => { + const formData = form.watch(); + formData.fcOpers = ref.current ? [...ref.current] : []; + formData.fcFiles = regFileList ? [...regFileList] : []; + + pbnstMngData([formData] as customPbnst[]); + }, [form.formState, regFileList]); + + useEffect(() => { + pbnstMngData(pbnst.pbnstMngRegData); + }, [pbnst.pbnstMngRegData]); + + + useEffect(() => { + if (!data) return; + //form.reset(data); + ref.current = data[0]?.fcOpers ?? null; + }, [data]) + + + useEffect(() => { + + if (!pbnst.pbnstRes) return; + const fcltNmList = pbnst.pbnstRes.map((item, index) => ({ + text: item.ruseUtztnFcltNm, + val: String(index) + })) + + console.log('fcltNmList ', fcltNmList) + setFcltNm(fcltNmList) + + }, [pbnst.pbnstRes]) + + // 2. Define a submit handler. + function onSubmit(values: z.infer<typeof pbnstRegZod>) { + values.fcOpers = ref.current || []; + values.fcFiles = regFileList || []; + console.log("form values:", values); + pbnstUpdate(values); + } + + useEffect(() => { if (relationfiles) { @@ -223,7 +243,7 @@ useEffect(() => { className="mt-4 ml-2" selectClass={undefined} selectArray={fcltNm ?? []} - onSelectValue={(val) => {console.log("val", val)}} + onSelectValue={(val) => {selectFclt( Number(val))}} value={""} /> </div> diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index e58f7b856..ead010fa0 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -49,10 +49,10 @@ const pbnstRegTotal = ()=>{ if(data ){ let regData = { - superKey: String(data.bscFctCd + "1"), swtrmtFcltFk: String(data.bscFctCd ), - pbnstRuseFcltPk: 1, - fcBizs: [{ pbnstRuseFcltFk: 1 ,cycl:1 } as unknown as fcBizType], + pbnstRuseFcltPk: String(data.bscFctCd + "1"), + ruseUtztnFcltNm: data.bscFctNm, + fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "1") ,cycl:1 } as unknown as fcBizType], }; setPbnstBdstForm(regData as unknown as customPbnst); diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index bd9930c3c..ec1854636 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -1,19 +1,64 @@ -import React from "react"; +import React, { useCallback, useState } from "react"; import { FormControl, FormItem, FormLabel, FormMessage } from "../form"; +import { Button, Checkbox } from "@common/components/ui"; -const FormUi = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes<HTMLDivElement> & {label:string|undefined} ->(({children, label},ref)=>{ +export const BZNM_TOT_NO = '총사업자등록번호'; +export const CANDIDATE = '공급처 후보지 선택(필수아님)'; + +interface FormUiProps extends React.HTMLAttributes<HTMLDivElement> { + label?: string; + onCheckboxChange?: (checked: boolean) => void; + isDisabled?: boolean; +} + +interface FormElementProps extends React.HTMLAttributes<HTMLElement> { + disabled?: boolean; +} + +const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>( + ({ children, label, onCheckboxChange, isDisabled }, ref) => { + const [isChecked, setIsChecked] = useState(false); + + const handleCheckboxChange = useCallback((checked: boolean) => { + setIsChecked(checked); + onCheckboxChange?.(checked); + }, [onCheckboxChange]); + console.log(children); return ( - <FormItem ref={ref}> - {label?<FormLabel className="text-xl">{label}</FormLabel>:<></>} - <FormControl> - {children} - </FormControl> - <FormMessage /> - </FormItem> - ) -}) + <FormItem ref={ref}> + {label && <FormLabel className="text-xl">{label}</FormLabel>} + {label === BZNM_TOT_NO && ( + <div className="float-right"> + <div className="flex items-center gap-2"> + <Checkbox + id="check" + checked={isChecked} + onCheckedChange={handleCheckboxChange} + /> + <label className="w-20 text-xl text-gray-600" htmlFor="check">해당없음</label> + </div> + </div> + )} + {label === CANDIDATE && ( + <FormControl> + {children} + </FormControl> + )} + {label !== BZNM_TOT_NO && label !== CANDIDATE && ( + <FormControl> + {React.isValidElement(children) && isDisabled + ? React.cloneElement(children, { + disabled: true, + ...(children.props as FormElementProps) + }) + : children} + </FormControl> + )} + <FormMessage /> + </FormItem> + ); + } +); + FormUi.displayName = 'FormUi'; -export { FormUi }; +export { FormUi }; \ No newline at end of file From d66d2f727d216e7553ede76a809b656f6fc88fb0 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Fri, 30 May 2025 10:50:00 +0900 Subject: [PATCH 34/62] =?UTF-8?q?=ED=8F=BC=20=EC=9C=A0=EB=AC=B4=20?= =?UTF-8?q?=EC=B2=B4=ED=81=AC=EB=B0=95=EC=8A=A4=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 6 +++--- .../ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 4 ++-- .../mngReg/mngRegFormDetail/mngRegFormDetail.tsx | 13 ++++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 042a57f11..c3c2af5e4 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -75,9 +75,9 @@ export type formDetailType = { }; export const wasteWaterFcltINfo: formDetailType[] = [ - { id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부" }, - { id: "tmsInstlYn", lable: "Tms설치여부" }, - { id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부" }, + { id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부", type: "selectYn" }, + { id: "tmsInstlYn", lable: "Tms설치여부", type: "selectYn" }, + { id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부", type: "selectYn" }, ]; export const concentratedWaterInfo: formDetailType[] = [ diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 0e5e8f97d..a1b925dfe 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -118,7 +118,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }; useEffect(() => { - + if(getBizCycle){ @@ -254,7 +254,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <Input type="text" value={""} - readOnly + readOnly={true} className="w-32 border-gray-300 rounded pr-8 " /> <Button diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 0afb35206..5d9d1fee5 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -1,7 +1,8 @@ +import { useWrStore } from "@/app/store"; import type { formDetailType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; import { formH1Class } from "@/components/lib/class/comClass"; import { safeDate } from "@/components/lib/func/commom"; -import { FormField, FormUi } from "@common/business_components/ui"; +import { FormField, FormUi, SelectBox } from "@common/business_components/ui"; import { DatePicker, Input } from "@common/components/ui"; export default function MngRegFormDetail({ @@ -19,6 +20,7 @@ export default function MngRegFormDetail({ cycle?:string sonClass?: string; }) { + const { code, } = useWrStore((state) => state); return ( <> <h1 className={formH1Class}>{h1Title}</h1> @@ -46,6 +48,15 @@ export default function MngRegFormDetail({ /> ) : item.type === "number" ? ( <Input placeholder="" type="number" value={field.value??0} onChange={(e) =>{field.onChange(Number(e.target.value))}} /> + ) : item.type === "selectYn" ? ( + <SelectBox + label={""} + selectClass={""} + className="w-full" + selectArray={code.yn} + onSelectValue={(val: string | number) => field.onChange(val)} + value={field.value} + /> ) : ( <Input placeholder="" type="text" value={field.value??''} onChange={field.onChange} /> )} From 913c710001eccebe66aa8d020c51858a11aa39a3 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Fri, 30 May 2025 11:01:46 +0900 Subject: [PATCH 35/62] =?UTF-8?q?=EA=B3=B5=EA=B8=89=EA=B4=80=EB=A1=9C=20?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EB=B8=94=20=EB=B3=B5=EA=B5=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index a1b925dfe..95fdcd8b2 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -274,6 +274,15 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { 삭제 </Button> </div> + <div> + <RuseMngTable + tableData={pplInstls} + headList={pbnst.pplInstlsHeadLisat} + code={ppiSelectList ?? []} + ref={ref} + upHeadList={[]} + /> + </div> <MngRegFormDetail formList={ruseWaterQulityList} From 6bfe08ed8c2269f2d9066cf36718cc09117f14cb Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Fri, 30 May 2025 11:26:46 +0900 Subject: [PATCH 36/62] =?UTF-8?q?formUi=20=EB=B3=80=EA=B2=BD=20=ED=9B=84?= =?UTF-8?q?=EB=B3=B4=EC=9E=90=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business_components/src/ui/form_ui/index.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index ec1854636..b834d5515 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -1,8 +1,8 @@ +import { Checkbox } from "@common/components/ui"; import React, { useCallback, useState } from "react"; import { FormControl, FormItem, FormLabel, FormMessage } from "../form"; -import { Button, Checkbox } from "@common/components/ui"; -export const BZNM_TOT_NO = '총사업자등록번호'; +export const BZNM_TOT_NO = '종사업자등록번호'; export const CANDIDATE = '공급처 후보지 선택(필수아님)'; interface FormUiProps extends React.HTMLAttributes<HTMLDivElement> { @@ -23,11 +23,11 @@ const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>( setIsChecked(checked); onCheckboxChange?.(checked); }, [onCheckboxChange]); - console.log(children); return ( <FormItem ref={ref}> {label && <FormLabel className="text-xl">{label}</FormLabel>} {label === BZNM_TOT_NO && ( + <> <div className="float-right"> <div className="flex items-center gap-2"> <Checkbox @@ -38,6 +38,8 @@ const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>( <label className="w-20 text-xl text-gray-600" htmlFor="check">해당없음</label> </div> </div> + {children} + </> )} {label === CANDIDATE && ( <FormControl> @@ -61,4 +63,4 @@ const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>( ); FormUi.displayName = 'FormUi'; -export { FormUi }; \ No newline at end of file +export { FormUi }; From 9cdf6fb0477cbb7f43794fc9d46b9a60fd7828f7 Mon Sep 17 00:00:00 2001 From: JIeunhuh <entks301@naver.com> Date: Fri, 30 May 2025 14:34:10 +0900 Subject: [PATCH 37/62] =?UTF-8?q?=ED=85=8D=EC=8A=A4=ED=8A=B8=20=ED=81=AC?= =?UTF-8?q?=EA=B8=B0=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/components/src/ui/input/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/components/src/ui/input/index.tsx b/packages/common/components/src/ui/input/index.tsx index 11cbca71d..f3abe2d82 100644 --- a/packages/common/components/src/ui/input/index.tsx +++ b/packages/common/components/src/ui/input/index.tsx @@ -7,7 +7,7 @@ const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>( return ( <input className={cn( - "flex h-[3.2rem] w-full rounded-md border border-input bg-form px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", + "flex h-[3.2rem] w-full rounded-md border border-input bg-form px-3 py-2 text-xl ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-placeholder focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-xl", className, )} ref={ref} From 6314b8059e720a6253ec3399f283e1b8cfa3d608 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Fri, 30 May 2025 15:29:29 +0900 Subject: [PATCH 38/62] =?UTF-8?q?=ED=8F=BC=20=ED=95=A9=EA=B3=84=20readonly?= =?UTF-8?q?=20/=20=EC=9E=90=EB=8F=99=EA=B3=84=EC=82=B0=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 15 ++++++++++++--- .../table/pbnstReg/ruseMngTable/ruseMngTable.tsx | 11 +++++++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 95fdcd8b2..d1bf87adb 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -43,6 +43,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const [ppiYn, setPpiYn] = useState("Y"); const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); const [modalData, setModalData] = useState<fcOrgwtType | null>(null); + const [sumCpct, setSumCpct] = useState<number>(0); const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), @@ -50,7 +51,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { // 2. Define a submit handler. function onSubmit(values: fcBizType) { - console.log(values); + // console.log(values); } const { fields: fcOrgwtFiled } = useFieldArray({ @@ -128,7 +129,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { } }, [getBizCycle,pbnst.pbnstResObj]); - + useEffect(() => { const ppl = []; if (code.pplLenght) { @@ -253,7 +254,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <Label className="text-right">합계</Label> <Input type="text" - value={""} + value={sumCpct} readOnly={true} className="w-32 border-gray-300 rounded pr-8 " /> @@ -281,6 +282,14 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { code={ppiSelectList ?? []} ref={ref} upHeadList={[]} + onTableSet={(val) => { + if (!ref.current) return; + let sum = 0; + ref.current.forEach(item => { + sum += Number(item.cpct) || 0; + }); + setSumCpct(sum); + }} /> </div> diff --git a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx index c1a7e95ca..43a08e203 100644 --- a/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx +++ b/apps/wr/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable.tsx @@ -21,6 +21,7 @@ type RuseMngTableProps = { headList: TableUpperProps[]; upHeadList: chHeadType[]; code?: { name: string, val: SelectDataType[] }[]; + onTableSet?:(item:any)=> void; }; const RuseMngTable = React.forwardRef<any, RuseMngTableProps>( @@ -28,14 +29,20 @@ const RuseMngTable = React.forwardRef<any, RuseMngTableProps>( tableData, headList, upHeadList, - code + code, + onTableSet }, ref) => { const [tableState, setTableState] = useState([...tableData]); useEffect(() => { if (ref && typeof ref === "object" && "current" in ref) { ref.current = tableState; } - }, [tableState]); + if(onTableSet) + onTableSet (tableState) + }, [tableState,onTableSet]); + + + useEffect(() => { if(tableData) From 43d80be24bbd78164a896511b0f3861eca887b20 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Fri, 30 May 2025 16:19:46 +0900 Subject: [PATCH 39/62] =?UTF-8?q?=EA=B3=B5=EA=B8=89=EA=B4=80=EB=A1=9C=20?= =?UTF-8?q?=EC=9C=A0=EB=AC=B4=EC=97=90=20=EB=94=B0=EB=A5=B8=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 243 +++++++++--------- 1 file changed, 127 insertions(+), 116 deletions(-) diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index d1bf87adb..d1cfe8ebf 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -34,7 +34,7 @@ import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; export function PbnstBuseForm({ data }: { data: fcBizType[] }) { // const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null); - const ref = useRef<ppInstlType[] |null>( null); + const ref = useRef<ppInstlType[] | null>(null); const { code, pbnst, pbnstBizData } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [getBizCycle, setBizCycle] = useState("1"); @@ -72,12 +72,19 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { const formData = form.watch() - formData.pplInstls = ref.current? [...ref.current]:[] // ← form 내부 상태 기준으로 복사 + formData.pplInstls = ref.current ? [...ref.current] : [] // ← form 내부 상태 기준으로 복사 console.log("formData pplReg", formData) pbnstBizData(formData as fcBizType); }, [form.formState]); + useEffect(() => { + + if (ppiYn === "N") { + form.setValue('pplInstls', []) + } + }, [ppiYn, pbnst.pplInstlsHeadLisat]) + useEffect(() => { console.log("pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData); }, [pbnst.pbnstMngRegData]); @@ -89,8 +96,8 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }; const plusHist = () => { - const regData ={ - ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk??"", + const regData = { + ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? "", choose: false, ppMqlt: "", pdmt: '', @@ -107,7 +114,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }; const plusArray = () => { - + } const removeSelected = () => { @@ -119,17 +126,17 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }; useEffect(() => { - - if(getBizCycle){ + + if (getBizCycle) { const index = Number(getBizCycle) - 1; form.reset(pbnst.pbnstResObj?.fcBizs[index]); ref.current = pbnst.pbnstResObj?.fcBizs[index]?.pplInstls ?? []; } - }, [getBizCycle,pbnst.pbnstResObj]); - + }, [getBizCycle, pbnst.pbnstResObj]); + useEffect(() => { const ppl = []; if (code.pplLenght) { @@ -218,116 +225,120 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { sonClass="col-span-4" /> - <h1 className={formH1Class}>재이용 원수취수 현황</h1> - <div> - <div className="text-right mb-3"> - <Button - type="button" - onClick={ - // () => { - // setIsFcOrgwts(true) - // setModalData(modalData) - // } - buttonClick - } - size={commonButonSize} - className=""> - 추가등록 - </Button> - </div> - <RuseMngTable + <h1 className={formH1Class}>재이용 원수취수 현황</h1> + <div> + <div className="text-right mb-3"> + <Button + type="button" + onClick={ + // () => { + // setIsFcOrgwts(true) + // setModalData(modalData) + // } + buttonClick + } + size={commonButonSize} + className=""> + 추가등록 + </Button> + </div> + <RuseMngTable tableData={fcOrgwtFiled} - headList={pbnst.pbnstOrgwtHeadList} - upHeadList={[]} /> - </div> - <h1 className={formH1Class}>재이용 공급관로 설치 현황</h1> - <div className="flex items-center gap-4 mx-3 mb-3"> - <Label className="text-right">공급관로설치유무</Label> - <SelectBox - label="" - selectArray={code.yn} - value={ppiYn} - className="w-32" - selectClass="w-full" - onSelectValue={(val) => setPpiYn(String(val))} - /> - <Label className="text-right">합계</Label> - <Input - type="text" - value={sumCpct} - readOnly={true} - className="w-32 border-gray-300 rounded pr-8 " - /> - <Button - type="button" - size={commonButonSize} - className="!text-xl" - onClick={plusHist} - > - 추가등록 - </Button> - <Button - type="button" - size={commonButonSize} - className="!text-xl !bg-red-500 !text-white ml-1" - onClick={removeSelected} - > - 삭제 - </Button> - </div> - <div> - <RuseMngTable - tableData={pplInstls} - headList={pbnst.pplInstlsHeadLisat} - code={ppiSelectList ?? []} - ref={ref} - upHeadList={[]} - onTableSet={(val) => { - if (!ref.current) return; - let sum = 0; - ref.current.forEach(item => { - sum += Number(item.cpct) || 0; - }); - setSumCpct(sum); - }} - /> - </div> - - <MngRegFormDetail - formList={ruseWaterQulityList} - h1Title={"하수처리수 재이용시설 보증수질"} - form={form} - moClass="grid grid-cols-12 gap-4" - sonClass="col-span-4" - /> - - <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> - <div> - <div className="text-right mb-3"> - <Input - type="text" - className="!text-xl w-1/3" - onClick={plusArray} - placeholder="수요처 추가" - > - </Input> + headList={pbnst.pbnstOrgwtHeadList} + upHeadList={[]} /> + </div> + <h1 className={formH1Class}>재이용 공급관로 설치 현황</h1> + <div className="flex items-center gap-4 mx-3 mb-3"> + <Label className="text-right">공급관로설치유무</Label> + <SelectBox + label="" + selectArray={code.yn} + value={ppiYn} + className="w-32" + selectClass="w-full" + onSelectValue={(val) => setPpiYn(String(val))} + /> + <Label className="text-right">합계</Label> + <Input + type="text" + value={sumCpct} + readOnly={true} + className="w-32 border-gray-300 rounded pr-8 " + /> + {ppiYn === 'Y' ? <> + <Button + type="button" + size={commonButonSize} + className="!text-xl" + onClick={plusHist} + > + 추가등록 + </Button> + <Button + type="button" + size={commonButonSize} + className="!text-xl !bg-red-500 !text-white ml-1" + onClick={removeSelected} + > + 삭제 + </Button> + </> : <> + </> + } + </div> + <div> + <RuseMngTable + tableData={pplInstls} + headList={pbnst.pplInstlsHeadLisat} + code={ppiSelectList ?? []} + ref={ref} + upHeadList={[]} + onTableSet={(val) => { + if (!ref.current) return; + let sum = 0; + ref.current.forEach(item => { + sum += Number(item.cpct) || 0; + }); + setSumCpct(sum); + }} + /> </div> - <RuseMngTable - tableData={[]} - headList={pbnst.pbnstDemandHeadList} - /> - </div> - </form> - </Form> - </div> - <UiModal - open={isFcOrgwts} - onOpenChange={(open: boolean) => setIsFcOrgwts(open)} - bodyClass={"w-[50vw] max-w-none h-[60vh]"} - body={<FcOrgwtsRegModal data={modalData ? [modalData] : []} onRightSet={(val) => { console.log("val", val); return {}; }} ></FcOrgwtsRegModal>} - ></UiModal> - </div> + <MngRegFormDetail + formList={ruseWaterQulityList} + h1Title={"하수처리수 재이용시설 보증수질"} + form={form} + moClass="grid grid-cols-12 gap-4" + sonClass="col-span-4" + /> + + <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> + <div> + <div className="text-right mb-3"> + <Input + type="text" + className="!text-xl w-1/3" + onClick={plusArray} + placeholder="수요처 추가" + > + </Input> + </div> + <RuseMngTable + tableData={[]} + headList={pbnst.pbnstDemandHeadList} + /> + </div> + </form> + </Form> + </div> + + <UiModal + open={isFcOrgwts} + onOpenChange={(open: boolean) => setIsFcOrgwts(open)} + bodyClass={"w-[50vw] max-w-none h-[60vh]"} + body={<FcOrgwtsRegModal data={modalData ? [modalData] : []} onRightSet={(val) => { console.log("val", val); return {}; }} ></FcOrgwtsRegModal>} + ></UiModal> + </div> </> ); } From 858486c36a2e09c12118f6e6c86e107eb0e77853 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Fri, 30 May 2025 17:00:31 +0900 Subject: [PATCH 40/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=ED=8F=BC?= =?UTF-8?q?=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20=EB=B0=8F=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 10 +++++++ .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 30 ++++++++++++------- .../mngRegFormDetail/mngRegFormDetail.tsx | 4 +-- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index c3c2af5e4..07cbe401f 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -64,6 +64,16 @@ export const fcOrgwtsHeadListExport: TableUpperProps[] = [ { id: "addr", title: "위치" }, ]; +export const dmdCoList: formDetailType[] = [ + { id: "dmdCoNm", lable: "수요처명" }, + { id: "daddr", lable: "위치(주소)" }, + { id: "useUsgCd", lable: "사용용도" }, + { id: "splyBgngDay", lable: "공급시작일", type: "date" }, + { id: "splyEndDay", lable: "공급종료일", type: "date" }, + { id: "splyCpct", lable: "(계약)공급량(m3/일)" }, + { id: "splyFmYn", lable: "공급 유량계 유무", type: "selectYn" }, +]; + export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, ]; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index d1cfe8ebf..4e704c21c 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -5,6 +5,7 @@ import { businessMoneyInfo, businessSttnInfo, concentratedWaterInfo, + dmdCoList, ruseFcltinfo, ruseWaterQulityList, wasteWaterFcltINfo, @@ -312,22 +313,29 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { sonClass="col-span-4" /> - <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> + {/* <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> */} <div> <div className="text-right mb-3"> - <Input - type="text" - className="!text-xl w-1/3" - onClick={plusArray} - placeholder="수요처 추가" - > - </Input> + <Button + type="button" + onClick={() => {}} + size={commonButonSize} + className=""> + 수요처 추가 + </Button> </div> - <RuseMngTable + <MngRegFormDetail + formList={dmdCoList} + h1Title={"하수처리수 재이용수 수요처"} + form={form} + moClass="grid grid-cols-12 gap-4 mt-3" + sonClass="col-span-4" + /> + {/* <RuseMngTable tableData={[]} headList={pbnst.pbnstDemandHeadList} - /> - </div> + /> */} + </div> </form> </Form> </div> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 5d9d1fee5..85dde2e3c 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -14,7 +14,7 @@ export default function MngRegFormDetail({ cycle, }: { formList: formDetailType[]; - h1Title: string; + h1Title?: string; form: any; moClass?: string; cycle?:string @@ -23,7 +23,7 @@ export default function MngRegFormDetail({ const { code, } = useWrStore((state) => state); return ( <> - <h1 className={formH1Class}>{h1Title}</h1> + { h1Title ? <h1 className={formH1Class}>{h1Title}</h1> : <></>} <div className={moClass}> {formList?.map((item, index) => { From 65ab4ea5633384e78ebe9add89ae5da6bc5a4076 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Fri, 30 May 2025 17:01:34 +0900 Subject: [PATCH 41/62] Co-authored-by: truthplumage <truthplumage@users.noreply.github.com> --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 12 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 12 +- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 4 +- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 134 ++++++++++++------ .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 3 +- 5 files changed, 109 insertions(+), 56 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index e1f62c313..d7fb33b4c 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -23,7 +23,7 @@ import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnst import { Toaster } from "react-hot-toast"; export default function PublicReuseFaciltyInsert() { - const { code, pbnst, pubHasuInit,pbnstRegInit } = useWrStore((state) => state); + const { code, pbnst, pubHasuInit,pbnstRegInit,pbnstMngData } = useWrStore((state) => state); const { pubFacHeadList,pbnstHasuRes, pbnstRes } = pbnst; const [currentTab, setCurrentTab] = useState<string>("mng"); const [fcltMng, setFcltMng] = useState<ruseFcltType[]>(); @@ -60,9 +60,7 @@ useEffect(() => { if (selectRow) { setSelectedRow(selectRow); } - - console.log('selectRow ', selectRow) pbnstRegInit(selectRow) // setSelectBdst(pbnstRes); @@ -109,7 +107,11 @@ useEffect(() => { <Button size={"sm"} className="" - onClick={() => setIsNewReg(!issNewReg) } + onClick={() => { + pbnstMngData([] as customPbnst[] ) + setIsNewReg(!issNewReg) + + } } > 신규등록 </Button> @@ -148,7 +150,7 @@ useEffect(() => { </Button> </TabsList> <TabsContent className="max-h-full" value="mng"> - <PbnstMngForm data={selectBdst || null} /> + <PbnstMngForm formType="update" /> </TabsContent> <TabsContent className="max-h-full" value="buse"> <PbnstBuseForm data={pbnstBiz || []} /> diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 387368827..fb47d1f53 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -37,6 +37,7 @@ const fcOrgwtsHeadList = fcOrgwtsHeadListExport; export type pubFacState = { pbnst: { isInit: boolean; + isReginit:boolean; pubFacHeadList: TableUpperProps[]; pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; @@ -61,7 +62,8 @@ type pubFacActions = { fileDownLoad: (atflCd: string) => void; pbnstMngData: (data: customPbnst[]) => void; pbnstBizData(data: fcBizType): void; - getBizCycle: (pbnstObj: customPbnst) => void; + getBizCycle: (pbnstObj: customPbnst) => void; + pbnstRegFormInit:()=>void }; export type pubFacType = pubFacState & pubFacActions; @@ -69,6 +71,7 @@ export type pubFacType = pubFacState & pubFacActions; export const pubFacStateExport: pubFacState = { pbnst: { isInit: false, + isReginit:false, pubFacHeadList: pubFacHeadList, pbnstMngUpHeadList: pbnstMngUpHeadList, pbnstMngNm: pbnstMngNm, @@ -242,6 +245,13 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { return state; }); }, + pbnstRegFormInit:()=>{ + return set((state: pubFacState) => { + + return state.pbnst.pbnstMngRegData; + }); + + }, pbnstBizData: (data: fcBizType) => { return set((state: pubFacState) => { if (state.pbnst.pbnstMngRegData) { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index daaaaab98..ae2749c84 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -96,7 +96,7 @@ const fcOrgwtSchema = z.object({ export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: z.number().default(1), - pbnstRuseFcltFk: z.number().nullish(), + pbnstRuseFcltFk: z.string().nullish(), superkey: z.string().default("").nullish(), cycl: z.number(), seCd: z.string(), @@ -167,7 +167,7 @@ export const fcBizSchema = z.object({ }); export const pbnstRegZod = z.object({ - pbnstRuseFcltPk: z.number().default(1), + pbnstRuseFcltPk: z.string().default(''), swtrmtFcltFk: z.string().default(""), superkey:z.string().default(""), ruseUtztnFcltNm: z.string().default(""), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 9dcd9b5e5..865f7cbb1 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -33,22 +33,30 @@ export type FilesType = { file: File; }; - export function PbnstMngForm({ data }: { data: customPbnst[] }) { - const { pbnst, pbnstUpdate ,pbnstMngData, fileDelete,getBizCycle} = useWrStore((state) => state); - - +export function PbnstMngForm({ + formType, + firstFcltData, +}: { + formType: string; + firstFcltData?: customPbnst; +}) { + const { pbnst, pbnstUpdate, pbnstMngData, fileDelete, getBizCycle,pbnstRegFormInit } = + useWrStore((state) => state); const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null); - const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); + const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null); - const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null); + const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null); + const [progress, setProgress] = useState(0); //const new File([] as BlobPart[], "") 파일 다운로드 활용 - const ref = useRef<operType[] | null>( null); + const ref = useRef<operType[] | null>(null); + + const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), - defaultValues: pbnstRegZod.parse({}), + defaultValues: formType === 'reg' && pbnst.pbnstMngRegData ? pbnst.pbnstMngRegData[0] : pbnstRegZod.parse({}), }); const { fields: fcOpersField, @@ -59,20 +67,19 @@ export type FilesType = { name: "fcOpers", }); - - const handleProgress = (percentage: string) => { setProgress(Number(percentage)); }; - const selectFclt = (val: number) => { if (pbnst.pbnstRes && pbnst.pbnstRes[val]) { - getBizCycle(pbnst.pbnstRes[val]) - form.reset(pbnst.pbnstRes[val]) + //시설 선택시 데이터 초기화 + getBizCycle(pbnst.pbnstRes[val]); + ref.current = pbnst.pbnstRes[val].fcOpers; + form.reset(pbnst.pbnstRes[val]); + } }; -} const fileDownload = (index: number) => {}; const plusHist = () => { const regData = { @@ -160,50 +167,58 @@ export type FilesType = { fileKnd: string, regFile: fcFileType[] ) => { - const planDatas = regFile?.filter((item) => item.fileKnd !== fileKnd) || []; - const data = files.map((item) => ({ + const exFileDatas = + regFile?.filter((item) => item.fileKnd !== fileKnd) || []; + const currentdata = files.map((item) => ({ fileTkn: item.atflCd, filePath: item.file.name, fileKnd: fileKnd, rgtr: TEST_UUID, mdfr: TEST_UUID, })); - return [...planDatas, ...data]; - } + return [...exFileDatas, ...currentdata]; + }; + + // 등록할때 신규 값을 계속 가지고 있으려고 + useEffect(() => { + if ( + firstFcltData && + (form.getValues("swtrmtFcltFk") === "" || + form.getValues("swtrmtFcltFk") === undefined) + ) { + + form.setValue("swtrmtFcltFk", firstFcltData.swtrmtFcltFk); + form.setValue( + "pbnstRuseFcltPk", + String(firstFcltData.swtrmtFcltFk + "1") + ); + } + }, [firstFcltData]); useEffect(() => { const formData = form.watch(); + + console.log('formData ', formData) formData.fcOpers = ref.current ? [...ref.current] : []; formData.fcFiles = regFileList ? [...regFileList] : []; - pbnstMngData([formData] as customPbnst[]); }, [form.formState, regFileList]); + useEffect(() => { pbnstMngData(pbnst.pbnstMngRegData); }, [pbnst.pbnstMngRegData]); - useEffect(() => { - if (!data) return; - //form.reset(data); - ref.current = data[0]?.fcOpers ?? null; - }, [data]) - - - useEffect(() => { - if (!pbnst.pbnstRes) return; - const fcltNmList = pbnst.pbnstRes.map((item, index) => ({ + const fcltNmList = pbnst.pbnstRes.map((item, index) => ({ text: item.ruseUtztnFcltNm, - val: String(index) - })) + val: String(index), + })); - console.log('fcltNmList ', fcltNmList) - setFcltNm(fcltNmList) - - }, [pbnst.pbnstRes]) + setFcltNm(fcltNmList); + }, [pbnst.pbnstRes]); // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { @@ -213,8 +228,10 @@ export type FilesType = { pbnstUpdate(values); } - - + useEffect(() => { + console.log("form errors:", form.formState.errors); + }, [form.formState.errors]); + useEffect(() => { if (relationfiles) { setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || [])); @@ -237,15 +254,40 @@ export type FilesType = { <form onSubmit={form.handleSubmit(onSubmit)}> <div className="flex justify-between items-center mx-3 mb-3"> <div className="col-span-2 flex items-top"> - <Label className={formTableName + "pr-3 col-span-2 "}>재이용 시설명</Label> - <SelectBox - label="" - className="mt-4 ml-2" - selectClass={undefined} - selectArray={fcltNm ?? []} - onSelectValue={(val) => {selectFclt( Number(val))}} - value={""} - /> + <Label className={formTableName + "pr-3 col-span-2 "}> + 재이용 시설명 + </Label> + + {formType === "reg" ? ( + <FormField + control={form.control} + name="ruseUtztnFcltNm" + render={({ field }) => ( + <FormUi label=""> + <Input + className="!text-2xl" + placeholder="" + type="text" + onChange={(e) => { + field.onChange(String(e.target.value)); + }} + value={field.value} + /> + </FormUi> + )} + /> + ) : ( + <SelectBox + label="" + className="mt-4 ml-2" + selectClass={undefined} + selectArray={fcltNm ?? []} + onSelectValue={(val) => { + selectFclt(Number(val)); + }} + value={""} + /> + )} </div> <Button type="submit" size={commonButonSize}> diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index ead010fa0..3841a7fd8 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -51,7 +51,6 @@ const pbnstRegTotal = ()=>{ let regData = { swtrmtFcltFk: String(data.bscFctCd ), pbnstRuseFcltPk: String(data.bscFctCd + "1"), - ruseUtztnFcltNm: data.bscFctNm, fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "1") ,cycl:1 } as unknown as fcBizType], }; @@ -86,7 +85,7 @@ const pbnstRegTotal = ()=>{ </Button> </TabsList> <TabsContent className="max-h-full" value="mng"> - <PbnstMngForm data={pbnstBdstForm} /> + <PbnstMngForm formType={'reg'} firstFcltData={pbnstBdstForm} /> </TabsContent> <TabsContent className="max-h-full" value="buse"> <PbnstBuseForm data={pbnstBdstForm.fcBizs} /> From 690c135b90735cecd990f9a2062ee7d7491d07a3 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Mon, 2 Jun 2025 10:59:18 +0900 Subject: [PATCH 42/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EA=B0=9D=EC=B2=B4=EC=B4=88?= =?UTF-8?q?=EA=B8=B0=ED=99=94=20=EB=B0=8F=20=ED=8C=8C=EC=9D=BC=20=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 143 ++++++++------ .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 53 +++-- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 102 ++++++---- apps/wr/components/lib/api/index.ts | 26 ++- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 187 ++++++++++-------- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 129 ++++++++---- .../fcOrgwtsRegModal/fcOrgwtsRegModal.tsx | 32 ++- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 55 +++--- apps/wr/middleware.ts | 21 +- 9 files changed, 447 insertions(+), 301 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index d7fb33b4c..70f41af7b 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -15,74 +15,75 @@ import { Tabs, TabsList, TabsTrigger, TabsContent } from "@common/components"; import { useEffect, useState } from "react"; import ListDiv from "@common/business_components/ui/list_div"; import { tableData } from "@/components/lib/func/commom"; -import type { customPbnst, fcBizSchema, fcBizType, pubHasuType, ruseFcltType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import type { + customPbnst, + fcBizSchema, + fcBizType, + pubHasuType, + ruseFcltType, +} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; import { z } from "zod"; import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal"; import { Toaster } from "react-hot-toast"; +import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; export default function PublicReuseFaciltyInsert() { - const { code, pbnst, pubHasuInit,pbnstRegInit,pbnstMngData } = useWrStore((state) => state); - const { pubFacHeadList,pbnstHasuRes, pbnstRes } = pbnst; + const { + code, + pbnst, + searchFclts, + pubHasuInit, + pbnstRegInit, + getSwtrmtFcltNm, + pbnstMngData, + } = useWrStore((state) => state); + const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; const [currentTab, setCurrentTab] = useState<string>("mng"); - const [fcltMng, setFcltMng] = useState<ruseFcltType[]>(); const [pbnstBiz, setPbnstBiz] = useState<fcBizType[]>(); - const [issNewReg, setIsNewReg] = useState<boolean>(false); + const [isRuseReg, setIsRuseReg] = useState<{ + isModal: boolean; + data: pubHasuType; + }>({ isModal: false, data: {} as pubHasuType }); const [searchTxt, setSearchTxt] = useState<string>(); const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); - const [selectedRow, setSelectedRow] = useState<pubHasuType | null>(null); -useEffect(() => { - if (!pbnst.isInit ) { - pubHasuInit('1','11'); - - ///pbnstRegInit( '41'); + useEffect(() => { + if (!pbnst.isInit) { + pubHasuInit("1", "11"); } }, [pbnst.isInit, pubHasuInit]); -useEffect(() => { - - - if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { - setbdstTable(tableData(pbnstHasuRes, { code })); + useEffect(() => { + if(code.sggCd.length){ + if(searchFclts){ + setbdstTable(tableData(searchFclts, { code })); + }else if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { + setbdstTable(tableData(pbnstHasuRes, { code })); + } } - }, [code, pbnstHasuRes]); + }, [code, pbnstHasuRes,searchFclts]); - const onSelectValue = (val: string) => { - console.log(val); - }; const cellClick = (val: number | undefined) => { if (val === undefined) return; const selectRow = pbnstHasuRes?.[val]; if (selectRow) { - setSelectedRow(selectRow); + setIsRuseReg({ ...isRuseReg, data: selectRow }); + pbnstRegInit(selectRow); } - - pbnstRegInit(selectRow) - - // setSelectBdst(pbnstRes); - // setPbnstBiz(pbnstRes?.fcBizs) - }; - const resetContents = () => { - setFcltMng([]); // 빈 배열로 설정하여 신규 모드로 전환 }; const handleTabChange = (value: string) => { setCurrentTab(value); }; - useEffect(() => { - - console.log("pbnstBiz", pbnstBiz); - },[pbnstBiz]) - return ( <> <ContentsDiv> - <div className="grid grid-cols-4 gap-4"> + <div className="grid grid-cols-4 gap-4"> <div className="col-span-4"> <Title title={"하수재이용 시설 등록"} /> <SearchDiv> @@ -100,6 +101,9 @@ useEffect(() => { className="" size={"sm"} onClick={(e) => { + searchTxt && searchTxt?.length > 0 + ? getSwtrmtFcltNm(searchTxt) + : pubHasuInit("1", "11") }} > 조회 @@ -108,10 +112,14 @@ useEffect(() => { size={"sm"} className="" onClick={() => { - pbnstMngData([] as customPbnst[] ) - setIsNewReg(!issNewReg) - - } } + pbnstMngData([] as customPbnst[]); + isRuseReg.data.bscFctCd + ? setIsRuseReg({ ...isRuseReg, isModal: true }) + : ToastFormUi({ + body: "하수리시시설을 테이블을 선택하고 등록버튼을 눌러주세요", + title: "재이용시설 등록", + }); + }} > 신규등록 </Button> @@ -125,52 +133,57 @@ useEffect(() => { <div className="col-span-4 h-full min-h-0"> <ListDiv className="min-h-0"> <ScrollArea className="h-[60vh]"> - <UiTable + <UiTable tableData={bdstTable || []} headlist={pubFacHeadList} pageSize={100} total={10} headName={"공공 하수처리시설 등록"} cellClick={cellClick} - onPageChange={(page: number) => { } } children={undefined} /> - </ScrollArea> + onPageChange={(page: number) => {}} + children={undefined} + /> + </ScrollArea> </ListDiv> </div> <ListDiv className="col-span-2 pr-6 "> - - <ScrollArea className="h-[60vh]"> - - - <Tabs defaultValue="mng" onValueChange={handleTabChange}> - <TabsList className=""> - <TabsTrigger className="!text-xl" value="mng">시설정보</TabsTrigger> - <TabsTrigger className="!text-xl" value="buse">차수별정보</TabsTrigger> - <Button size={"sm"} className="!justify-end"> - 저장 + <ScrollArea className="h-[60vh]"> + <Tabs defaultValue="mng" onValueChange={handleTabChange}> + <TabsList className=""> + <TabsTrigger className="!text-xl" value="mng"> + 시설정보 + </TabsTrigger> + <TabsTrigger className="!text-xl" value="buse"> + 차수별정보 + </TabsTrigger> + <Button size={"sm"} className="!justify-end"> + 저장 </Button> </TabsList> - <TabsContent className="max-h-full" value="mng"> + <TabsContent className="max-h-full" value="mng"> <PbnstMngForm formType="update" /> - </TabsContent> - <TabsContent className="max-h-full" value="buse"> - <PbnstBuseForm data={pbnstBiz || []} /> - </TabsContent> - </Tabs> - </ScrollArea> + </TabsContent> + <TabsContent className="max-h-full" value="buse"> + <PbnstBuseForm formType="update" /> + </TabsContent> + </Tabs> + </ScrollArea> </ListDiv> <UiModal - body={<PbnstRegModal data={selectedRow || []}></PbnstRegModal>} + body={ + <PbnstRegModal + data={isRuseReg.data || ({} as customPbnst)} + ></PbnstRegModal> + } bodyClass="w-[68vw] max-w-none h-[90vh]" - open={issNewReg} + open={isRuseReg.isModal} onOpenChange={(open) => { - setIsNewReg(open); + setIsRuseReg({ data: {} as pubHasuType, isModal: open }); }} /> </div> - <Toaster position="top-center" /> + <Toaster position="top-center" /> </ContentsDiv> </> ); } - - diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index fb47d1f53..fde9fc79d 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -12,6 +12,7 @@ import { fcBizSchema, type customPbnst, type fcBizType, + type PbnstUpdateIndex, type pubHasuType, } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; @@ -37,7 +38,6 @@ const fcOrgwtsHeadList = fcOrgwtsHeadListExport; export type pubFacState = { pbnst: { isInit: boolean; - isReginit:boolean; pubFacHeadList: TableUpperProps[]; pbnstMngUpHeadList: TableUpperProps[]; pbnstMngNm: chHeadType[]; @@ -51,6 +51,8 @@ export type pubFacState = { pbnstDemandHeadList: TableUpperProps[]; fcOrgwtsHeadList: TableUpperProps[]; pbnstMngRegData: customPbnst[]; + pbnsUpdateIndex: PbnstUpdateIndex; + dmdComList:any[] }; }; type pubFacActions = { @@ -63,7 +65,8 @@ type pubFacActions = { pbnstMngData: (data: customPbnst[]) => void; pbnstBizData(data: fcBizType): void; getBizCycle: (pbnstObj: customPbnst) => void; - pbnstRegFormInit:()=>void + getDmdCompany:(txt :string)=>void; + getPbnstUpdateIndex: (data: PbnstUpdateIndex) => void; }; export type pubFacType = pubFacState & pubFacActions; @@ -71,7 +74,6 @@ export type pubFacType = pubFacState & pubFacActions; export const pubFacStateExport: pubFacState = { pbnst: { isInit: false, - isReginit:false, pubFacHeadList: pubFacHeadList, pbnstMngUpHeadList: pbnstMngUpHeadList, pbnstMngNm: pbnstMngNm, @@ -85,6 +87,8 @@ export const pubFacStateExport: pubFacState = { pbnstDemandHeadList: pbnstDemandHeadList, fcOrgwtsHeadList: fcOrgwtsHeadList, pbnstMngRegData: [], + pbnsUpdateIndex : {} as PbnstUpdateIndex, + dmdComList:[] }, }; @@ -229,7 +233,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { try { const response = await getFetch( fetchType.CS, - `/api/v1/atflcd/download/${atflCd}` + `/attach-service/api/v1/atflcd/download/${atflCd}` ); if (!response.ok) { @@ -239,21 +243,24 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { console.error("Error downloading file:", error); } }, + pbnstMngData: (data: customPbnst[]) => { + if(data.length > 0){ + + + } + return set((state: pubFacState) => { state.pbnst.pbnstMngRegData = data; + state.pbnst.pbnstBizCycle=data.length <=0 ? [{ text: "없음", val: "1" }] : state.pbnst.pbnstBizCycle return state; }); }, - pbnstRegFormInit:()=>{ - return set((state: pubFacState) => { - - return state.pbnst.pbnstMngRegData; - }); - - }, + pbnstBizData: (data: fcBizType) => { return set((state: pubFacState) => { + + if (state.pbnst.pbnstMngRegData) { const regData = state.pbnst.pbnstMngRegData.find( (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk @@ -262,6 +269,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { const bizIdx = regData.fcBizs.findIndex( (item) => item.pbnstRuseFcltBizPk == data.pbnstRuseFcltBizPk ); + if (bizIdx >= 0) { regData.fcBizs[bizIdx] = data; } @@ -269,6 +277,25 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } return state; }); - }, - }; + },getDmdCompany: async (txt:string)=>{ + + const company = await getFetch( + fetchType.WR, + `/reuseFc/request/${txt}/3`) + + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + isInit: false, + }, + + })) + },getPbnstUpdateIndex:async(data : PbnstUpdateIndex)=>{ + return set((state: pubFacState) => { + state.pbnst.pbnsUpdateIndex = data + return state; + } + )} + }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index ae2749c84..be758c87c 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -14,6 +14,11 @@ export type selectLabel = { val: string; }; +export type PbnstUpdateIndex ={ + mng:number, + biz:number +} + export type publicReuseFacilityType = { sido: string; sigungo: string; @@ -80,7 +85,7 @@ const fcOperSchema = z.object({ }); const fcOrgwtSchema = z.object({ - pbnstRuseFcltBizFk: z.number().nullish(), + pbnstRuseFcltBizFk: z.string().nullish(), swtrmtFcltFk: z.number().default(0), orgwtWtritQnt: z.number(), tmsYn: z.enum(["Y", "N"] ).default("N"), @@ -98,9 +103,9 @@ export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: z.number().default(1), pbnstRuseFcltFk: z.string().nullish(), superkey: z.string().default("").nullish(), - cycl: z.number(), - seCd: z.string(), - bizMthdCd: z.string(), + cycl: z.number().default(1), + seCd: z.string().default(""), + bizMthdCd: z.string().default(""), instlAprvSncnDt: z.date().nullish(), bizCmcnDay: z.date().nullish(), gvsbs: z.number().default(0), @@ -108,31 +113,31 @@ export const fcBizSchema = z.object({ cusrAlotm: z.number().default(0), etc: z.string().default(''), totalMoney: z.number().default(0).nullish(), - rprcsFcltCpct: z.number(), - majorPrcsMsrcCd: z.string(), - addr: z.string(), - rprcsMthdCd: z.string(), - inoutYn: z.enum(["Y", "N"]), + rprcsFcltCpct: z.number().default(0), + majorPrcsMsrcCd: z.string().default(""), + addr: z.string().default(''), + rprcsMthdCd: z.string().default(""), + inoutYn: z.enum(["Y", "N"]).default("Y"), mainSplyPumpCpct: z.number().nullish(), erctWtrOcrnCpct: z.number().nullish(), erctUswtrLinkSpt: z.string().nullish(), erctUswtrFcltCpct: z.number().nullish(), erctUswtrPrcsMeth: z.string().nullish(), erctUswtrPrcsMsrcCd: z.string().nullish(), - wwtEmsnFcltPrmsnYn: z.enum(["Y", "N"]), - tmsInstlYn: z.enum(["Y", "N"]), - pbnstDrngInflwExclYn: z.enum(["Y", "N"]), - bod: z.number(), - grssClfg: z.number(), - combResdch: z.number(), - trbt: z.number(), - clIonQnt: z.number(), - smll: z.number(), - crmty: z.number(), - tph: z.number(), - tn: z.number(), - ph: z.number(), - cdtnv: z.number(), + wwtEmsnFcltPrmsnYn: z.enum(["Y", "N"]).default("Y"), + tmsInstlYn: z.enum(["Y", "N"]).default("Y"), + pbnstDrngInflwExclYn: z.enum(["Y", "N"]).default("Y"), + bod: z.number().default(0), + grssClfg: z.number().default(0), + combResdch: z.number().default(0), + trbt: z.number().default(0), + clIonQnt: z.number().default(0), + smll: z.number().default(0), + crmty: z.number().default(0), + tph: z.number().default(0), + tn: z.number().default(0), + ph: z.number().default(0), + cdtnv: z.number().default(0), designCst: z.number().nullish(), cstrnSpvsCst: z.number().nullish(), fcltSbsdCst: z.number().nullish(), @@ -150,26 +155,52 @@ export const fcBizSchema = z.object({ fcltSbsdCstClcln: z.number().nullish(), wstCstClcln: z.number().nullish(), cnstCmcnCstClcln: z.number().nullish(), - mntrgEqpmntInstlCstClcln: z.number(), + mntrgEqpmntInstlCstClcln: z.number().default(0), gisDbCstClcln: z.number().nullish(), elpwrMtrngCstClcln: z.number().nullish(), mchnCstClcln: z.number().nullish(), archCstClcln: z.number().nullish(), pplCstClcln: z.number().nullish(), ruseFcltCstClcln: z.number().nullish(), - fcOrgwts: z.array(fcOrgwtSchema), - pplInstls: z.array(pplInstlSchema), + fcOrgwts: z.array(fcOrgwtSchema).nullish(), + pplInstls: z.array(pplInstlSchema).nullish(), flg: z.string().nullish(), regDt: z.string().nullish(), - rgtr: z.string(), + rgtr: z.string().nullish(), mdfcnDt: z.string().nullish(), - mdfr: z.string(), + mdfr: z.string().nullish(), }); + +const pubHasuZod = z.object({ + choose: z.boolean().default(false), + bscFctCd: z.string(), + sido: z.string().default(""), + gugun: z.string().default(""), + bscFctNm: z.string().default(""), + efflWqltStndrdNm: z.string().default(""), + fctCpc: z.number().default(0), + addr:z.string().nullish() +}); + +export type pubHasuType = z.infer<typeof pubHasuZod>; + + + +const dmdColist = z.object({ + dmdCoNm: z.boolean().default(false), + daddr: z.string(), + useUsgCd: z.string().default(""), + splyBgngDay: z.string().default(""), + splyEndDay: z.string().default(""), + splyCpct: z.string().default(""), + splyFmYn: z.number().default(0), +}); + + export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.string().default(''), swtrmtFcltFk: z.string().default(""), - superkey:z.string().default(""), ruseUtztnFcltNm: z.string().default(""), fcltCpct: z.number().default(0), ruseCpct: z.number().default(0), @@ -181,21 +212,10 @@ export const pbnstRegZod = z.object({ fcFiles: z.array(fcFileSchema).default([]), fcBizs: z.array(fcBizSchema).default([]), fcOpers: z.array(fcOperSchema).default([]), + fcDemands: z.array(dmdColist).default([]).nullish(), hasuhasu: z.number().default(0), }); -const pubHasuZod = z.object({ - choose: z.boolean().default(false), - bscFctCd: z.string(), - sido: z.string().default(""), - gugun: z.string().default(""), - bscFctNm: z.string().default(""), - efflWqltStndrdNm: z.string().default(""), - fctCpc: z.number().default(0), -}); - -export type pubHasuType = z.infer<typeof pubHasuZod>; - //관경 제외 export const exampleData = [ { diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index 7b8507910..c2529c8a2 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -24,8 +24,30 @@ export const getFetch = async (type: string, url: string) => { if (!response.ok) { throw new Error(`오류 발생: ${response.status}`); } - const res = await response.json(); - return res.data; + const contentType = response.headers.get("content-type") ?? ""; + + if (contentType.includes("application/json")) { + // JSON 응답 처리 + const res = await response.json(); + return res.data; + } else { + // 파일 응답 처리 (ex. PDF, Excel 등) + const blob = await response.blob(); + const blobUrl = window.URL.createObjectURL(blob); + const a = document.createElement("a"); + + // 파일명 추출 (서버에서 header에 Content-Disposition을 보낼 경우 활용) + const disposition = response.headers.get("Content-Disposition"); + const match = disposition?.match(/filename="?(.+)"?/); + const filename = match?.[1] || "downloaded_file"; + + a.href = blobUrl; + a.download = filename; + a.click(); + window.URL.revokeObjectURL(blobUrl); + + return null; // 다운로드이므로 반환값 없음 + } }; export const postFectch = async (url: string, params: any, type?: string) => { diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 4e704c21c..620f93803 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -13,7 +13,6 @@ import { import { fcBizSchema, type fcBizType, - type fcOrgwtType, type ppInstlType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; @@ -33,21 +32,36 @@ import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; -export function PbnstBuseForm({ data }: { data: fcBizType[] }) { - // const ref = useRef<ppInstlType[] | null>(data[0]?.pplInstls ?? null); +export function PbnstBuseForm({ + formType, + firstBizData, +}: { + formType: string; + firstBizData?: fcBizType[]; +}) { const ref = useRef<ppInstlType[] | null>(null); - const { code, pbnst, pbnstBizData } = useWrStore((state) => state); + const { code, pbnst, pbnstBizData ,getPbnstUpdateIndex} = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [getBizCycle, setBizCycle] = useState("1"); const [ppiSelectList, setPpiSelectList] = useState<[{ name: string; val: SelectDataType[] }]>(); const [ppiYn, setPpiYn] = useState("Y"); const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); - const [modalData, setModalData] = useState<fcOrgwtType | null>(null); const [sumCpct, setSumCpct] = useState<number>(0); const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), + defaultValues: + formType === "reg" && + pbnst.pbnstMngRegData && + pbnst.pbnstMngRegData[0]?.fcBizs + ? (pbnst.pbnstMngRegData[0].fcBizs[0] ?? {}) + : formType === "update" && + typeof pbnst.pbnsUpdateIndex.biz === "number" && + pbnst.pbnsUpdateIndex.biz >= 0 && + pbnst.pbnstRes + ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs[pbnst.pbnsUpdateIndex.biz] + : fcBizSchema.parse({}), }); // 2. Define a submit handler. @@ -69,54 +83,56 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { name: "pplInstls", }); + // 등록할때 신규 값을 계속 가지고 있으려고 useEffect(() => { - - const formData = form.watch() - - formData.pplInstls = ref.current ? [...ref.current] : [] // ← form 내부 상태 기준으로 복사 - console.log("formData pplReg", formData) - - pbnstBizData(formData as fcBizType); - }, [form.formState]); - - useEffect(() => { - - if (ppiYn === "N") { - form.setValue('pplInstls', []) + if (formType === "reg") { + if ( + firstBizData && + firstBizData[0] && + (form.getValues("pbnstRuseFcltFk") === "" || + form.getValues("pbnstRuseFcltFk") === undefined) + ) { + form.setValue( + "pbnstRuseFcltFk", + String(firstBizData[0].pbnstRuseFcltFk) + ); + form.setValue("cycl", firstBizData[0].cycl); + } + const formData = form.watch(); + formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사 + pbnstBizData(formData as fcBizType); } - }, [ppiYn, pbnst.pplInstlsHeadLisat]) + }, [firstBizData, form.formState, formType]); useEffect(() => { - console.log("pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData); - }, [pbnst.pbnstMngRegData]); + if (ppiYn === "N") { + form.setValue("pplInstls", []); + } + }, [ppiYn]); - const buttonClick = () => { - setIsFcOrgwts(true); - const moData = data[0]?.fcOrgwts?.[0] ?? null; - setModalData(moData); - }; + useEffect(() => { + console.log("pbnst. bug pbnstMngRegData ", pbnst.pbnstMngRegData); + }, [pbnst.pbnstMngRegData]); const plusHist = () => { const regData = { ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? "", choose: false, ppMqlt: "", - pdmt: '', + pdmt: "", cpct: 0, - } + }; const currentTableDataFromRef = ref.current ? [...ref.current] : []; const newDataForRHF = [...currentTableDataFromRef, regData]; form.setValue("pplInstls", newDataForRHF, { shouldValidate: true, // 필요하다면 유효성 검사 실행 - shouldDirty: true, // 폼 상태를 dirty로 변경 + shouldDirty: true, // 폼 상태를 dirty로 변경 }); const latestOpers = form.getValues("pplInstls"); ref.current = [...latestOpers]; }; - const plusArray = () => { - - } + const plusArray = () => {}; const removeSelected = () => { if (!ref.current) return; @@ -127,19 +143,15 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { }; useEffect(() => { - - - if (getBizCycle) { - + if (getBizCycle&&formType !== "reg") { const index = Number(getBizCycle) - 1; form.reset(pbnst.pbnstResObj?.fcBizs[index]); ref.current = pbnst.pbnstResObj?.fcBizs[index]?.pplInstls ?? []; } - - }, [getBizCycle, pbnst.pbnstResObj]); + }, [getBizCycle, pbnst.pbnstResObj , formType]); useEffect(() => { - const ppl = []; + const ppl = [] as { name: string; val: SelectDataType[] }[]; if (code.pplLenght) { ppl.push({ name: "pplLenght", val: code.pplLenght }); } @@ -148,12 +160,11 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { } if (ppl.length > 0) { setPpiSelectList(ppl); + } else { + setPpiSelectList(undefined); } }, [code]); - useEffect(() => { - }, [ppiSelectList]); - useEffect(() => { console.log("form errors:", form.formState.errors); }, [form.formState.errors]); @@ -172,7 +183,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <h1 className=" text-xl"></h1> <div className="flex items-center gap-2 mx-3"> <h1 className={formTableName}>등록차수</h1> - <SelectBox label="" selectArray={pbnstBizCycle} @@ -181,6 +191,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { selectClass={selectClass} onSelectValue={(val) => { setBizCycle(String(val)); + getPbnstUpdateIndex({...pbnst.pbnsUpdateIndex, biz: Number(val)}) }} ></SelectBox> @@ -196,7 +207,6 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { moClass="grid grid-cols-12 gap-4" sonClass="col-span-4" /> - <MngRegFormDetail formList={businessMoneyInfo} h1Title={"사업비"} @@ -231,22 +241,18 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { <div className="text-right mb-3"> <Button type="button" - onClick={ - // () => { - // setIsFcOrgwts(true) - // setModalData(modalData) - // } - buttonClick - } + onClick={() => setIsFcOrgwts(true)} size={commonButonSize} - className=""> + className="" + > 추가등록 </Button> </div> <RuseMngTable tableData={fcOrgwtFiled} headList={pbnst.pbnstOrgwtHeadList} - upHeadList={[]} /> + upHeadList={[]} + /> </div> <h1 className={formH1Class}>재이용 공급관로 설치 현황</h1> <div className="flex items-center gap-4 mx-3 mb-3"> @@ -266,26 +272,28 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { readOnly={true} className="w-32 border-gray-300 rounded pr-8 " /> - {ppiYn === 'Y' ? <> - <Button - type="button" - size={commonButonSize} - className="!text-xl" - onClick={plusHist} - > - 추가등록 - </Button> - <Button - type="button" - size={commonButonSize} - className="!text-xl !bg-red-500 !text-white ml-1" - onClick={removeSelected} - > - 삭제 - </Button> - </> : <> + {ppiYn === "Y" ? ( + <> + <Button + type="button" + size={commonButonSize} + className="!text-xl" + onClick={plusHist} + > + 추가등록 + </Button> + <Button + type="button" + size={commonButonSize} + className="!text-xl !bg-red-500 !text-white ml-1" + onClick={removeSelected} + > + 삭제 + </Button> </> - } + ) : ( + <></> + )} </div> <div> <RuseMngTable @@ -297,7 +305,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { onTableSet={(val) => { if (!ref.current) return; let sum = 0; - ref.current.forEach(item => { + ref.current.forEach((item) => { sum += Number(item.cpct) || 0; }); setSumCpct(sum); @@ -313,29 +321,25 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { sonClass="col-span-4" /> - {/* <h1 className={formH1Class}>하수처리수 재이용수 수요처</h1> */} <div> <div className="text-right mb-3"> <Button type="button" onClick={() => {}} size={commonButonSize} - className=""> + className="" + > 수요처 추가 </Button> </div> <MngRegFormDetail - formList={dmdCoList} - h1Title={"하수처리수 재이용수 수요처"} - form={form} - moClass="grid grid-cols-12 gap-4 mt-3" - sonClass="col-span-4" - /> - {/* <RuseMngTable - tableData={[]} - headList={pbnst.pbnstDemandHeadList} - /> */} - </div> + formList={dmdCoList} + h1Title={"하수처리수 재이용수 수요처"} + form={form} + moClass="grid grid-cols-12 gap-4 mt-3" + sonClass="col-span-4" + /> + </div> </form> </Form> </div> @@ -344,7 +348,16 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) { open={isFcOrgwts} onOpenChange={(open: boolean) => setIsFcOrgwts(open)} bodyClass={"w-[50vw] max-w-none h-[60vh]"} - body={<FcOrgwtsRegModal data={modalData ? [modalData] : []} onRightSet={(val) => { console.log("val", val); return {}; }} ></FcOrgwtsRegModal>} + body={ + <FcOrgwtsRegModal + closeModal={() => { + setIsFcOrgwts(false); + }} + onRightSet={(val) => { + form.setValue("fcOrgwts", val); + }} + ></FcOrgwtsRegModal> + } ></UiModal> </div> </> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 865f7cbb1..863b887b6 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -5,11 +5,9 @@ import { FileUpload, FormUi, SelectBox } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; import { Button, Input } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; -import { use, useEffect, useRef, useState } from "react"; +import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; -import moment from "moment"; - import { commonButonSize, formH1Class, @@ -22,7 +20,6 @@ import { type customPbnst, type fcFileType, type operType, - type ruseFcltType, type selectLabel, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; @@ -40,23 +37,37 @@ export function PbnstMngForm({ formType: string; firstFcltData?: customPbnst; }) { - const { pbnst, pbnstUpdate, pbnstMngData, fileDelete, getBizCycle,pbnstRegFormInit } = - useWrStore((state) => state); + const { + pbnst, + pbnstUpdate, + pbnstMngData, + fileDelete, + fileDownLoad, + getBizCycle, + getPbnstUpdateIndex, + } = useWrStore((state) => state); const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null); const [planFiles, setPlanFiles] = useState<FilesType[] | null>(null); const [relationfiles, setRelationFiles] = useState<FilesType[] | null>(null); const [fcltNm, setFcltNm] = useState<selectLabel[] | null>(null); + const [fcOpresData, setFcOpresData] = useState<operType[] | null>(null); const [progress, setProgress] = useState(0); //const new File([] as BlobPart[], "") 파일 다운로드 활용 - const ref = useRef<operType[] | null>(null); - const form = useForm<z.infer<typeof pbnstRegZod>>({ resolver: zodResolver(pbnstRegZod), - defaultValues: formType === 'reg' && pbnst.pbnstMngRegData ? pbnst.pbnstMngRegData[0] : pbnstRegZod.parse({}), + defaultValues: + formType === "reg" && pbnst.pbnstMngRegData + ? pbnst.pbnstMngRegData[0] + : formType === "update" && + typeof pbnst.pbnsUpdateIndex.mng === "number" && + pbnst.pbnsUpdateIndex.mng >= 0 && + pbnst.pbnstRes + ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng] + : pbnstRegZod.parse({}), }); const { fields: fcOpersField, @@ -73,11 +84,9 @@ export function PbnstMngForm({ const selectFclt = (val: number) => { if (pbnst.pbnstRes && pbnst.pbnstRes[val]) { - //시설 선택시 데이터 초기화 - getBizCycle(pbnst.pbnstRes[val]); - ref.current = pbnst.pbnstRes[val].fcOpers; form.reset(pbnst.pbnstRes[val]); + getPbnstUpdateIndex({ ...pbnst.pbnsUpdateIndex, mng: val }); } }; const fileDownload = (index: number) => {}; @@ -97,8 +106,6 @@ export function PbnstMngForm({ shouldValidate: true, // 필요하다면 유효성 검사 실행 shouldDirty: true, // 폼 상태를 dirty로 변경 }); - const latestOpers = form.getValues("fcOpers"); - ref.current = [...latestOpers]; }; const removeSelected = () => { @@ -186,25 +193,68 @@ export function PbnstMngForm({ (form.getValues("swtrmtFcltFk") === "" || form.getValues("swtrmtFcltFk") === undefined) ) { - form.setValue("swtrmtFcltFk", firstFcltData.swtrmtFcltFk); form.setValue( "pbnstRuseFcltPk", String(firstFcltData.swtrmtFcltFk + "1") ); + form.setValue("fcBizs", firstFcltData.fcBizs); } }, [firstFcltData]); - useEffect(() => { - const formData = form.watch(); + const defaultFiles = form.getValues("fcFiles"); - console.log('formData ', formData) - formData.fcOpers = ref.current ? [...ref.current] : []; - formData.fcFiles = regFileList ? [...regFileList] : []; - pbnstMngData([formData] as customPbnst[]); - }, [form.formState, regFileList]); + console.log("defaultFiles : ", defaultFiles); + if (defaultFiles && defaultFiles.length > 0) { + const relationFileList = defaultFiles.filter( + (item) => item.fileKnd === "계통도" + ); + const planFileList = defaultFiles.filter( + (item) => item.fileKnd === "평면도" + ); + if (relationFileList.length > 0) + setRelationFiles( + relationFileList.map((item) => ({ + atflCd: item.fileTkn, + file: new File([] as BlobPart[], item.filePath), + })) + ); // 또는 파일 형식 변환 로직이 있다면 여기에 추가 + + if (planFileList.length > 0) + setPlanFiles( + planFileList.map((item) => ({ + atflCd: item.fileTkn, + file: new File([] as BlobPart[], item.filePath), + })) + ); + } + }, [form.formState.defaultValues]); // 초기화 이후 1회 실행 + + // 등록할때 신규 값을 계속 가지고 있으려고 + useEffect(() => { + if ( + formType === "update" && + pbnst.pbnsUpdateIndex.biz >= 0 && + pbnst.pbnstRes + ) { + const bizData = pbnst.pbnstRes[pbnst.pbnsUpdateIndex.biz]; + + console.log(" bizData : ", bizData); + if (bizData) { + getBizCycle(bizData); + } + } + }, [pbnst.pbnsUpdateIndex, pbnst.pbnstRes, formType, getBizCycle]); + useEffect(() => { + if (formType === "reg") { + const formData = form.watch(); + formData.fcOpers = ref.current ? [...ref.current] : []; + formData.fcFiles = regFileList ? [...regFileList] : []; + pbnstMngData([formData] as customPbnst[]); + } + }, [form.formState, regFileList, formType]); useEffect(() => { pbnstMngData(pbnst.pbnstMngRegData); @@ -222,16 +272,11 @@ export function PbnstMngForm({ // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { - values.fcOpers = ref.current || []; + values.fcOpers = fcOpresData || []; values.fcFiles = regFileList || []; - console.log("form values:", values); pbnstUpdate(values); } - useEffect(() => { - console.log("form errors:", form.formState.errors); - }, [form.formState.errors]); - useEffect(() => { if (relationfiles) { setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || [])); @@ -271,7 +316,7 @@ export function PbnstMngForm({ onChange={(e) => { field.onChange(String(e.target.value)); }} - value={field.value} + value={field.value ?? ""} /> </FormUi> )} @@ -322,6 +367,9 @@ export function PbnstMngForm({ tableData={fcOpersField} headList={pbnst.pbnstMngUpHeadList} upHeadList={pbnst.pbnstMngNm} + onTableSet={(val) => { + setFcOpresData(val); + }} ref={ref} ></RuseMngTable> </div> @@ -341,7 +389,7 @@ export function PbnstMngForm({ onChange={(e) => { field.onChange(Number(e.target.value)); }} - value={field.value} + value={field.value ?? 0} /> </FormUi> )} @@ -359,7 +407,7 @@ export function PbnstMngForm({ onChange={(e) => { field.onChange(Number(e.target.value)); }} - value={field.value} + value={field.value ?? 0} /> </FormUi> )} @@ -377,7 +425,7 @@ export function PbnstMngForm({ onChange={(e) => { field.onChange(Number(e.target.value)); }} - value={field.value} + value={field.value ?? 0} /> </FormUi> )} @@ -395,7 +443,7 @@ export function PbnstMngForm({ onChange={(e) => { field.onChange(Number(e.target.value)); }} - value={field.value} + value={field.value ?? 0} /> </FormUi> )} @@ -414,7 +462,13 @@ export function PbnstMngForm({ if (files) fileHandler(files, "relation"); }} fileTypes="PDF" - onFileClick={(index) => {}} + onFileClick={(index) => { + fileDownLoad( + relationfiles?.find( + (item, fileIndex) => fileIndex === index + )?.atflCd as string + ); + }} ></FileUpload> </FormUi> </div> @@ -426,6 +480,13 @@ export function PbnstMngForm({ if (files) fileHandler(files, "plan"); }} fileTypes="PDF" + onFileClick={(index) => { + fileDownLoad( + planFiles?.find( + (item, fileIndex) => fileIndex === index + )?.atflCd as string + ); + }} ></FileUpload> </FormUi> </div> diff --git a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx index d904854f7..b04386752 100644 --- a/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal.tsx @@ -12,7 +12,7 @@ import { ArrowLeft, ArrowRight } from "lucide-react"; import { useEffect, useRef, useState } from "react"; import { useFieldArray } from "react-hook-form"; -export default function FcOrgwtsRegModal({ data, onRightSet }: { data: fcOrgwtType[], onRightSet?: (rightData:fcOrgwtType[]) => {}}) { +export default function FcOrgwtsRegModal({ onRightSet, closeModal }: { onRightSet?: (rightData:fcOrgwtType[]) => void,closeModal?:(val:boolean) =>void }) { const { code, pbnst, getSwtrmtFcltNm, searchFclts } = useWrStore((state) => state); const { fcOrgwtsHeadList, pbnstHasuRes } = pbnst; const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); @@ -36,28 +36,26 @@ export default function FcOrgwtsRegModal({ data, onRightSet }: { data: fcOrgwtTy }, [searchFclts]) useEffect(() => { - // console.log("머지", pbnstHasuRes); if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { setbdstTable(tableData(pbnstHasuRes, { code })); + + console.log('bdstTable ', bdstTable) } }, [code, pbnstHasuRes]); useEffect(() => { - if(onRightSet) + console.log('rightData ', rightData) + if(onRightSet) onRightSet( - rightData?.map(item => ({ - pbnstRuseFcltBizFk: data[0]?.pbnstRuseFcltBizFk ?? 0, - swtrmtFcltFk: item.bscFctCd, - orgwtWtritQnt: "0", - tmsYn: "N", - dschgFmYn: "N", - dtlPstnExpln: "", - rgtr: "", - mdfr: "", - regDt: undefined, - mdfcnDt: undefined, - useYn: undefined, - })) ?? [] + (rightData as pubHasuType[])?.map(item => ({ + swtrmtFcltFk: item.bscFctCd, // 임시값, 실제 데이터에 맞게 수정 + orgwtWtritQnt: Number(item.fctCpc), // 임시값, 실제 데이터에 맞게 수정 + tmsYn: "N", // 임시값, 실제 데이터에 맞게 수정 + dschgFmYn: "N", // 임시값, 실제 데이터에 맞게 수정 + dtlPstnExpln: item.addr, // 임시값, 실제 데이터에 맞게 수정 + choose: false, // 임시값, 실제 데이터에 맞게 수정 + // 필요한 경우 다른 속성들도 추가 + })) as unknown as fcOrgwtType[] ); }, [rightData]) @@ -67,7 +65,7 @@ export default function FcOrgwtsRegModal({ data, onRightSet }: { data: fcOrgwtTy <div className="flex items-center justify-between"> <Title title={"취수하수처리장 추가"} /> <Button className="m-2" size={"sm"} - onClick={() => { }}>저장</Button> + onClick={() => {closeModal && closeModal(false) }}>저장</Button> </div> <div className="flex flex-row flex-grow gap-4 mt-4"> diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index 3841a7fd8..6e13c6ea4 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -1,17 +1,12 @@ "use client"; - import { useWrStore } from "@/app/store"; import type { customPbnst, fcBizType, pubHasuType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; -import { getCity } from "@/components/lib/func/commom"; import { PbnstMngForm } from "@/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm"; -import { - ScrollArea, -} from "@common/business_components"; +import { ScrollArea } from "@common/business_components"; import { Button, Tabs, @@ -23,7 +18,7 @@ import { useEffect, useState } from "react"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; export function PbnstRegModal({ data }: { data: pubHasuType }) { - const { pbnst ,pbnstUpdate} = useWrStore((state) => { + const { pbnst, pbnstUpdate } = useWrStore((state) => { return state; }); const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>( @@ -31,39 +26,33 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) { ); const [currentTab, setCurrentTab] = useState<string>("mng"); -const pbnstRegTotal = ()=>{ - console.log(" pbnst.pbnstMngRegData ", pbnst.pbnstMngRegData) - - if(pbnst.pbnstMngRegData[0]) - pbnstUpdate(pbnst.pbnstMngRegData[0]) -} - + const pbnstRegTotal = () => { + if (pbnst.pbnstMngRegData[0]) pbnstUpdate(pbnst.pbnstMngRegData[0]); + }; const handleTabChange = (value: string) => { setCurrentTab(value); }; useEffect(() => { - - - if(data ){ - + if (data) { let regData = { - swtrmtFcltFk: String(data.bscFctCd ), - pbnstRuseFcltPk: String(data.bscFctCd + "1"), - fcBizs: [{ pbnstRuseFcltFk: String(data.bscFctCd + "1") ,cycl:1 } as unknown as fcBizType], + swtrmtFcltFk: String(data.bscFctCd), + pbnstRuseFcltPk: String(data.bscFctCd + "1"), + fcBizs: [ + { + pbnstRuseFcltFk: String(data.bscFctCd + "1"), + cycl: 1, + } as unknown as fcBizType, + ], }; - + setPbnstBdstForm(regData as unknown as customPbnst); } - }, [data]); - - useEffect(() =>{ - - console.log('pbnst.pbnstMngRegData ', pbnst.pbnstMngRegData) - },[pbnst.pbnstMngRegData]) + useEffect(() => {}, [pbnstBdstForm]); + useEffect(() => {}, [pbnst.pbnstMngRegData]); return ( <> <h1 className="text-2xl font-medium text-label pl-8"> @@ -80,15 +69,19 @@ const pbnstRegTotal = ()=>{ <TabsTrigger className="!text-xl" value="buse"> 차수별정보 </TabsTrigger> - <Button onClick={pbnstRegTotal} size={"sm"} className="!justify-end"> + <Button + onClick={pbnstRegTotal} + size={"sm"} + className="!justify-end" + > 저장 </Button> </TabsList> <TabsContent className="max-h-full" value="mng"> - <PbnstMngForm formType={'reg'} firstFcltData={pbnstBdstForm} /> + <PbnstMngForm formType={"reg"} firstFcltData={pbnstBdstForm} /> </TabsContent> <TabsContent className="max-h-full" value="buse"> - <PbnstBuseForm data={pbnstBdstForm.fcBizs} /> + <PbnstBuseForm formType={"reg"} firstBizData={pbnstBdstForm.fcBizs} /> </TabsContent> </Tabs> </ScrollArea> diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index 080ed30c9..b33f446d6 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -2,10 +2,9 @@ import { NextRequest, NextResponse } from "next/server"; import { CS_URL } from "./components/lib/config"; //import { CLAIM_NAME, AUTH_USER_ID } from "./src/shared/config"; -const CLAIM_NAME = "Authorization" -const AUTH_USER_ID = "token-id" -const serverApiUrl = - CS_URL; +const CLAIM_NAME = "Authorization"; +const AUTH_USER_ID = "token-id"; +const serverApiUrl = CS_URL; export function middleware(req: NextRequest) { const pathname = req.nextUrl.pathname; console.log(`[Middleware] Request URL: ${req.url}`); @@ -13,16 +12,18 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/server")) { const queryParams = searchParams.toString(); - const newUrl = `${serverApiUrl}${pathname.replace("/server", "")}${queryParams ? `?${queryParams}` : "" - }`; + const newUrl = `${serverApiUrl}${pathname.replace("/server", "")}${ + queryParams ? `?${queryParams}` : "" + }`; console.log(`[Middleware] Rewriting from '/server' path to: ${newUrl}`); return NextResponse.rewrite(new URL(newUrl)); } if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); - const token = "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJleHAiOjE3NDg0Mzc0OTF9.JM2NHEwTpgDW9nonZY3186IK_frIh667SyxMQfPwqa_lc-5mcTFNtrWXH5b72_ng39qiPSi504iF1roFEJ0c6w" - const userId = 'a0ec7a07-752a-4f7f-89a6-854e63d2e3a0' + const token = + "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJtbmdyWW4iOiJZIiwiZXhwIjoxNzQ4NzkzNzAwfQ.BK1F_t9ou3R26aLc02lsyOsr2tMvqQjOdKrLz5rViUEFq_AURtvnbAxfhVCdJVgFXgUyesPln1Ydl6to-KMKbw"; + const userId = "a0ec7a07-752a-4f7f-89a6-854e63d2e3a0"; //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; const newUrl = `${serverApiUrl}${pathname}`; @@ -31,13 +32,12 @@ export function middleware(req: NextRequest) { console.log("pathname ", pathname); //wr:dev: pathname /attach-service/api/v1/tus/upload/5e60b70a-956e-40c3-be5a-cdd3100bf8ad - //http://dev.onasys.co.kr:8000/attach-service/api/v1/tus/upload/5e60b70a-956e-40c3-be5a-cdd3100bf8ad if (token) requestHeaders.set(CLAIM_NAME, token); if (userId) requestHeaders.set(AUTH_USER_ID, userId); console.log( - `[Middleware] Rewriting from '/attach-service' path to: ${newUrl}`, + `[Middleware] Rewriting from '/attach-service' path to: ${newUrl}` ); return NextResponse.rewrite(new URL(newUrl), { headers: requestHeaders, @@ -50,4 +50,3 @@ export function middleware(req: NextRequest) { export const config = { matcher: ["/server/:path*", "/attach-service/:path*"], }; - From 67659bd16ffcc162f033802bbcd2762f27e37ff3 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Mon, 2 Jun 2025 11:02:43 +0900 Subject: [PATCH 43/62] =?UTF-8?q?=ED=8C=8C=EC=9D=BC=ED=81=B4=EB=A6=AD=20?= =?UTF-8?q?=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=EC=82=BD=EC=9E=85(=EC=9D=B8?= =?UTF-8?q?=EB=8D=B1=EC=8A=A4)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/file-upload/lib/file_upload.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx index 3fe1aafd8..b73bcb886 100644 --- a/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx +++ b/packages/common/business_components/src/ui/file-upload/lib/file_upload.tsx @@ -303,9 +303,7 @@ export const FileUploaderItem = forwardRef< > <div className="font-medium leading-none tracking-tight flex items-center gap-1.5 h-full !w-4/5 overflow-hidden " - onClick={() =>{ - - + onClick={() =>{onFileClick?.(index) }}> {children} </div> From aedb173ba7d27c31ad73d28d35b2761cf7976941 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Mon, 2 Jun 2025 11:15:19 +0900 Subject: [PATCH 44/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B3=B5=ED=86=B5=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=20=EB=B9=BC=EB=8A=94=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/form_ui/index.tsx | 10 ++- .../business_components/src/ui/index.ts | 2 +- .../src/ui/sdmSearchForm/index.tsx | 85 +++++++++++++++++++ 3 files changed, 93 insertions(+), 4 deletions(-) create mode 100644 packages/common/business_components/src/ui/sdmSearchForm/index.tsx diff --git a/packages/common/business_components/src/ui/form_ui/index.tsx b/packages/common/business_components/src/ui/form_ui/index.tsx index b834d5515..de4b37f61 100644 --- a/packages/common/business_components/src/ui/form_ui/index.tsx +++ b/packages/common/business_components/src/ui/form_ui/index.tsx @@ -1,5 +1,5 @@ import { Checkbox } from "@common/components/ui"; -import React, { useCallback, useState } from "react"; +import React, { useCallback, useEffect, useState } from "react"; import { FormControl, FormItem, FormLabel, FormMessage } from "../form"; export const BZNM_TOT_NO = '종사업자등록번호'; @@ -17,7 +17,11 @@ interface FormElementProps extends React.HTMLAttributes<HTMLElement> { const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>( ({ children, label, onCheckboxChange, isDisabled }, ref) => { - const [isChecked, setIsChecked] = useState(false); + const [isChecked, setIsChecked] = useState(isDisabled); + + useEffect(() => { + setIsChecked(isDisabled); + }, [isDisabled]); const handleCheckboxChange = useCallback((checked: boolean) => { setIsChecked(checked); @@ -50,7 +54,7 @@ const FormUi = React.forwardRef<HTMLDivElement, FormUiProps>( <FormControl> {React.isValidElement(children) && isDisabled ? React.cloneElement(children, { - disabled: true, + disabled: isDisabled, ...(children.props as FormElementProps) }) : children} diff --git a/packages/common/business_components/src/ui/index.ts b/packages/common/business_components/src/ui/index.ts index 90bf029c0..606852d1e 100644 --- a/packages/common/business_components/src/ui/index.ts +++ b/packages/common/business_components/src/ui/index.ts @@ -19,4 +19,4 @@ export * from "./tab"; export * from "./table"; export * from "./table_div"; export * from "./title"; - +export * from "./sdmSearchForm"; \ No newline at end of file diff --git a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx b/packages/common/business_components/src/ui/sdmSearchForm/index.tsx new file mode 100644 index 000000000..89edc233c --- /dev/null +++ b/packages/common/business_components/src/ui/sdmSearchForm/index.tsx @@ -0,0 +1,85 @@ +import React, { useCallback, useEffect, useRef, useState } from 'react'; + +type thisProps = { + label: string | undefined; + initValue: string | undefined; + setRtnData : (rtnData: any[]) => void; +} + +export default function SdmSearchForm({label=undefined, initValue=undefined, setRtnData=()=>{}} :thisProps) { + + /* const { getDemandCompList, Sdm } = useDmStore((state) => state); + + const { + demandCompList + } = Sdm; */ + + const [isOpen, setIsOpen] = useState(false); + const [textValue, setTextValue] = useState(initValue || ''); + const wrapperRef = useRef<HTMLDivElement>(null); + const handleInputChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => { + const value = e.target.value; + setTextValue(value); + if (value) { + setIsOpen(true); + } else { + setIsOpen(false); + } + }, []); + + /* const handleSuggestionClick = useCallback((dmdCoNm: string) => { + setTextValue(dmdCoNm); + }, []); */ + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) { + setIsOpen(false); + } + }; + + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, []); + + return ( + <div ref={wrapperRef}> + <input + type="text" + value={textValue} + onChange={handleInputChange} + /* onFocus={() => setIsOpen(true)} */ + className="w-full h-[3.2rem] !text-xl pl-3 text-gray-600 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder={`${label}을(를) 입력하세요`} + /> + {isOpen && ( + <div className=" z-1 w-full mt-2 bg-white border border-gray-300 rounded-md shadow-lg h-90 overflow-auto"> + <div className="max-h-72"> + {/* {demandCompList && demandCompList.length > 0 ? demandCompList.map((item : DemandCompType, index : number) => ( + <div + key={index} + className="!text-xl w-full text-left px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto" + onClick={() => handleSuggestionClick(item.dmdCoNm)} + role="button" + tabIndex={0} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + handleSuggestionClick(item.dmdCoNm); + } + }} + > + {item.dmdInfoPk.substring(0,10)} <span className="float-right">{item.dmdCoNm}</span> + </div> + )) : ( */} + <div className="!text-xl w-full px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto"> + 검색 결과가 없습니다. + </div> + {/* )) : ( */} + </div> + </div> + )} + </div> + ) +} \ No newline at end of file From 1eef53fe7dcd6605137b2db80f738df4bf586c72 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Mon, 2 Jun 2025 11:16:48 +0900 Subject: [PATCH 45/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=EA=B2=80?= =?UTF-8?q?=EC=83=89=20=EA=B3=B5=ED=86=B5=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=EB=A1=9C=20=EB=B9=BC=EB=8A=94=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=A7=84=ED=96=89=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/business_components/src/ui/sdmSearchForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx b/packages/common/business_components/src/ui/sdmSearchForm/index.tsx index 89edc233c..a724d1d97 100644 --- a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx +++ b/packages/common/business_components/src/ui/sdmSearchForm/index.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; -type thisProps = { +export type thisProps = { label: string | undefined; initValue: string | undefined; setRtnData : (rtnData: any[]) => void; From feb5711ad438c3640d9e6ab6bccfc393778f2613 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Mon, 2 Jun 2025 11:25:31 +0900 Subject: [PATCH 46/62] =?UTF-8?q?export=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/business_components/src/ui/sdmSearchForm/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx b/packages/common/business_components/src/ui/sdmSearchForm/index.tsx index a724d1d97..62009826e 100644 --- a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx +++ b/packages/common/business_components/src/ui/sdmSearchForm/index.tsx @@ -6,7 +6,7 @@ export type thisProps = { setRtnData : (rtnData: any[]) => void; } -export default function SdmSearchForm({label=undefined, initValue=undefined, setRtnData=()=>{}} :thisProps) { +export const SdmSearchForm = ({label=undefined, initValue=undefined, setRtnData=()=>{}} :thisProps) => { /* const { getDemandCompList, Sdm } = useDmStore((state) => state); From aca4cc579522fe1ed5a988fa409cfcb2c49890cd Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Mon, 2 Jun 2025 16:22:56 +0900 Subject: [PATCH 47/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=EC=8B=A4=EC=A0=81=20=ED=8D=BC=EB=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/page.tsx | 7 + .../prfmncReg/pbnstPrfmncReg/page.tsx | 127 ++++++++++++++++++ .../prfmncReg/pbnstPrfmncReg/headList.tsx | 26 ++++ .../store/prfmncReg/pbnstPrfmncReg/index.tsx | 77 +++++++++++ apps/wr/app/store/store.tsx | 9 +- 5 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx create mode 100644 apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx create mode 100644 apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx diff --git a/apps/wr/app/page.tsx b/apps/wr/app/page.tsx index 086e76f22..a4955b36a 100644 --- a/apps/wr/app/page.tsx +++ b/apps/wr/app/page.tsx @@ -41,6 +41,13 @@ export default function Home() { <div> <h2 className="text-xl font-semibold mb-4">지도점검 결과</h2> <div className="grid grid-cols-12 gap-4"> + <div className="col-span-2"> + <Button className="w-full"> + <Link href="ruseFcltMng/prfmncReg/pbnstPrfmncReg"> + 하수재이용실적 등록 + </Link> + </Button> + </div> <div className="col-span-2"> <Button className="w-full"> <Link href="ruseFcltMng/prfmncReg/chkgdnReg"> diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx new file mode 100644 index 000000000..e3f3e9fe9 --- /dev/null +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -0,0 +1,127 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { yearOptions } from "@/components/lib/func/commom"; +import { ContentsDiv, Title, SearchDiv, SearchFormLeft, SelectBox, SearchInput, SearchFormRight, ScrollArea, UiTable } from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { Button, Label } from "@common/components/ui"; +import { useState, useEffect } from "react"; + +export default function prfmncPrfmncReg() { + const { code, prfmnc, prfmncHasuInit, searchFclts, } = useWrStore((state) => state); + const { pbnstPrfmncHeadList, monthHeadList,prfmncRes } = prfmnc; + const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); + const [searchTxt, setSearchTxt] = useState<string>(); + + const [searchYear, setSearchYear] = useState<string>(String(new Date().getFullYear())); + useEffect(() => { + if (!prfmnc.isInit) { + prfmncHasuInit("1", "11"); + } + }, [prfmnc.isInit, prfmncHasuInit]); + useEffect(() => { + console.log("prfmnc.prfmncRes", prfmncRes) + },[prfmncRes]); + + return ( + <> + <ContentsDiv> + <div className="grid grid-cols-4 gap-4"> + <div className="col-span-4"> + <Title title={"하수재이용 시설 등록"} /> + <SearchDiv> + <SearchFormLeft> + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-48 mt-2 text-xl text-gray-600">{'실적등록년도'}</Label> + <SelectBox + className="w-full h-full text-2xl" + label="" + selectClass={""} + selectArray={yearOptions} + value={searchYear} + onSelectValue={(val: string | number) => + setSearchYear(String(val)) + } + /> + </div> + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-28 mt-2 text-xl text-gray-600">{'시설명'}</Label> + <SearchInput + className={"w-full text-2xl"} + label="" + textValue={searchTxt || ""} + setText={(e) => { + setSearchTxt(e); + }} + /> + </div> + </SearchFormLeft> + <SearchFormRight + className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> + <div className="space-y"> + <div className="flex flex-row space-x-2"> + <Button + size={"sm"} + onClick={(e) => { }} + > + 조회 + </Button> + <Button + size={"sm"} + onClick={() => { }} + > + 저장 + </Button> + <Button + size={"sm"} + onClick={() => { }} + > + 파일등록 + </Button> + <Button color="green" size={"sm"} onClick={() => { }}> + 양식받기 + </Button> + </div> + </div> + </SearchFormRight> + </SearchDiv> + </div> + </div> + + <div className="grid grid-cols-12 gap-4 h-full"> + <div className="col-span-4 h-full min-h-0"> + <ListDiv className="min-h-0"> + <ScrollArea className="h-[60vh]"> + <UiTable + tableData={bdstTable || []} + headlist={pbnstPrfmncHeadList} + pageSize={100} + total={10} + headName={"하수재이용시설 목록"} + cellClick={() => { }} + onPageChange={(page: number) => { }} + children={undefined} + /> + </ScrollArea> + </ListDiv> + </div> + <ListDiv className="col-span-8 pr-6 "> + <ScrollArea className="h-[60vh]"> + <UiTable + tableData={[]} + headlist={monthHeadList} + pageSize={100} + total={10} + headName={"하수처리수재이용 실적(m3) 등록결과"} + cellClick={() => { }} + onPageChange={() => { }} + children={undefined} + /> + </ScrollArea> + </ListDiv> + </div> + </ContentsDiv> + </> + ); +} diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx new file mode 100644 index 000000000..fd2fc9ada --- /dev/null +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx @@ -0,0 +1,26 @@ +import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg"; + +export const pbnstPrfmncHeadListExport: TableUpperProps[] = [ + { id: "sido", title: "시도" }, + { id: "gugun", title: "시군구" }, + { id: "bscFctNm", title: "시설명" }, + { id: "sisul", title: "재이용시설명" }, + { id: "sisulCd", title: "재이용시설코드" }, +]; + +export const monthHeadListExport: TableUpperProps[] = [ + { id: "gubun", title: "구분" }, + { id: "total", title: "계" }, + { id: "mon1", title: "1월" }, + { id: "mon2", title: "2월" }, + { id: "mon3", title: "3월" }, + { id: "mon4", title: "4월" }, + { id: "mon5", title: "5월" }, + { id: "mon6", title: "6월" }, + { id: "mon7", title: "7월" }, + { id: "mon8", title: "8월" }, + { id: "mon9", title: "9월" }, + { id: "mon10", title: "10월" }, + { id: "mon11", title: "11월" }, + { id: "mon12", title: "12월" }, +]; diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx new file mode 100644 index 000000000..a726aa463 --- /dev/null +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx @@ -0,0 +1,77 @@ +import { fetchType, getFetch, postFectch } from "@/components/lib/api"; +import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg"; +import { + pbnstPrfmncHeadListExport, + monthHeadListExport, +} from "./headList"; +import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; + +const pbnstPrfmncHeadList = pbnstPrfmncHeadListExport; +const monthHeadList = monthHeadListExport; + +export type pbnstPrfmncState = { + prfmnc: { + isInit: boolean; + pbnstPrfmncHeadList: TableUpperProps[]; + monthHeadList: TableUpperProps[]; + prfmncRes: pubHasuType[]; + } +} + +export const pbnstPrfmncStateExport: pbnstPrfmncState = { + prfmnc: { + isInit: false, + pbnstPrfmncHeadList: pbnstPrfmncHeadList, + monthHeadList: monthHeadList, + prfmncRes: [], + } +} + +export type pbnstPrfmncType = pbnstPrfmncState & pbnstPrfmncActions; + +type pbnstPrfmncActions = { + prfmncHasuInit: (page: string, sggOrCity: string) => void; +} + +const checkWrRegList = async () => { + const wrRegList = await getFetch("wr", `/reuseFc/pubFc`); + return wrRegList; +}; +const hasuListFetch = async (page: string, sggOrCity: string) => { + const checkWrRegListRes = await checkWrRegList(); + + const rainRes = await postFectch( + `/prcsFclt/ruseInfo/${page ? page : 1}/10/A/${sggOrCity ? sggOrCity : "11"}/0/1/SW`, + checkWrRegListRes, + fetchType.COMMON + ); + + const hasuList = rainRes.data.map((item: any) => { + return { + ...item, + ruse: item.ruse === false ? "N" : "Y", + }; + }); + + return hasuList; +}; +export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (set: any) => { + return { + prfmncHasuInit: async (page: string, sggOrCity: string) => { + try { + const prfmncRes = await hasuListFetch(page, sggOrCity); +console.log("prfmncRes", prfmncRes) + return set((state: pbnstPrfmncState) => ({ + ...state, + prfmnc: { + ...state.prfmnc, + prfmncRes: prfmncRes, + isInit: false, + }, + })); + } catch (errorHasu) { + console.log(errorHasu); + } + }, + } +} \ No newline at end of file diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index 19c7575df..4bc699604 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -88,6 +88,7 @@ import { pbnstSttnActionsExport, pbnstSttnStateExport, type pbnstSttnState, type import { coSttnActionsExport, coSttnStateExport, type coSttnState, type coSttnType } from "./matDmd/coSttn"; // 옮겨야함 import { ldrmntCoSttnActionsExport, ldrmntCoSttnStateExport, type ldrmntCoSttnState, type ldrmntCoSttnType } from "./matDmd/ldrmntCoSttn"; // 옮겨야함 import { searchActions, type comFcltActions, type comFcltState } from "./common/searchCode"; +import { pbnstPrfmncActionsExport, pbnstPrfmncStateExport, type pbnstPrfmncState, type pbnstPrfmncType } from "./prfmncReg/pbnstPrfmncReg"; export type WrStore = comCodeType & pubFacType & @@ -106,7 +107,8 @@ export type WrStore = comCodeType & pbnstSttnType& comFcltActions&comFcltState& coSttnType& // 옮겨야함 - ldrmntCoSttnType // 옮겨야함 + ldrmntCoSttnType& // 옮겨야함 + pbnstPrfmncType ; export const StoreZus = ( @@ -126,7 +128,8 @@ export const StoreZus = ( rswtChkSttnState & pbnstSttnState& coSttnState& // 옮겨야함 - ldrmntCoSttnState // 옮겨야함 + ldrmntCoSttnState& // 옮겨야함 + pbnstPrfmncState = { ...comCodeStateExport, ...pubFacStateExport, @@ -145,6 +148,7 @@ export const StoreZus = ( ...pbnstSttnStateExport, ...coSttnStateExport, // 옮겨야함 ...ldrmntCoSttnStateExport, // 옮겨야함 + ...pbnstPrfmncStateExport, } ) => { return createStore<WrStore>()((set) => { @@ -174,6 +178,7 @@ export const StoreZus = ( ...pbnstSttnActionsExport(set), ...coSttnActionsExport(set), // 옮겨야함 ...ldrmntCoSttnActionsExport(set), // 옮겨야함 + ...pbnstPrfmncActionsExport(set), }; }); }; From 72585f9d910df960bfdf04af074bfc1cd496727f Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Mon, 2 Jun 2025 16:23:08 +0900 Subject: [PATCH 48/62] =?UTF-8?q?=ED=95=98=EC=88=98=20=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EC=9E=91=EC=97=85=20=EC=99=84?= =?UTF-8?q?=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 2 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 114 ++++++++++++------ .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 2 +- apps/wr/components/lib/api/index.ts | 6 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 70 +++++++++-- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 23 ++-- .../fcltReg/pbnstRegModal/pbnstRegModal.tsx | 4 +- apps/wr/middleware.ts | 2 +- 8 files changed, 155 insertions(+), 68 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 07cbe401f..465cad08b 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -103,7 +103,7 @@ export const ruseFcltinfo: formDetailType[] = [ { id: "majorPrcsMsrcCd", lable: "주처리공법" }, { id: "addr", lable: "위치(주소)" }, { id: "rprcsMthdCd", lable: "재처리방식" }, - { id: "inoutYn", lable: "위치(처리장 내외)" }, // 머가 내? 외?, + { id: "inoutYn", lable: "위치(처리장 내외)" ,type: "selectYn" }, // 머가 내? 외?, { id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" }, ]; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index fde9fc79d..6eb722257 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -1,5 +1,5 @@ import { z } from "zod"; -import type { TableUpperProps } from "../rainReg"; +import { TEST_UUID, type TableUpperProps } from "../rainReg"; import { deleteFectch, fetchType, @@ -12,7 +12,7 @@ import { fcBizSchema, type customPbnst, type fcBizType, - type PbnstUpdateIndex, + type pbnstInsertIndex, type pubHasuType, } from "./type"; import type { SelectDataType } from "@common/business_components/ui"; @@ -51,22 +51,23 @@ export type pubFacState = { pbnstDemandHeadList: TableUpperProps[]; fcOrgwtsHeadList: TableUpperProps[]; pbnstMngRegData: customPbnst[]; - pbnsUpdateIndex: PbnstUpdateIndex; - dmdComList:any[] + pbnsUpdateIndex: pbnstInsertIndex; + dmdComList: any[]; }; }; type pubFacActions = { pubHasuInit: (page: string, sggOrCity: string) => void; pbnstRegInit: (pubHasuRes: pubHasuType) => void; pbnstReg: (txt: string | undefined) => void; - pbnstUpdate(pbnstRes: customPbnst): Promise<void>; + pbnstInsert(pbnstRes: customPbnst): Promise<void>; + appendRuseFclt(array: customPbnst[]): void; fileDelete: (atflCd: string) => void; fileDownLoad: (atflCd: string) => void; pbnstMngData: (data: customPbnst[]) => void; pbnstBizData(data: fcBizType): void; - getBizCycle: (pbnstObj: customPbnst) => void; - getDmdCompany:(txt :string)=>void; - getPbnstUpdateIndex: (data: PbnstUpdateIndex) => void; + getBizCycle: (pbnstObj: customPbnst) => void; + getDmdCompany: (txt: string) => void; + getpbnstInsertIndex: (data: pbnstInsertIndex) => void; }; export type pubFacType = pubFacState & pubFacActions; @@ -87,8 +88,8 @@ export const pubFacStateExport: pubFacState = { pbnstDemandHeadList: pbnstDemandHeadList, fcOrgwtsHeadList: fcOrgwtsHeadList, pbnstMngRegData: [], - pbnsUpdateIndex : {} as PbnstUpdateIndex, - dmdComList:[] + pbnsUpdateIndex: {} as pbnstInsertIndex, + dmdComList: [], }, }; @@ -121,6 +122,34 @@ const initFetch = async (code: string | undefined) => { return pbnstRes; }; +const writeRgtrAndMdfr = (data: customPbnst) => { + data.rgtr = TEST_UUID; + data.mdfr = TEST_UUID; + data.fcBizs = data.fcBizs.map((item) => { + item.rgtr = TEST_UUID; + item.mdfr = TEST_UUID; + item.fcOrgwts = item.fcOrgwts?.map((item) => { + item.mdfr = TEST_UUID; + item.rgtr = TEST_UUID; + return item; + }); + + return item; + }); + data.fcOpers = data.fcOpers.map((item) => { + item.rgtr = TEST_UUID; + item.mdfr = TEST_UUID; + return item; + }); + data.fcFiles = data.fcFiles.map((item) => { + item.rgtr = TEST_UUID; + item.mdfr = TEST_UUID; + return item; + }); + + + return data; +}; export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { return { pubHasuInit: async (page: string, sggOrCity: string) => { @@ -140,7 +169,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } }, - pbnstRegInit: async (pubHasuRes: pubHasuType ) => { + pbnstRegInit: async (pubHasuRes: pubHasuType) => { try { //const pbnstRes = await initFetch(txt); const pbnstRes = exampleData; @@ -160,7 +189,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnstReg: async (txt: string | undefined) => { try { - const pbnstRes = await hasuListFetch('11' , '11'); + const pbnstRes = await hasuListFetch("11", "11"); return set((state: pubFacState) => ({ ...state, pbnst: { @@ -173,11 +202,13 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { console.log(errorHasu); } }, - pbnstUpdate: async (pbnstRes: customPbnst) => { + pbnstInsert: async (pbnstRes: customPbnst) => { try { + + console.log('writeRgtrAndMdfr(pbnstRes) ', writeRgtrAndMdfr(pbnstRes)) const response = await postFectch( `/reuseFc/pubFc`, - JSON.stringify(pbnstRes) + JSON.stringify( writeRgtrAndMdfr(pbnstRes)) ); return set((state: pubFacState) => ({ @@ -199,6 +230,8 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { val: item.cycl, }; }); + + console.log(" pbnstBizCycle ", pbnstBizCycle); return set((state: pubFacState) => ({ ...state, pbnst: { @@ -243,24 +276,23 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { console.error("Error downloading file:", error); } }, - + pbnstMngData: (data: customPbnst[]) => { - if(data.length > 0){ - - + if (data.length > 0) { } return set((state: pubFacState) => { state.pbnst.pbnstMngRegData = data; - state.pbnst.pbnstBizCycle=data.length <=0 ? [{ text: "없음", val: "1" }] : state.pbnst.pbnstBizCycle + state.pbnst.pbnstBizCycle = + data.length <= 0 + ? [{ text: "없음", val: "1" }] + : state.pbnst.pbnstBizCycle; return state; }); }, - + pbnstBizData: (data: fcBizType) => { return set((state: pubFacState) => { - - if (state.pbnst.pbnstMngRegData) { const regData = state.pbnst.pbnstMngRegData.find( (item) => data.pbnstRuseFcltFk === item.pbnstRuseFcltPk @@ -277,25 +309,37 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } return state; }); - },getDmdCompany: async (txt:string)=>{ - - const company = await getFetch( - fetchType.WR, - `/reuseFc/request/${txt}/3`) + }, + getDmdCompany: async (txt: string) => { + const company = await getFetch(fetchType.WR, `/reuseFc/request/${txt}/3`); + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + isInit: false, + }, + })); + }, + getpbnstInsertIndex: async (data: pbnstInsertIndex) => { + return set((state: pubFacState) => { + state.pbnst.pbnsUpdateIndex = data; + return state; + }); + }, + appendRuseFclt: async (array: customPbnst[]) => { + try { return set((state: pubFacState) => ({ ...state, pbnst: { ...state.pbnst, + pbnstRes: array, isInit: false, }, - - })) - },getPbnstUpdateIndex:async(data : PbnstUpdateIndex)=>{ - return set((state: pubFacState) => { - state.pbnst.pbnsUpdateIndex = data - return state; + })); + } catch (e) { + console.log(e); } - )} - }; + }, + }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index be758c87c..a70e5030e 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -14,7 +14,7 @@ export type selectLabel = { val: string; }; -export type PbnstUpdateIndex ={ +export type pbnstInsertIndex ={ mng:number, biz:number } diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index c2529c8a2..e853428f5 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -35,11 +35,7 @@ export const getFetch = async (type: string, url: string) => { const blob = await response.blob(); const blobUrl = window.URL.createObjectURL(blob); const a = document.createElement("a"); - - // 파일명 추출 (서버에서 header에 Content-Disposition을 보낼 경우 활용) - const disposition = response.headers.get("Content-Disposition"); - const match = disposition?.match(/filename="?(.+)"?/); - const filename = match?.[1] || "downloaded_file"; + const filename = "downloaded_file.PDF"; a.href = blobUrl; a.download = filename; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 620f93803..eccff62b5 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -12,6 +12,7 @@ import { } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; import { fcBizSchema, + type customPbnst, type fcBizType, type ppInstlType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; @@ -40,9 +41,16 @@ export function PbnstBuseForm({ firstBizData?: fcBizType[]; }) { const ref = useRef<ppInstlType[] | null>(null); - const { code, pbnst, pbnstBizData ,getPbnstUpdateIndex} = useWrStore((state) => state); + const { + code, + pbnst, + pbnstBizData, + getpbnstInsertIndex, + appendRuseFclt, + getBizCycle, + } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; - const [getBizCycle, setBizCycle] = useState("1"); + const [bizCycle, setBizCycle] = useState("1"); const [ppiSelectList, setPpiSelectList] = useState<[{ name: string; val: SelectDataType[] }]>(); const [ppiYn, setPpiYn] = useState("Y"); @@ -57,11 +65,13 @@ export function PbnstBuseForm({ pbnst.pbnstMngRegData[0]?.fcBizs ? (pbnst.pbnstMngRegData[0].fcBizs[0] ?? {}) : formType === "update" && - typeof pbnst.pbnsUpdateIndex.biz === "number" && - pbnst.pbnsUpdateIndex.biz >= 0 && - pbnst.pbnstRes - ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs[pbnst.pbnsUpdateIndex.biz] - : fcBizSchema.parse({}), + typeof pbnst.pbnsUpdateIndex.biz === "number" && + pbnst.pbnsUpdateIndex.biz >= 0 && + pbnst.pbnstRes + ? pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs[ + pbnst.pbnsUpdateIndex.biz + ] + : fcBizSchema.parse({}), }); // 2. Define a submit handler. @@ -69,6 +79,33 @@ export function PbnstBuseForm({ // console.log(values); } + // 2. Define a submit handler. + function addRuseFcltObj() { + const newItem = fcBizSchema.parse({}); + const index = pbnst.pbnsUpdateIndex.mng; + + let regData: fcBizType = {} as fcBizType; + if ( + pbnst.pbnstRes && + pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng] && + pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs + ) { + regData = { + pbnstRuseFcltFk: + String(pbnst.pbnstRes[0]?.swtrmtFcltFk) + + String(pbnst.pbnstRes.length + 1), + cycl: Number( + (pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs?.length || 0) + 1 + ), + } as fcBizType; + + const newPbnstRes = [...(pbnst.pbnstRes as customPbnst[])]; + newPbnstRes[index]?.fcBizs?.length && newPbnstRes[index]?.fcBizs?.push(regData); + getBizCycle(newPbnstRes[index] as customPbnst); + appendRuseFclt(newPbnstRes); + } + } + const { fields: fcOrgwtFiled } = useFieldArray({ control: form.control, name: "fcOrgwts", @@ -143,12 +180,12 @@ export function PbnstBuseForm({ }; useEffect(() => { - if (getBizCycle&&formType !== "reg") { - const index = Number(getBizCycle) - 1; + if (bizCycle && formType !== "reg") { + const index = Number(bizCycle) - 1; form.reset(pbnst.pbnstResObj?.fcBizs[index]); ref.current = pbnst.pbnstResObj?.fcBizs[index]?.pplInstls ?? []; } - }, [getBizCycle, pbnst.pbnstResObj , formType]); + }, [bizCycle, pbnst.pbnstResObj, formType]); useEffect(() => { const ppl = [] as { name: string; val: SelectDataType[] }[]; @@ -186,16 +223,23 @@ export function PbnstBuseForm({ <SelectBox label="" selectArray={pbnstBizCycle} - value={getBizCycle ?? pbnstBizCycle[0]?.val} + value={bizCycle ?? pbnstBizCycle[0]?.val} className={""} selectClass={selectClass} onSelectValue={(val) => { setBizCycle(String(val)); - getPbnstUpdateIndex({...pbnst.pbnsUpdateIndex, biz: Number(val)}) + getpbnstInsertIndex({ + ...pbnst.pbnsUpdateIndex, + biz: Number(val), + }); }} ></SelectBox> - <Button type="submit" size={commonButonSize}> + <Button + onClick={addRuseFcltObj} + type="button" + size={commonButonSize} + > 저장 </Button> </div> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 863b887b6..53edfd14e 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -18,6 +18,7 @@ import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTab import { pbnstRegZod, type customPbnst, + type fcBizType, type fcFileType, type operType, type selectLabel, @@ -39,12 +40,13 @@ export function PbnstMngForm({ }) { const { pbnst, - pbnstUpdate, + pbnstInsert, pbnstMngData, fileDelete, fileDownLoad, getBizCycle, - getPbnstUpdateIndex, + getpbnstInsertIndex, + appendRuseFclt } = useWrStore((state) => state); const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null); @@ -86,10 +88,9 @@ export function PbnstMngForm({ if (pbnst.pbnstRes && pbnst.pbnstRes[val]) { getBizCycle(pbnst.pbnstRes[val]); form.reset(pbnst.pbnstRes[val]); - getPbnstUpdateIndex({ ...pbnst.pbnsUpdateIndex, mng: val }); + getpbnstInsertIndex({ ...pbnst.pbnsUpdateIndex, mng: val }); } }; - const fileDownload = (index: number) => {}; const plusHist = () => { const regData = { choose: false, @@ -205,7 +206,6 @@ export function PbnstMngForm({ useEffect(() => { const defaultFiles = form.getValues("fcFiles"); - console.log("defaultFiles : ", defaultFiles); if (defaultFiles && defaultFiles.length > 0) { const relationFileList = defaultFiles.filter( (item) => item.fileKnd === "계통도" @@ -241,7 +241,6 @@ export function PbnstMngForm({ ) { const bizData = pbnst.pbnstRes[pbnst.pbnsUpdateIndex.biz]; - console.log(" bizData : ", bizData); if (bizData) { getBizCycle(bizData); } @@ -268,15 +267,19 @@ export function PbnstMngForm({ })); setFcltNm(fcltNmList); + }, [pbnst.pbnstRes]); // 2. Define a submit handler. function onSubmit(values: z.infer<typeof pbnstRegZod>) { values.fcOpers = fcOpresData || []; values.fcFiles = regFileList || []; - pbnstUpdate(values); + pbnstInsert(values); } + + + useEffect(() => { if (relationfiles) { setRegFileList(regFileFilter(relationfiles, "계통도", regFileList || [])); @@ -335,9 +338,9 @@ export function PbnstMngForm({ )} </div> - <Button type="submit" size={commonButonSize}> - 저장 - </Button> + {/* <Button onClick={addRuseFcltObj} type="button" size={commonButonSize}> + 추가 + </Button> */} </div> <div> diff --git a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx index 6e13c6ea4..3929551e8 100644 --- a/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx +++ b/apps/wr/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal.tsx @@ -18,7 +18,7 @@ import { useEffect, useState } from "react"; import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm"; export function PbnstRegModal({ data }: { data: pubHasuType }) { - const { pbnst, pbnstUpdate } = useWrStore((state) => { + const { pbnst, pbnstInsert } = useWrStore((state) => { return state; }); const [pbnstBdstForm, setPbnstBdstForm] = useState<customPbnst>( @@ -27,7 +27,7 @@ export function PbnstRegModal({ data }: { data: pubHasuType }) { const [currentTab, setCurrentTab] = useState<string>("mng"); const pbnstRegTotal = () => { - if (pbnst.pbnstMngRegData[0]) pbnstUpdate(pbnst.pbnstMngRegData[0]); + if (pbnst.pbnstMngRegData[0]) pbnstInsert(pbnst.pbnstMngRegData[0]); }; const handleTabChange = (value: string) => { diff --git a/apps/wr/middleware.ts b/apps/wr/middleware.ts index b33f446d6..330252074 100644 --- a/apps/wr/middleware.ts +++ b/apps/wr/middleware.ts @@ -22,7 +22,7 @@ export function middleware(req: NextRequest) { if (pathname.startsWith("/attach-service")) { const requestHeaders = new Headers(req.headers); const token = - "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJtbmdyWW4iOiJZIiwiZXhwIjoxNzQ4NzkzNzAwfQ.BK1F_t9ou3R26aLc02lsyOsr2tMvqQjOdKrLz5rViUEFq_AURtvnbAxfhVCdJVgFXgUyesPln1Ydl6to-KMKbw"; + "eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhMGVjN2EwNy03NTJhLTRmN2YtODlhNi04NTRlNjNkMmUzYTAiLCJhdXRob3JpdGllcyI6IlJPTEVfQURNSU4sUk9MRV9BTk9OWU1PVVMiLCJtbmdyWW4iOiJZIiwiZXhwIjoxNzQ4ODQ4NDkxfQ.ZiYpKxAMyyoPuUquxsWxfQbMBzYN4tsa7itZ49_OEsdGvbUUmKzrIV6Or7VVbEjtAqhh7W97nqB5EP6GRzFC9Q"; const userId = "a0ec7a07-752a-4f7f-89a6-854e63d2e3a0"; //const token = req.cookies.get(CLAIM_NAME)?.value; //const userId = req.cookies.get(AUTH_USER_ID)?.value; From 618d2cb00cfb70649c3b5c683797c9e857eacff2 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Tue, 3 Jun 2025 15:19:16 +0900 Subject: [PATCH 49/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=9E=91=EC=97=85=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 4 +- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 12 ++-- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 66 +++++++++++-------- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 37 ++++++++++- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 6 +- .../mngRegFormDetail/mngRegFormDetail.tsx | 4 +- 6 files changed, 85 insertions(+), 44 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index 70f41af7b..f818a494f 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -35,7 +35,7 @@ export default function PublicReuseFaciltyInsert() { pbnst, searchFclts, pubHasuInit, - pbnstRegInit, + pbnstRegClick, getSwtrmtFcltNm, pbnstMngData, } = useWrStore((state) => state); @@ -72,7 +72,7 @@ export default function PublicReuseFaciltyInsert() { const selectRow = pbnstHasuRes?.[val]; if (selectRow) { setIsRuseReg({ ...isRuseReg, data: selectRow }); - pbnstRegInit(selectRow); + pbnstRegClick(selectRow); } }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 6eb722257..d4dce6d09 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -57,7 +57,7 @@ export type pubFacState = { }; type pubFacActions = { pubHasuInit: (page: string, sggOrCity: string) => void; - pbnstRegInit: (pubHasuRes: pubHasuType) => void; + pbnstRegClick: (pubHasuRes: pubHasuType) => void; pbnstReg: (txt: string | undefined) => void; pbnstInsert(pbnstRes: customPbnst): Promise<void>; appendRuseFclt(array: customPbnst[]): void; @@ -117,8 +117,8 @@ const hasuListFetch = async (page: string, sggOrCity: string) => { return hasuList; }; -const initFetch = async (code: string | undefined) => { - const pbnstRes = await getFetch("wr", `${code}`); +const initFetch = async (ruseFcltPk: string | undefined) => { + const pbnstRes = await getFetch("wr", `/reuseFc/pubFc/${ruseFcltPk}`); return pbnstRes; }; @@ -169,11 +169,9 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } }, - pbnstRegInit: async (pubHasuRes: pubHasuType) => { + pbnstRegClick: async (pubHasuRes: pubHasuType) => { try { - //const pbnstRes = await initFetch(txt); - const pbnstRes = exampleData; - + const pbnstRes = await initFetch(pubHasuRes.bscFctCd); return set((state: pubFacState) => ({ ...state, pbnst: { diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index a70e5030e..17b99afcc 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -99,6 +99,42 @@ const fcOrgwtSchema = z.object({ }); + +const pubHasuZod = z.object({ + choose: z.boolean().default(false), + bscFctCd: z.string(), + sido: z.string().default(""), + gugun: z.string().default(""), + bscFctNm: z.string().default(""), + efflWqltStndrdNm: z.string().default(""), + fctCpc: z.number().default(0), + addr:z.string().nullish() +}); + +const demandInfoList = z.object({ + +}) + + +export type pubHasuType = z.infer<typeof pubHasuZod>; + + + +const dmdColist = z.object({ + dmdCoNm: z.boolean().default(false), + daddr: z.string(), + useUsgCd: z.string().default(""), + splyBgngDay: z.string().default(""), + splyEndDay: z.string().default(""), + splyCpct: z.string().default(""), + splyFmYn: z.number().default(0), + telno:z.string().default('') +}); + + + + + export const fcBizSchema = z.object({ pbnstRuseFcltBizPk: z.number().default(1), pbnstRuseFcltFk: z.string().nullish(), @@ -164,40 +200,13 @@ export const fcBizSchema = z.object({ ruseFcltCstClcln: z.number().nullish(), fcOrgwts: z.array(fcOrgwtSchema).nullish(), pplInstls: z.array(pplInstlSchema).nullish(), + demandInfo: z.array(dmdColist).default([]).nullish(), flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string().nullish(), mdfcnDt: z.string().nullish(), mdfr: z.string().nullish(), }); - - -const pubHasuZod = z.object({ - choose: z.boolean().default(false), - bscFctCd: z.string(), - sido: z.string().default(""), - gugun: z.string().default(""), - bscFctNm: z.string().default(""), - efflWqltStndrdNm: z.string().default(""), - fctCpc: z.number().default(0), - addr:z.string().nullish() -}); - -export type pubHasuType = z.infer<typeof pubHasuZod>; - - - -const dmdColist = z.object({ - dmdCoNm: z.boolean().default(false), - daddr: z.string(), - useUsgCd: z.string().default(""), - splyBgngDay: z.string().default(""), - splyEndDay: z.string().default(""), - splyCpct: z.string().default(""), - splyFmYn: z.number().default(0), -}); - - export const pbnstRegZod = z.object({ pbnstRuseFcltPk: z.string().default(''), swtrmtFcltFk: z.string().default(""), @@ -212,7 +221,6 @@ export const pbnstRegZod = z.object({ fcFiles: z.array(fcFileSchema).default([]), fcBizs: z.array(fcBizSchema).default([]), fcOpers: z.array(fcOperSchema).default([]), - fcDemands: z.array(dmdColist).default([]).nullish(), hasuhasu: z.number().default(0), }); diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index eccff62b5..f127579fc 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -56,6 +56,8 @@ export function PbnstBuseForm({ const [ppiYn, setPpiYn] = useState("Y"); const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); const [sumCpct, setSumCpct] = useState<number>(0); + const [searchDmdCo, setSeachDmdCo] = useState<String>(); + const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), @@ -103,9 +105,17 @@ export function PbnstBuseForm({ newPbnstRes[index]?.fcBizs?.length && newPbnstRes[index]?.fcBizs?.push(regData); getBizCycle(newPbnstRes[index] as customPbnst); appendRuseFclt(newPbnstRes); - } } + const { fields: demandInfo, + append:appendDemand, + remove:removeDemand } = useFieldArray({ + control: form.control, + name: "demandInfo", + }); + + + const { fields: fcOrgwtFiled } = useFieldArray({ control: form.control, name: "fcOrgwts", @@ -169,7 +179,21 @@ export function PbnstBuseForm({ ref.current = [...latestOpers]; }; - const plusArray = () => {}; + const plusArray = () => { +<> +<MngRegFormDetail + formList={dmdCoList} + h1Title={"하수처리수 재이용수 수요처"} + form={form} + moClass="grid grid-cols-12 gap-4 mt-3" + sonClass="col-span-4" + onIputData={(val) => { + setSeachDmdCo(val); + }} + /> + +</> + }; const removeSelected = () => { if (!ref.current) return; @@ -369,7 +393,7 @@ export function PbnstBuseForm({ <div className="text-right mb-3"> <Button type="button" - onClick={() => {}} + onClick={() => {appendDemand}} size={commonButonSize} className="" > @@ -382,8 +406,15 @@ export function PbnstBuseForm({ form={form} moClass="grid grid-cols-12 gap-4 mt-3" sonClass="col-span-4" + onIputData={(val) => { + setSeachDmdCo(val); + }} /> </div> + + + + </form> </Form> </div> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index 53edfd14e..ed78452d0 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -260,12 +260,14 @@ export function PbnstMngForm({ }, [pbnst.pbnstMngRegData]); useEffect(() => { - if (!pbnst.pbnstRes) return; - const fcltNmList = pbnst.pbnstRes.map((item, index) => ({ + if ( pbnst.pbnstRes && pbnst.pbnstRes?.length> 0) return; + const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({ text: item.ruseUtztnFcltNm, val: String(index), })); + + if(fcltNmList) setFcltNm(fcltNmList); }, [pbnst.pbnstRes]); diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 85dde2e3c..6793aacba 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -12,6 +12,7 @@ export default function MngRegFormDetail({ moClass, sonClass, cycle, + onIputData }: { formList: formDetailType[]; h1Title?: string; @@ -19,6 +20,7 @@ export default function MngRegFormDetail({ moClass?: string; cycle?:string sonClass?: string; + onIputData?: (data: any) => void; }) { const { code, } = useWrStore((state) => state); return ( @@ -58,7 +60,7 @@ export default function MngRegFormDetail({ value={field.value} /> ) : ( - <Input placeholder="" type="text" value={field.value??''} onChange={field.onChange} /> + <Input placeholder="" type="text" value={field.value??''} onChange={field.onChange} /> )} </FormUi> )} From b96207cced396af35ee526e0883c1f2a0b2b16ab Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Tue, 3 Jun 2025 17:01:43 +0900 Subject: [PATCH 50/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EA=B3=B5=ED=86=B5=20=EC=BB=B4=ED=8F=AC=EB=84=8C?= =?UTF-8?q?=ED=8A=B8=20=EB=A7=8C=EB=93=9C=EB=8A=94=20=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business_components/src/ui/index.ts | 2 +- .../src/ui/sdmInsertForm/form.tsx | 246 ++++++++++++++++++ .../src/ui/sdmInsertForm/index.tsx | 164 ++++++++++++ .../sdmNameBox.tsx} | 46 ++-- 4 files changed, 439 insertions(+), 19 deletions(-) create mode 100644 packages/common/business_components/src/ui/sdmInsertForm/form.tsx create mode 100644 packages/common/business_components/src/ui/sdmInsertForm/index.tsx rename packages/common/business_components/src/ui/{sdmSearchForm/index.tsx => sdmInsertForm/sdmNameBox.tsx} (68%) diff --git a/packages/common/business_components/src/ui/index.ts b/packages/common/business_components/src/ui/index.ts index 606852d1e..0986f7953 100644 --- a/packages/common/business_components/src/ui/index.ts +++ b/packages/common/business_components/src/ui/index.ts @@ -19,4 +19,4 @@ export * from "./tab"; export * from "./table"; export * from "./table_div"; export * from "./title"; -export * from "./sdmSearchForm"; \ No newline at end of file +export * from "./sdmInsertForm/sdmNameBox"; \ No newline at end of file diff --git a/packages/common/business_components/src/ui/sdmInsertForm/form.tsx b/packages/common/business_components/src/ui/sdmInsertForm/form.tsx new file mode 100644 index 000000000..6d3219468 --- /dev/null +++ b/packages/common/business_components/src/ui/sdmInsertForm/form.tsx @@ -0,0 +1,246 @@ +import { FormField } from "../form"; +import { SelectBox } from "../select"; +import { Input } from "@common/components"; +import { FormUi } from "../form_ui"; +import { useCallback, useState } from "react"; +import type { ControllerRenderProps, UseFormReturn } from "react-hook-form"; +import { SdmSearchForm } from "./sdmNameBox"; +import type { DemandCompType } from "../../../../../../apps/dm/app/store/sdmMng"; + +type SelectDataType = { + text: string; + val: string; +}; + +interface FormSchema { + ctpvCd: string; + sggCd: string; + dmdCoNm: string; + dmdInfoPk: string; + daddr: string; + telno: string; + bznmTotNo?: string; + rgtr?: string; +} + +interface SdmRegFormProps { + form: UseFormReturn<FormSchema>; + onCheckboxChange?: (checked: boolean) => void; + selectSidoData: SelectDataType[]; + selectSigunData: SelectDataType[]; + dataList: DemandCompType[]; + rtnValue: (searchText: string, pageCnt: number) => void; + setIsDuplicate: (value: boolean) => void; +} + +type FieldComponent = (field: ControllerRenderProps<FormSchema, keyof FormSchema>) => JSX.Element; + +export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigunData, dataList, rtnValue, setIsDuplicate }: SdmRegFormProps) { + const [sidoValue, setSidoValue] = useState<string>(''); + const [sigunValue, setSigunValue] = useState<string>(''); + const [filteredSigunData, setFilteredSigunData] = useState<SelectDataType[]>([{ text: "전체", val: '0' }]); + const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(true); + + const initializeSigunData = useCallback((sidoCd: string) => { + if (sidoCd === '0') { + setSigunValue('0'); + setFilteredSigunData([{ text: "전체", val: '0' }]); + } else { + const newFilteredData = [ + { text: "전체", val: '0' }, + ...selectSigunData.filter((item: SelectDataType) => item.val.substring(0, 2) === sidoCd) + ]; + setSigunValue('0'); + setFilteredSigunData(newFilteredData); + } + }, [selectSigunData]); + + const onSelectValue = useCallback(( + val: string, + type: string, + field: ControllerRenderProps<FormSchema, keyof FormSchema> | undefined + ) => { + switch (type) { + case "ctpvCd": + initializeSigunData(val); + setSidoValue(val); + field?.onChange(val); + form.setValue('dmdInfoPk', ''); + form.setValue('bznmTotNo', ''); + break; + case "sggCd": + setSigunValue(val); + field?.onChange(val); + form.setValue('dmdInfoPk', ''); + form.setValue('bznmTotNo', ''); + break; + } + }, [initializeSigunData, form]); + + const handleCheckboxChange = useCallback((checked: boolean) => { + setIsBznmTotNoDisabled(checked); + onCheckboxChange?.(checked); + }, [onCheckboxChange]); + + const setRtnValue = useCallback((searchText: string, pageCnt: number) => { + rtnValue(searchText, pageCnt); + }, [rtnValue]); + + const setRtnData = useCallback((item: DemandCompType) => { + const rtnCompData = item; + form.setValue('dmdCoNm', rtnCompData?.dmdCoNm || ''); + form.setValue('dmdInfoPk', rtnCompData?.dmdInfoPk.substring(0,10) || ''); + form.setValue('bznmTotNo', rtnCompData?.dmdInfoPk.substring(10,14)==='0000' ? '' : rtnCompData?.dmdInfoPk.substring(10,14)); + + const sidoCd = rtnCompData?.ctpvCd.trim() || ''; + setSidoValue(sidoCd); + form.setValue('ctpvCd', sidoCd); + initializeSigunData(sidoCd); + + setTimeout(() => { + const sigunCd = rtnCompData?.sggCd.trim() || ''; + setSigunValue(sigunCd); + form.setValue('sggCd', sigunCd); + }, 100); + + if(rtnCompData?.dmdInfoPk.substring(10,14) === '0000') { + handleCheckboxChange(true); + } else { + handleCheckboxChange(false); + } + + form.setValue('daddr', rtnCompData?.daddr || ''); + form.setValue('telno', rtnCompData?.telno || ''); + + // 선택을 했을 때 중복 상태를 true로 설정 + setIsDuplicate(true); + }, [form, handleCheckboxChange, initializeSigunData, setIsDuplicate]); + + const setRtnText = useCallback((text: string) => { + form.setValue('dmdCoNm', text); + }, [form]); + + const formFields: Array<{ + name: keyof FormSchema; + label: string; + component: FieldComponent; + }> = [ + { + name: "ctpvCd", + label: "시도", + component: (field) => ( + <SelectBox + selectClass={undefined} + label="" + selectArray={selectSidoData} + onSelectValue={(val) => onSelectValue(val.toString(), 'ctpvCd', field)} + className="" + value={sidoValue} + /> + ) + }, + { + name: "sggCd", + label: "시군구", + component: (field) => ( + <SelectBox + selectClass={undefined} + label="" + selectArray={filteredSigunData} + onSelectValue={(val) => onSelectValue(val.toString(), 'sggCd', field)} + className="" + value={sigunValue} + /> + ) + }, + { + name: "dmdCoNm", + label: "회사명", + component: (field) => ( + <SdmSearchForm + rtnData={setRtnData} + label="수요처명" + initValue={''} + dataList={dataList} + rtnValue={setRtnValue} + rtnText={setRtnText} + {...field} + /> + ) + }, + { + name: "dmdInfoPk", + label: "사업자등록번호", + component: (field) => ( + <Input + placeholder="사업자등록번호를 입력하세요" + type="text" + className="!text-xl text-gray-600" + {...field} + /> + ) + }, + { + name: "bznmTotNo", + label: "종사업자등록번호", + component: (field) => ( + <FormUi + label="종사업자등록번호" + onCheckboxChange={handleCheckboxChange} + isDisabled={isBznmTotNoDisabled} + > + <Input + placeholder="여러사업장이 있을 경우 입력해주세요" + type="text" + className="!mt-5 !text-xl text-gray-600" + disabled={isBznmTotNoDisabled} + {...field} + /> + </FormUi> + ) + }, + { + name: "daddr", + label: "사업자주소", + component: (field) => ( + <Input + placeholder="주소를 입력하세요" + type="text" + className="!text-xl text-gray-600" + {...field} + /> + ) + }, + { + name: "telno", + label: "전화번호", + component: (field) => ( + <Input + placeholder="전화번호를 입력하세요" + type="text" + className="!text-xl text-gray-600" + {...field} + /> + ) + } + ]; + + return ( + <> + {formFields.map(({ name, label, component }) => ( + <FormField + key={String(name)} + control={form.control} + name={name} + render={({ field }) => ( + name === 'bznmTotNo' ? component(field) : ( + <FormUi label={label}> + {component(field)} + </FormUi> + ) + )} + /> + ))} + </> + ); +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx new file mode 100644 index 000000000..4a972180a --- /dev/null +++ b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx @@ -0,0 +1,164 @@ +"use client"; + +/* import { useDmStore } from "@/app/store"; */ +import { SdmRegForm } from "./form"; +import type { DemandCompType } from "../../../../../../apps/dm/app/store/sdmMng"; +import { Button } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +/* import { useRouter } from "next/navigation"; */ +import { useCallback, useEffect, useState } from "react"; +import { FormProvider, useForm, type SubmitHandler } from "react-hook-form"; +import { toast, Toaster } from "sonner"; +/* import { Toaster, toast } from "react-hot-toast"; */ +import * as z from "zod"; +import type { SelectDataType } from "../search_input_select"; + +type thisProps = { + selectSidoData: SelectDataType[]; + selectSigunData: SelectDataType[]; + dataList: DemandCompType[]; + rtnValue: (searchText: string, pageCnt: number) => void; + rtnInputData: (data: DemandCompType) => void; +} + +const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean) => z.object({ + ctpvCd: z.string().min(1, "시/도를 선택해주세요"), + sggCd: z.string().min(1, "시/군/구를 선택해주세요"), + dmdCoNm: z.string() + .min(1, "회사명을 입력해주세요") + .max(20, "회사명은 20자 이내로 입력해주세요"), + dmdInfoPk: z.string() + .min(1, "사업자등록번호를 입력해주세요") + .regex(/^\d{10}$/, "사업자등록번호는 10자리 숫자만 입력 가능합니다") + .refine(() => !isDuplicate, "이미 등록된 사업자등록번호입니다"), + bznmTotNo: isBznmTotNoDisabled + ? z.string().optional() + : z.string() + .length(4, "종사업자등록번호는 4자리 숫자만 입력 가능합니다"), + daddr: z.string() + .min(1, "주소를 입력해주세요") + .min(6, "주소는 6자 이상 입력해주세요") + .max(40, "주소는 40자 이내로 입력해주세요"), + telno: z.string() + .min(8, "전화번호는 8자 이상 입력해주세요") + .max(12, "전화번호는 12자 이내로 입력해주세요") + .regex(/^[0-9-]+$/, "전화번호는 숫자와 하이픈(-)만 입력 가능합니다"), + rgtr: z.string().optional(), +}); + +type FormSchema = ReturnType<typeof createFormSchema>; +export type FormData = z.infer<FormSchema>; + +const defaultValues: FormData = { + ctpvCd: '', + sggCd: '', + dmdCoNm: '', + dmdInfoPk: '', + bznmTotNo: '', + daddr: '', + telno: '', + rgtr: "3fa85f64-5717-4562-b3fc-2c963f66afa6", +}; + +export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData}: thisProps) { + /* const { insertSdmData } = useDmStore((state) => state); + const router = useRouter(); */ + + const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(true); + const [isDuplicate, setIsDuplicate] = useState(false); + const formSchema = createFormSchema(isBznmTotNoDisabled, isDuplicate); + + const form = useForm<z.infer<FormSchema>>({ + resolver: zodResolver(formSchema), + defaultValues, + mode: "onChange", + criteriaMode: "all", + shouldFocusError: false, + shouldUnregister: false + }); + + // 체크박스 상태가 변경될 때마다 bznmTotNo 필드의 에러를 초기화 + useEffect(() => { + if (isBznmTotNoDisabled) { + form.clearErrors('bznmTotNo'); + form.setValue('bznmTotNo', ''); + } + }, [isBznmTotNoDisabled, form]); + + const setRtnValue = useCallback((searchText: string, pageCnt: number) => { + rtnValue(searchText, pageCnt); + }, [rtnValue]); + + const onSubmit: SubmitHandler<z.infer<FormSchema>> = async (data) => { + try { + // form 에러 체크 + const formErrors = form.formState.errors; + if (Object.keys(formErrors).length > 0) { + const errorMessage = Object.values(formErrors)[0]?.message || '입력값을 확인해주세요.'; + toast.error(errorMessage); + return; + } + + const dmdInfoPk = data.dmdInfoPk + (data.bznmTotNo || '0000'); + const formData = { + ...data, + dmdInfoPk, + }; + + console.log(formData); + /* await insertSdmData(formData); */ + rtnInputData(formData as DemandCompType); + + const queryParams = new URLSearchParams({ + dmdCoNm: data.dmdCoNm, + ctpvCd: data.ctpvCd, + sggCd: data.sggCd, + dmdInfoPk, + bznmTotNo: data.bznmTotNo || '', + daddr: data.daddr, + telno: data.telno, + }); + + //router.push(`/pages/sdmMng/sdmInfoInsert?${queryParams.toString()}`); + toast.success('수요처가 성공적으로 등록되었습니다.'); + } catch (error) { + console.error('Error submitting form:', error); + toast.error('수요처 등록에 실패했습니다.'); + } + }; + + return ( + <> + <div className="text-center mb-8"> + <h1 className="text-4xl font-bold text-gray-900 underline"> + 수요처등록 + </h1> + </div> + + <div className="max-w-3xl mx-auto bg-white rounded-lg shadow-md p-6"> + <FormProvider {...form}> + <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6"> + <SdmRegForm + form={form} + onCheckboxChange={setIsBznmTotNoDisabled} + selectSidoData={selectSidoData} + selectSigunData={selectSigunData} + dataList={dataList} + rtnValue={setRtnValue} + setIsDuplicate={setIsDuplicate} + /> + <div className="flex justify-center pt-4"> + <Button + type="submit" + className="w-32 bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded-md transition-colors duration-200" + > + 수요처등록 + </Button> + </div> + </form> + </FormProvider> + </div> + <Toaster position="top-center" /> + </> + ); +} \ No newline at end of file diff --git a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx b/packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx similarity index 68% rename from packages/common/business_components/src/ui/sdmSearchForm/index.tsx rename to packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx index 62009826e..18d048692 100644 --- a/packages/common/business_components/src/ui/sdmSearchForm/index.tsx +++ b/packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx @@ -1,18 +1,24 @@ import React, { useCallback, useEffect, useRef, useState } from 'react'; +import type { DemandCompType } from "../../../../../../apps/dm/app/store/sdmMng"; export type thisProps = { label: string | undefined; initValue: string | undefined; - setRtnData : (rtnData: any[]) => void; + dataList : DemandCompType[]; + rtnValue : (searchText: string, pageCnt: number) => void; + rtnData : (item: DemandCompType) => void; + rtnText : (text: string) => void; } -export const SdmSearchForm = ({label=undefined, initValue=undefined, setRtnData=()=>{}} :thisProps) => { - - /* const { getDemandCompList, Sdm } = useDmStore((state) => state); - - const { - demandCompList - } = Sdm; */ +/** + * 수요처 검색 컴포넌트 + * @param label 라벨 + * @param initValue 초기값 + * @param rtnValue 검색 결과 반환 함수 + * @param dataList 검색할 때 넘기는 데이터 리스트 + * @param rtnData 검색 결과 반환 함수 + */ +export const SdmSearchForm = ({label=undefined, initValue=undefined, rtnValue=()=>{}, dataList=[], rtnData=()=>{}, rtnText=()=>{} } :thisProps) => { const [isOpen, setIsOpen] = useState(false); const [textValue, setTextValue] = useState(initValue || ''); @@ -20,16 +26,20 @@ export const SdmSearchForm = ({label=undefined, initValue=undefined, setRtnData= const handleInputChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => { const value = e.target.value; setTextValue(value); + rtnValue(value, 10); + rtnText(value); if (value) { setIsOpen(true); } else { setIsOpen(false); } - }, []); + }, [rtnValue, rtnText]); - /* const handleSuggestionClick = useCallback((dmdCoNm: string) => { - setTextValue(dmdCoNm); - }, []); */ + const handleSuggestionClick = useCallback((item: DemandCompType) => { + setTextValue(item.dmdCoNm); + rtnData(item); + setIsOpen(false); + }, [rtnData]); useEffect(() => { const handleClickOutside = (event: MouseEvent) => { @@ -43,7 +53,7 @@ export const SdmSearchForm = ({label=undefined, initValue=undefined, setRtnData= document.removeEventListener('mousedown', handleClickOutside); }; }, []); - + return ( <div ref={wrapperRef}> <input @@ -57,26 +67,26 @@ export const SdmSearchForm = ({label=undefined, initValue=undefined, setRtnData= {isOpen && ( <div className=" z-1 w-full mt-2 bg-white border border-gray-300 rounded-md shadow-lg h-90 overflow-auto"> <div className="max-h-72"> - {/* {demandCompList && demandCompList.length > 0 ? demandCompList.map((item : DemandCompType, index : number) => ( + {dataList && dataList.length > 0 ? dataList.map((item : DemandCompType, index : number) => ( <div key={index} className="!text-xl w-full text-left px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto" - onClick={() => handleSuggestionClick(item.dmdCoNm)} + onClick={() => handleSuggestionClick(item)} role="button" tabIndex={0} onKeyDown={(e) => { if (e.key === 'Enter' || e.key === ' ') { - handleSuggestionClick(item.dmdCoNm); + handleSuggestionClick(item); } }} > {item.dmdInfoPk.substring(0,10)} <span className="float-right">{item.dmdCoNm}</span> </div> - )) : ( */} + )) : ( <div className="!text-xl w-full px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto"> 검색 결과가 없습니다. </div> - {/* )) : ( */} + )} </div> </div> )} From c28dd728c51f58dd50f55e99c797d0fdc7f0a3de Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Tue, 3 Jun 2025 19:24:33 +0900 Subject: [PATCH 51/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=9A=94=EC=B2=98=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltReg/pbnstReg/headList.tsx | 9 - .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 21 +- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 10 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 220 ++++++++++++++---- .../mngRegFormDetail/mngRegFormDetail.tsx | 47 +++- 5 files changed, 240 insertions(+), 67 deletions(-) diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx index 465cad08b..186bfd3c0 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/headList.tsx @@ -64,15 +64,6 @@ export const fcOrgwtsHeadListExport: TableUpperProps[] = [ { id: "addr", title: "위치" }, ]; -export const dmdCoList: formDetailType[] = [ - { id: "dmdCoNm", lable: "수요처명" }, - { id: "daddr", lable: "위치(주소)" }, - { id: "useUsgCd", lable: "사용용도" }, - { id: "splyBgngDay", lable: "공급시작일", type: "date" }, - { id: "splyEndDay", lable: "공급종료일", type: "date" }, - { id: "splyCpct", lable: "(계약)공급량(m3/일)" }, - { id: "splyFmYn", lable: "공급 유량계 유무", type: "selectYn" }, -]; export const pbnstMngNmExport: chHeadType[] = [ { headNm: "upChangeRe", text: "운영대행기간", length: 2 }, diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index d4dce6d09..62a6447f7 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -68,6 +68,7 @@ type pubFacActions = { getBizCycle: (pbnstObj: customPbnst) => void; getDmdCompany: (txt: string) => void; getpbnstInsertIndex: (data: pbnstInsertIndex) => void; + searchDmdColist:(txt:string) =>void }; export type pubFacType = pubFacState & pubFacActions; @@ -338,6 +339,24 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (e) { console.log(e); } - }, + },searchDmdColist:async (txt:string)=>{ + + try{ + console.log(' txt ', txt) + const coList = await getFetch(fetchType.WR, `reuseFc/request/${txt}/{3}`); + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + dmdCoList: coList, + isInit: false, + }, + })); + }catch(e){ + console.log(e) + + } + + } }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index 17b99afcc..f3f695725 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -121,14 +121,14 @@ export type pubHasuType = z.infer<typeof pubHasuZod>; const dmdColist = z.object({ - dmdCoNm: z.boolean().default(false), + dmdCoNm: z.string().default(''), daddr: z.string(), useUsgCd: z.string().default(""), - splyBgngDay: z.string().default(""), - splyEndDay: z.string().default(""), + splyBgngDay: z.date().default(new Date()), + splyEndDay: z.date().default(new Date()), splyCpct: z.string().default(""), splyFmYn: z.number().default(0), - telno:z.string().default('') + //telno:z.string().default('') }); @@ -200,7 +200,7 @@ export const fcBizSchema = z.object({ ruseFcltCstClcln: z.number().nullish(), fcOrgwts: z.array(fcOrgwtSchema).nullish(), pplInstls: z.array(pplInstlSchema).nullish(), - demandInfo: z.array(dmdColist).default([]).nullish(), + fcDemands: z.array(dmdColist).default([]).nullish(), flg: z.string().nullish(), regDt: z.string().nullish(), rgtr: z.string().nullish(), diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index f127579fc..608b2ccab 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -5,7 +5,6 @@ import { businessMoneyInfo, businessSttnInfo, concentratedWaterInfo, - dmdCoList, ruseFcltinfo, ruseWaterQulityList, wasteWaterFcltINfo, @@ -25,13 +24,23 @@ import { import FcOrgwtsRegModal from "@/components/ui/modal/fcltReg/fcOrgwtsRegModal/fcOrgwtsRegModal"; import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable"; import { SelectBox } from "@common/business_components"; -import { UiModal, type SelectDataType } from "@common/business_components/ui"; -import { Form } from "@common/business_components/ui/form"; -import { Button, Input, Label } from "@common/components"; +import { + FormUi, + SearchInputSelect, + UiModal, + type SelectDataType, +} from "@common/business_components/ui"; +import { Form, FormField } from "@common/business_components/ui/form"; +import { Button, DatePicker, Input, Label } from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; +import { + handleCommaNumberChange, + formatCommaNumber, + safeDate, +} from "@/components/lib/func/commom"; export function PbnstBuseForm({ formType, @@ -48,6 +57,7 @@ export function PbnstBuseForm({ getpbnstInsertIndex, appendRuseFclt, getBizCycle, + searchDmdColist, } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [bizCycle, setBizCycle] = useState("1"); @@ -58,7 +68,6 @@ export function PbnstBuseForm({ const [sumCpct, setSumCpct] = useState<number>(0); const [searchDmdCo, setSeachDmdCo] = useState<String>(); - const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), defaultValues: @@ -90,7 +99,7 @@ export function PbnstBuseForm({ if ( pbnst.pbnstRes && pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng] && - pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs + pbnst.pbnstRes[pbnst.pbnsUpdateIndex.mng]?.fcBizs ) { regData = { pbnstRuseFcltFk: @@ -102,20 +111,22 @@ export function PbnstBuseForm({ } as fcBizType; const newPbnstRes = [...(pbnst.pbnstRes as customPbnst[])]; - newPbnstRes[index]?.fcBizs?.length && newPbnstRes[index]?.fcBizs?.push(regData); + newPbnstRes[index]?.fcBizs?.length && + newPbnstRes[index]?.fcBizs?.push(regData); getBizCycle(newPbnstRes[index] as customPbnst); appendRuseFclt(newPbnstRes); + } } - const { fields: demandInfo, - append:appendDemand, - remove:removeDemand } = useFieldArray({ + const { + fields: fcDemands, + append: appendDemand, + remove: removeDemand, + } = useFieldArray({ control: form.control, - name: "demandInfo", + name: "fcDemands", }); - - const { fields: fcOrgwtFiled } = useFieldArray({ control: form.control, name: "fcOrgwts", @@ -151,6 +162,10 @@ export function PbnstBuseForm({ } }, [firstBizData, form.formState, formType]); + useEffect(() => { + console.log("searchDmdCo ", searchDmdCo); + }, [searchDmdCo]); + useEffect(() => { if (ppiYn === "N") { form.setValue("pplInstls", []); @@ -180,19 +195,19 @@ export function PbnstBuseForm({ }; const plusArray = () => { -<> -<MngRegFormDetail - formList={dmdCoList} - h1Title={"하수처리수 재이용수 수요처"} - form={form} - moClass="grid grid-cols-12 gap-4 mt-3" - sonClass="col-span-4" - onIputData={(val) => { - setSeachDmdCo(val); - }} - /> -</> + console + .log('qweqwe ') + appendDemand({ + dmdCoNm: "", + daddr: "", + useUsgCd: "", + splyBgngDay: new Date(), + splyEndDay: new Date(), + splyCpct: "", + splyFmYn: 0, + //telno: "", + }); }; const removeSelected = () => { @@ -388,33 +403,154 @@ export function PbnstBuseForm({ moClass="grid grid-cols-12 gap-4" sonClass="col-span-4" /> - <div> + <h1 className={formH1Class}>{'하수처리수 재이용수 수요처'}</h1> <div className="text-right mb-3"> <Button type="button" - onClick={() => {appendDemand}} + onClick={plusArray} size={commonButonSize} - className="" + className="mt-6" > 수요처 추가 </Button> </div> - <MngRegFormDetail - formList={dmdCoList} - h1Title={"하수처리수 재이용수 수요처"} - form={form} - moClass="grid grid-cols-12 gap-4 mt-3" - sonClass="col-span-4" - onIputData={(val) => { - setSeachDmdCo(val); - }} - /> + {fcDemands.map((field, index) => ( + <div className="grid grid-cols-12 gap-4 mt-3"> + <div className="col-span-4"> + <FormField + control={form.control} + name={`fcDemands.${index}.dmdCoNm`} + render={({ field: f }) => ( + <FormUi label="수요처명"> + <SearchInputSelect + className={""} + label={""} + selectData={[]} + onSelectValue={(val) => { + searchDmdColist(val); + }} + textValue={f.value} + setText={(val) => { + setSeachDmdCo(val); + }} + selectValue={searchDmdCo} + ></SearchInputSelect> + </FormUi> + )} + /> + </div> + <div className="col-span-4"> + <FormField + control={form.control} + name={`fcDemands.${index}.daddr`} + render={({ field: f }) => ( + <FormUi label="위치(주소)"> + <Input + placeholder="-" + type="text" + onChange={(e) => f.onChange(e.target.value)} + value={f.value} + className={selectClass} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-4"> + <FormField + control={form.control} + name={`fcDemands.${index}.useUsgCd`} + render={({ field: f }) => ( + <FormUi label="사용용도"> + <Input + placeholder="-" + type="text" + onChange={(e) => f.onChange(e.target.value)} + value={f.value} + className={selectClass} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3"> + <FormField + control={form.control} + name={`fcDemands.${index}.splyBgngDay`} + render={({ field: f }) => ( + <FormUi label="공급시작일"> + <DatePicker + mode={"single"} + selected={safeDate(f.value) || new Date()} + onSelect={(date: Date | undefined) => + f.onChange(date) + } + className={"rounded-lg !w-full"} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3"> + <FormField + control={form.control} + name={`fcDemands.${index}.splyEndDay`} + render={({ field: f }) => ( + <FormUi label="공급종료일"> + <DatePicker + mode={"single"} + selected={safeDate(f.value) || new Date()} + onSelect={(date: Date | undefined) => + f.onChange(date) + } + className={"rounded-lg !w-full"} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3"> + <FormField + control={form.control} + name={`fcDemands.${index}.splyCpct`} + render={({ field: f }) => ( + <FormUi label="(계약)공급량(m3/일)"> + <Input + placeholder="" + type="number" + value={f.value ?? 0} + onChange={(e) => { + f.onChange(Number(e.target.value)); + }} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3"> + <FormField + control={form.control} + name={`fcDemands.${index}.splyFmYn`} + render={({ field: f }) => ( + <FormUi label="공급 유량계 유무"> + <SelectBox + label={""} + selectClass={""} + className="w-full" + selectArray={code.yn} + onSelectValue={(val: string | number) => + f.onChange(val) + } + value={f.value} + /> + </FormUi> + )} + /> + </div> + </div> + ))} </div> - - - - </form> </Form> </div> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx index 6793aacba..7f9ff4fef 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegFormDetail/mngRegFormDetail.tsx @@ -1,9 +1,17 @@ +'use client' import { useWrStore } from "@/app/store"; import type { formDetailType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList"; import { formH1Class } from "@/components/lib/class/comClass"; import { safeDate } from "@/components/lib/func/commom"; -import { FormField, FormUi, SelectBox } from "@common/business_components/ui"; +import { + FormField, + FormUi, + SearchInputSelect, + SelectBox, + type SelectDataType, +} from "@common/business_components/ui"; import { DatePicker, Input } from "@common/components/ui"; +import { useState } from "react"; export default function MngRegFormDetail({ formList, @@ -12,24 +20,28 @@ export default function MngRegFormDetail({ moClass, sonClass, cycle, - onIputData + onIputData, + searchSelectData }: { formList: formDetailType[]; h1Title?: string; form: any; moClass?: string; - cycle?:string + cycle?: string; sonClass?: string; onIputData?: (data: any) => void; + searchSelectData?: SelectDataType[]; }) { - const { code, } = useWrStore((state) => state); + const { code } = useWrStore((state) => state); + + const [searchData, setSearchData]= useState<string>('') + return ( <> - { h1Title ? <h1 className={formH1Class}>{h1Title}</h1> : <></>} + {h1Title ? <h1 className={formH1Class}>{h1Title}</h1> : <></>} <div className={moClass}> {formList?.map((item, index) => { - - const fieldId = cycle? `${cycle}.${item.id}`: item.id; + const fieldId = cycle ? `${cycle}.${item.id}` : item.id; return ( <div className={sonClass} key={index + `${item.id}`}> <FormField @@ -49,18 +61,32 @@ export default function MngRegFormDetail({ className={"rounded-lg !w-full"} /> ) : item.type === "number" ? ( - <Input placeholder="" type="number" value={field.value??0} onChange={(e) =>{field.onChange(Number(e.target.value))}} /> + <Input + placeholder="" + type="number" + value={field.value ?? 0} + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + /> ) : item.type === "selectYn" ? ( <SelectBox label={""} selectClass={""} className="w-full" selectArray={code.yn} - onSelectValue={(val: string | number) => field.onChange(val)} + onSelectValue={(val: string | number) => + field.onChange(val) + } value={field.value} /> ) : ( - <Input placeholder="" type="text" value={field.value??''} onChange={field.onChange} /> + <Input + placeholder="" + type="text" + value={field.value ?? ""} + onChange={field.onChange} + /> )} </FormUi> )} @@ -72,3 +98,4 @@ export default function MngRegFormDetail({ </> ); } + From c49b2a8e08e64eab72be679627917df48375fc16 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Tue, 3 Jun 2025 21:06:52 +0900 Subject: [PATCH 52/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EC=8B=A4=EC=A0=81=20=EB=93=B1=EB=A1=9D=20=EC=97=91?= =?UTF-8?q?=EC=85=80=20=EB=93=B1=EB=A1=9D=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../prfmncReg/pbnstPrfmncReg/page.tsx | 240 ++++++++++-------- .../store/prfmncReg/pbnstPrfmncReg/excel.tsx | 43 ++++ .../prfmncReg/pbnstPrfmncReg/headList.tsx | 8 + .../pbnPrfExcelModal/pbnPrfExcelModal.tsx | 168 ++++++++++++ .../rainChjgdDetail/rainChkgdDetailTable.tsx | 0 5 files changed, 347 insertions(+), 112 deletions(-) create mode 100644 apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx create mode 100644 apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx delete mode 100644 apps/wr/components/ui/table/chkgdTable/rainChjgdDetail/rainChkgdDetailTable.tsx diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index e3f3e9fe9..b62286b3d 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -3,125 +3,141 @@ import { useWrStore } from "@/app/store"; import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { yearOptions } from "@/components/lib/func/commom"; -import { ContentsDiv, Title, SearchDiv, SearchFormLeft, SelectBox, SearchInput, SearchFormRight, ScrollArea, UiTable } from "@common/business_components/ui"; +import PbnPrfExcelModal from "@/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal"; +import { + ContentsDiv, + Title, + SearchDiv, + SearchFormLeft, + SelectBox, + SearchInput, + SearchFormRight, + ScrollArea, + UiTable, + UiModal, +} from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Label } from "@common/components/ui"; import { useState, useEffect } from "react"; +import { set } from "react-hook-form"; +import { Toaster } from "react-hot-toast"; export default function prfmncPrfmncReg() { - const { code, prfmnc, prfmncHasuInit, searchFclts, } = useWrStore((state) => state); - const { pbnstPrfmncHeadList, monthHeadList,prfmncRes } = prfmnc; - const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); - const [searchTxt, setSearchTxt] = useState<string>(); + const { code, prfmnc, prfmncHasuInit, searchFclts } = useWrStore( + (state) => state + ); + const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc; + const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); + const [searchTxt, setSearchTxt] = useState<string>(); + const [isExcelOpen, setIsExcelOPen] = useState<boolean>(false); - const [searchYear, setSearchYear] = useState<string>(String(new Date().getFullYear())); - useEffect(() => { - if (!prfmnc.isInit) { - prfmncHasuInit("1", "11"); - } - }, [prfmnc.isInit, prfmncHasuInit]); - useEffect(() => { - console.log("prfmnc.prfmncRes", prfmncRes) - },[prfmncRes]); + const [searchYear, setSearchYear] = useState<string>( + String(new Date().getFullYear()) + ); + useEffect(() => { + if (!prfmnc.isInit) { + prfmncHasuInit("1", "11"); + } + }, [prfmnc.isInit, prfmncHasuInit]); + useEffect(() => { + console.log("prfmnc.prfmncRes", prfmncRes); + }, [prfmncRes]); - return ( - <> - <ContentsDiv> - <div className="grid grid-cols-4 gap-4"> - <div className="col-span-4"> - <Title title={"하수재이용 시설 등록"} /> - <SearchDiv> - <SearchFormLeft> - <div className="col-span-2 flex flex-row space-x-2"> - <Label className="w-48 mt-2 text-xl text-gray-600">{'실적등록년도'}</Label> - <SelectBox - className="w-full h-full text-2xl" - label="" - selectClass={""} - selectArray={yearOptions} - value={searchYear} - onSelectValue={(val: string | number) => - setSearchYear(String(val)) - } - /> - </div> - <div className="col-span-2 flex flex-row space-x-2"> - <Label className="w-28 mt-2 text-xl text-gray-600">{'시설명'}</Label> - <SearchInput - className={"w-full text-2xl"} - label="" - textValue={searchTxt || ""} - setText={(e) => { - setSearchTxt(e); - }} - /> - </div> - </SearchFormLeft> - <SearchFormRight - className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> - <div className="space-y"> - <div className="flex flex-row space-x-2"> - <Button - size={"sm"} - onClick={(e) => { }} - > - 조회 - </Button> - <Button - size={"sm"} - onClick={() => { }} - > - 저장 - </Button> - <Button - size={"sm"} - onClick={() => { }} - > - 파일등록 - </Button> - <Button color="green" size={"sm"} onClick={() => { }}> - 양식받기 - </Button> - </div> - </div> - </SearchFormRight> - </SearchDiv> - </div> + return ( + <> + <ContentsDiv> + <div className="grid grid-cols-4 gap-4"> + <div className="col-span-4"> + <Title title={"하수재이용 시설 등록"} /> + <SearchDiv> + <SearchFormLeft> + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-48 mt-2 text-xl text-gray-600"> + {"실적등록년도"} + </Label> + <SelectBox + className="w-full h-full text-2xl" + label="" + selectClass={""} + selectArray={yearOptions} + value={searchYear} + onSelectValue={(val: string | number) => + setSearchYear(String(val)) + } + /> </div> - - <div className="grid grid-cols-12 gap-4 h-full"> - <div className="col-span-4 h-full min-h-0"> - <ListDiv className="min-h-0"> - <ScrollArea className="h-[60vh]"> - <UiTable - tableData={bdstTable || []} - headlist={pbnstPrfmncHeadList} - pageSize={100} - total={10} - headName={"하수재이용시설 목록"} - cellClick={() => { }} - onPageChange={(page: number) => { }} - children={undefined} - /> - </ScrollArea> - </ListDiv> - </div> - <ListDiv className="col-span-8 pr-6 "> - <ScrollArea className="h-[60vh]"> - <UiTable - tableData={[]} - headlist={monthHeadList} - pageSize={100} - total={10} - headName={"하수처리수재이용 실적(m3) 등록결과"} - cellClick={() => { }} - onPageChange={() => { }} - children={undefined} - /> - </ScrollArea> - </ListDiv> + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-28 mt-2 text-xl text-gray-600"> + {"시설명"} + </Label> + <SearchInput + className={"w-full text-2xl"} + label="" + textValue={searchTxt || ""} + setText={(e) => { + setSearchTxt(e); + }} + /> </div> - </ContentsDiv> - </> - ); + </SearchFormLeft> + <SearchFormRight className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> + <div className="space-y"> + <div className="flex flex-row space-x-2"> + <Button size={"sm"} onClick={(e) => {}}> + 조회 + </Button> + <Button size={"sm"} onClick={() => {}}> + 저장 + </Button> + <Button size={"sm"} onClick={() => {setIsExcelOPen(true)}}> + 파일등록 + </Button> + <Button color="green" size={"sm"} onClick={() => {}}> + 양식받기 + </Button> + </div> + </div> + </SearchFormRight> + </SearchDiv> + </div> + </div> + + <div className="grid grid-cols-12 gap-4 h-full"> + <div className="col-span-4 h-full min-h-0"> + <ListDiv className="min-h-0"> + <ScrollArea className="h-[60vh]"> + <UiTable + tableData={bdstTable || []} + headlist={pbnstPrfmncHeadList} + pageSize={100} + total={10} + headName={"하수재이용시설 목록"} + cellClick={() => {}} + onPageChange={(page: number) => {}} + children={undefined} + /> + </ScrollArea> + </ListDiv> + </div> + <ListDiv className="col-span-8 pr-6 "> + <ScrollArea className="h-[60vh]"> + <UiTable + tableData={[]} + headlist={monthHeadList} + pageSize={100} + total={10} + headName={"하수처리수재이용 실적(m3) 등록결과"} + cellClick={() => {}} + onPageChange={() => {}} + children={undefined} + /> + </ScrollArea> + </ListDiv> + </div> + </ContentsDiv> + <UiModal bodyClass={""} body={<PbnPrfExcelModal></PbnPrfExcelModal>} open={isExcelOpen} onOpenChange={() => {setIsExcelOPen(!isExcelOpen)}}></UiModal> + <Toaster position="top-center" /> + + </> + ); } diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx new file mode 100644 index 000000000..b0cbb7724 --- /dev/null +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/excel.tsx @@ -0,0 +1,43 @@ +import { TEST_UUID } from "../../ruseFcltMng/fcltReg/rainReg"; + + + const nameMap = { + "세척수": "wshwtr", + "냉각수": "coolUswtr", + "청소수": "cleanUswtr", + "식수대": "drwtUswtr", + "희석용수": "dltnUswtr", + "중수도": "ithlRswtr", + "기타": "ithlEtcUswtr", + "청소화장실용수": "cleanToilUswtr", + "세척살수용수": "resn", + "조경용수": "lndwtr", + "친수용수": "hydUswtr", + "지하수충전": "ugwtChr", + "농업용수": "farmUswtr", + "하천등유지용수": "rvrKeepUswtr", + "공업용수": "indstUswtr" + }; + + +export const excelToPbnPrfData = (excelData: any[], year: string) => { + // 월별 데이터 하나로 병합 + const merged = {} as any; + excelData.forEach((item: any) => { + const key = nameMap[item["용수명"]]; + if (!key) return; + + for (let i = 1; i <= 12; i++) { + const month = i.toString().padStart(2, "0"); + const ym = year + month; + + if (!merged[ym]) merged[ym] = { ym }; + merged[ym][key] = Number(item[`${i}월`] ?? 0); + } + }); + + const pbnPrfData = Object.values(merged); + console.log(pbnPrfData); + + return pbnPrfData; +}; \ No newline at end of file diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx index fd2fc9ada..a41eeba52 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/headList.tsx @@ -1,5 +1,13 @@ +import { z } from "zod"; import type { TableUpperProps } from "../../ruseFcltMng/fcltReg/rainReg"; +export const pbnPrfRegExcelZod = z.object({ + ym: z.string().default(""), + bscFctNm: z.string().default(""), + pbnstRuseFcltNm: z.string().default(""), + file: z.instanceof(File).optional(), +}); + export const pbnstPrfmncHeadListExport: TableUpperProps[] = [ { id: "sido", title: "시도" }, { id: "gugun", title: "시군구" }, diff --git a/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx b/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx new file mode 100644 index 000000000..8190b96e8 --- /dev/null +++ b/apps/wr/components/ui/modal/chkgd/pbnPrfExcelModal/pbnPrfExcelModal.tsx @@ -0,0 +1,168 @@ +import { useWrStore } from "@/app/store"; +import { excelToPbnPrfData } from "@/app/store/prfmncReg/pbnstPrfmncReg/excel"; +import { pbnPrfRegExcelZod } from "@/app/store/prfmncReg/pbnstPrfmncReg/headList"; +import { yearOptions } from "@/components/lib/func/commom"; +import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; +import { + FileUpload, + FormField, + FormUi, + SelectBox, + Form, + Title, + type SelectDataType, + filePicked, +} from "@common/business_components/ui"; +import { Button } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useEffect, useState } from "react"; +import { useForm } from "react-hook-form"; +import type { z } from "zod"; + +export default function PbnPrfExcelModal() { + const { code, prfmnc, searchFclts } = useWrStore((state) => state); + + + const [bscFctNmList, setBscFctNmList] = useState<SelectDataType[] | null>(null); + const [files, setFiles] = useState<File[] | null>(null); +const [excelData, setExcelData] = useState<any[]>(); + const form = useForm<z.infer<typeof pbnPrfRegExcelZod>>({ + resolver: zodResolver(pbnPrfRegExcelZod), + defaultValues: { + ym: String(new Date().getFullYear()), + }, + }); + const onSubmit = (values: z.infer<typeof pbnPrfRegExcelZod>) => { + console.log(values); + }; + useEffect(() => { + + if(prfmnc.prfmncRes.length > 0){ + + const basFctNmList = prfmnc.prfmncRes.map((item)=>( + { + val:item.bscFctCd, + text:item.bscFctNm + } + )) + setBscFctNmList(basFctNmList) + } + + }, [prfmnc.prfmncRes]); + + + useEffect(()=>{ + + if(files){ + + const file = files[0]; + if (form.getValues("ym").length < 1) { + ToastFormUi({ + body: "파일업로드 이전에 등록년도를 작성해주세요 ", + title: "지도점검 등록", + }); + setFiles(null); + return; + } + + if(file) + filePicked(file, 0).then((res) => { + if (res !== undefined) + console.log(excelToPbnPrfData(res, form.getValues("ym"))) + }); + + + } + },[files]) + + return ( + <> + <div> + <Form {...form}> + <form onSubmit={form.handleSubmit(onSubmit)}> + <div> + <Title title={"하수재이용 실적등록"}> +
+
+

+ {"점검정보 입력"} +

+ + +
+ +
+ ( + + field.onChange(val)} + /> + + )} + /> + + ( + + field.onChange(String(val))} + /> + + )} + /> + ( + + field.onChange(String(val))} + /> + + )} + /> + + ( + + { + if (files) setFiles(files); + }} + fileTypes="xlsx" + > + + )} + /> +
+ + +
+ + ); +} diff --git a/apps/wr/components/ui/table/chkgdTable/rainChjgdDetail/rainChkgdDetailTable.tsx b/apps/wr/components/ui/table/chkgdTable/rainChjgdDetail/rainChkgdDetailTable.tsx deleted file mode 100644 index e69de29bb..000000000 From c2d471c5a2d57c77b5d3f64d683cf4c41af84fc6 Mon Sep 17 00:00:00 2001 From: jyha00 Date: Wed, 4 Jun 2025 09:27:59 +0900 Subject: [PATCH 53/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EA=B2=80=ED=86=A0=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EB=A7=8C?= =?UTF-8?q?=EB=93=9C=EB=8A=94=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/matMng/matDmd/coMatRvw/page.tsx | 69 +++++++++++ apps/wr/app/page.tsx | 12 ++ .../prfmncReg/pbnstPrfmncReg/page.tsx | 23 +++- .../wr/app/store/matDmd/coMatRvw/headList.tsx | 109 ++++++++++++++++++ apps/wr/app/store/matDmd/coMatRvw/index.tsx | 34 ++++++ .../store/prfmncReg/pbnstPrfmncReg/index.tsx | 4 +- apps/wr/app/store/store.tsx | 9 +- apps/wr/public/sample_pbnstPrfmncReg.xlsx | Bin 0 -> 13777 bytes 8 files changed, 251 insertions(+), 9 deletions(-) create mode 100644 apps/wr/app/matMng/matDmd/coMatRvw/page.tsx create mode 100644 apps/wr/app/store/matDmd/coMatRvw/headList.tsx create mode 100644 apps/wr/app/store/matDmd/coMatRvw/index.tsx create mode 100644 apps/wr/public/sample_pbnstPrfmncReg.xlsx diff --git a/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx b/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx new file mode 100644 index 000000000..4b2dfcef8 --- /dev/null +++ b/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx @@ -0,0 +1,69 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +import { ContentsDiv, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, Title, UiTable } from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { Button, Label } from "@common/components/ui"; + + +export default function coMatRvw() { + const { code, coRvw, } = useWrStore((state) => state); + const { coRvwHeadList, } = coRvw; + return ( + <> + +
+
+ + <SearchDiv> + <SearchFormLeft> + + <div className="col-span-2 flex flex-row space-x-2"> + <Label className="w-28 mt-2 text-xl text-gray-600">{'시설명'}</Label> + <SearchInput + className={"w-full text-2xl"} + label="" + textValue={""} + setText={(e) => { + }} + /> + </div> + </SearchFormLeft> + <SearchFormRight + className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> + <div className="space-y"> + <div className="flex flex-row space-x-2"> + <Button + size={"sm"} + onClick={(e) => { }} + > + 조회 + </Button> + </div> + </div> + </SearchFormRight> + </SearchDiv> + </div> + </div> + + <div className="grid grid-cols-6 gap-4 "> + <div className="col-span-6"> + <ListDiv> + <UiTable + headName={[]} + tableData={[]} + children={undefined} + headlist={coRvwHeadList} + pageSize={20} + total={100000} + cellClick={(index: number | undefined, headId: string) => { + }} + onPageChange={() => { }} + ></UiTable> + </ListDiv> + </div> + </div> + </ContentsDiv> + </> + ) +} \ No newline at end of file diff --git a/apps/wr/app/page.tsx b/apps/wr/app/page.tsx index a4955b36a..a6f5856c3 100644 --- a/apps/wr/app/page.tsx +++ b/apps/wr/app/page.tsx @@ -119,6 +119,18 @@ export default function Home() { </div> </div> </div> + + {/* 수요처 매칭 */} + <div> + <h2 className="text-xl font-semibold mb-4">수요처 매칭</h2> + <div className="grid grid-cols-12 gap-4"> + <div className="col-span-2"> + <Button className="w-full"> + <Link href="matMng/matDmd/coMatRvw">수요처 매칭 검토</Link> + </Button> + </div> + </div> + </div> </div> </> ); diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index e3f3e9fe9..2d29672b3 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -2,34 +2,45 @@ import { useWrStore } from "@/app/store"; import type { pubHasuType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; -import { yearOptions } from "@/components/lib/func/commom"; +import { excelDownload, yearOptions } from "@/components/lib/func/commom"; import { ContentsDiv, Title, SearchDiv, SearchFormLeft, SelectBox, SearchInput, SearchFormRight, ScrollArea, UiTable } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, Label } from "@common/components/ui"; -import { useState, useEffect } from "react"; +import { useState, useEffect, useCallback } from "react"; export default function prfmncPrfmncReg() { const { code, prfmnc, prfmncHasuInit, searchFclts, } = useWrStore((state) => state); - const { pbnstPrfmncHeadList, monthHeadList,prfmncRes } = prfmnc; + const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc; const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); const [searchTxt, setSearchTxt] = useState<string>(); const [searchYear, setSearchYear] = useState<string>(String(new Date().getFullYear())); + const excelClick = useCallback(() => { + console.log("dd") + excelDownload( + prfmnc.excelList, + "하수재이용실적", + "sample_pbnstPrfmncReg.xlsx", + "A1:O1" + ); + }, [prfmnc.excelList]) + useEffect(() => { if (!prfmnc.isInit) { prfmncHasuInit("1", "11"); } }, [prfmnc.isInit, prfmncHasuInit]); useEffect(() => { + setbdstTable(prfmncRes) console.log("prfmnc.prfmncRes", prfmncRes) - },[prfmncRes]); + }, [prfmncRes]); return ( <> <ContentsDiv> <div className="grid grid-cols-4 gap-4"> <div className="col-span-4"> - <Title title={"하수재이용 시설 등록"} /> + <Title title={"하수재이용실적 등록"} /> <SearchDiv> <SearchFormLeft> <div className="col-span-2 flex flex-row space-x-2"> @@ -79,7 +90,7 @@ export default function prfmncPrfmncReg() { > 파일등록 </Button> - <Button color="green" size={"sm"} onClick={() => { }}> + <Button color="green" size={"sm"} onClick={excelClick}> 양식받기 </Button> </div> diff --git a/apps/wr/app/store/matDmd/coMatRvw/headList.tsx b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx new file mode 100644 index 000000000..906c97047 --- /dev/null +++ b/apps/wr/app/store/matDmd/coMatRvw/headList.tsx @@ -0,0 +1,109 @@ +import { z } from "zod"; +import type { CommonTableProps } from "../../common/type/headder"; + +export const sttnHeadListType = z.array( + z.object({ + id: z.string(), + title: z.string(), + visible: z.boolean(), + }) +); + +export const coRvwHeadListExport: z.infer<typeof sttnHeadListType> = [ + { + id: "ctpv", + title: "시도", + visible: true, + }, + { + id: "sgg", + title: "시군구", + visible: true, + }, + { + id: "coNm", + title: "회사명", + visible: true, + }, + { + id: "addr", + title: "공장주소", + visible: true, + }, + { + id: "telNo", + title: "전화번호", + visible: true, + }, + { + id: "regDt", //바꾸기 + title: "신청일자", + visible: true, + }, + { + id: "state", //바꾸기 + title: "진행상태", + visible: true, + }, +]; + + +// id는 다확인해야함 +export const coRvwNodeListExport: CommonTableProps[] = [ + { + id: "ctpv", + title: "시도", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "sgg", + title: "시군구", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "coNm", + title: "회사명", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "addr", + title: "공장주소", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + },{ + id: "telNo", + title: "전화번호", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "regDt", //바꾸기 + title: "신청일자", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "state", //바꾸기 + title: "진행상태", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + +]; \ No newline at end of file diff --git a/apps/wr/app/store/matDmd/coMatRvw/index.tsx b/apps/wr/app/store/matDmd/coMatRvw/index.tsx new file mode 100644 index 000000000..6e62da829 --- /dev/null +++ b/apps/wr/app/store/matDmd/coMatRvw/index.tsx @@ -0,0 +1,34 @@ +import type { z } from "zod"; +import type { sttnHeadListType } from "../coSttn/headList"; +import { coRvwHeadListExport, coRvwNodeListExport } from "./headList"; +import type { CommonTableProps } from "../../common/type/headder"; + +const coRvwHeadList = coRvwHeadListExport; +const coRvwNodeList = coRvwNodeListExport; + +export type coRvwState = { + coRvw: { + isInit: boolean; + coRvwHeadList: z.infer<typeof sttnHeadListType>; + coRvwNodeList: CommonTableProps[]; + + }; +}; + +export const coRvwStateExport: coRvwState = { + coRvw: { + isInit: false, + coRvwHeadList: coRvwHeadList, + coRvwNodeList: coRvwNodeList, + } +} + +export type coRvwType = coRvwState & coRvwActions; + +type coRvwActions = { +}; + +export const coRvwActionsExport: (set: any) => coRvwActions = (set: any) => { + return { + } +} \ No newline at end of file diff --git a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx index a726aa463..282c277ec 100644 --- a/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx +++ b/apps/wr/app/store/prfmncReg/pbnstPrfmncReg/index.tsx @@ -15,6 +15,7 @@ export type pbnstPrfmncState = { pbnstPrfmncHeadList: TableUpperProps[]; monthHeadList: TableUpperProps[]; prfmncRes: pubHasuType[]; + excelList: Number[]; } } @@ -24,6 +25,7 @@ export const pbnstPrfmncStateExport: pbnstPrfmncState = { pbnstPrfmncHeadList: pbnstPrfmncHeadList, monthHeadList: monthHeadList, prfmncRes: [], + excelList: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], } } @@ -60,7 +62,7 @@ export const pbnstPrfmncActionsExport: (set: any) => pbnstPrfmncActions = (set: prfmncHasuInit: async (page: string, sggOrCity: string) => { try { const prfmncRes = await hasuListFetch(page, sggOrCity); -console.log("prfmncRes", prfmncRes) + console.log("prfmncRes", prfmncRes) return set((state: pbnstPrfmncState) => ({ ...state, prfmnc: { diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index 4bc699604..aa3d19851 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -89,6 +89,7 @@ import { coSttnActionsExport, coSttnStateExport, type coSttnState, type coSttnTy import { ldrmntCoSttnActionsExport, ldrmntCoSttnStateExport, type ldrmntCoSttnState, type ldrmntCoSttnType } from "./matDmd/ldrmntCoSttn"; // 옮겨야함 import { searchActions, type comFcltActions, type comFcltState } from "./common/searchCode"; import { pbnstPrfmncActionsExport, pbnstPrfmncStateExport, type pbnstPrfmncState, type pbnstPrfmncType } from "./prfmncReg/pbnstPrfmncReg"; +import { coRvwActionsExport, coRvwStateExport, type coRvwState, type coRvwType } from "./matDmd/coMatRvw"; export type WrStore = comCodeType & pubFacType & @@ -108,7 +109,8 @@ export type WrStore = comCodeType & comFcltActions&comFcltState& coSttnType& // 옮겨야함 ldrmntCoSttnType& // 옮겨야함 - pbnstPrfmncType + pbnstPrfmncType& + coRvwType ; export const StoreZus = ( @@ -129,7 +131,8 @@ export const StoreZus = ( pbnstSttnState& coSttnState& // 옮겨야함 ldrmntCoSttnState& // 옮겨야함 - pbnstPrfmncState + pbnstPrfmncState& + coRvwState = { ...comCodeStateExport, ...pubFacStateExport, @@ -149,6 +152,7 @@ export const StoreZus = ( ...coSttnStateExport, // 옮겨야함 ...ldrmntCoSttnStateExport, // 옮겨야함 ...pbnstPrfmncStateExport, + ...coRvwStateExport, } ) => { return createStore<WrStore>()((set) => { @@ -179,6 +183,7 @@ export const StoreZus = ( ...coSttnActionsExport(set), // 옮겨야함 ...ldrmntCoSttnActionsExport(set), // 옮겨야함 ...pbnstPrfmncActionsExport(set), + ...coRvwActionsExport(set) }; }); }; diff --git a/apps/wr/public/sample_pbnstPrfmncReg.xlsx b/apps/wr/public/sample_pbnstPrfmncReg.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..67f0d559e096443366eeff0f951b5648e422a972 GIT binary patch literal 13777 zcmeHuWn3T2lJ*~m;O_43?(XjH?(PsIxI4k!-Ggf&xH|+0Zo!?roOADeb1wJn{`ULs zeCW}7rn{%Ct7;UaK|oOe-~dPf06+*ZNbu_V2m}DYfCB)?07zhMVS76lQ#%)Z6;B6K zXI(lETN{FWP+*E&0Px%M|F``wo`C_CaVZc+gf8f={)CE?;#&fub+4cMr9#Ibg(EKP zEE&OLDyuE-Y%4@c+7V#%n)M?-{E0uX*Q>eII|PNWeQ4<_0w{Wp4Jz%eF1UPYYD5DH zI~3_WN(ZqN)?y|n#b#YWX<Ao|X|?h_h)IvoxIU?defKoQQz{87DT`M;{A48n2N6VF z7DWD2MJbkWsK7g|qNrfoaIl*{d8`tBaDBfkyBv*5%)E&RjcT*wK~O2=Va<v`ke)lF znt@CKTpMttgPLeM!~#Ub79w=^L+1NWjv0D&RCP1MrIj#rn-}yDzg>5Aeb-4JoDnPv zJ(Ya&`8xMDr%T?#L7HIECj1{u3qR0Qv+Df{yy5*fqL}>Y<Y@};QUhY=7@x^;2i$Q@ z@P2JXz&Q7C%&Y)qKi)GR5bmjwG9YiO&t>ZLxSxP<H99?3?^bwili4`lT{t&(6e7gW zQukf}vnfuir^W{m#DB8YIPr4P7K`cP=MLf1hE2m=V={lZ2LS+n{Q?0f{F~r5sWK2> zzj33?n_NP_39i1Asf{x|-5>4$3GDx3DgDdPD-&ep`x#(D&Ly5hhwtXs;}C?T-32Au z303?)O0K~-MHi4@uXmH<AgEvkfr$He`aOSJUFV5D8YaBmW~q!sLg6NEcCQLaeROn% zpdxch5p%5E8bEZLznQ;H7nky+aO;evs%S0ElOEY57Mr~gsY95gQ^$frF2V^x<4q6H z8j{uAFuJb>nio<&tqQ4aVb48EoXqfFOesEu<qzYOIhjdE9d<S{U#|8UwjsQEz*1GV z;IynY%68%+^3*r6>A4cg=th3=p_R)VRw80Sx@Vdc|4N#B<FD1oaxt3aIlvCpUorf1 zBrp=cbmPs2{il$;S{|u?c)K(9CPG*MNFWaz`hUoYyS<aOk-fe3ANK8EG6VEx<ldhB z-@SDt%1aM0APk-dZW4~I7gv1=v-tucx>Qk(Pf$2pY?F~Rc3-l&p-|^)SeCl&xDj{f z$HTO`ZoU}d4m0ObLLjY#a1ce0txoO1%cHv<K(J6fSLI%6AP}hQ=vn7Gq~`1+(tIc> zf-e4n#@U~q6f-ibc;N0}yZAD17U!$Ns9r`vwc?)Tm-wv~2o&;cBYi5!r%S8>!vo{X z&5f>dtf1J94%dTwncyG8pQaT;u{3)*{311x1O>CrhZjxme{M;j#hb@S5^>sHlBS*H z7@}n?S3()PSmRaNt*wob(6TzUlYwgD*7|HA(0??GL-vH)GgHODTk&w14J~qf4NoO! z*YNpUPEwVI0rq%PwKJdq0Q?(^ym8WBd8krF)_P6=qYL^q)bMQ8hvf;CO?zb>6`H8% zdPga4*`yxRjS1PD?2K+O=s<8P(jX5K4PNg9p31Yj?5`kuq=Jf0m20NWtFb4Z$)^be z>vX5<V5;##$l3-&V-ZmbVlp!zKAzUaBf~;iM8qwnDL_r>kamB&J2-UNo-*Y=Bp?{h z!ANFLI|UB;Gg2oZGnD~(3Kc1Mv6b1Oj3Uxuuu`JaXwzv-G7_0X^!JKYgJBLcLflaX z`7#F9u>4F6NPTjeSy(Ns4RAVAt8DWsg<?zr8BB9C)c~WUkk>OA3DII43;Ha#Aeesa zDN5+%IVLu2fa$#8#`oi;l%2Vx(4aI&FO|_4i4<NE%ZCqN!;o#s5Sdv%I6xFT3Hoa* zcs3_8!?nlkx3M*c@K-G<Q{*#_v~dEEu{=1IE^NM1$^)0#+La;=OvR&svpna$b|0x4 z#v(zT<@!Eym`4aHCDp@1OeIW_D|d>^1Ue0Z@LbBnu};;jB-ZIb(h;)DEr^h@<32;D zOKMy;eRRN8;eAbfc2Fq(iC6&rB0c03k@8hW#0k-WB5Z!eLy;E0VVDHS&3m2hWYPML zGJ_O+uKDTo8=5t2`!_F-f}{A-wJttxdcACP^qh#h%?S6@!HU?yQ1jS`{ryFIec|b3 z*Lv-hsQ61vm^nL@^wt<foeoMppSDLI&zl>Y)0lR*uT{Yoz>rYzg!132fzMlg%^P?G zQ}+VcRN>L;06ARQo$F0cdZXDk&Dwf3=gnRl#j9AJ#_ls`azlw(x3j;rQR686uIiE$ z$wbmYMEf{>#GhC;2(iiwk$M9?dS}V3D%x0|;r>qD`CUsqo4+xrAUXg5`wu2{cJZ_^ zb^b%m{m>Y<+hIfKLO<Y!{6hU$x4RUwD~coD1FYRBpp>hwm2YE2sg!$A*(n;Z=1qZS zA>R(>MKJ|&pv`*7?IIzSk`UeC*1T+|^h6MkWZq>T!i+P1uuN65z==k>MN|I*GTF=^ z?IE?qQ{T-Snbl>Rj8uoBIN@MY<7ml`?f)=Xnq(azkB%V?EmF%=kFJC!yhxh}HlgU* z13mU#a!53W1ZHrJ7CJytt6Y@R6=d?bjgx4M4JpL4J~9p`Jax2B(nF6x(kvLMZK2+V zT0UfQKMI<q0N}dou4q*CoDFFO>vhCS$|(s-?@0zPP&(QWMRM<33F7`ezc3!u=$w26 zUYDL>;A=q?v!)i5J`>a)#Ibc)e`-{>QJoifL$jwX50$?5epp|Wefy4LA0>JUs5OWt zZ@)s!ICiRkN895~-{bM*CY}GQXlG_#=2Vj>#=$%^iIhV&A_mM{rkgG)A-RDB>mgMb zJL2_xqI}6jciy=Kf{1;QE9|L^W4VpnQku+|c|7jd>{ng#OM}337YXwWVY{Z6AjZR& z46>EUvsC^UkDJ@=V)45MXpzY#*|q|DcEO_5jNEd!uw`Ozsd+wXLIcR6jN!9VjF9jP z$b^)Ez(I!E@}~w@AjC0(?#~{x=f2-h+XSrnA>H*AoTQXK8TnOSiODjCZPg5nl|uv< zd3>53K67olMl(o;Vd3xvieaWx;^01do(Fj_v*O9;NF-2=dl1qkrB8yRBQ0FIpdhuF zz|5!Wo}*r&-Wm(oA+6s9jtS+OSB)zHxmjFFN|5>*L(PH*YyK4s&@t4x^FjEMkOPbR zb-%~D<rQD%6^g?TZ|i5?L1iCGAYX4%cKOd|I%_I)$Qf0$I#ay;OHLB_QWKSRg-xM_ zQajnCj9!mmiu48?=2GF>I1<HqSzuussaRF;hrFsu3w!Fb4e5raZ?_+7`5U5rpi#ke z@#k4&Sr=>d90c`(va~u{w2iQ%;Fi8HF{pfr4)84{qy7vYLPdcZXa#Ehd0M38((KtW zu1Xyk)!f5$uB;rNkD^O0R8+P6%eSUgNY@;!yq{%=fxc??oMG2lEo&flOsbM=O(kCP z<6u<%8`)~-i9RZ%rsp|cx!ga8Z+pK_6K<qzsH*QM7T?(h8@xIqajhk2f5-9G3jU7s z)B$y9g!rvrE!nF|Y<(^v#Y#`~cGG@C_r-78h*cYj3W|9!k4u@2TEOg!6_wsPZCv?m zsr6Pgn#3sO#8kq!hVlMkyR+^-O3gil_Id5iIA^-1u(vDvrITj*>?XNkUW$F{bUIZ< z1o1B~BR?D%c*8+T&Sf9vT7rbl5#);HmUy#eN-lb!J9hB3XeVPWJdSQ@P^|piHIytO zBO+|TUK`URPZoN57IO{&?a{sn*Bu2@cbTm_4{|M`k8<6MP+1(;L6$Y#oKQQppLjdW zBj=rcyY1?#pB*S9V<-)qYOLU!%zGsnI)Z|=z58svHh28r^v!=dV8{bB$bD~jgx-uQ z@o%%~Y+-8Z;`~ov?9UUX|L=(f$M#zFGa!hZe|ipD@+RR9Rfr(fmm*vwdjW{*t>)iK zS+tNoJRK|r3&r#sZ!qZkYogyoeljM4uCfy#{KO*inZ_rJuel~yg9p}6G8nCTc&dF| z`Yt>&Rco8mOl@As#t?19e#jxs@upH)tlUJ#^hU`zUFLRcRo=o)wt;=O24pQu85bOS zm!UCNZc!&Sr+t=V=;Jx%bEU-PWbg=Sf&pi~1n;ow>1eQ#;Ia5^n)@RTRMhd<y0iP= zF4VYfnWTIFCsV-q*C~kTV?YtT19=tp@J?L#1S71>PSmQp4`TGV0=}9WcZc%g-GF1- zv%BjsxyzRE#8ZZC1{Y5=_XYUV4`XzT+MnJlwB3Sr97k&?P_#U8hO=~CpF!m0q{6?( zX`n*aeNrTO!RYrJSgwnKDvRUWTb2y>WEgpf#Ga}wx3ay|hiIgiYdWX-;j13R#jB+G zdJ^M{&tq56J@Lm3NOHy*@a0Qz4vU^%eteq&_uFi1UpUZW+p*EBTd2Qdg7PHMFHUd1 zQy3Tkfbkzp@cZ*esf^mKG9YxIAMitVh}YY&!}mJHkwJbI4#+>;kx@<(4X#OO#JxM_ zE+iqA1@4FNmb5T$<>vme{ir!&Gn$1iwpchuPO|ekUF^VB*6+2Iznvr<UWHu+Yuvhi zKU;^M-%sNt%KH*`pAaPImi17mR#nks!BN!Lj%M+G2CKxPXQ2w(9=Ajmm{L=QJn>3M zF;8+*p-q`XX7$6+Im{|WwXpnlYa!6hlbi;BJ*C@+to$=e<H<BdG!$w=(Is-F1WGmD z$|gq_(&;;A&Jvp+avAK`QVixDmcnpf^69T_C)Ed4fr@wY5f2EyWpi#U{3x!pGb_}f zOW^AU-F!elruo*%v`6XZVPVAt6tthvu;d|z*!-L#t(iEvpSF}U5Kami39>VKGwhcG zem!mqYkw#fa&C6_Dbf}Fd&t!@vQ|u%`uJ;%H~5I7OZJh8SRlx+bfjr6g($v~R%F=& zD<{;fhS=@ox+vj2mthecCUXbe)q8`vbG%1>12zBxM9(e{eM#vlqy^tc1c<2%A0OEp zVz`H0nr@DmfElPD4x?hldSX*u7=!^tCVzaTYv7Wt^=W}rXmdAAI;f=Elp$($HH~g= z{9#;Wdm}qp2aLTv!}L=pHM$7esGgr7TLGxE9O<lkT}D}5lM(S*V_44mbrX7Zw`yne zwYYeN1Q?a8Sh(9o0xgF2h8(tb(Rg}I2fWgY&(yBgdA?+x88R@6I_FoCcwkIyTHJCz zrofdPXIvecI9g(>J0!?M<2_Hq{X=FcT4#8J`Z#c#*yIkXGX*Nh;fu4(K3@Zp1=7#* zB*E$7><=#S-?;EUm6ZVeC0Ev495fp1k67rRKE8{EsjVsfpY5OGd7`NuiOr7UM}N%^ zb9Hvlwlj)kU;EXqdE5@EUQP<nRQr~q0y90n0~;BbG;d0X5@lv4RcP~4K?($x<+_O9 zj4)633E!&_)4Q-KbKF#UCV`cP`Ln!u&IIS93%CE4n@E;$rbFL$iZ-9R6E05dQrf_5 zins3+J&R5#G)gR@DWhE*^w>J|D!!iso^3dS_)@?l<E9WTJBm@WD$OM#3b9|zxC6{4 z8BKWH$3+t@9P$Im6R}1O%4DlS$oM5!Bb0z;>O?3^!~OHgE}z$*&hFlpo#J`n8V;Ha z`6FG8(a}^NxcMlgLG^!rB%2`2r$xuYYA68eqSXl{qWdm9N?XR?((2n4)?6>8VpCc% ze_YXBsi$V>qo8O@HoH}>IC<5n<!!1DRI2gy=BQJvrn$ZZV8IfYU997h;a9SJ_=u?n zQWT4}y6)AY#rE^_%MsRoGrd2!UVzfm23FT5d{5*b#~t<;lATB%e;oSQ!s^pEwd<|- zP%B7C`qYNdJv3R>o}7MQGIaU+!TwRNTW=(4pJF&f)op}~j0P>kiB_mZV+P_Qs1k|9 zN!TEa{1oI2hd>ex^7cuBC1g0eFyoGbPI=N}5!G`lzdSExY%Xn7<4OWL!<MyZLTtY{ zRC;*I6QhPJ>+meOe9Sp7U)SC7#mm#zJHLq)wc;o*Zi?)qn{58)$C`6~*VpIW(0%wW z$qc^meXiGKd3~Oz(>wI^P`v$WkH^yj^H_Y|m$M3fKOcj-4Y?_WP<V;pHfKzH&P5GS z+{T|@`+v+^!3c>&VNrmtqRsLmV)cwdi`cfpvFUmc10~l1(NEZ8>fH64(1jK4N*kI0 z?l1~)Q#5cLB%6yoJs4t3Zif=vV%kHd@~Tb&gJK`OuP}$H>(XI_Y^FM-6ltbVzG`q> zVsrN_&9r9(WB9ET7X&-9Ax_9{yCBqkF%bw6Bic=NlK^$pT!IuTh21<^ci@Uz@me1Y zB|{1U%SXEek%48`6LAh8$`}EPC_VeBOCp3l@*>JK<H$=#FrzG!K8tNUVe48=GNn&@ zkSbt!Vz^llIV?gJh_hsKMl|GNl8OsT7-6P1K?3J`BK{0eLg7?TukF1{;}rVAJpeR_ z-R~P@K)hB0-Rp{=o~4vca5>6TH*iU0w&$TU1=S~ID)0m=87tva-j$=^_G?qotz9f9 zpm-IwJN$DCvJtK_H#v(B@)>{Wnl4LhjS&XTG4rDLmLL7v*)P3T_UPS))MK4I!H%n@ zFIsKl*yv}-LWf-%3LT^KD_Q*=EN8-bD=MW~yH>>P&|8eFWEicMfhxG<hTF(QeJ=>( z1_AnNt5cMdGV*QA#yATv<r=497f`EKcMP$&OC0MpDWgvIpCcf|iRkGcDx8+A!%%c9 z_PuM9J)0`B$~!L;K2|<aku(m;AgMx!Kh`7U|0F^xH#hIgw=|rN+e^*U5_8=BklP&b zfhH42!>&nZQ+g7}K>8B}-Y7?rIPmDfx9^#jh3uS(N0@+$FjMd!@pe+x*zM%rsl_YO zA}a)WMH!Mp()|e0jwxA>y(5}KU(!S8a>;e;a9}y3y>@H|v?7L~Y;)_XQCQq!wCt*m z`nQ%K$F<HtZ(n|5j1#!G>ii_)`ZU`RFEIo3i|ZScbn5{TUNM|{eqy<x2&f#6RDKF| zd-peRENWQAwQr~h!R{$K$R@kG#1Mk)K~dz$JV;(kO-P4_*Qh9b^B<1YRbOs;>&Y^N zTkrZW;+YGteqaTnTpgPp_AqWaJS)p}a*{b@w;|Q@{F0NANk2J)h@c9caS|~n{APxt zJEq)<G>wXT(|j3ln{tDR^X05>OGU2Mp6585PgQ!-GCzGXJ*0eCbC#~y-acVbV>hw1 zmnzw=$@Y8O0&A)kM7UKJsa(3NzLC&W>25UU9LbI=X3FQR<j->x4uZL!`OUrd6`XxX z;fq-hc^e~@$;bmvx@AcE>plnW$Tl9(0|n3}J<e3EA4u1DNFdRC4>_Hvuo*<`B5k4} z<tKOuY47Al?7amC;Xf3GY*Kru)~HzApIYUeKFvE#(x-mO`lg$vA%c<oa=lOl525H1 zzusAT+4PiZ;kn>uH;_-Hd`B%Rs<YmmMBV(98qlHdhzp$WT%vZ!UNJ6LHC5UC1Xi<Z ziSk*nO8H<R(5qz=_F1gKf6)~Vb;(*Cq-Mby#cG#;!lNmnaMJ?qNUvz-_UKe>(t2|| zg>mXig^x-9qc>{J>EFBFbs25`$`AkmFVTPLb^U45GPSgwx7kqq&Sidq?3CQ*VXSJh zG4#kSgxBbB$+q~qML}i{rme`;FY9j-kANRSg8l%DJl8St-5;K*<9WO!-gMEE)HEG* zv(Z@3o+eyv)G%A!ue&(4KabTeP@W%gOSg%j#l$`@Wa^UfdojIMOWLepC3J=0v8kx5 zt3F<zVySSEy(~OJ<E{rADW|w94C&r&&^(n&ph;KkVm#HWvEP$yW^D~M^bC(RYWk++ zq+dwSxxBC@Daj@Yd#7L3pgZq1IxD@lEBWwZdMB>+gWKUE$+rG6i<6bhlM5!NMKqnq z)?kglGK0j{w}C(6iAQ=gpGwUYeJ%Z2Y@QK*EC4E-tiTkUIJePVsvZm5eZj%-2G*I$ z2=pZ}zD3Hy{piPGyp4obBI&@$!81+7Govh<i5%tzU?FH}x|9cX(A^3z&<LKZJPq@d zLh|?|xzz;ZXp0>3#J|$oLa1f0OTTV?Bk1e)z4@|cg6d^`*)OUM-~`?p>x0%!F#V{+ zt;?5e6-p8CFK1kHwpunl5YKLxFid0MMv3?*k14drtZCZoU9fO7spWK+{@AsQyJGCo zh&tNDCC5Gs*a1m5po<F!#oj~3n@c@62F~6?2hPTCmmoiX-s(v*atB`=>N(5WHJHNa zZ8|O5Y??qY7nG{4w%9Q!CZ7mA*%q6!h(2jxw`j^MiWat+j5Fu7HSg>3qLGs?EbojW zOG}Y$$1R{;rz_Y~LVv16v0LZMFm&@iZ*(L$(&<{V<(eJZeUK3zFNukpcDu8&x0PEJ zQd%`<{%Y6onXMW_J7e{hu&rw2A;YF&6|Ej%l$S0dhwZk~%CVlw)?&G1P?Uopmx0&l z_z>){a-AC;wA{vd+;}L6oeEzWok~1#{0!1(8D0|o!h3{2M0>%GbRka3@-UlIMRO;a zB_n2fu@LYHZ>h!&YMo6(_;~IJXcT<Dv*4SHFEiIqhEfAj@2n-_E7X*-M#YDfQVpBs zTroOv0t0Vs@#eODEQE~Cq3FtsTq~ahRvy&?dh7f0A#+V)1y&nrHK^E90`PodDvO>A zL{ygT!?)(g@>{d_@YWm*A||iC<jM{w_?8Pm(#xZk!;}$)tmEbCY;iHP-8%ALk0DL$ zVztCsR*dYlEZg7RIvD=qV^U|idE`wJ*YWPTM2f%3jrYV#uZai4(kzV^#nP;dmu0O_ z7h_u-M*C{2v}S0ehv!}n<G9Z)$Mvh*33Q>uH%Sq%RVPR^ow6!1fd;k<+dV5!nmQ-S zHcu0dqyN+F9zYK0%&OM^k;kB?|6^<b0E7^n2xb5y&B!1mfD;@Im|z<IYRBoZtX_s+ zT;!2f<nyR1$}8u-0%wOD4L0()?Y&Mv9KMT?Jo&Y2p8z?GYo7#plxts^9LFrwKG)WE zu)+tPD(JzY^c0Wg*`n3S0#?0tDP?X>2o9oMfYy>ub^a(&CeT`-YUPRH%SRx15I%5V zm|86l8=Oor4PrDvI4#C{=u*BLlQvHLl8|-BsA{!gq&B3D;a__TOi%~rJquqadTP?l z0sPS6-=S^MzT=c^y|j%6tc~%L;kz+Gk3d)eBuE`V!e$!mfS5UcWyHo&!~~i@s%?nX z#1T4x2F3&9CnJIZ!GJ(;fChl1KG*L7L30l76a!aeLcN-pG@}E;r7fh^7zYMDNVy%X znua0tpWO|{2xCBi{y2a`TgfMa%bbK<6+lw15WU65Mb4(DW`EG<t<Zc^57YGmZew^O zH@$q1e6NBaFX#gXg+ihdCn0Er7;o8GJ!DIzVF)3;*)M1%rIY{IXX_F(p{)jkU#5<g zu>%$<cW@ZoC5LekoF|8I7+fdEF%M<VwWUL@lZo)HuH<HX_nh5>l|+rcF>tU>T(x=i z;J_%BT|PQop_C%5grF-B^aB!=L?J<4pbV->F@ZCfW>}calPW8*?@iRg2zWv<j+gUW zht;R6=R%_sg$a1TE>KAn;uHjlz`{{Y$_bdk(y51qL`+sJH61;huZTpxxxq;`?zl6d zEw)A6Hm~J<Rk$wd5#A9g#67-`kjo{=3l#Z)L_Mq`X!e0gJ?>N3aN~}YtakQvOC`rD zC&_e-egcab*UCIqCnJ|)v2{_l+L3ipfEt!nQM?+Kb&+zFOL6i<)65`cStcYtt<W+b zwC#6~L$W<kKdAl|bK{-zvQm_M+09VhjK2;p%wg}|kexqaSn^>EZm>d5t7EFb8e(Jj zZ2IMb2ZyOA2z2N6=h-a=AI8STj?dM1f2NhHE$Rp^=`8|ZRU2zB5%~6wM_-5>3>)Z{ zCAJ(Rh1m8V>0=3(oU3YCu$pzmt`w-!en)WTg$5cY2ZG$Z#=cZm9DMe_s<woof#rF; zAmMpYU7t!Wo+OS^b<I;xBp%XUf+zAgD89kKoh_%L7#oA+_^410=k*(cw`hh)v-vsy z+WPwA?+vjCUs1NsTlk~>EjWVmk7cE^g`tzFiL#56rJebo!TA9-UF#JEj4u2Wew>M$ z1(DUJbqOUg!6jY#X8bs-IRU5b1mpDfdTS~-tuKs`P0HqZL_!d9tNFDrgp(KiC*yTX zN;h`Igu#jXFCK46IqBs`18s{*2i{pis+h`Q3`~+U5}5?0i}sef{R|9G6>_L`r?9;3 z%&jfj(?jIJD+*xk?J^Eo%e`b0&x=OG<Bf<!Mo5W-80%vcz4fFYraHp%9+v&N&7`8H zp1Sp}i3TX{^}*#HuCN6(jGN}sr<l2v*=3X}*zn$oK^;Vjvhlzs5tpy>dKB_js2es{ zGo<|Im)pz6MHl0!?Kk^Vy~M+?7DURd91wSKJZ_`}Phqz%(u3F-dfPF(t;4dX<s4{< zgQz`rV}vf{w=1l!)IAAbY_-}bF<=3bt%X>>^wJT>`NTmHV7Wie*Mew3GXn0JU*qnq zq3gqNaiYDSph0JGbVw*z0j9fcm02v+t(zK|mCu*f1};pgHSPhvU%)SrW+OLRf0>8d zsOZ}*j>yYR0$<psw(NyzZl$TiqqoDJJi6YVqSv%|karipg0oBGghlyZ)MC7v&xb#H zPw|01d6k}E=hfSXe0yb5xeddi^Ci)Fw9vSoGR&|A*FEu5F`ubbR$%Vh$tM|`VuxB1 zV90NSp}`thb{k$dA_6}MT81a?W_yP4!y-z%qGQoz`?)NN>j+ebFYX}Fp=pvs4H+g7 zpx#|8hgr9S7e?j>Ul>|BpS>zw%x6e!c?yj`4{U!g(YU|COmg*T-`g<d;p8<gRlvzS zASTL(wV^Co>tpHvw~5SMKVzPWw>wgA!AgX;l(>n#v4WGmgEPIMgTo&I$hYE=|4W3w zNoi)Hpfw63%Gb9<xZ!YT#vzqxicEw}G9C)L+iFE&I(vJs3=_#=?QzwCpbdTCCsEsr z??qEVDR|Fv<9-m#%r0Ek@PRF<cfYRoQ}2-Kc_&R(0_%h-Ky7c|VldlWs8*kIJ4ddf z$tmh%%913j2n3;PEi(9g1jNM94Ke}PpCC<<S)8je3~U}?oXorh)dWWxN7A9inFqN> zK|^uJ;hh!W?shz&`_}@b2-hiA1m;NKr0%-&%Jxum)^lhg05T)9`Eh~F=ysC&AM6_E z(<8ITIVA$yiJ)AJzlVyof<;4};f<s*L-ixbFq6?D_$(5%_mt;Fr!k}?%)m;0m&+KA zXfd?$MZsl&MwJVcG6PknGf-{bQ&_C8oly97W8&&^7~5UN_e#d0@!3t+ZGByfr}$+B zA;Q%dbt)Is5Z8$)6ZDA+n{nrLP=}di0CwWY<&dA|<)Mhb{Z^mu`2zme%R!TWi;gef zp;F89>vN+2uj9S_!SVUSPV4!G4<G#rVO{kYnjnR=I}whe*Qv?8LOEO4`@IsQ%*O<< z)E3XmY~$8zfr%^PwxY@?3tO_Egl?>EGin6cTf8m`IC#S3V!yY`3;g=qKp&;BvnKZ& z|6jjlQOW<IksaPtv5TpbvZ;&9A3B---8mzjk)_><x~%-F0D>=JBh|I?QIYr@a;gCE z7WFm~QfZV#<`9r$WjMQmq0MMrhJb1~$lb;hw%0)(gk9$q_C0B5qdmJEAy88hY(A>4 zwY&M(o#mFDbaZlfd|<rKr4BF%M4w=z@;*}PIj8066tILiYNUz6L6<tOZ7bK4h9tVn zUz{jjGKYjP1m4{>+|iKy#K_Pg=OE+Ui&tF;!bGaW=7g_{Rk;6lE5z*8Olh@yv(F)u zNro;i@6`Jo>*kNK=|eR+XTH>p_g(R|{V|frA^FZn!ni<1JNai$k9<cjQUz)MhxFan zJ|FqAO8WW)B^}uU3EK!YFw^9Gvw$y_dd`{5m5n^C%pTIQpO3}25>AaoYf@l*JGC^# zT$d@Ts|?qhK&F$F2Cqd8mLPy1Xr%h;$5*;0MNzy$97K47@jlh%<Xfc0BOA@HmZz-> z!P6l2K*}yMfk1m1K(n(5uR1GES2S7aRZR1qCIzL&A1-b2ebcKo=c4e4F%ALt(p<)H z-EeL3TtuZ1>mpvEI5q`FlbsAtnl%#5kS$p~xwNFG@Kl4Jsvz&(rl^glP5E+eQ=l|0 z*VR!GH9H^5-NV>!Bc3VF!EeBC=04(bc+b^+43|z%g1*NvQXv_$O4xteTgcP9Tui3G zbC@SM3RTT}L_WREo4R(OXywE!dX71!EOpf>KVzOtBgATVXEAZ!F#2+PC|qA##AE5R zKt3#g!p9md-N&M_W@%P1Ks)`5>J0qib5w9x-8of~d0GiwE}lyz=^o6^D|s5}w^+wa zZt{aqzE_TCld*Dqqa91Ths?f;T`?FXBXZq2lQrE1Nv=zS>p8gWIoL0bDXrWT?qTiY zGVXp_p|lG^kvP*vyt1VcDX!h&NDC^}ba98K(QS^qEST_#Q8N$4UPZT-31D>18}~Y0 zu_go~g6p`^&NgJck9Gb}SkEOWqpTxwWb%ug@jvvIfB3MhJ#-~Fai?&%#r0DWH-SY@ zK7<_@N<Mr6{Xwhfx|5(j{nLPfALo|K*g0dBi2rfdz5Dqz^%67nhlXLGt1<HvObmoh z6=Q|WQQ@mwlijOD)F;00zYKmkk#zs94YG>g8e@68ll0+#Dt}CW%3l(%biV=0ryLSL z7Qb1p`?^+6sF2{fm}IJT7aF_XK~Y@Xf$pi^-n{O<x(xoF!MvcLZUInqh+ZMymhdS$ zBSjGs^oghJwKZ>#%?yVll1ztT%CD7m^3l3tQ08OKcot9I>~M5^ig~QCF(g>k6`fn3 zwURAJ<|iX%U#K1BKG_-xt(T3F0bz4VR`Q}nUN`5@I}Mc^ahJm{E4k*%X!5A=ecy(V z&yjvv06p4#Zn>hr@hAIEI-K+U^`y$(cl8vvN=PY?bazbt!?NmljnX7m*HaQ6taG1J zNbeVT-eaq(o&uezeBv!?YXubYEmGzh?h9%DaeNx0O&QMyNO`VQQFk%chT2-bs6CEG zUJ9tmnF^>HOKJbCMJ~eYDtCgMSs&mB&`YT28>o)I%|&+P2S;_jDZK2r$w&By;xjh1 zF&4Hkw6y!f_?t{g!}Sp$eB9~`cPD6QX}qzOYPZ;ix&{Qt6hXy;hfS|W(v_#cLgA0V z3(xa361lth)rJVh?+Q#ouEG|ZJ9K8MLlE#e%sQIFGI`{O7VFVb^(I@8;=_c4?O+Zg z3?UckNzAR8yNMvn+bvk)Z7<x+#lm^+lNwD$q<D4}aDnGmgF3>j5b5y^hyxVQljZPs zcl0TdHOcEGO)`e<=)Q82tdnG@Bp&$TMdv*7PfhZ;JT5=Jr4|1(nFFexmZ<$UOuaYH z8}YAxj<LOy>Hj%8Zy*1kTX2G`+*`i=)1AZ`;U!;PV&k)jBo)w6gp@=ha9zWRB{m{= zitXDn95VAGDRoNb2M$oVnGh8MLeCw~$;}Q-PTVTdL*76(QBr0Ua8OSI%|Yn4;VB!g zTlqM1n&ixs<X{-vo?Jygk2t2}TB-izY7`6Yj~6(SpM%R_XscAAhC*ls6_7bXUA8-B z0=3-dp(`ocOQ3rY3B@%&7G-KhSm)Mo5v>q$9>*OCrow(?h9QNFTlmfZc@eu9h_*Kg z5k2D^(Px*GVTs)`xmStGeYb*=<=CVJR?!;1bs2i^=H$5^b%b8OfeMmTl1VB9(v&>G zzmdbIzuBdit-MyTfK5|Yhum`F3G{4}I0<ur@~fI#Be9bd_)h0@;dqy_-S$=FA;vCZ zcnBZny&?-~|3KFLb+ujlU6<S<+CcL|_W*GY$F?I=7&6jr7`MR2kBwi55A1JK`wxx; z0;YXi^ZotL7XSJH|Jwh}uNMl^{|@l)Mc@A-{A1ttChvbK0e?^U?}e~`CER#Rc>dRA zvF~x-mqGqUqIg@~zAK7+PyD_-?Kkl_^q<7Pi`CwfzON(sO{)K<$Nu@=|E{X!J>dJQ zjNgDpi2n`X?;4HwfbWYOegm2yy$AeV^6(zzeG2+F3JmI>DDM-}?*ZON{eJ_jVE=75 z{v6SJl=mTv-zdh!f1><H0OLKvzb`X?(*pn(qyWJCMdy3!_YV4R`WuQr-~Y}%|66zc zJ?ML{<2R@)&Hn`SPaotx=zEL$8}y9!Ptbp}ukWe<-AMhW1pt=m{xVDdGFb}JU~kg; Shv`NDD7@8qS~LD}_WuAe7T<ON literal 0 HcmV?d00001 From 40f26c77673f68933c33da2124c885affb6e0dd6 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Wed, 4 Jun 2025 11:05:02 +0900 Subject: [PATCH 54/62] =?UTF-8?q?-=EC=88=98=EC=9A=94=EC=B2=98=20=EC=A0=95?= =?UTF-8?q?=EB=B3=B4=20=EC=9E=85=EB=A0=A5=ED=8F=BC=20=EA=B3=B5=ED=86=B5?= =?UTF-8?q?=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20=EC=9E=91=EC=97=85?= =?UTF-8?q?=EC=A7=84=ED=96=89=EC=A4=91(=ED=8C=A8=EC=8A=A4=EC=9B=8C?= =?UTF-8?q?=EB=93=9C=EB=A7=8C=20=EB=82=A8=EC=9D=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/sdmInsertForm/form.tsx | 43 ++++++++++++++++++- .../src/ui/sdmInsertForm/index.tsx | 20 ++++++++- .../src/ui/sdmInsertForm/sdmNameBox.tsx | 12 +++++- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/packages/common/business_components/src/ui/sdmInsertForm/form.tsx b/packages/common/business_components/src/ui/sdmInsertForm/form.tsx index 6d3219468..d59108c5b 100644 --- a/packages/common/business_components/src/ui/sdmInsertForm/form.tsx +++ b/packages/common/business_components/src/ui/sdmInsertForm/form.tsx @@ -21,6 +21,7 @@ interface FormSchema { telno: string; bznmTotNo?: string; rgtr?: string; + dmdAplyPswd?: string; } interface SdmRegFormProps { @@ -40,7 +41,8 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun const [sigunValue, setSigunValue] = useState<string>(''); const [filteredSigunData, setFilteredSigunData] = useState<SelectDataType[]>([{ text: "전체", val: '0' }]); const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(true); - + const [orgBznmNo, setOrgBznmNo] = useState<string>(''); + const initializeSigunData = useCallback((sidoCd: string) => { if (sidoCd === '0') { setSigunValue('0'); @@ -92,6 +94,8 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun form.setValue('dmdInfoPk', rtnCompData?.dmdInfoPk.substring(0,10) || ''); form.setValue('bznmTotNo', rtnCompData?.dmdInfoPk.substring(10,14)==='0000' ? '' : rtnCompData?.dmdInfoPk.substring(10,14)); + // 수요처 불러온 후 사업자번호를 바꿀경우를 대비함 + setOrgBznmNo(rtnCompData?.dmdInfoPk); const sidoCd = rtnCompData?.ctpvCd.trim() || ''; setSidoValue(sidoCd); form.setValue('ctpvCd', sidoCd); @@ -120,6 +124,29 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun form.setValue('dmdCoNm', text); }, [form]); + const bznNoChange = useCallback((e: React.ChangeEvent<HTMLInputElement>, noType: string) => { + const value = e.target.value; + console.log('form value : '+form.getValues('dmdInfoPk')); + console.log('org value : '+orgBznmNo); + + if(noType === 'dmdInfoPk') { + if(orgBznmNo.substring(0,10) === value) { + setIsDuplicate(true); + } else { + setIsDuplicate(false); + } + form.setValue('dmdInfoPk', value); + } else { + if(orgBznmNo.substring(10,14) === value) { + setIsDuplicate(true); + } else { + setIsDuplicate(false); + } + form.setValue('bznmTotNo', value); + } + + }, [form, orgBznmNo, setIsDuplicate]); + const formFields: Array<{ name: keyof FormSchema; label: string; @@ -177,6 +204,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun type="text" className="!text-xl text-gray-600" {...field} + onChange={(e) => bznNoChange(e, 'dmdInfoPk')} /> ) }, @@ -195,6 +223,7 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun className="!mt-5 !text-xl text-gray-600" disabled={isBznmTotNoDisabled} {...field} + onChange={(e) => bznNoChange(e, 'bznmTotNo')} /> </FormUi> ) @@ -222,6 +251,18 @@ export function SdmRegForm({ form, onCheckboxChange, selectSidoData, selectSigun {...field} /> ) + }, + { + name: "dmdAplyPswd", + label: "패스워드", + component: (field) => ( + <Input + placeholder="패스워드를 입력하세요" + type="password" + className="!text-xl text-gray-600" + {...field} + /> + ) } ]; diff --git a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx index 4a972180a..c79712c58 100644 --- a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx +++ b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx @@ -30,11 +30,12 @@ const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean) => dmdInfoPk: z.string() .min(1, "사업자등록번호를 입력해주세요") .regex(/^\d{10}$/, "사업자등록번호는 10자리 숫자만 입력 가능합니다") - .refine(() => !isDuplicate, "이미 등록된 사업자등록번호입니다"), + .refine(() => isBznmTotNoDisabled ? !isDuplicate : true, "이미 등록된 사업자등록번호입니다"), bznmTotNo: isBznmTotNoDisabled ? z.string().optional() : z.string() - .length(4, "종사업자등록번호는 4자리 숫자만 입력 가능합니다"), + .length(4, "종사업자등록번호는 4자리 숫자만 입력 가능합니다") + .refine(() => !isDuplicate, "이미 등록된 사업자등록번호입니다"), daddr: z.string() .min(1, "주소를 입력해주세요") .min(6, "주소는 6자 이상 입력해주세요") @@ -44,6 +45,10 @@ const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean) => .max(12, "전화번호는 12자 이내로 입력해주세요") .regex(/^[0-9-]+$/, "전화번호는 숫자와 하이픈(-)만 입력 가능합니다"), rgtr: z.string().optional(), + dmdAplyPswd : z.string() + .min(1, "패스워드를 입력해주세요") + .min(8, "패스워드는 8자 이상 입력해주세요") + .max(16, "패스워드는 16자 이내로 입력해주세요"), }); type FormSchema = ReturnType<typeof createFormSchema>; @@ -58,8 +63,19 @@ const defaultValues: FormData = { daddr: '', telno: '', rgtr: "3fa85f64-5717-4562-b3fc-2c963f66afa6", + dmdAplyPswd : '', }; +/** + * 수요처 등록 폼 + * @param selectSidoData 시/도 데이터 + * @param selectSigunData 시/군/구 데이터 + * @param dataList 수요처 목록 + * @param rtnValue 검색 결과(텍스트) 콜백 + * @param rtnInputData 수요처 리스트 콜백 + * @returns + */ + export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData}: thisProps) { /* const { insertSdmData } = useDmStore((state) => state); const router = useRouter(); */ diff --git a/packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx b/packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx index 18d048692..83571b6ff 100644 --- a/packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx +++ b/packages/common/business_components/src/ui/sdmInsertForm/sdmNameBox.tsx @@ -80,7 +80,17 @@ export const SdmSearchForm = ({label=undefined, initValue=undefined, rtnValue=() } }} > - {item.dmdInfoPk.substring(0,10)} <span className="float-right">{item.dmdCoNm}</span> + {item.dmdInfoPk.substring(10,14) !== '0000' ? ( + <> + <span className="text-gray-500">사업자번호 : </span> {item.dmdInfoPk.substring(0,10)}  + <span className="text-gray-500">종사업자번호 : </span> {item.dmdInfoPk.substring(10,14)}  + </> + ) : ( + <> + <span className="text-gray-500">사업자번호 : </span> {item.dmdInfoPk.substring(0,10)}  + </> + )} + <span className="float-right">{item.dmdCoNm}</span> </div> )) : ( <div className="!text-xl w-full px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto"> From 2c773de04f5a4f6a964e3961fe59db5bca7cd110 Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Wed, 4 Jun 2025 11:08:00 +0900 Subject: [PATCH 55/62] =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EC=97=90?= =?UTF-8?q?=EC=84=9C=20=ED=95=84=EC=9A=94=ED=95=9C=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=A3=BC=EC=84=9D=EC=9C=BC=EB=A1=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/sdmInsertForm/index.tsx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx index c79712c58..723d87cf6 100644 --- a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx +++ b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx @@ -76,6 +76,32 @@ const defaultValues: FormData = { * @returns */ +/** + * 페이지에서 작업 + const {Common, initializeCommonData, getDemandCompList, insertSdmData, Sdm} = useDmStore((state) => state); + const { selectSidoData, selectSigunData } = Common; + const { demandCompList } = Sdm; + + // 공통데이터 (시도, 시군구 데이터 호출) + useEffect(() => { + initializeCommonData(); + }, [initializeCommonData]); + + // 컴포넌트에서 텍스트 검색 호출 + const callback = useCallback((searchText: string, pageCnt: number) => { + searchText = searchText.trim(); + if(searchText.length > 0) { + getDemandCompList(searchText, pageCnt); + } + }, [getDemandCompList]); + + // 컴포넌트에서 수요처 등록 호출 + const handleInsertSdmData = useCallback((data: DemandCompType) => { + insertSdmData(data); + + }, [insertSdmData]); + */ + export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData}: thisProps) { /* const { insertSdmData } = useDmStore((state) => state); const router = useRouter(); */ From 6e96477174cf40b3f69813664f72f2418af51917 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Wed, 4 Jun 2025 11:10:42 +0900 Subject: [PATCH 56/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EC=84=9C=EC=B9=98=ED=8F=BC=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/store/common/searchCode/index.ts | 67 ++++++++------ apps/wr/app/store/common/searchCode/type.tsx | 13 +++ .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 2 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 31 +++---- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 8 +- .../components/ui/searchInput/searchInput.tsx | 92 +++++++++++++++++++ 6 files changed, 165 insertions(+), 48 deletions(-) create mode 100644 apps/wr/app/store/common/searchCode/type.tsx create mode 100644 apps/wr/components/ui/searchInput/searchInput.tsx diff --git a/apps/wr/app/store/common/searchCode/index.ts b/apps/wr/app/store/common/searchCode/index.ts index 579c7c528..d87e0836c 100644 --- a/apps/wr/app/store/common/searchCode/index.ts +++ b/apps/wr/app/store/common/searchCode/index.ts @@ -1,29 +1,44 @@ -import { fetchType, getFetch, postFectch } from "@/components/lib/api" -import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type" +import { fetchType, getFetch, postFectch } from "@/components/lib/api"; +import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; +import type { DemandCompType } from "./type"; export type comFcltState = { - searchFclts: pubHasuType -} + searchFclts: pubHasuType; + demandCompList: DemandCompType[]; +}; export type comFcltActions = { - getSwtrmtFcltNm: (searchNm: string) => void -} - + getSwtrmtFcltNm: (searchNm: string) => void; + getDemandCompList :(searchNm: string) => void +}; + export const searchActions: (set: any) => comFcltActions = (set: any) => { - return { - getSwtrmtFcltNm: async (searchNm: string) => { - const fcltNm = await getFetch("common", `/prcsFclt/info/1/20/${searchNm}`); - const fcltNmCd: pubHasuType[] = fcltNm.map((item: any) => ({ - bscFctCd: item.bscFctCd, - sido: item.sido, - gugun: item.gugun, - bscFctNm: item.bscFctNm, - addr: item.addr, - fctCpc: item.fctCpc - })) - return set((state: comFcltState) => ({ - ...state, - searchFclts: fcltNmCd - } - )) - }, - } -} \ No newline at end of file + return { + getSwtrmtFcltNm: async (searchNm: string) => { + const fcltNm = await getFetch( + "common", + `/prcsFclt/info/1/20/${searchNm}` + ); + const fcltNmCd: pubHasuType[] = fcltNm.map((item: any) => ({ + bscFctCd: item.bscFctCd, + sido: item.sido, + gugun: item.gugun, + bscFctNm: item.bscFctNm, + addr: item.addr, + fctCpc: item.fctCpc, + })); + return set((state: comFcltState) => ({ + ...state, + searchFclts: fcltNmCd, + })); + }, + getDemandCompList: async (searchNm: string) => { + const coList = await getFetch( + fetchType.WR, + `reuseFc/request/${searchNm}/{3}` + ); + return set((state: comFcltState) => ({ + ...state, + demandCompList: coList, + })); + }, + }; +}; diff --git a/apps/wr/app/store/common/searchCode/type.tsx b/apps/wr/app/store/common/searchCode/type.tsx new file mode 100644 index 000000000..a8cfb2e69 --- /dev/null +++ b/apps/wr/app/store/common/searchCode/type.tsx @@ -0,0 +1,13 @@ + +export type DemandCompType = { + dmdInfoPk : string | ''; + bzmnNo : string | ''; + dmdCoNm : string | ''; + daddr : string | ''; + telno : string | ''; + rgtr : string | ''; + useUsgCd : string | ''; + ctpvCd : string | ''; + sggCd : string | ''; + + } \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 62a6447f7..73bdf9665 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -173,6 +173,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnstRegClick: async (pubHasuRes: pubHasuType) => { try { const pbnstRes = await initFetch(pubHasuRes.bscFctCd); + console.log('pbnstRes ' , pbnstRes) return set((state: pubFacState) => ({ ...state, pbnst: { @@ -204,7 +205,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { pbnstInsert: async (pbnstRes: customPbnst) => { try { - console.log('writeRgtrAndMdfr(pbnstRes) ', writeRgtrAndMdfr(pbnstRes)) const response = await postFectch( `/reuseFc/pubFc`, JSON.stringify( writeRgtrAndMdfr(pbnstRes)) diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 608b2ccab..4ef27037b 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -37,10 +37,10 @@ import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; import { - handleCommaNumberChange, - formatCommaNumber, safeDate, } from "@/components/lib/func/commom"; +import SearchInputText from "@/components/ui/searchInput/searchInput"; +import type { DemandCompType } from "@/app/store/common/searchCode/type"; export function PbnstBuseForm({ formType, @@ -66,7 +66,7 @@ export function PbnstBuseForm({ const [ppiYn, setPpiYn] = useState("Y"); const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); const [sumCpct, setSumCpct] = useState<number>(0); - const [searchDmdCo, setSeachDmdCo] = useState<String>(); + const [searchDmdCo, setSeachDmdCo] = useState<DemandCompType[]>(); const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), @@ -195,9 +195,7 @@ export function PbnstBuseForm({ }; const plusArray = () => { - - console - .log('qweqwe ') + console.log("qweqwe "); appendDemand({ dmdCoNm: "", daddr: "", @@ -404,7 +402,7 @@ export function PbnstBuseForm({ sonClass="col-span-4" /> <div> - <h1 className={formH1Class}>{'하수처리수 재이용수 수요처'}</h1> + <h1 className={formH1Class}>{"하수처리수 재이용수 수요처"}</h1> <div className="text-right mb-3"> <Button type="button" @@ -423,19 +421,14 @@ export function PbnstBuseForm({ name={`fcDemands.${index}.dmdCoNm`} render={({ field: f }) => ( <FormUi label="수요처명"> - <SearchInputSelect - className={""} - label={""} - selectData={[]} - onSelectValue={(val) => { - searchDmdColist(val); + <SearchInputText + label={undefined} + initValue={f.value} + setValue={f.onChange} + setRtnData={(valList : DemandCompType[]) =>{ + setSeachDmdCo(valList) }} - textValue={f.value} - setText={(val) => { - setSeachDmdCo(val); - }} - selectValue={searchDmdCo} - ></SearchInputSelect> + ></SearchInputText> </FormUi> )} /> diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index ed78452d0..c809b3653 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -91,6 +91,8 @@ export function PbnstMngForm({ getpbnstInsertIndex({ ...pbnst.pbnsUpdateIndex, mng: val }); } }; + + const plusHist = () => { const regData = { choose: false, @@ -246,6 +248,8 @@ export function PbnstMngForm({ } } }, [pbnst.pbnsUpdateIndex, pbnst.pbnstRes, formType, getBizCycle]); + + //신규 등록시 입력할때 데이터 넣기 useEffect(() => { if (formType === "reg") { const formData = form.watch(); @@ -260,13 +264,13 @@ export function PbnstMngForm({ }, [pbnst.pbnstMngRegData]); useEffect(() => { - if ( pbnst.pbnstRes && pbnst.pbnstRes?.length> 0) return; + + if ( pbnst.pbnstRes && pbnst.pbnstRes?.length<= 0) return; const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({ text: item.ruseUtztnFcltNm, val: String(index), })); - if(fcltNmList) setFcltNm(fcltNmList); diff --git a/apps/wr/components/ui/searchInput/searchInput.tsx b/apps/wr/components/ui/searchInput/searchInput.tsx new file mode 100644 index 000000000..3b645a467 --- /dev/null +++ b/apps/wr/components/ui/searchInput/searchInput.tsx @@ -0,0 +1,92 @@ + +import { useWrStore } from '@/app/store'; +import type { DemandCompType } from '@/app/store/common/searchCode/type'; +import React, { useCallback, useEffect, useRef, useState } from 'react'; + +type thisProps = { + label: string | undefined; + initValue: string | undefined; + setValue : (dmdCoNm?: string) => void; + setRtnData : (rtnData: DemandCompType[]) => void; +} + + +export default function SearchInputText({label=undefined, initValue=undefined, setValue=()=>{}, setRtnData=()=>{}} :thisProps) { + + const { getDemandCompList, demandCompList } = useWrStore((state) => state); + + + const [isOpen, setIsOpen] = useState(false); + const [textValue, setTextValue] = useState(initValue || ''); + const wrapperRef = useRef<HTMLDivElement>(null); + const handleInputChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => { + const value = e.target.value; + setTextValue(value); + setValue(value); + if (value) { + setIsOpen(true); + getDemandCompList(value); + } else { + setIsOpen(false); + } + }, [getDemandCompList, setValue]); + + const handleSuggestionClick = useCallback((dmdCoNm: string) => { + setTextValue(dmdCoNm); + setValue(dmdCoNm); + setIsOpen(false); + setRtnData(demandCompList); + }, [demandCompList, setRtnData, setValue]); + + useEffect(() => { + const handleClickOutside = (event: MouseEvent) => { + if (wrapperRef.current && !wrapperRef.current.contains(event.target as Node)) { + setIsOpen(false); + } + }; + + document.addEventListener('mousedown', handleClickOutside); + return () => { + document.removeEventListener('mousedown', handleClickOutside); + }; + }, []); + + return ( + <div ref={wrapperRef}> + <input + type="text" + value={textValue} + onChange={handleInputChange} + /* onFocus={() => setIsOpen(true)} */ + className="w-full h-[3.2rem] !text-xl pl-3 text-gray-600 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + placeholder={`${label}을(를) 입력하세요`} + /> + {isOpen && ( + <div className=" z-1 w-full mt-2 bg-white border border-gray-300 rounded-md shadow-lg h-90 overflow-auto"> + <div className="max-h-72"> + {demandCompList && demandCompList.length > 0 ? demandCompList.map((item : DemandCompType, index : number) => ( + <div + key={index} + className="!text-xl w-full text-left px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto" + onClick={() => handleSuggestionClick(item.dmdCoNm)} + role="button" + tabIndex={0} + onKeyDown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { + handleSuggestionClick(item.dmdCoNm); + } + }} + > + {item.dmdInfoPk.substring(0,10)} <span className="float-right">{item.dmdCoNm}</span> + </div> + )) : ( + <div className="!text-xl w-full px-5 py-3 hover:bg-gray-100 cursor-pointer overflow-auto"> + 검색 결과가 없습니다. + </div> + )} + </div> + </div> + )} + </div> + ) +} \ No newline at end of file From b7f643ab0c0ffd7298706bce904bc57c2f63aafa Mon Sep 17 00:00:00 2001 From: YangJinSoo94 <jschrome782@gmail.com> Date: Wed, 4 Jun 2025 11:20:51 +0900 Subject: [PATCH 57/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=BB=B4=ED=8F=AC=EB=84=8C=ED=8A=B8=20export=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/business_components/src/ui/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/common/business_components/src/ui/index.ts b/packages/common/business_components/src/ui/index.ts index 0986f7953..a1fa95f39 100644 --- a/packages/common/business_components/src/ui/index.ts +++ b/packages/common/business_components/src/ui/index.ts @@ -19,4 +19,4 @@ export * from "./tab"; export * from "./table"; export * from "./table_div"; export * from "./title"; -export * from "./sdmInsertForm/sdmNameBox"; \ No newline at end of file +export * from "./sdmInsertForm"; \ No newline at end of file From 103defd7001dd44dc5910a8ea3fe8f7c499feb16 Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 4 Jun 2025 16:17:40 +0900 Subject: [PATCH 58/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EA=B2=80=ED=86=A0,=20=EC=9E=AC=EC=9D=B4=EC=9A=A9=EA=B2=80?= =?UTF-8?q?=ED=86=A0=EC=9D=B4=EB=A0=A5=20=ED=99=94=EB=A9=B4=20=ED=8D=BC?= =?UTF-8?q?=EB=B8=94=EB=A6=AC=EC=8B=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/matMng/matDmd/coMatRvw/page.tsx | 341 ++++++++++++++++- .../app/matMng/matDmd/ruseRvwHstry/page.tsx | 353 ++++++++++++++++++ apps/wr/app/page.tsx | 5 + .../prfmncReg/pbnstPrfmncReg/page.tsx | 6 +- .../store/matDmd/ruseRvwHstry/headList.tsx | 185 +++++++++ .../app/store/matDmd/ruseRvwHstry/index.tsx | 34 ++ apps/wr/app/store/store.tsx | 11 +- 7 files changed, 918 insertions(+), 17 deletions(-) create mode 100644 apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx create mode 100644 apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx create mode 100644 apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx diff --git a/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx b/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx index 4b2dfcef8..8e5bf6a75 100644 --- a/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx +++ b/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx @@ -1,14 +1,42 @@ "use client"; import { useWrStore } from "@/app/store"; -import { ContentsDiv, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, Title, UiTable } from "@common/business_components/ui"; +import { formTableName } from "@/components/lib/class/comClass"; +import { ContentsDiv, Form, FormField, FormUi, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, SelectBox, Title, UiTable } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; -import { Button, Label } from "@common/components/ui"; +import { Button, DatePicker, Input, Label } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useState } from "react"; +import { useFieldArray, useForm } from "react-hook-form"; +import { z } from "zod"; export default function coMatRvw() { - const { code, coRvw, } = useWrStore((state) => state); - const { coRvwHeadList, } = coRvw; + const { coRvw, } = useWrStore((state) => state); + const { coRvwHeadList, } = coRvw; + const [fromDate, setFromDate] = useState<Date>(new Date()); + const [toDate, setToDate] = useState<Date>(new Date()); + + const schema = z.object({ + fcltCpct: z.number().optional(), + }); + + const form = useForm<z.infer<typeof schema>>({ + resolver: zodResolver(schema), + defaultValues: { + fcltCpct: 0, + } + }); + + const { + fields: [], + append, + remove, + } = useFieldArray({ + control: form.control, + name: "", + }); + return ( <> <ContentsDiv> @@ -17,12 +45,42 @@ export default function coMatRvw() { <Title title={"수요매칭검토"} /> <SearchDiv> <SearchFormLeft> - - <div className="col-span-2 flex flex-row space-x-2"> - <Label className="w-28 mt-2 text-xl text-gray-600">{'시설명'}</Label> + <div className="col-span-8 flex flex-row"> + <SelectBox + className="col-span-2 w-1/3 h-full text-2xl" + label="시도" + selectClass={""} + selectArray={[]} + value={""} + onSelectValue={(val: string | number) => { } + } + /> + <SelectBox + className="col-span-2 w-1/3 h-full text-2xl" + label="시군구" + selectClass={""} + selectArray={[]} + value={""} + onSelectValue={(val: string | number) => { } + } + /> + <div className="col-span-5 w-full"> + <div className="flex flex-row items-center"> + <Label className="text-xl text-gray-600">수요신청년도</Label> + <div className="flex flex-row"> + <DatePicker mode={'single'} + selected={fromDate} + onSelect={(date: Date | undefined) => { if (date) setFromDate(date) }} /> + <span>~</span> + <DatePicker mode={'single'} + selected={toDate} + onSelect={(date: Date | undefined) => { if (date) setToDate(date) }} /> + </div> + </div> + </div> <SearchInput - className={"w-full text-2xl"} - label="" + className={"text-2xl"} + label="회사명" textValue={""} setText={(e) => { }} @@ -50,7 +108,7 @@ export default function coMatRvw() { <div className="col-span-6"> <ListDiv> <UiTable - headName={[]} + headName={"수요매칭검토현황"} tableData={[]} children={undefined} headlist={coRvwHeadList} @@ -60,10 +118,271 @@ export default function coMatRvw() { }} onPageChange={() => { }} ></UiTable> + <hr /> + <Form {...form}> + <h3 className="mt-4 ml-2 text-2xl font-medium text-label">표준공사비 산정</h3> + <div className="flex items-center mx-3 mb-3"> + <h1 className="">처리시설 표준공사비 산정</h1> + + <Button + size={"sm"} + onClick={(e) => { }} + > + 계산 + </Button> + <Button + size={"sm"} + onClick={(e) => { }} + > + 저장 + </Button> + + </div> + <div className="grid grid-cols-12 gap-4 ml-4 mr-4"> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="용도"> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? ""} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="요구수량(M3/d)"> + <Input + placeholder="" + type="number" + step="0.1" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <Label className="">용도에 따른 처리공정<i className="diveicon di-search" /></Label> + + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value || ""} + className="mt-2" + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="처리시설 용량(요구수량 * 365일)"> + <Input + placeholder="" + type="number" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>처리시설용량에 따른 공사비(백만원)</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 공사비 산정표 보기 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="number" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>시설부대경비 요율(%)</Label> + <Button + size={"sm"} + onClick={(e) => { }} + > + 요율표 보기 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="number" + step="0.01" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + + <div className="col-span-3 mt-4"> + <Label>총사업비 (백만원)<i className="diveicon di-search" /></Label> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + className="mt-2" + type="number" + step="0.01" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>공급처 선정</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 후보지 선택 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? ""} + /> + </FormUi> + )} + /> + </div> + + <div className="col-span-4 mt-4"> + <div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="공급관로 표준공사비(백만원)"> + <Input + placeholder="" + type="text" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="mt-4"> + <Label>관로 표준공사비 산정 프로그램</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 다운로드 + </Button> + </div> + <div className="col-span-4 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <Label className="text-xl">처리시설 + 공급관로 총사업비(백만원) + <FormUi label=""> + <Input + placeholder="" + type="text" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + readOnly={true} + value={field.value ?? 0} + /> + </FormUi> + </Label> + )} + /> + </div> + </div> + </div> + </Form> </ListDiv> </div> </div> - </ContentsDiv> + </ContentsDiv > </> ) } \ No newline at end of file diff --git a/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx b/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx new file mode 100644 index 000000000..be8fe5472 --- /dev/null +++ b/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx @@ -0,0 +1,353 @@ +"use client"; + +import { useWrStore } from "@/app/store"; +import { formTableName } from "@/components/lib/class/comClass"; +import { ContentsDiv, Form, FormField, FormUi, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, SelectBox, Title, UiTable } from "@common/business_components/ui"; +import ListDiv from "@common/business_components/ui/list_div"; +import { Button, DatePicker, Input, Label } from "@common/components/ui"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useState } from "react"; +import { useFieldArray, useForm } from "react-hook-form"; +import { z } from "zod"; + + +export default function ruseRvwHstry() { + const { ruseHstry, } = useWrStore((state) => state); + const { ruseHstryHeadList, } = ruseHstry; + const [fromDate, setFromDate] = useState<Date>(new Date()); + const [toDate, setToDate] = useState<Date>(new Date()); + const schema = z.object({ + fcltCpct: z.number().optional(), + }); + + const form = useForm<z.infer<typeof schema>>({ + resolver: zodResolver(schema), + defaultValues: { + fcltCpct: 0, + } + }); + + const { + fields: [], + append, + remove, + } = useFieldArray({ + control: form.control, + name: "", + }); + + return ( + <> + <ContentsDiv> + <div className="grid grid-cols-4 gap-4"> + <div className="col-span-4"> + <Title title={"재이용검토이력"} /> + <SearchDiv> + <SearchFormLeft> + <div className="col-span-8 flex flex-row"> + <SelectBox + className="col-span-2 w-1/3 h-full text-2xl" + label="시도" + selectClass={""} + selectArray={[]} + value={""} + onSelectValue={(val: string | number) => { } + } + /> + <SelectBox + className="col-span-2 w-1/3 h-full text-2xl" + label="시군구" + selectClass={""} + selectArray={[]} + value={""} + onSelectValue={(val: string | number) => { } + } + /> + <div className="col-span-5 w-full"> + <div className="flex flex-row items-center"> + <Label className="text-xl text-gray-600">수요신청년도</Label> + <div className="flex flex-row"> + <DatePicker mode={'single'} + className="w-full" + selected={fromDate} + onSelect={(date: Date | undefined) => { if (date) setFromDate(date) }} /> + <span>~</span> + <DatePicker mode={'single'} + selected={toDate} + onSelect={(date: Date | undefined) => { if (date) setToDate(date) }} /> + </div> + </div> + </div> + <SearchInput + className={"text-2xl"} + label="시설명" + textValue={""} + setText={(e) => { + }} + /> + <SearchInput + className={"text-2xl"} + label="회사명" + textValue={""} + setText={(e) => { + }} + /> + </div> + </SearchFormLeft> + <SearchFormRight + className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> + <div className="space-y"> + <div className="flex flex-row space-x-2"> + <Button + size={"sm"} + onClick={(e) => { }} + > + 조회 + </Button> + <Button + size={"sm"} + onClick={(e) => { }} + > + 검토완료 + </Button> + </div> + </div> + </SearchFormRight> + </SearchDiv> + </div> + </div> + + <div className="grid grid-cols-6 gap-4 "> + <div className="col-span-6"> + <ListDiv> + <UiTable + headName={"재이용검토현황"} + tableData={[]} + children={undefined} + headlist={ruseHstryHeadList} + pageSize={20} + total={100000} + cellClick={(index: number | undefined, headId: string) => { + }} + onPageChange={() => { }} + ></UiTable> + <hr /> + <Form {...form}> + <h3 className="mt-4 ml-2 text-2xl font-medium text-label">수요신청 상세현황</h3> + <h1 className="mt-1 ml-3">표준공사비 산정</h1> + <div className="flex items-center mx-3 mb-3"> + <h1 className="">처리시설 표준공사비 산정</h1> + <Button + size={"sm"} + onClick={(e) => { }} + > + 재계산 + </Button> + <Button + size={"sm"} + onClick={(e) => { }} + > + 저장 + </Button> + + </div> + <div className="grid grid-cols-12 gap-4 ml-4 mr-4"> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="용도"> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? ""} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="요구수량(M3/d)"> + <Input + placeholder="" + type="number" + step="0.1" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <Label className="">용도에 따른 처리공정<i className="diveicon di-search" /></Label> + + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value || ""} + className="mt-2" + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="처리시설 용량(요구수량 * 365일)"> + <Input + placeholder="" + type="number" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>처리시설용량에 따른 공사비(백만원)</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 공사비 산정표 보기 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="number" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>시설부대경비 요율(%)</Label> + <Button + size={"sm"} + onClick={(e) => { }} + > + 요율표 보기 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="number" + step="0.01" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + + <div className="col-span-3 mt-4"> + <Label>총사업비 (백만원)<i className="diveicon di-search" /></Label> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + className="mt-2" + type="number" + step="0.01" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>공급처 선정</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 후보지 선택 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? ""} + /> + </FormUi> + )} + /> + </div> + + <div className="col-span-4 mt-4"> + <div className="mt-4"> + <Label>관로 표준공사비 산정</Label> + </div> + </div> + </div> + </Form> + </ListDiv> + </div> + </div> + </ContentsDiv > + </> + ) +} \ No newline at end of file diff --git a/apps/wr/app/page.tsx b/apps/wr/app/page.tsx index a6f5856c3..ff6ef558d 100644 --- a/apps/wr/app/page.tsx +++ b/apps/wr/app/page.tsx @@ -129,6 +129,11 @@ export default function Home() { <Link href="matMng/matDmd/coMatRvw">수요처 매칭 검토</Link> </Button> </div> + <div className="col-span-2"> + <Button className="w-full"> + <Link href="matMng/matDmd/ruseRvwHstry">재이용검토이력</Link> + </Button> + </div> </div> </div> </div> diff --git a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx index c0d31cfeb..c5dce841b 100644 --- a/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/prfmncReg/pbnstPrfmncReg/page.tsx @@ -22,7 +22,7 @@ import { set } from "react-hook-form"; import { Toaster } from "react-hot-toast"; export default function prfmncPrfmncReg() { - const { code, prfmnc, prfmncHasuInit, searchFclts } = useWrStore( + const { code, prfmnc, prfmncHasuInit, } = useWrStore( (state) => state ); const { pbnstPrfmncHeadList, monthHeadList, prfmncRes } = prfmnc; @@ -38,7 +38,7 @@ export default function prfmncPrfmncReg() { const excelClick = useCallback(() => { console.log("dd") excelDownload( - prfmnc.excelList, + [[]], "하수재이용실적", "sample_pbnstPrfmncReg.xlsx", "A1:O1" @@ -104,7 +104,7 @@ export default function prfmncPrfmncReg() { <Button size={"sm"} onClick={() => {setIsExcelOPen(true)}}> 파일등록 </Button> - <Button color="green" size={"sm"} onClick={() => {}}> + <Button color="green" size={"sm"} onClick={excelClick}> 양식받기 </Button> </div> diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx new file mode 100644 index 000000000..f394229cf --- /dev/null +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/headList.tsx @@ -0,0 +1,185 @@ +import { z } from "zod"; +import type { CommonTableProps } from "../../common/type/headder"; + +export const sttnHeadListType = z.array( + z.object({ + id: z.string(), + title: z.string(), + visible: z.boolean(), + }) +); + +export const ruseHstryHeadListExport: z.infer<typeof sttnHeadListType> = [ + { + id: "ctpv", + title: "시도", + visible: true, + }, + { + id: "sgg", + title: "시군구", + visible: true, + }, + { + id: "coNm", + title: "회사명", + visible: true, + }, + { + id: "addr", + title: "공장주소", + visible: true, + }, + { + id: "telNo", + title: "전화번호", + visible: true, + }, + { + id: "regDt", //바꾸기 + title: "신청일자", + visible: true, + }, + { + id: "rvwDt", //바꾸기 + title: "검토일자", + visible: true, + }, + { + id: "matDt", //바꾸기 + title: "매칭 완료일자", + visible: true, + }, + { + id: "gong", //바꾸기 + title: "공급처", + visible: true, + }, + { + id: "dmndQty", //바꾸기 + title: "요구수량(M3/d)", + visible: true, + }, + { + id: "useUsgCd", //바꾸기 + title: "사용용도", + visible: true, + }, + { + id: "state", //바꾸기 + title: "진행상태", + visible: true, + }, + { + id: "matYn", //바꾸기 + title: "매칭완료 여부", + visible: true, + }, +]; + + +// id는 다확인해야함 +export const ruseHstryNodeListExport: CommonTableProps[] = [ + { + id: "ctpv", + title: "시도", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "sgg", + title: "시군구", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "coNm", + title: "회사명", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "addr", + title: "공장주소", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + },{ + id: "telNo", + title: "전화번호", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "regDt", //바꾸기 + title: "신청일자", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "rvwDt", //바꾸기 + title: "검토일자", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + },{ + id: "matDt", //바꾸기 + title: "매칭 완료일자", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + },{ + id: "gong", //바꾸기 + title: "공급처", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "dmndQty", //바꾸기 + title: "요구수량(M3/d)", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "useUsgCd", //바꾸기 + title: "사용용도", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "state", //바꾸기 + title: "진행상태", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + { + id: "matYn", //바꾸기 + title: "매칭완료 여부", + visible: true, + row: 1, + rowSpan: 1, + colSpan: 1, + }, + +]; \ No newline at end of file diff --git a/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx new file mode 100644 index 000000000..e41f792b6 --- /dev/null +++ b/apps/wr/app/store/matDmd/ruseRvwHstry/index.tsx @@ -0,0 +1,34 @@ +import type { z } from "zod"; +import type { sttnHeadListType } from "../coSttn/headList"; +import type { CommonTableProps } from "../../common/type/headder"; +import { ruseHstryHeadListExport, ruseHstryNodeListExport } from "./headList"; + +const ruseHstryHeadList = ruseHstryHeadListExport; +const ruseHstryNodeList = ruseHstryNodeListExport; + +export type ruseHstryState = { + ruseHstry: { + isInit: boolean; + ruseHstryHeadList: z.infer<typeof sttnHeadListType>; + ruseHstryNodeList: CommonTableProps[]; + + }; +}; + +export const ruseHstryStateExport: ruseHstryState = { + ruseHstry: { + isInit: false, + ruseHstryHeadList: ruseHstryHeadList, + ruseHstryNodeList: ruseHstryNodeList, + } +} + +export type ruseHstryType = ruseHstryState & ruseHstryActions; + +type ruseHstryActions = { +}; + +export const ruseHstryActionsExport: (set: any) => ruseHstryActions = (set: any) => { + return { + } +} \ No newline at end of file diff --git a/apps/wr/app/store/store.tsx b/apps/wr/app/store/store.tsx index aa3d19851..297983882 100644 --- a/apps/wr/app/store/store.tsx +++ b/apps/wr/app/store/store.tsx @@ -90,6 +90,7 @@ import { ldrmntCoSttnActionsExport, ldrmntCoSttnStateExport, type ldrmntCoSttnSt import { searchActions, type comFcltActions, type comFcltState } from "./common/searchCode"; import { pbnstPrfmncActionsExport, pbnstPrfmncStateExport, type pbnstPrfmncState, type pbnstPrfmncType } from "./prfmncReg/pbnstPrfmncReg"; import { coRvwActionsExport, coRvwStateExport, type coRvwState, type coRvwType } from "./matDmd/coMatRvw"; +import { ruseHstryActionsExport, ruseHstryStateExport, type ruseHstryState, type ruseHstryType } from "./matDmd/ruseRvwHstry"; export type WrStore = comCodeType & pubFacType & @@ -110,7 +111,8 @@ export type WrStore = comCodeType & coSttnType& // 옮겨야함 ldrmntCoSttnType& // 옮겨야함 pbnstPrfmncType& - coRvwType + coRvwType& + ruseHstryType ; export const StoreZus = ( @@ -132,7 +134,8 @@ export const StoreZus = ( coSttnState& // 옮겨야함 ldrmntCoSttnState& // 옮겨야함 pbnstPrfmncState& - coRvwState + coRvwState& + ruseHstryState = { ...comCodeStateExport, ...pubFacStateExport, @@ -153,6 +156,7 @@ export const StoreZus = ( ...ldrmntCoSttnStateExport, // 옮겨야함 ...pbnstPrfmncStateExport, ...coRvwStateExport, + ...ruseHstryStateExport, } ) => { return createStore<WrStore>()((set) => { @@ -183,7 +187,8 @@ export const StoreZus = ( ...coSttnActionsExport(set), // 옮겨야함 ...ldrmntCoSttnActionsExport(set), // 옮겨야함 ...pbnstPrfmncActionsExport(set), - ...coRvwActionsExport(set) + ...coRvwActionsExport(set), + ...ruseHstryActionsExport(set), }; }); }; From f4687be7659c3c3974a4a23a48a3ef5d2fc5b17d Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 4 Jun 2025 17:31:24 +0900 Subject: [PATCH 59/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EB=A7=A4=EC=B9=AD?= =?UTF-8?q?=EA=B2=80=ED=86=A0,=20=EC=9E=AC=EC=9D=B4=EC=9A=A9=EA=B2=80?= =?UTF-8?q?=ED=86=A0=EC=9D=B4=EB=A0=A5=20=EC=A1=B0=ED=9A=8C=EC=A1=B0?= =?UTF-8?q?=EA=B1=B4=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/wr/app/matMng/matDmd/coMatRvw/page.tsx | 43 +- .../app/matMng/matDmd/ruseRvwHstry/page.tsx | 624 +++++++++--------- 2 files changed, 351 insertions(+), 316 deletions(-) diff --git a/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx b/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx index 8e5bf6a75..b7bafc693 100644 --- a/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx +++ b/apps/wr/app/matMng/matDmd/coMatRvw/page.tsx @@ -2,20 +2,25 @@ import { useWrStore } from "@/app/store"; import { formTableName } from "@/components/lib/class/comClass"; -import { ContentsDiv, Form, FormField, FormUi, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, SelectBox, Title, UiTable } from "@common/business_components/ui"; +import { getCity } from "@/components/lib/func/commom"; +import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; +import { ContentsDiv, Form, FormField, FormUi, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, SelectBox, Title, UiTable, type SelectDataType } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, DatePicker, Input, Label } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; export default function coMatRvw() { - const { coRvw, } = useWrStore((state) => state); + const { code, coRvw, } = useWrStore((state) => state); const { coRvwHeadList, } = coRvw; const [fromDate, setFromDate] = useState<Date>(new Date()); const [toDate, setToDate] = useState<Date>(new Date()); + const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>() + const [objSearch, setObjSearch] = useState<objSearchType>({ sgg: "", city: "" }); + const schema = z.object({ fcltCpct: z.number().optional(), @@ -28,6 +33,18 @@ export default function coMatRvw() { } }); + const getSelCity = (val: string | number) => { + const cityValue = String(val); // Ensure val is treated as a string + const data = getCity(cityValue, code.sggCd); + setSelectSgg(data); + setObjSearch({ city: cityValue, sgg: '' }); + }; + + const getSgg = (val: string | number) => { + console.log(val); + setObjSearch({ ...objSearch, sgg: String(val) }) + }; + const { fields: [], append, @@ -37,6 +54,14 @@ export default function coMatRvw() { name: "", }); + useEffect(() => { + if (fromDate > toDate) { + const newFromDate = new Date(toDate); + newFromDate.setDate(toDate.getDate() - 1); + setFromDate(newFromDate); + } + }, [toDate]); + return ( <> <ContentsDiv> @@ -50,19 +75,15 @@ export default function coMatRvw() { className="col-span-2 w-1/3 h-full text-2xl" label="시도" selectClass={""} - selectArray={[]} - value={""} - onSelectValue={(val: string | number) => { } - } + selectArray={code.cityCd || []} + onSelectValue={getSelCity} /> <SelectBox className="col-span-2 w-1/3 h-full text-2xl" label="시군구" selectClass={""} - selectArray={[]} - value={""} - onSelectValue={(val: string | number) => { } - } + selectArray={selectSgg || []} + onSelectValue={getSgg} /> <div className="col-span-5 w-full"> <div className="flex flex-row items-center"> diff --git a/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx b/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx index be8fe5472..9b3d2262f 100644 --- a/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx +++ b/apps/wr/app/matMng/matDmd/ruseRvwHstry/page.tsx @@ -2,23 +2,37 @@ import { useWrStore } from "@/app/store"; import { formTableName } from "@/components/lib/class/comClass"; -import { ContentsDiv, Form, FormField, FormUi, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, SelectBox, Title, UiTable } from "@common/business_components/ui"; +import { getCity } from "@/components/lib/func/commom"; +import type { objSearchType } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal"; +import { ContentsDiv, Form, FormField, FormUi, ScrollArea, SearchDiv, SearchFormLeft, SearchFormRight, SearchInput, SelectBox, Title, UiTable, type SelectDataType } from "@common/business_components/ui"; import ListDiv from "@common/business_components/ui/list_div"; import { Button, DatePicker, Input, Label } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import { z } from "zod"; export default function ruseRvwHstry() { - const { ruseHstry, } = useWrStore((state) => state); + const { code, ruseHstry, } = useWrStore((state) => state); const { ruseHstryHeadList, } = ruseHstry; const [fromDate, setFromDate] = useState<Date>(new Date()); const [toDate, setToDate] = useState<Date>(new Date()); - const schema = z.object({ - fcltCpct: z.number().optional(), - }); + const schema = z.object({}); + const [selectSgg, setSelectSgg] = useState<SelectDataType[] | []>() + const [objSearch, setObjSearch] = useState<objSearchType>({ sgg: "", city: "" }); + + const getSelCity = (val: string | number) => { + const cityValue = String(val); // Ensure val is treated as a string + const data = getCity(cityValue, code.sggCd); + setSelectSgg(data); + setObjSearch({ city: cityValue, sgg: '' }); + }; + + const getSgg = (val: string | number) => { + console.log(val); + setObjSearch({ ...objSearch, sgg: String(val) }) + }; const form = useForm<z.infer<typeof schema>>({ resolver: zodResolver(schema), @@ -36,318 +50,318 @@ export default function ruseRvwHstry() { name: "", }); - return ( - <> - <ContentsDiv> - <div className="grid grid-cols-4 gap-4"> - <div className="col-span-4"> - <Title title={"재이용검토이력"} /> - <SearchDiv> - <SearchFormLeft> - <div className="col-span-8 flex flex-row"> - <SelectBox - className="col-span-2 w-1/3 h-full text-2xl" - label="시도" - selectClass={""} - selectArray={[]} - value={""} - onSelectValue={(val: string | number) => { } - } - /> - <SelectBox - className="col-span-2 w-1/3 h-full text-2xl" - label="시군구" - selectClass={""} - selectArray={[]} - value={""} - onSelectValue={(val: string | number) => { } - } - /> - <div className="col-span-5 w-full"> - <div className="flex flex-row items-center"> - <Label className="text-xl text-gray-600">수요신청년도</Label> - <div className="flex flex-row"> - <DatePicker mode={'single'} - className="w-full" - selected={fromDate} - onSelect={(date: Date | undefined) => { if (date) setFromDate(date) }} /> - <span>~</span> - <DatePicker mode={'single'} - selected={toDate} - onSelect={(date: Date | undefined) => { if (date) setToDate(date) }} /> - </div> +return ( + <> + <ContentsDiv> + <div className="grid grid-cols-4 gap-4"> + <div className="col-span-4"> + <Title title={"재이용검토이력"} /> + <SearchDiv> + <SearchFormLeft> + <div className="col-span-8 flex flex-row"> + <SelectBox + className="col-span-2 w-1/3 h-full text-2xl" + label="시도" + selectClass={""} + selectArray={code.cityCd || []} + onSelectValue={getSelCity} + > + {""} + </SelectBox> + <SelectBox + className="col-span-2 w-1/3 h-full text-2xl" + label="시군구" + selectClass={""} + selectArray={selectSgg || []} + onSelectValue={getSgg} + > + {""} + </SelectBox> + <div className="col-span-5 w-full"> + <div className="flex flex-row items-center"> + <Label className="text-xl text-gray-600">수요신청년도</Label> + <div className="flex flex-row"> + <DatePicker mode={'single'} + className="w-full" + selected={fromDate} + onSelect={(date: Date | undefined) => { if (date) setFromDate(date) }} /> + <span>~</span> + <DatePicker mode={'single'} + selected={toDate} + onSelect={(date: Date | undefined) => { if (date) setToDate(date) }} /> </div> </div> - <SearchInput - className={"text-2xl"} - label="시설명" - textValue={""} - setText={(e) => { - }} - /> - <SearchInput - className={"text-2xl"} - label="회사명" - textValue={""} - setText={(e) => { - }} - /> </div> - </SearchFormLeft> - <SearchFormRight - className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> - <div className="space-y"> - <div className="flex flex-row space-x-2"> - <Button - size={"sm"} - onClick={(e) => { }} - > - 조회 - </Button> - <Button - size={"sm"} - onClick={(e) => { }} - > - 검토완료 - </Button> - </div> - </div> - </SearchFormRight> - </SearchDiv> - </div> - </div> - - <div className="grid grid-cols-6 gap-4 "> - <div className="col-span-6"> - <ListDiv> - <UiTable - headName={"재이용검토현황"} - tableData={[]} - children={undefined} - headlist={ruseHstryHeadList} - pageSize={20} - total={100000} - cellClick={(index: number | undefined, headId: string) => { - }} - onPageChange={() => { }} - ></UiTable> - <hr /> - <Form {...form}> - <h3 className="mt-4 ml-2 text-2xl font-medium text-label">수요신청 상세현황</h3> - <h1 className="mt-1 ml-3">표준공사비 산정</h1> - <div className="flex items-center mx-3 mb-3"> - <h1 className="">처리시설 표준공사비 산정</h1> + <SearchInput + className={"text-2xl"} + label="시설명" + textValue={""} + setText={(e) => { + }} + /> + <SearchInput + className={"text-2xl"} + label="회사명" + textValue={""} + setText={(e) => { + }} + /> + </div> + </SearchFormLeft> + <SearchFormRight + className="w-2/12 mx-5 flex flex-col items-center justify-center space-x-2 "> + <div className="space-y"> + <div className="flex flex-row space-x-2"> <Button size={"sm"} onClick={(e) => { }} > - 재계산 + 조회 </Button> <Button size={"sm"} onClick={(e) => { }} > - 저장 + 검토완료 </Button> - </div> - <div className="grid grid-cols-12 gap-4 ml-4 mr-4"> - <div className="col-span-3 mt-4"> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label="용도"> - <Input - placeholder="" - type="text" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? ""} - /> - </FormUi> - )} - /> - </div> - <div className="col-span-3 mt-4"> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label="요구수량(M3/d)"> - <Input - placeholder="" - type="number" - step="0.1" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? 0} - /> - </FormUi> - )} - /> - </div> - <div className="col-span-3 mt-4"> - <Label className="">용도에 따른 처리공정<i className="diveicon di-search" /></Label> - - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label=""> - <Input - placeholder="" - type="text" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value || ""} - className="mt-2" - /> - </FormUi> - )} - /> - </div> - <div className="col-span-3 mt-4"> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label="처리시설 용량(요구수량 * 365일)"> - <Input - placeholder="" - type="number" - step="0.001" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? 0} - /> - </FormUi> - )} - /> - </div> - <div className="col-span-3 mt-4"> - <div className="flex items-center justify-between"> - <Label>처리시설용량에 따른 공사비(백만원)</Label> - <Button - size={"sm"} - onClick={(e) => { }} - className="bg-none" - > - 공사비 산정표 보기 - </Button> - </div> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label=""> - <Input - placeholder="" - type="number" - step="0.001" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? 0} - /> - </FormUi> - )} - /> - </div> - <div className="col-span-3 mt-4"> - <div className="flex items-center justify-between"> - <Label>시설부대경비 요율(%)</Label> - <Button - size={"sm"} - onClick={(e) => { }} - > - 요율표 보기 - </Button> - </div> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label=""> - <Input - placeholder="" - type="number" - step="0.01" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? 0} - /> - </FormUi> - )} - /> - </div> - - <div className="col-span-3 mt-4"> - <Label>총사업비 (백만원)<i className="diveicon di-search" /></Label> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label=""> - <Input - placeholder="" - className="mt-2" - type="number" - step="0.01" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? 0} - /> - </FormUi> - )} - /> - </div> - <div className="col-span-3 mt-4"> - <div className="flex items-center justify-between"> - <Label>공급처 선정</Label> - <Button - size={"sm"} - onClick={(e) => { }} - className="bg-none" - > - 후보지 선택 - </Button> - </div> - <FormField - control={form.control} - name="" - render={({ field }) => ( - <FormUi label=""> - <Input - placeholder="" - type="text" - onChange={(e) => { - field.onChange(Number(e.target.value)); - }} - value={field.value ?? ""} - /> - </FormUi> - )} - /> - </div> - - <div className="col-span-4 mt-4"> - <div className="mt-4"> - <Label>관로 표준공사비 산정</Label> - </div> - </div> - </div> - </Form> - </ListDiv> - </div> + </div> + </SearchFormRight> + </SearchDiv> </div> - </ContentsDiv > - </> - ) + </div> + + <div className="grid grid-cols-6 gap-4 "> + <div className="col-span-6"> + <ListDiv> + <UiTable + headName={"재이용검토현황"} + tableData={[]} + children={undefined} + headlist={ruseHstryHeadList} + pageSize={20} + total={100000} + cellClick={(index: number | undefined, headId: string) => { + }} + onPageChange={() => { }} + ></UiTable> + <hr /> + <Form {...form}> + <h3 className="mt-4 ml-2 text-2xl font-medium text-label">수요신청 상세현황</h3> + <h1 className="mt-1 ml-3">표준공사비 산정</h1> + <div className="flex items-center mx-3 mb-3"> + <h1 className="">처리시설 표준공사비 산정</h1> + <Button + size={"sm"} + onClick={(e) => { }} + > + 재계산 + </Button> + <Button + size={"sm"} + onClick={(e) => { }} + > + 저장 + </Button> + + </div> + <div className="grid grid-cols-12 gap-4 ml-4 mr-4"> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="용도"> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? ""} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="요구수량(M3/d)"> + <Input + placeholder="" + type="number" + step="0.1" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <Label className="">용도에 따른 처리공정<i className="diveicon di-search" /></Label> + + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value || ""} + className="mt-2" + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label="처리시설 용량(요구수량 * 365일)"> + <Input + placeholder="" + type="number" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>처리시설용량에 따른 공사비(백만원)</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 공사비 산정표 보기 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="number" + step="0.001" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>시설부대경비 요율(%)</Label> + <Button + size={"sm"} + onClick={(e) => { }} + > + 요율표 보기 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="number" + step="0.01" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + + <div className="col-span-3 mt-4"> + <Label>총사업비 (백만원)<i className="diveicon di-search" /></Label> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + className="mt-2" + type="number" + step="0.01" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? 0} + /> + </FormUi> + )} + /> + </div> + <div className="col-span-3 mt-4"> + <div className="flex items-center justify-between"> + <Label>공급처 선정</Label> + <Button + size={"sm"} + onClick={(e) => { }} + className="bg-none" + > + 후보지 선택 + </Button> + </div> + <FormField + control={form.control} + name="" + render={({ field }) => ( + <FormUi label=""> + <Input + placeholder="" + type="text" + onChange={(e) => { + field.onChange(Number(e.target.value)); + }} + value={field.value ?? ""} + /> + </FormUi> + )} + /> + </div> + + <div className="col-span-4 mt-4"> + <div className="mt-4"> + <Label>관로 표준공사비 산정</Label> + </div> + </div> + </div> + </Form> + </ListDiv> + </div> + </div> + </ContentsDiv > + </> +) } \ No newline at end of file From 789b9d38ae2a853f52fdb32026cf71af4be2cb6a Mon Sep 17 00:00:00 2001 From: jyha00 <jyha@mind-one.co.kr> Date: Wed, 4 Jun 2025 18:59:17 +0900 Subject: [PATCH 60/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=ED=98=84=ED=99=A9=20=EC=97=91=EC=85=80=20=EB=8B=A4?= =?UTF-8?q?=EC=9A=B4=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruseFcltMng/fcltSttn/pbnstSttn/page.tsx | 21 ++++-- .../ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx | 28 ++++++++ .../ruseFcltMng/fcltSttn/pbnstSttn/index.tsx | 67 +++++++++++++----- apps/wr/public/sample_pbnstSttn.xlsx | Bin 0 -> 9196 bytes 4 files changed, 93 insertions(+), 23 deletions(-) create mode 100644 apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx create mode 100644 apps/wr/public/sample_pbnstSttn.xlsx diff --git a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx index a662ffb7a..837cf23f1 100644 --- a/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltSttn/pbnstSttn/page.tsx @@ -15,20 +15,27 @@ import HeadChModal from "@/components/ui/modal/sttn/headChModal/headChModal"; import { useCallback, useEffect, useRef, useState } from "react"; import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan"; import type { customPbnst } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; +import { excelDownload, getCityOrSgg } from "@/components/lib/func/commom"; export default function PbnstSttn() { - const { code, pbnstSttn } = useWrStore( - (state) => state - ); - + const { code, pbnstSttn, pbnstSttnSearch } = useWrStore((state) => state); + const ref = useRef<ReturnType>({} as ReturnType); + const codeData = getCityOrSgg(ref); const [pageNation, setPageNation] = useState(1); const [isChHead, setIsChHead] = useState(false); const [bdstTable, setBdstTable] = useState<customPbnst[]>(); const excelClick = useCallback(() => { - }, []); + // if (codeData) pbnstSttnSearch(1, "10000", codeData); + excelDownload( + [[]], + "하수재이용시설 현황", + "sample_pbnstSttn.xlsx", + "A1:U2" + ); + }, [pbnstSttnSearch, codeData]); return ( <> @@ -65,7 +72,7 @@ export default function PbnstSttn() { // pbnstSttnSearch(1, "20", con); }} excelClick={excelClick} - initClick={function (): void {}} + initClick={function (): void { }} btnClass={btnClass} ref={ref} /> @@ -83,7 +90,7 @@ export default function PbnstSttn() { headlist={pbnstSttn.pbnstSttHeadList} pageSize={20} total={100000} - cellClick={(index: number | undefined,headId:string)=>{} } + cellClick={(index: number | undefined, headId: string) => { }} onPageChange={setPageNation} ></UiTable> </ListDiv> diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx new file mode 100644 index 000000000..a85a009a4 --- /dev/null +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/excel.tsx @@ -0,0 +1,28 @@ +import type { customPbnst } from "../../fcltReg/pbnstReg/type"; + +export const excelPbnstSttnParsing = (data: any[]): string[][] => { + const excelExportData: string[][] = []; + + data.forEach((item) => { + excelExportData.push([ + item.a, + String(item.aaa), + item.aaaa ?? "", + item.operMngCd ?? "", + String(item.cityText ?? ""), + String(item.sggText ?? ""), + String(item.bdnstNm ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + String(item.archArea ?? ""), + ]) + }) + return excelExportData; +} \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx index e1a60d921..cb6b8e392 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltSttn/pbnstSttn/index.tsx @@ -3,11 +3,12 @@ import type { z } from "zod"; import { pbnSttHeadListExport, pbnstSttNodeListExport - } from "./headList"; +} from "./headList"; import { fetchType, getFetch } from "@/components/lib/api"; import { controlHeadView } from "../rainSttn"; import type { sttnHeadListType } from "../rainSttn/headList"; import type { customPbnst } from "../../fcltReg/pbnstReg/type"; +import { excelPbnstSttnParsing } from "./excel"; const pbnstSttHeadList = pbnSttHeadListExport; const pbnstSttNodeList = pbnstSttNodeListExport; @@ -26,6 +27,7 @@ type pbnstSttnActions = { pbnstChSttnHead: ( headList: z.infer<typeof sttnHeadListType>, ) => void; + pbnstSttnSearch: (page: number, total: string, con: string) => void; }; export type pbnstSttnType = pbnstSttnState & pbnstSttnActions; @@ -34,8 +36,8 @@ export const pbnstSttnStateExport: pbnstSttnState = { pbnstSttn: { pbnstSttHeadList: pbnstSttHeadList, pbnstSttNodeList: pbnstSttNodeList, - pbnstSttnRes:[], - excelList:[], + pbnstSttnRes: [], + excelList: [], isInit: false, }, }; @@ -45,19 +47,52 @@ export const pbnstSttnActionsExport: (set: any) => pbnstSttnActions = ( ) => { return { pbnstChSttnHead: async ( - headList: z.infer<typeof sttnHeadListType> - ): Promise<void> => { - - console.log('head ', headList) - const changeNodeList= controlHeadView(headList,pbnstSttNodeList) - - return set((state: pbnstSttnState) => ({ - pbnstSttn: { - ...state.pbnstSttn, - pbnstSttHeadList: headList, - pbnstSttNodeList: changeNodeList, - }, - })); + headList: z.infer<typeof sttnHeadListType> + ): Promise<void> => { + + console.log('head ', headList) + const changeNodeList = controlHeadView(headList, pbnstSttNodeList) + + return set((state: pbnstSttnState) => ({ + pbnstSttn: { + ...state.pbnstSttn, + pbnstSttHeadList: headList, + pbnstSttNodeList: changeNodeList, }, + })); + }, + pbnstSttnSearch: async (page: number, total: string, con: string) => { + try { + const pbnstSttnRes = await getFetch( + fetchType.WR, + `/reuseFc/waterreuseFc/${page}/${total}/${con}` + ); + if (Number(total) > 9000) { + const pbnstExcel = excelPbnstSttnParsing(pbnstSttnRes); + set((state: pbnstSttnState) => { + return { + ...state, + pbnstSttn: { + ...state.pbnstSttn, + excelList: pbnstExcel, + }, + }; + }); + } else + set((state: pbnstSttnState) => { + + return { + ...state, + pbnstSttn: { + ...state.pbnstSttn, + pbnstSttnRes: pbnstSttnRes, + isInit: false, + }, + }; + }); + } catch (erTxt) { + console.log("error", erTxt); + } + }, } } diff --git a/apps/wr/public/sample_pbnstSttn.xlsx b/apps/wr/public/sample_pbnstSttn.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..8bbd47ea3b7a624c63debf7eca9da822aa4f69fa GIT binary patch literal 9196 zcmeHt1y@|j)^-yhxHs<Z?gS4(g1ftG<L)6ya0ng<5@c}K;0^&gxHk|8?r!1h%)R%W znaq5@;NI%Bs!p#yd-po0o^8)A6?s@VAmBLw5dZ*C0?dxGZH!<5fCM-I00)5hO#daw z$=%Y)-B`oN+0xCB&D+s|A|LJ<LoVPM^#1>i|Kc}L{(e-cmjm<Fwd}*oP1e`Twc?1p zhoOVmOsb+?eaQo*=K49dwof@x_n4A-xOV(C*b~csT&H6;wN8$Wp^*b^YN*j6LtUCi z#Qg02g9o&o_=HKWdb-ECKw@!DLSy4tt1LjeOH;2JkJP%v>vAF+Ts+a>Z`q53T3C>Q z7SvL`62YOR?lmQ?RV;y#-=;9XeZ`r!vt{%%I{(Hh2NzA{w~Xg$RH#C!qt0li*5Z1X zCg0)4(9At!V*YHEBRruUePtZ-ysd+uOp%AE_P2KzrFsJi_RO9B2L8UC3~|vHDtE1X zxHiVD`Z?kul%bRJ02TY_db|oQr-^_*G28-$(UTsEm3!KC9Fjf=u|;c6e1e4%0hJ@m zTH#=hl(HZ{Q)poE&~URrm-3-GiN90PSA<QtS2s_<E3Dnt^Daru;Vw#=fQZAjq1_jL z2jDIJH%F(byFpw(o&x|+Pp|-$znEo%CI|He6l)4lt3!dBrLn7}gBv^B&-s7m_+M;; ze|q%tBt_+34%F~t*@uXs>zS1VOi6h!3E4JEjlf{JWsHW{0vh6#PI?kd4Wc)&GC}Qu z4<kz}!m)cplvf)(<<Z!{7u1bj72#=jE*=O>bgrq=F6HZeSe`SNGglchuYDLi+vAza znoIKJhauF`Q>Rijm=kQ;L`XP=B;j}>86kQDin^<2H<d6mlIn*Q;nhw2xqHbISwVBD zMZ0KXk%9^blNq=}Zf4dCmHtBxl$W<en(8)!w$)}iu0m8k#ug4;=TcdnIFJ6UN*{*Q zsCck%xF%!<X>%`w^y+y|N3(tU_>p?chE9e<qsdEFp%LouMiL_WKJ6U(Mp~gpLIgmB z@pfSUmz{WlT<y(3Ap4)u>pwOF0}WwNE&tu4Tuo8Fj{~zE<wpdESC%I()`B}b)q&<d z2I6o%;}RVuci;ttn5orJXI7pa78LGtJT~Zg&5OPPi*wn{T=EVZ&KJkw_ys&@?0gIs z(d@8-EK~*_2m4@ezw8hNJ<|=RMKo!MB?l<*{f2>-FruJ{O6sCzGMvY5oWq05&J9dD z0>#W|{bul8nEF9QXnj)?MJA)w)>F&NrK{&3Lw(4<o)aR;38VP{zV1v@GT(H+x<Wkr z{9vW%Gj88qaEH1@QYKGU$}8d@?oJUgBtss=nB=yVpV6jyyzVY}Kf>6#bjC7zacs3Y zJU9b^?)2XwlceT0zz&5=BsAT@fZhRx%%8zht}z-n#Q|KQKE+7Awk1;(a-6o{37}x2 z<RKE`&RS@Wo6@<Yo=10ld*kJV{p_vN^X>uAN52Wdxg1E&CvoHS8iO*_hynn0Q3+e~ zqV<i-{dks{1*s}LmR=3&$Bh1_+a><<0=|gsSp+!1h*h&|rBVQ7@|~QSOsf^L=W9nA z7Y<%O$ZU9Gk5-Hz;{yXCT?dW9IvFKzRX5mjm{H$$QMSkc!z`TweX<F+>M)pY*M5zL zGot9KB$ZeEpn2_RImC>{wsnEoaYzYpsGg2G#PK;a^#hTk$F4MB>srp}6b)7k)o<kX z^Jb{XWi7SZ9C?&O0b&eXjgz7C;5$@hlhXKuCito8=x~&Iv~L2))gPbgH&$~)Q$Ari zq0ph8I6Gq_n9k?Gsd@Eq7DSrMSCH7;ynGCrDeE=TB3hQfIB@Gldy{WtIl2wT&P>W~ zr>~TZ#UeB+Vvon$@j4uRO`ZZ)A!f&?O14LMlC+Z4?-0d2O5Pg`N}AYqL=toHtnajN zDBijFqL~*@7>?l5K|tQNWo^{V)ce()s4KAZD(5s{OZ<=nDT(a{-c$P$vtU1QZ~4b` zM;K;~_7X_%B_|hSM92a#+wg~TEVe}VO5;AdQogQ$lX-RWy@}!6n`+@+<6eR0HYBSW z{PMvld}ZrI{@B69rWoz7LM^&gv(cMNPZgFY{G=Uk_(tCmH1UR!t>O5XY=!ES9Ohtd zq9~#2-uG5Ky!c0KIR`3-e22Q2NCW@?_%Cd^*_gUoTBy6b+B#Xg{q#oVDH5P54uXF< z?P3=bwigPBv<s%#*!<`xu=%t4)V!XNhJ8-(g(Zb4V4Bxcza28!gyd1ZvVCz0zz>Xj z+!9;!WPRq+D<U*|ee-y5{b)wsj>t6YhVAlE6=7wGogx}c#e91)Eus8T__H6mu7P*` zrX~R`x)3!9X-gAm;RA~NoZ3-tE#^9Gj8Bciv-sn>1eJETp8PHxU&3rNGU-0%Q!YxX zlC?LI>zD{R%88m5noK0_&XMIzmmf8UPmeJw#{%Z?*e+zik5=aEi>A8vn1QD*7TFw3 zWGU{nwSBrJZ&f|N>=a>z84_2Of)IV!6BjUszEB)zaqJECyEA`}hs~Xd@GkF|Rn+L& z&XnGVo%V3(BkcD%&K@E1spZ)y&kBuZ_E=aRHIC;*?SODTLoen?w_kIrw3kn=duzaF zsizL2(<@EvablVx&@(4!pN_AvI&WXw{!+dhEl5M09>wFc!lw{o7Z4KYkV8lCF)R8j zo(c%$@WU%^lWGP_2Qn=Nv*fKR7FC0PuJkMxu2w1_v+|)Gh0cMrh1q1aC5gLEm*Yc; z_WlqrcHNFrZj-^Qxr92UH?J=d3DS2|5A`ayU7FArmfZ)?CN535L;Xw2;t!v~O&;kz zg8nf~iDR4zWka*PSfZaL*6%*Y-Nw?<lKuCY^Cv70boHZ&`GJA#7h<UAM>l-mMzKNF zgPx6JPS~|dugNU+uNcY*GZH@&<2<9y14}XjCnwV+A!jPDVbORl3dO7_^AzvNeLoTU zeQNkHW~n}z#LL2+sVwtxT=35QMbNsZRQAgc&OIBc`l8ydq$Kh4>3vhFegR;19)k!J zU_6#3r&9~cmlc#H@<3-Y$0$sh`H(wKh$JgN(5z9D<qQi*9T+#}j0&M+iAo5bv(O`< z-$6W(uGe8qvFk@nocAyThAc2ABN3WzA5V1n|2T2;^0RH1$&1o)*5$|_?x>HAWkP-- z${-JCd=gAIPMOb&PefE#0Mo&05JAPZ_HvZ<H?gMXfR4z<+SeKmC1o@FWu4_lTBiOg zs*ZG1>!qp_=k0oamc}q8I)j&c?Rr&>wZ#A%p3s~k1NW@J;)UHiLM_<Bc)X<*-zGi2 zlg!6GqU}cZpyx&*YWJ%|9T1GJ=%3f0L8o%<*xo-c{T<Pa*&Eu7R=Su~Waa#;!`W^d z?5YnAk-1FW2a!Q{Mx92(G20A7;hLVqbaX6uS+1;-O*)eZ!EkCcvImj<sLEi(NdfWq zs5l!3Nw$bl{4Y7bsTh>Lzbj;VNE1^QVT{jZjj3Nu!sl4Gf0Y#9D}$5~m3q&q<H0*L zMXwxpEF#)*y?^?6KX@HDzNl3c<NJakXYVpc?BTBJSj^+c!&byLMu%LMXw<gQj|F98 z;rqjD{EP^)?Mm;v!vgDga*@ZQGO<8^lbTf}uu24mY*>pMA-Uk34jgIy$zbp1j2)_^ zR16UV+!EfD2o_P-D2kM0GdiE4H#JO34GjA@h|u7=*Mcpwa7*6Q0&q=GK$@yU>MYk- z=;O^1Uwk!?+!EIo4$iAM1oTS>`<)XGG1p|EN;-f)zgA@d0|#{k&WK-h%}=&vg%Jd< zP#1)`@L`QBZn$ICv|5OVOH*y7c*?@L=*}ZbmY_inR-A=m7JXOxBj~Wh;q&p%U=`5# zjilT{sIrD(-jy7k7}7`*4?n)*nsgCiqnK1z$e1EFA9wVqqyZbV?xcyE9+*N3qKBmD zLP_Qwj;IFQEz(HgDBoFWjnkle9LPKX)PRE88P(m_>4K7*FZy8miF*Uym{2blqjY;< zYG<qEP@Ihl*YurHS$+3503-FhwiLfdlZ%)2FYWlK;`szo^=y;=7*e!^))|%Agkwgk z{(_#zALmG{WZ94>zRHY%WuJS_Z#|HG`RK{0nLl=`E^Xf+PvY}=L#tkk3^D!@j^u8K zj>_lJnZ@kh&pbyj^A<HqvbXH0`BBz6m*@zZZ9_Fk=}k9qsCphT$4o+uwU)q)6AH>L z+~y>+kEJ??k*7#YcGn#7SMvfZRjH${pv-p&GF0sBw`H#L_K`rtvTeWW6rYB&?9%qL zq~P*<CYt&I1#C@}sJmLs{1YndQfup;d|T763E$K5^rT(3kaHW~A+vlS(Q#@pfXGk4 zn8?3nAR84ZlzBF~GqU!<_7lHg@*W|eEYkA%W}?&UO5!$pzqF!7d8tK;yuvIwN%>yP zSeMl7yY6A#f!2(O>0Ell8WJ?YSl@4seR}VPkQ{SsDuFznae7V_d%f%Ph+}$3a958f z1Y;Cl%?2k_LT{()5@jc0o`goY<ePV>$coUl^OH*@q~MfDUgxJWw{?y@Ct^lZT^_;3 z4D(7gz_Hjeq(+e7e-lHGBaH1k-+;Zldw~lSok8B$)_lC|uBFR**?ir5n#ld>e3K{? zc)oAB+r_!={GhJXE=cE`(}G<q{G_Cyka4hw@Qx{B(pAcua>NQ~_(i=L`ztQ#W#d`M zRq7=nN$XM1x`t9UNO(U-R8xM!Ha}w`BfNA-cZ#hD1WKCI*-9?yW=e5ta9nGd<xSH= zh_cJ3Rm$)%Hj@OGY{e2z(|q$FOwG(r$($Z{mdN$VZ|nw@3HIzo&1K)_tqzx`;Pkl~ z{)TP5;=kjC<KT_bSAbI7<;K*EOuH;hgNPTfE9lBZ%pv6z?GTHoJT6ShdaX1J@{{Pt zKrRf2FneoOY1rHx+T|VI&$v#or?qB}7^dq;5u`j`%obuGsJbVvw3nPU+^5<2%z8TY z<x{C&GrxLeu+sUSx$!<N<g>90>9c&dVy#{NvN5F!aCzfBeASXIFjJyJeP=e*w+Vvw zAYB(U=YftpZ?6qoHER#F+oE9bZb<qBvBBFjDxAF9JCvTVhm56ig3mQXxr~GTpy_4M zKV~^{)zJnD(CnEK4*)>>cb4Ps<6!xFdb6ps;<UsE>>#i9!t_4g8B8@NOpO+b3Vue) zK|xrpub1zT4`ftvXYwKdYco`@ICiliU%*^x*<Yi-_(UULu|Mz9Sh)I3VB>h*tHaIP zduTYB%Y2qK5gu1q>L}w4OOJV?N(bUsFMd@}Sh=KWjtQLr($`Gj&hW*472R7sZr64i zDP4+Cd`dm0lz7Ls$TXVX{){1{h#ZX}ROXVAw}zWZYoEZ$TvmQ@-1XcFf~7PubvKxl zgsJRWKJ0k9ak$y)(ld)gl3IB2A6c6dyvG4{yXejiDMu>4W5`9e_K7hAYCtMYYl>++ z+t=o`vAor=#Df(yn0_B<=9);W)cl3y;I-f4M&oKz5(T@X`96e3rwLCQn&4=}W-7hY zo@KQHZ&3LOMZx1ts)_UM*y#z3%kpkKw(*k(1~@*R-h+;V?sPGfT%;FT_b$F1(5AxA zS7PtLw~pylrY5Masq!xpnZ7Zpl;LH#!;n-R6GeXY#^e)>aQGxbWs7=$rusQ!u>Oe7 zAVO*QF5I#{)-d%>!`|7L5Q4eed{l~UuKn@O+dlibbBvEFh|)NR?$Obe(IIY3rR~## z`v?-wNB7haw9haPG1p`J>+k75(a1%H!`4~JpdBhki2neF7<_pNeARu>(=G&IoE~~E zv@J=83C>i+4QA4ua_^BX?XspZWVzIiBKa}#R;~KDI5}+N?OM8R70AlnT9P6x9iOTp zEd6r$xjQNgYbRc3P_=}q_yIYJEOG8Vf;RHuT(Rj!9k%^A^||$X`%}^MddKzq^fr|7 zkeh3l=JvikDKf-0$jqruM8_20Op%X!kJxIjG3p0D(5I(2+fJeVAtS2|yL;8B5~6f5 zhWpMB0j*INLh4NF(N(n!>Jw{lp%z-!?21@%IjuUcE=#$xO{DRKsYz-nsc>UG;&5N4 zXdtO%^!R`ctMuC2s=cO1v@%v<d)USdRBC5Y&z7~gZ9tp)0uu{*+sQ)e<@OxK6=PpA z7G^*4z1O(49tEq(-XX(z2rP~*22kz`w-;^7zgY(9hMSFYX^^4RUaD<8gufps5wiXo z*BX6hcypQZEs^0#|Ky%NF35Z1W<nY62}yeR$!;hFzc3kH@JV3^@>)ccm`suES%wTf z%pJqy!Y9VmzyidtA3=e)Cs!U3C%5mong_IfB1C!kxW%p18i(JvfSDeXtR~CHm=e@! zY5JLqocOXS?M5L9VU=70!~3d`N&UQ-NX&+<?Yrkk=$Gx-=+)cs%bDx;6*OpHF|_N> z*Up&Ee5tMZ_R#M7j^TeC)NW(2S*4|^u6d95$7j>GBM9$gY|9Anu5>q>oE*^GTiTz@ zIqF9Wr66~-;KClTU3C!)DF@8$z6uyTL<{$xCPuptWIr=Jb`?lByiJ63ACcdN?aWs$ z2~(z4ifQps$D9pl#lCH=Frg_~%?n%6>2ZR17XNb+O=Xm~zzquk@FM{L1pjh7KMQv^ z8%s-fH}>C`-!thLEkpGU4qyNz;}IkKvpf>h>*BR$iqH-Gy^e?^$-%~5I+#t!v7#A@ zVryMTLoxj}-F43L(#amTd^_tFm8lQ;x)!kyPy9UBuy(-34?fWrshk8F<D~an_3>94 zxn<oG<m+*#7&S#2zPSm}qI&YWa2@RVykn6zHKE^6Xsv{)v5js=@ZpOse#5u?4Px8W z7AT!WLijc~Najty3-(v6Xg<QRLacQjTI?(KSvktr4J>zY2GTc!MFLSeTETr(ayTt> z`9q`mCaoic^wGfa$EXQe4ZD4O8BuwvakywpluiFS)$1=Jo!f6FDGcbGpQU)lPc_F^ zx}2;^{Ggb=z0C$^3;15q=zgAjFP+4er!b_xYs_(#7pWe+n9IN;!I&gVr!Vx$c2TB| zOyeXz4kjM6tBQ(5EbZ$+tI5Q&{$#p?nxJ(XlA@M9l4)Con{3F4RP}OvNn|b@W~+zZ zp`R2DVc3U5;SxFrb)b|FECQ+bSEBYHJJcT8idL=B3o|gDbNOK|>7D+({YC$cCf6E= z?=bke^z$8xs>v>oSmIs*5i|F_7?)v&f@Pw$1Dj#nfZ;w|kuvTgwr`)uo81Ukgubm> z8cY*%_XeA34tADvlc5%rAs4IP*aSx-d%N=bdc<1mf9s!3ZzGy7-6~@}vw}UADHRnc ztHsxttC_pq3OX!Iy~L_-c*DyAda%pY`A)#6!onSc`U+y3y+I7y<smH9c);nDtMj9o z7r0!>#LF4k5hetletzVzw)))4xHMtE_d5$jgvW(tTZGSr<yeH*#R0_YER^bDlqsOa zxUEQ1mRbd!(m~M48{Cmn7q`D82%ONFyD*xf<sQ*)l|f-QBc74t4ENOTwqjde2aF)h zP4^tT05siC3DMWs+HP>r*8*E_NWLrKpr0cymX4CI13nyX@CyXT?QS#)07hGH;1Em< z@IP(<9?Ax$DaGDY>-0h*6sXeWIY$dKy%QW;*iCr09fr=Tj0qa5DVXoXZ<vPPrcLT7 zm!NFAaQ7{;dZ(7Fxa~g^+6<K&u03-^6Jr2|CuG`UMh&06axA&qB7A`VCx-010%4jk zw2sw<vSe6LQq=-vuHp)Ec4IdOxmy0a9r!;k73zWBC;h1%7GPG)uF5P&D{iQY6s1Ms znJVJQYBpGlX8T08{S{M#k45BqJmUqmby+e~0eiKQmXM6CqzYW7w&dQ+IL{>y{|Kt> z47~Dkp3NOp^on;&Suw;T%qSC$Tqf;s`0z=d@3Tlq+xda!gYmiP@}VygT#R-5{k<1q z`C@{qVb_o-QOdixyM=qvIQU?(E@itBKHb(^qF|D|L_)6j5>Qlo_;zWMa$lFHDXm2N zxDb|o*KFRnmMze%tb{($TAA#-IDmMo{?O>-YpWew=;YK7gPXDTUf-mnwtqZi?4$%t zQe`m?>dC&w?t5&xHkgAgj$P>%m!d>GG&6obx7+*8Gxi-)#uxM2$YBThRQJYD7C%;F z9%mqM`^cr_Kgc&e#6;qYC$5)GsQ5!Y_}@ucxj4_j4^YVAK!3&jGvrL2o&Se8DAfKv zJ|uN3EpuRoAE$Un40+A!>QUCa#(>rO@-(#<-?r^5@ZrTdF1)N?(yw9#0ph_3Yk6y= zLUMgcZ*zRJGM?s+C(NU#6wT}K%(zx@9fXE;pDW!@HhXkeYT-xFv&fei{8sLzQq4-^ z$%G*q`RW3Oib$65RkKDl5$6{H<<@ZNLZsoi_alSSlnpLp0h)wp+eQ$+wFL65Th0iy zQ06>g)HZQGnsL1c2zYWoj@_`TF(kN90HvF#BEgBVlZZ6n4A<%-KT-Lbxhm!g_Jt!) zb4ttFH!YTiT8?59UB)c&lev&)xEWT*JOu@{dI5Whf_PmnF&jr2mitO<cL8{NO`Z`- zQ;){HU3+3|>09@p>xc7+spE)k<M_~IOM>gId6CL7dci|9jRWGgV3@aI0YfPgD7*R% zDp*h5!lc~SsIaHOb>%S50&ZXCj5C#dlSQr-Rh;B|D(}pe6<d*+gDNqN@LI)yqk69x zcF{ahAZUHGhg^$n7DmiX;b;BlMmsrAzBk`oeT9d`zF*W9WUN(n>i+mYCkpe76-xX5 z^SO%u?BIXae>i2KBL7zff9(MONATyG1~rpE^@D#E{A*Y2&w`(!B;^0UNA|0pUt1-A zXgY=-9r>kk@~iN#T=*Zt@+iLx|BV^{Rl~2W=^q-*p=BrZ?|<b`e^u~nq56jcPAEGM zRp9o2W$Uk^zb2c1h?YQe&woGq-%`(Cwfr@b{-FaJS4jYXzs1#G#sBIR|12Ix_9yXw Z`$!dec<Al|0Lai!Ff?>)QU3h){{ZXE^dA5K literal 0 HcmV?d00001 From 446d9aeef582c15660a0074fdb355eaa523ddb20 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Wed, 4 Jun 2025 20:05:11 +0900 Subject: [PATCH 61/62] =?UTF-8?q?=ED=95=98=EC=88=98=EC=9E=AC=EC=9D=B4?= =?UTF-8?q?=EC=9A=A9=20=EB=93=B1=EB=A1=9D=20=EC=97=85=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=8A=B8=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ruseFcltMng/fcltReg/pbnstReg/page.tsx | 28 ++- apps/wr/app/store/common/code/index.ts | 14 ++ apps/wr/app/store/common/searchCode/index.ts | 18 +- apps/wr/app/store/common/searchCode/type.tsx | 13 -- .../ruseFcltMng/fcltReg/pbnstReg/index.tsx | 119 +++++++----- .../ruseFcltMng/fcltReg/pbnstReg/type.tsx | 32 +++- apps/wr/components/lib/api/index.ts | 2 +- .../fcltReg/pbnstReg/buseReg/bugRegForm.tsx | 179 ++++++++++++++---- .../fcltReg/pbnstReg/mngReg/mngRegForm.tsx | 19 +- .../components/ui/searchInput/searchInput.tsx | 10 +- 10 files changed, 313 insertions(+), 121 deletions(-) diff --git a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx index f818a494f..86dce20d6 100644 --- a/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx +++ b/apps/wr/app/ruseFcltMng/fcltReg/pbnstReg/page.tsx @@ -28,6 +28,7 @@ import { z } from "zod"; import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal"; import { Toaster } from "react-hot-toast"; import { ToastFormUi } from "@/components/ui/toast/toastFromUi"; +import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg"; export default function PublicReuseFaciltyInsert() { const { @@ -38,6 +39,8 @@ export default function PublicReuseFaciltyInsert() { pbnstRegClick, getSwtrmtFcltNm, pbnstMngData, + pbnstRuseFcltUpdate, + pbnstRuseBizUpdate, } = useWrStore((state) => state); const { pubFacHeadList, pbnstHasuRes, pbnstRes } = pbnst; const [currentTab, setCurrentTab] = useState<string>("mng"); @@ -51,12 +54,35 @@ export default function PublicReuseFaciltyInsert() { const [bdstTable, setbdstTable] = useState<pubHasuType[]>(); const [selectBdst, setSelectBdst] = useState<customPbnst | null>(null); + useEffect(() => { if (!pbnst.isInit) { pubHasuInit("1", "11"); } }, [pbnst.isInit, pubHasuInit]); + + + const saveRuseData = async ()=>{ + const data = writeRgtrAndMdfr(pbnst.pbnstMngRegData) + let bizs =[] as fcBizType[] + data.forEach((fclt) =>{ + bizs = [ + ...bizs, + ...fclt.fcBizs + ] + }) + + + await pbnstRuseFcltUpdate(data) + console.log('bizs ', bizs) + + await pbnstRuseBizUpdate(bizs) + + console.log(' data ', data) + } + + useEffect(() => { if(code.sggCd.length){ if(searchFclts){ @@ -156,7 +182,7 @@ export default function PublicReuseFaciltyInsert() { <TabsTrigger className="!text-xl" value="buse"> 차수별정보 </TabsTrigger> - <Button size={"sm"} className="!justify-end"> + <Button size={"sm"} onClick={ saveRuseData}className="!justify-end"> 저장 </Button> </TabsList> diff --git a/apps/wr/app/store/common/code/index.ts b/apps/wr/app/store/common/code/index.ts index b02918872..3f6da6dec 100644 --- a/apps/wr/app/store/common/code/index.ts +++ b/apps/wr/app/store/common/code/index.ts @@ -91,6 +91,18 @@ const chBuCd = [ ] + +const dmdUszCd = [ + { val: "조경용수", text: "조경용수" }, + { val: "청소화장실용수", text: "청소화장실용수" }, + { val: "농업용수", text: "농업용수" }, + { val: "공업용수", text: "공업용수" }, + { val: "친수용수", text: "친수용수" }, + { val: "기타", text: "기타" }, + +] + + const pplQulity = [ { val: "도복장강관", text: "도복장강관" }, { val: "PE관", text: "PE관" }, @@ -136,6 +148,7 @@ export type comCodeState = { yn: SelectDataType[]; pplQulity: SelectDataType[]; pplLenght: SelectDataType[]; + dmdUszCd:SelectDataType[] buildingType: { RST:string, RNB:string, @@ -277,6 +290,7 @@ export const comCodeStateExport: comCodeState = { pplQulity:pplQulity, pplLenght:pplLenght, yn: yn, + dmdUszCd:dmdUszCd, buildingType:buildingType, }, }; diff --git a/apps/wr/app/store/common/searchCode/index.ts b/apps/wr/app/store/common/searchCode/index.ts index d87e0836c..c1b46a901 100644 --- a/apps/wr/app/store/common/searchCode/index.ts +++ b/apps/wr/app/store/common/searchCode/index.ts @@ -1,13 +1,14 @@ import { fetchType, getFetch, postFectch } from "@/components/lib/api"; import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type"; -import type { DemandCompType } from "./type"; +import type { DemandCompType } from "@common/business_components/ui"; export type comFcltState = { searchFclts: pubHasuType; demandCompList: DemandCompType[]; }; export type comFcltActions = { getSwtrmtFcltNm: (searchNm: string) => void; - getDemandCompList :(searchNm: string) => void + getDemandCompList :(searchNm: string,cnt:number) => void + regDemandCompany:(data:DemandCompType ) => void }; export const searchActions: (set: any) => comFcltActions = (set: any) => { @@ -30,15 +31,22 @@ export const searchActions: (set: any) => comFcltActions = (set: any) => { searchFclts: fcltNmCd, })); }, - getDemandCompList: async (searchNm: string) => { + getDemandCompList: async (searchNm: string ,cnt:number) => { const coList = await getFetch( fetchType.WR, - `reuseFc/request/${searchNm}/{3}` + `/reuseFc/request/${searchNm}/${cnt}` ); return set((state: comFcltState) => ({ ...state, demandCompList: coList, })); - }, + },regDemandCompany: async (data:DemandCompType)=>{ + + try{ + const response = await postFectch('/reuseFc/request',data,fetchType.WR ) + }catch(err){ + console.log(err) + } + } }; }; diff --git a/apps/wr/app/store/common/searchCode/type.tsx b/apps/wr/app/store/common/searchCode/type.tsx index a8cfb2e69..e69de29bb 100644 --- a/apps/wr/app/store/common/searchCode/type.tsx +++ b/apps/wr/app/store/common/searchCode/type.tsx @@ -1,13 +0,0 @@ - -export type DemandCompType = { - dmdInfoPk : string | ''; - bzmnNo : string | ''; - dmdCoNm : string | ''; - daddr : string | ''; - telno : string | ''; - rgtr : string | ''; - useUsgCd : string | ''; - ctpvCd : string | ''; - sggCd : string | ''; - - } \ No newline at end of file diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx index 73bdf9665..22980aa16 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/index.tsx @@ -5,6 +5,7 @@ import { fetchType, getFetch, postFectch, + putFectch, } from "@/components/lib/api"; import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; import { @@ -66,9 +67,9 @@ type pubFacActions = { pbnstMngData: (data: customPbnst[]) => void; pbnstBizData(data: fcBizType): void; getBizCycle: (pbnstObj: customPbnst) => void; - getDmdCompany: (txt: string) => void; getpbnstInsertIndex: (data: pbnstInsertIndex) => void; - searchDmdColist:(txt:string) =>void + pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void; + pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void; }; export type pubFacType = pubFacState & pubFacActions; @@ -123,30 +124,40 @@ const initFetch = async (ruseFcltPk: string | undefined) => { return pbnstRes; }; -const writeRgtrAndMdfr = (data: customPbnst) => { - data.rgtr = TEST_UUID; - data.mdfr = TEST_UUID; - data.fcBizs = data.fcBizs.map((item) => { +export const writeRgtrAndMdfr = (data: customPbnst[]) => { + + data.forEach((pbnst) => { + pbnst.rgtr = TEST_UUID; + pbnst.mdfr = TEST_UUID; + + pbnst.fcBizs = pbnst.fcBizs?.map((item) => { item.rgtr = TEST_UUID; item.mdfr = TEST_UUID; - item.fcOrgwts = item.fcOrgwts?.map((item) => { - item.mdfr = TEST_UUID; - item.rgtr = TEST_UUID; - return item; + item.fcOrgwts = item.fcOrgwts?.map((orgwt) => { + orgwt.mdfr = TEST_UUID; + orgwt.rgtr = TEST_UUID; + return orgwt; + }); + + item.fcDemands = item.fcDemands?.map((dmd) => { + dmd.mdfr = TEST_UUID; + dmd.rgtr = TEST_UUID; + return dmd; }); - return item; }); - data.fcOpers = data.fcOpers.map((item) => { - item.rgtr = TEST_UUID; - item.mdfr = TEST_UUID; - return item; + pbnst.fcOpers = pbnst.fcOpers.map((oper) => { + oper.rgtr = TEST_UUID; + oper.mdfr = TEST_UUID; + return oper; }); - data.fcFiles = data.fcFiles.map((item) => { - item.rgtr = TEST_UUID; - item.mdfr = TEST_UUID; - return item; + pbnst.fcFiles = pbnst.fcFiles.map((file) => { + file.rgtr = TEST_UUID; + file.mdfr = TEST_UUID; + return file; }); +}); + return data; @@ -207,7 +218,7 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { const response = await postFectch( `/reuseFc/pubFc`, - JSON.stringify( writeRgtrAndMdfr(pbnstRes)) + JSON.stringify( writeRgtrAndMdfr([pbnstRes])) ); return set((state: pubFacState) => ({ @@ -221,7 +232,39 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (error) { console.error("Error updating pbnst:", error); } - }, + },pbnstRuseFcltUpdate : async(ruseRes:customPbnst[])=>{ + try { + + const response = await putFectch( + `/reuseFc/pubFc`, + ruseRes + ); + + } catch (error) { + console.error("Error pbnstRuseFcltUpdate:", error); + } + } ,pbnstRuseBizUpdate : async(ruseRes:fcBizType[])=>{ + try { + + console.log('ruseRes ', ruseRes) + const response = await putFectch( + `/reuseFc/pubFcBiz`, + ruseRes + ); + const pbnstRes = await hasuListFetch("11", "11"); + + return set((state: pubFacState) => ({ + ...state, + pbnst: { + ...state.pbnst, + pbnstRes: pbnstRes, + isInit: false, + }, + })); + } catch (error) { + console.error("Error pbnstRuseFcltUpdate:", error); + } + } , getBizCycle: async (pbnstObj: customPbnst) => { const pbnstBizCycle = pbnstObj.fcBizs.map((item) => { return { @@ -303,23 +346,15 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { if (bizIdx >= 0) { regData.fcBizs[bizIdx] = data; + const pbnstData = state.pbnst.pbnstMngRegData + state.pbnst.pbnstMngRegData= [...pbnstData] + } } } return state; }); }, - getDmdCompany: async (txt: string) => { - const company = await getFetch(fetchType.WR, `/reuseFc/request/${txt}/3`); - - return set((state: pubFacState) => ({ - ...state, - pbnst: { - ...state.pbnst, - isInit: false, - }, - })); - }, getpbnstInsertIndex: async (data: pbnstInsertIndex) => { return set((state: pubFacState) => { state.pbnst.pbnsUpdateIndex = data; @@ -339,24 +374,6 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => { } catch (e) { console.log(e); } - },searchDmdColist:async (txt:string)=>{ - - try{ - console.log(' txt ', txt) - const coList = await getFetch(fetchType.WR, `reuseFc/request/${txt}/{3}`); - return set((state: pubFacState) => ({ - ...state, - pbnst: { - ...state.pbnst, - dmdCoList: coList, - isInit: false, - }, - })); - }catch(e){ - console.log(e) - - } - - } + }, }; }; diff --git a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx index f3f695725..01aac072a 100644 --- a/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx +++ b/apps/wr/app/store/ruseFcltMng/fcltReg/pbnstReg/type.tsx @@ -44,6 +44,25 @@ export type ruseFcltType = { splyExtraCpct: number; }; +export type PbnstDemandComType = { + dmdInfoPk : string | ''; + bzmnNo : string | ''; + dmdCoNm : string | ''; + daddr : string | ''; + telno : string | ''; + rgtr : string | ''; + useUsgCd : string | ''; + ctpvCd : string | ''; + sggCd : string | ''; + dmdAplyPswd: string | ''; + splyCpct: number | 0; + splyFmYn:string|'Y' + dmdInfoFk:string|'' + +} + + + export type fcBizType = z.infer<typeof fcBizSchema>; export type fcOrgwtType = z.infer<typeof fcOrgwtSchema>; export type ppInstlType = z.infer<typeof pplInstlSchema>; @@ -53,7 +72,7 @@ export type fcFileType = z.infer<typeof fcFileSchema>; const pplInstlSchema = z.object({ - ruseFcltBizFk: z.string(), + ruseFcltBizFk: z.number(), choose:z.boolean().default(false), pdmt: z.string().default(''), ppMqlt: z.string().default(""), @@ -72,7 +91,7 @@ const fcFileSchema = z.object({ const fcOperSchema = z.object({ pbnstRuseFcltOperInfoPk: z.number().nullish(), - pbnstRuseFcltFk: z.number().nullish(), + pbnstRuseFcltFk: z.string().nullish(), operMthd: z.string(), rprtvBzenty: z.string(), bgngDt: z.date().default(new Date()), @@ -121,13 +140,18 @@ export type pubHasuType = z.infer<typeof pubHasuZod>; const dmdColist = z.object({ + dmdInfoFk:z.string().default(''), dmdCoNm: z.string().default(''), daddr: z.string(), useUsgCd: z.string().default(""), splyBgngDay: z.date().default(new Date()), splyEndDay: z.date().default(new Date()), - splyCpct: z.string().default(""), - splyFmYn: z.number().default(0), + splyCpct: z.number().default(0), + splyFmYn: z.string().default('Y'), + rgtr: z.string().nullish(), + mdfr: z.string().nullish(), + pbnstRuseFcltBizPk: z.number(), + pbnstRuseFcltFk: z.string(), //telno:z.string().default('') }); diff --git a/apps/wr/components/lib/api/index.ts b/apps/wr/components/lib/api/index.ts index e853428f5..ad0ab4729 100644 --- a/apps/wr/components/lib/api/index.ts +++ b/apps/wr/components/lib/api/index.ts @@ -22,7 +22,7 @@ export const getFetch = async (type: string, url: string) => { }); if (!response.ok) { - throw new Error(`오류 발생: ${response.status}`); + console.log(`오류 발생: ${response.status}`); } const contentType = response.headers.get("content-type") ?? ""; diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx index 4ef27037b..04e17867c 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/buseReg/bugRegForm.tsx @@ -13,6 +13,7 @@ import { fcBizSchema, type customPbnst, type fcBizType, + type PbnstDemandComType, type ppInstlType, } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; import { selectClass } from "@/app/store/ruseFcltMng/fcltReg/rainReg"; @@ -31,16 +32,22 @@ import { type SelectDataType, } from "@common/business_components/ui"; import { Form, FormField } from "@common/business_components/ui/form"; -import { Button, DatePicker, Input, Label } from "@common/components"; +import { + Button, + DataTable, + DatePicker, + Input, + Label, +} from "@common/components"; import { zodResolver } from "@hookform/resolvers/zod"; import { useEffect, useRef, useState } from "react"; import { useFieldArray, useForm } from "react-hook-form"; import MngRegFormDetail from "../mngReg/mngRegFormDetail/mngRegFormDetail"; -import { - safeDate, -} from "@/components/lib/func/commom"; +import { safeDate } from "@/components/lib/func/commom"; import SearchInputText from "@/components/ui/searchInput/searchInput"; -import type { DemandCompType } from "@/app/store/common/searchCode/type"; +import SdmInsertForm, { + type DemandCompType, +} from "@common/business_components/ui/sdmInsertForm"; export function PbnstBuseForm({ formType, @@ -53,11 +60,13 @@ export function PbnstBuseForm({ const { code, pbnst, + demandCompList, pbnstBizData, getpbnstInsertIndex, appendRuseFclt, getBizCycle, - searchDmdColist, + getDemandCompList, + regDemandCompany, } = useWrStore((state) => state); const { pbnstBizCycle, pbnstRes } = pbnst; const [bizCycle, setBizCycle] = useState("1"); @@ -66,7 +75,10 @@ export function PbnstBuseForm({ const [ppiYn, setPpiYn] = useState("Y"); const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false); const [sumCpct, setSumCpct] = useState<number>(0); - const [searchDmdCo, setSeachDmdCo] = useState<DemandCompType[]>(); + const [isDmdModal, setIsDmdModal] = useState<{ + isMoal: boolean; + data: DemandCompType; + }>({ isMoal: false, data: {} as DemandCompType }); const form = useForm<fcBizType>({ resolver: zodResolver(fcBizSchema), @@ -143,6 +155,9 @@ export function PbnstBuseForm({ // 등록할때 신규 값을 계속 가지고 있으려고 useEffect(() => { + const formData = form.watch(); + + formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사 if (formType === "reg") { if ( firstBizData && @@ -156,15 +171,16 @@ export function PbnstBuseForm({ ); form.setValue("cycl", firstBizData[0].cycl); } - const formData = form.watch(); - formData.pplInstls = ref.current ? [...ref.current] : []; // ← form 내부 상태 기준으로 복사 pbnstBizData(formData as fcBizType); - } - }, [firstBizData, form.formState, formType]); + }else if(formType === "update"){ + + console.log('formdata ', formData) + pbnstBizData(formData as fcBizType); + + + } + }, [firstBizData, form.formState, formType, pbnst.pbnstRes]); - useEffect(() => { - console.log("searchDmdCo ", searchDmdCo); - }, [searchDmdCo]); useEffect(() => { if (ppiYn === "N") { @@ -178,7 +194,7 @@ export function PbnstBuseForm({ const plusHist = () => { const regData = { - ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? "", + ruseFcltBizFk: ref.current?.[0]?.ruseFcltBizFk ?? form.getValues('pbnstRuseFcltBizPk'), choose: false, ppMqlt: "", pdmt: "", @@ -195,15 +211,16 @@ export function PbnstBuseForm({ }; const plusArray = () => { - console.log("qweqwe "); appendDemand({ dmdCoNm: "", daddr: "", useUsgCd: "", splyBgngDay: new Date(), splyEndDay: new Date(), - splyCpct: "", - splyFmYn: 0, + splyCpct: 0, + splyFmYn: "Y", + pbnstRuseFcltBizPk: form.getValues('pbnstRuseFcltBizPk'), + pbnstRuseFcltFk: form.getValues('pbnstRuseFcltFk')??'', //telno: "", }); }; @@ -401,12 +418,27 @@ export function PbnstBuseForm({ moClass="grid grid-cols-12 gap-4" sonClass="col-span-4" /> - <div> + <div key={"hasu"}> <h1 className={formH1Class}>{"하수처리수 재이용수 수요처"}</h1> <div className="text-right mb-3"> <Button type="button" - onClick={plusArray} + onClick={() => { + plusArray(); + }} + size={commonButonSize} + className="mt-6 mr-3" + > + 수요항목 추가 + </Button> + <Button + type="button" + onClick={() => { + setIsDmdModal({ + isMoal: true, + data: {} as DemandCompType, + }); + }} size={commonButonSize} className="mt-6" > @@ -414,8 +446,11 @@ export function PbnstBuseForm({ </Button> </div> {fcDemands.map((field, index) => ( - <div className="grid grid-cols-12 gap-4 mt-3"> - <div className="col-span-4"> + <div + key={index + "loot"} + className="grid grid-cols-12 gap-4 mt-3" + > + <div key={index + "keySon1"} className="col-span-4"> <FormField control={form.control} name={`fcDemands.${index}.dmdCoNm`} @@ -424,16 +459,60 @@ export function PbnstBuseForm({ <SearchInputText label={undefined} initValue={f.value} - setValue={f.onChange} - setRtnData={(valList : DemandCompType[]) =>{ - setSeachDmdCo(valList) + setValue={(val) => { + f.onChange(val); + + if (val) getDemandCompList(val, 3); + }} + setRtnData={(valList: PbnstDemandComType[]) => { + console.log('valList[0] ', index) + if ( + valList.length > 0 && + valList['0'] + ) { + form.setValue( + `fcDemands.${index}.pbnstRuseFcltBizPk`, + form.getValues('pbnstRuseFcltBizPk') + ); + form.setValue( + `fcDemands.${index}.pbnstRuseFcltFk`, + form.getValues('pbnstRuseFcltFk')??'' + + ); + form.setValue( + `fcDemands.${index}.dmdCoNm`, + valList['0'].dmdCoNm + ); + form.setValue( + `fcDemands.${index}.daddr`, + valList['0'].daddr + ); + form.setValue( + `fcDemands.${index}.useUsgCd`, + valList['0'].useUsgCd + ); + form.setValue( + `fcDemands.${index}.splyCpct`, + valList['0'].splyCpct + ); + form.setValue( + `fcDemands.${index}.splyFmYn`, + valList['0'].splyFmYn ?? "Y" + ); + + form.setValue( + `fcDemands.${index}.dmdInfoPk`, + valList['0'].dmdInfoPk ?? "Y" + ); + } + }} ></SearchInputText> </FormUi> )} /> </div> - <div className="col-span-4"> + <div key={index + "keySon2"} className="col-span-4"> <FormField control={form.control} name={`fcDemands.${index}.daddr`} @@ -442,6 +521,7 @@ export function PbnstBuseForm({ <Input placeholder="-" type="text" + readOnly onChange={(e) => f.onChange(e.target.value)} value={f.value} className={selectClass} @@ -450,24 +530,27 @@ export function PbnstBuseForm({ )} /> </div> - <div className="col-span-4"> + <div key={index + "keySon3"} className="col-span-4"> <FormField control={form.control} name={`fcDemands.${index}.useUsgCd`} render={({ field: f }) => ( <FormUi label="사용용도"> - <Input - placeholder="-" - type="text" - onChange={(e) => f.onChange(e.target.value)} + <SelectBox + label={""} + selectClass={""} + className="w-full" + selectArray={code.dmdUszCd} + onSelectValue={(val: string | number) => + f.onChange(val) + } value={f.value} - className={selectClass} /> </FormUi> )} /> </div> - <div className="col-span-3"> + <div key={index + "keySon4"} className="col-span-3"> <FormField control={form.control} name={`fcDemands.${index}.splyBgngDay`} @@ -485,7 +568,7 @@ export function PbnstBuseForm({ )} /> </div> - <div className="col-span-3"> + <div key={index + "keySon5"} className="col-span-3"> <FormField control={form.control} name={`fcDemands.${index}.splyEndDay`} @@ -503,7 +586,7 @@ export function PbnstBuseForm({ )} /> </div> - <div className="col-span-3"> + <div key={index + "keySon6"} className="col-span-3"> <FormField control={form.control} name={`fcDemands.${index}.splyCpct`} @@ -521,7 +604,7 @@ export function PbnstBuseForm({ )} /> </div> - <div className="col-span-3"> + <div key={index + "keySon7"} className="col-span-3"> <FormField control={form.control} name={`fcDemands.${index}.splyFmYn`} @@ -563,6 +646,30 @@ export function PbnstBuseForm({ ></FcOrgwtsRegModal> } ></UiModal> + + <UiModal + bodyClass={"w-[40vw] max-w-none h-[90vh]"} + open={isDmdModal.isMoal} + onOpenChange={() => { + setIsDmdModal({ isMoal: false, data: {} as DemandCompType }); + }} + body={ + <SdmInsertForm + selectSidoData={code.cityCd} + selectSigunData={code.sggCd} + dataList={demandCompList} + rtnValue={(searchText: string, pageCnt: number) => { + getDemandCompList(searchText, pageCnt); + }} + rtnInputData={(data) => { + console.log(" rtn data ", data); + regDemandCompany(data as DemandCompType); + setIsDmdModal({ isMoal: false, data: data as DemandCompType }); + }} + bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"} + ></SdmInsertForm> + } + ></UiModal> </div> </> ); diff --git a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx index c809b3653..3f0776a4e 100644 --- a/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx +++ b/apps/wr/components/ui/form/fcltReg/pbnstReg/mngReg/mngRegForm.tsx @@ -94,8 +94,10 @@ export function PbnstMngForm({ const plusHist = () => { + const currentTableDataFromRef = ref.current ? [...ref.current] : []; const regData = { choose: false, + pbnstRuseFcltFk:form.getValues('pbnstRuseFcltPk')??"", rgtr: "", mdfr: "", operMthd: "", @@ -103,7 +105,6 @@ export function PbnstMngForm({ bgngDt: new Date(), endDt: new Date(), }; - const currentTableDataFromRef = ref.current ? [...ref.current] : []; const newDataForRHF = [...currentTableDataFromRef, regData]; form.setValue("fcOpers", newDataForRHF, { shouldValidate: true, // 필요하다면 유효성 검사 실행 @@ -251,13 +252,21 @@ export function PbnstMngForm({ //신규 등록시 입력할때 데이터 넣기 useEffect(() => { + const formData = form.watch(); + formData.fcOpers = ref.current ? [...ref.current] : []; + formData.fcFiles = regFileList ? [...regFileList] : []; if (formType === "reg") { - const formData = form.watch(); - formData.fcOpers = ref.current ? [...ref.current] : []; - formData.fcFiles = regFileList ? [...regFileList] : []; pbnstMngData([formData] as customPbnst[]); + } else if (formType === "update"){ + const updateRes = pbnst.pbnstRes?.map((item)=>{ + if(item.pbnstRuseFcltPk === item.pbnstRuseFcltPk){ + item=formData as customPbnst + } + return item + }) + pbnstMngData(updateRes as customPbnst[]); } - }, [form.formState, regFileList, formType]); + }, [form.formState, regFileList, formType, pbnst.pbnstRes]); useEffect(() => { pbnstMngData(pbnst.pbnstMngRegData); diff --git a/apps/wr/components/ui/searchInput/searchInput.tsx b/apps/wr/components/ui/searchInput/searchInput.tsx index 3b645a467..413c3593a 100644 --- a/apps/wr/components/ui/searchInput/searchInput.tsx +++ b/apps/wr/components/ui/searchInput/searchInput.tsx @@ -1,19 +1,20 @@ import { useWrStore } from '@/app/store'; -import type { DemandCompType } from '@/app/store/common/searchCode/type'; +import type { PbnstDemandComType } from '@/app/store/ruseFcltMng/fcltReg/pbnstReg/type'; +import type { DemandCompType } from '@common/business_components/ui'; import React, { useCallback, useEffect, useRef, useState } from 'react'; type thisProps = { label: string | undefined; initValue: string | undefined; setValue : (dmdCoNm?: string) => void; - setRtnData : (rtnData: DemandCompType[]) => void; + setRtnData : (rtnData: PbnstDemandComType[]) => void; } export default function SearchInputText({label=undefined, initValue=undefined, setValue=()=>{}, setRtnData=()=>{}} :thisProps) { - const { getDemandCompList, demandCompList } = useWrStore((state) => state); + const { demandCompList } = useWrStore((state) => state); const [isOpen, setIsOpen] = useState(false); @@ -25,11 +26,10 @@ export default function SearchInputText({label=undefined, initValue=undefined, s setValue(value); if (value) { setIsOpen(true); - getDemandCompList(value); } else { setIsOpen(false); } - }, [getDemandCompList, setValue]); + }, [ setValue]); const handleSuggestionClick = useCallback((dmdCoNm: string) => { setTextValue(dmdCoNm); From 8a2439b4ba53ab5e954980d633b74f15965f1d96 Mon Sep 17 00:00:00 2001 From: leedj312 <dlehd467@gmail.com> Date: Wed, 4 Jun 2025 20:06:47 +0900 Subject: [PATCH 62/62] =?UTF-8?q?=EC=88=98=EC=9A=94=EC=B2=98=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EB=B0=94=EB=94=94=ED=81=B4=EB=9E=98=EC=8A=A4=20?= =?UTF-8?q?=EB=B0=8F=20=ED=8C=A8=EC=8A=A4=EC=9B=8C=EB=93=9C=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/ui/sdmInsertForm/index.tsx | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx index 723d87cf6..4b4a94648 100644 --- a/packages/common/business_components/src/ui/sdmInsertForm/index.tsx +++ b/packages/common/business_components/src/ui/sdmInsertForm/index.tsx @@ -2,7 +2,6 @@ /* import { useDmStore } from "@/app/store"; */ import { SdmRegForm } from "./form"; -import type { DemandCompType } from "../../../../../../apps/dm/app/store/sdmMng"; import { Button } from "@common/components/ui"; import { zodResolver } from "@hookform/resolvers/zod"; /* import { useRouter } from "next/navigation"; */ @@ -13,12 +12,28 @@ import { toast, Toaster } from "sonner"; import * as z from "zod"; import type { SelectDataType } from "../search_input_select"; + +export type DemandCompType = { + dmdInfoPk : string | ''; + bzmnNo : string | ''; + dmdCoNm : string | ''; + daddr : string | ''; + telno : string | ''; + rgtr : string | ''; + useUsgCd : string | ''; + ctpvCd : string | ''; + sggCd : string | ''; + dmdAplyPswd: string | ''; +} + + type thisProps = { selectSidoData: SelectDataType[]; selectSigunData: SelectDataType[]; dataList: DemandCompType[]; rtnValue: (searchText: string, pageCnt: number) => void; rtnInputData: (data: DemandCompType) => void; + bodyClassNm?: string; } const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean) => z.object({ @@ -102,7 +117,7 @@ const defaultValues: FormData = { }, [insertSdmData]); */ -export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData}: thisProps) { +export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData,bodyClassNm}: thisProps) { /* const { insertSdmData } = useDmStore((state) => state); const router = useRouter(); */ @@ -177,7 +192,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList </h1> </div> - <div className="max-w-3xl mx-auto bg-white rounded-lg shadow-md p-6"> + <div className= {bodyClassNm?bodyClassNm:"!max-w-3xl mx-auto bg-white rounded-lg shadow-md p-6"}> <FormProvider {...form}> <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6"> <SdmRegForm