From 6debee6b5729b5d2247138637c03e4808e30e754 Mon Sep 17 00:00:00 2001 From: truthwing Date: Tue, 22 Apr 2025 17:19:34 +0900 Subject: [PATCH] =?UTF-8?q?search=20base=20form=20=EC=B6=94=EA=B0=80(?= =?UTF-8?q?=EC=82=AC=EC=9A=A9=EB=B2=95=EC=9D=80=20=EB=A9=94=EC=8B=A0?= =?UTF-8?q?=EC=A0=80=EB=A1=9C=20=EC=9A=B0=EC=84=A0=20=EC=A0=84=EB=8B=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business_components/src/ui/index.ts | 19 +-- .../src/ui/search_base_form/index.tsx | 134 ++++++++++++++++++ .../src/ui/search_form_left/index.tsx | 4 +- 3 files changed, 146 insertions(+), 11 deletions(-) create mode 100644 packages/common/business_components/src/ui/search_base_form/index.tsx diff --git a/packages/common/business_components/src/ui/index.ts b/packages/common/business_components/src/ui/index.ts index e2273e8e5..e591be5b5 100644 --- a/packages/common/business_components/src/ui/index.ts +++ b/packages/common/business_components/src/ui/index.ts @@ -1,20 +1,21 @@ export * from "./chart"; export * from "./date_picker"; +export * from "./dialog_ui"; +export * from "./excel_download"; export * from "./file-upload"; export * from "./form"; export * from "./form_ui"; +export * from "./list_div"; +export * from "./main_content_div"; export * from "./scroll"; +export * from "./search_base_form"; export * from "./search_form"; +export * from "./search_form_left"; +export * from "./search_form_right"; export * from "./search_input"; export * from "./search_input_select"; export * from "./select"; -export * from "./table"; -export * from "./main_content_div"; -export * from "./title"; -export * from "./search_form_left"; -export * from "./search_form_right"; -export * from "./table_div"; -export * from "./list_div"; export * from "./tab"; -export * from "./dialog_ui"; -export * from "./excel_download"; \ No newline at end of file +export * from "./table"; +export * from "./table_div"; +export * from "./title"; 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 new file mode 100644 index 000000000..da21761ee --- /dev/null +++ b/packages/common/business_components/src/ui/search_base_form/index.tsx @@ -0,0 +1,134 @@ +import { Button } from "@common/components/ui"; +import { useCallback, useEffect, useState } from "react"; +import { SearchFormLeft, type EnvPartSelectDataType } from "../search_form_left"; +import { SearchFormRight } from "../search_form_right"; +import type { SelectDataType } from "../search_input_select"; +type SearchBaseType = { + leftChildren:React.ReactNode; + rightChildren:React.ReactNode; + selectSidoData?: SelectDataType[] | []; + selectSigunData?: SelectDataType[] | []; + selectRegionData?: SelectDataType[] | []; + selectUnitWaterShedData?: SelectDataType[] | []; + selectMiddleRegionData?: SelectDataType[] | []; + selectEnvPartData?: EnvPartSelectDataType[] | []; + queryClick:(returnType:ReturnType) => void; + excelClick:(returnType:ReturnType) => void; + btnClass:string; +} +export type ReturnType = { + partValue: string; + sidoValue: string; + sigunValue: string; + regionValue: string; + unitWaterShedValue: string; + middleRegionValue: string; + envPartValue: string; + envPartSidoValue: string; + envPartSigunValue: string; +} + + +function SearchBaseForm ({ + leftChildren, + rightChildren, + selectSidoData, + selectSigunData, + selectRegionData, + selectUnitWaterShedData, + selectMiddleRegionData, + selectEnvPartData, + btnClass, + queryClick, + }: SearchBaseType) { + const [partValue, setPartValue] = useState("0"); + const [sidoValue, setSidoValue] = useState("0"); + const [sigunValue, setSigunValue] = useState("0"); + const [regionValue, setRegionValue] = useState("0"); + const [untitWaterShedValue, setUntitWaterShedValue] = useState("0"); + const [middleRegionValue, setMiddleRegionValue] = useState("0"); + const [envPartValue, setEnvPartValue] = useState("0"); + const [envPartSidoValue, setEnvPartSidoValue] = useState("0"); + const [envPartSigunValue, setEnvPartSigunValue] = useState("0"); + const [resetTrigger, setResetTrigger] = useState(false); + const queryVal = () => { + console.log("조회버튼 클릭"); + queryClick({ + partValue: partValue, + sidoValue: sidoValue, + sigunValue: sigunValue, + regionValue: regionValue, + unitWaterShedValue: untitWaterShedValue, + middleRegionValue: middleRegionValue, + envPartValue: envPartValue, + envPartSidoValue: envPartSidoValue, + envPartSigunValue: envPartSigunValue, + }); + } + const initVal = useCallback(() => { + setResetTrigger(true); + }, [setResetTrigger]); + useEffect(() => { + if (resetTrigger) { + setResetTrigger(false); + } + }, [resetTrigger]); + const excelDownload = useCallback(() => { + console.log("엑셀다운로드 클릭"); + console.log(partValue, sidoValue, sigunValue, regionValue, untitWaterShedValue, middleRegionValue, envPartValue, envPartSidoValue, envPartSigunValue); + }, [partValue, sidoValue, sigunValue, regionValue, untitWaterShedValue, middleRegionValue, envPartValue, envPartSidoValue, envPartSigunValue]); + // useEffect(() => { + // if (ref && ref.current) { + // ref.current.partValue = partValue; + // ref.current.sidoValue = sidoValue; + // ref.current.sigunValue = sigunValue; + // ref.current.regionValue = regionValue; + // ref.current.unitWaterShedValue = untitWaterShedValue; + // ref.current.middleRegionValue = middleRegionValue; + // ref.current.envPartValue = envPartValue; + // ref.current.envPartSidoValue = envPartSidoValue; + // ref.current.envPartSigunValue = envPartSigunValue; + // } + // }, [partValue, sidoValue, sigunValue, regionValue, untitWaterShedValue, middleRegionValue, envPartValue, envPartSidoValue, envPartSigunValue]); + return ( +
+ + {leftChildren} + + + +
+ + +
+ {rightChildren} +
+
+ ) + } + + export { SearchBaseForm }; + \ No newline at end of file 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 248e8f625..fbd56a68f 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 @@ -41,7 +41,7 @@ type SearchFormLeftProps = { resetTrigger?: boolean; } -type EnvPartSelectDataType = SelectDataType & { +export type EnvPartSelectDataType = SelectDataType & { adstDliStrCd: string, } @@ -315,4 +315,4 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel ) } -export { SearchFormLeft }; \ No newline at end of file +export { SearchFormLeft };