From cf6222011f32da9cf3a76162b0fa0707a35176cc Mon Sep 17 00:00:00 2001 From: jyha00 Date: Thu, 29 May 2025 14:44:26 +0900 Subject: [PATCH] =?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[] }) {

재이용 원수취수 현황

+
+
- + type="button" + size={commonButonSize} + className="!text-xl" + onClick={plusHist} + > + 추가등록 + +
@@ -269,7 +272,9 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {

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

+
+
setIsFcOrgwts(open)} - bodyClass={"w-[60vw] max-w-none h-[60vh]"} + bodyClass={"w-[50vw] max-w-none h-[60vh]"} body={} >
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(); - const [isFcOrgwtsData, setIsFcOrgwtsData] = useState(false); - const [pkTable, setPkTable] = useState(); - const rightRef = useRef([] as fcOrgwtType[]); - const leftRef = useRef([] as fcOrgwtType[]); - const [rightData, setRightData] = useState(); + const [bdstTable, setbdstTable] = useState(); + const rightRef = useRef([] as pubHasuType[]); + const leftRef = useRef([] as pubHasuType[]); + const [rightData, setRightData] = useState(); + const [inputVal, setInputVal] = useState(""); + + 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 ( <>
-
+
- <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>