원수취수 작업 완료

This commit is contained in:
jyha00
2025-05-28 21:07:01 +09:00
parent 055091d64d
commit 89893fca98
4 changed files with 90 additions and 40 deletions
@@ -52,6 +52,7 @@ export const pbnstOrgwtHeadListRxport: TableUpperProps[] = [
{ id: "dtlPstnExpln", title: "상세위치 설명", }, { id: "dtlPstnExpln", title: "상세위치 설명", },
]; ];
export const fcOrgwtsHeadListExport: TableUpperProps[] = [ export const fcOrgwtsHeadListExport: TableUpperProps[] = [
{ id: "choose", title: "선택", type: "checkbox" },
{ id: "sido", title: "시도" }, { id: "sido", title: "시도" },
{ id: "gugun", title: "시군구" }, { id: "gugun", title: "시군구" },
{ id: "bscFctNm", title: "시설명" }, { id: "bscFctNm", title: "시설명" },
@@ -185,6 +185,7 @@ export const fcBizSchema = z.object({
}); });
export const pbnstRegZod = z.object({ export const pbnstRegZod = z.object({
choose: z.boolean().default(false),
pbnstRuseFcltPk: z.number().default(0), pbnstRuseFcltPk: z.number().default(0),
swtrmtFcltFk: z.string().default(""), swtrmtFcltFk: z.string().default(""),
ruseUtztnFcltNm: z.string().default(""), ruseUtztnFcltNm: z.string().default(""),
@@ -1,13 +1,16 @@
"use client"; "use client";
import { useWrStore } from "@/app/store"; import { useWrStore } from "@/app/store";
import type { customPbnst, fcBizType, fcOrgwtType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type"; 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 { tableData } from "@/components/lib/func/commom";
import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable";
import { Title, UiTable } from "@common/business_components/ui"; import { Title, UiTable } from "@common/business_components/ui";
import { Label } from "@common/business_components/ui/form/lib/label"; import { Label } from "@common/business_components/ui/form/lib/label";
import { Button } from "@common/business_components/ui/table/lib/button"; import { Button } from "@common/business_components/ui/table/lib/button";
import { Input } from "@common/components/ui"; import { Input } from "@common/components/ui";
import { ArrowLeft, ArrowRight } from "lucide-react"; 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[] }) { export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) {
const { code, pbnst } = useWrStore((state) => state); const { code, pbnst } = useWrStore((state) => state);
@@ -15,12 +18,12 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) {
const [bdstTable, setbdstTable] = useState<customPbnst[]>(); const [bdstTable, setbdstTable] = useState<customPbnst[]>();
const [isFcOrgwtsData, setIsFcOrgwtsData] = useState<boolean>(false); const [isFcOrgwtsData, setIsFcOrgwtsData] = useState<boolean>(false);
const [pkTable, setPkTable] = useState<customPbnst[]>(); 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(() => { useEffect(() => {
console.log("isFcOrgwtsData", isFcOrgwtsData); // console.log("머지", pbnstHasuRes);
}, [isFcOrgwtsData]);
useEffect(() => {
// console.log("어휴", pbnstHasuRes);
if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) { if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) {
setbdstTable(tableData(pbnstHasuRes, { code })); setbdstTable(tableData(pbnstHasuRes, { code }));
} }
@@ -29,62 +32,105 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) {
useEffect(() => { useEffect(() => {
if (!data) return; if (!data) return;
const findPk = data.map(element => { 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; return pk;
}); });
setPkTable(findPk); setPkTable(findPk);
}, [data]); }, [data]);
useEffect(()=>{
})
return ( return (
<> <>
<div className="flex flex-col h-full"> <div className="flex flex-col h-full">
<div> <div>
<Title title={"취수하수처리장 추가"} /> <Title title={"취수하수처리장 추가"} />
<Button className="m-2" size={"sm"} onClick={()=>{}}>저장</Button> <Button className="m-2" size={"sm"} onClick={() => { }}>저장</Button>
</div> </div>
<div className="flex flex-row flex-grow gap-4 mt-4"> <div className="flex flex-row flex-grow gap-4 mt-4">
<div className="w-3/7"> <div className="w-3/7">
<Label className="w-full text-2xl text-gray-600 text-right">공공하수처리시설 목록</Label> <Label className="w-full text-2xl text-gray-600 text-right">공공하수처리시설 목록</Label>
<div className="flex items-center"> <div className="flex items-center">
<Label className="w-full text-xl text-gray-600 text-right">시설명</Label> <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) => {}}/> <Input className="w-1/3 !text-xl ml-2" type="text" value={""} onChange={(e) => { }} />
<Button className="m-2" size={"sm"} onClick={()=>{}}>조회</Button> <Button className="m-2" size={"sm"} onClick={() => { }}>조회</Button>
</div> </div>
<div className="border-t border-gray-300 my-4"></div> <div className="border-t border-gray-300 my-4"></div>
<UiTable <RuseMngTable
tableData={bdstTable || []}
headList={fcOrgwtsHeadList}
upHeadList={[]} // TODO: Replace with actual upHeadList data if available
ref={leftRef}
/>
{/* <UiTable
headName={""} headName={""}
tableData={bdstTable || []} tableData={bdstTable || []}
headlist={fcOrgwtsHeadList} headlist={fcOrgwtsHeadList}
pageSize={0} pageSize={0}
total={0} total={0}
cellClick={undefined} cellClick={cellClick}
onPageChange={function (page: number): void { onPageChange={function (page: number): void {
throw new Error("Function not implemented."); throw new Error("Function not implemented.");
}} }}
></UiTable> ></UiTable> */}
</div> </div>
<div className="flex flex-col items-center justify-center w-1/7 gap-2"> <div className="flex flex-col items-center justify-center w-1/7 gap-2">
<ArrowRight <ArrowRight
type="button" type="button"
onClick={() => { onClick={() => {
setIsFcOrgwtsData(!isFcOrgwtsData); if (leftRef && typeof leftRef === "object" && "current" in leftRef) {
}} const checked = leftRef.current?.filter((item) => ((item as unknown as customPbnst)?.choose))
className="w-12 h-12 text-gray-500" const unchecked = leftRef.current?.filter((item) => !(item as unknown as customPbnst)?.choose)
/> if (checked && checked.length > 0) {
<ArrowLeft checked.forEach(item=>(item as unknown as customPbnst).choose = false)
type="button" setRightData([...(checked as unknown as customPbnst[]),
onClick={() => {}} ...((rightRef.current ?? []) as unknown as customPbnst[])
className="w-12 h-12 text-gray-500" /> ])
</div>
}
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 */} {/* Right Table container: Takes 2/5 of the width */}
<div className="w-3/7"> <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={"취수하수처리장 목록"} headName={"취수하수처리장 목록"}
tableData={pkTable || []} tableData={pkTable || []}
headlist={fcOrgwtsHeadList} headlist={fcOrgwtsHeadList}
@@ -94,10 +140,10 @@ export default function FcOrgwtsRegModal({ data }: { data: fcOrgwtType[] }) {
onPageChange={function (page: number): void { onPageChange={function (page: number): void {
throw new Error("Function not implemented."); throw new Error("Function not implemented.");
}} }}
></UiTable> ></UiTable> */}
</div>
</div> </div>
</div> </div>
</div>
</> </>
); );
} }
@@ -1,5 +1,7 @@
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"; import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList"; 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 { selectClass, type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { DatePicker, SelectBox, type SelectDataType } from "@common/business_components/ui"; import { DatePicker, SelectBox, type SelectDataType } from "@common/business_components/ui";
import { import {
@@ -21,12 +23,12 @@ type RuseMngTableProps = {
code?: { name: string, val: SelectDataType[] }[]; code?: { name: string, val: SelectDataType[] }[];
}; };
const RuseMngTable = React.forwardRef<any[], RuseMngTableProps>( const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
({ ({
tableData, tableData,
headList, headList,
upHeadList, upHeadList,
code = [] code
}, ref) => { }, ref) => {
const [tableState, setTableState] = useState([...tableData]); const [tableState, setTableState] = useState([...tableData]);
useEffect(() => { useEffect(() => {