원수취수 상위페이지에 데이터 넘겨야함
This commit is contained in:
@@ -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
|
||||
}
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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(""),
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user