지도점검 현황 작업중

This commit is contained in:
leedj312
2025-05-19 09:47:23 +09:00
parent 1466e04638
commit 7da488dbbf
19 changed files with 735 additions and 416 deletions
@@ -40,7 +40,7 @@ export default function RswtSttn() {
chBuilding: chgBuilding[];
}>({ isOpen: false, chBuilding: [] });
const codeData = getCityOrSgg(ref);
const codeCityOrSgg = getCityOrSgg(ref);
const cellClick=(index:number|undefined, headId: string)=>{
@@ -50,9 +50,10 @@ const cellClick=(index:number|undefined, headId: string)=>{
}else if( headId==='chBuildingYn' && index!==undefined && bdstTable!==undefined){
if (
bdstTable[index] &&
bdstTable[index]?.chgBuilding[0]?.bdstChgNm!==null
bdstTable[index]?.chBuildingYn ==='Y'
) {
setBdstChgProps({ isOpen:true , chBuilding: bdstTable[index].chgBuilding});
}
}
@@ -73,7 +74,7 @@ const cellClick=(index:number|undefined, headId: string)=>{
...item,
...item.reuseBuilding[0],
...item.reuseBuilding[0]?.rswtrObj,
chBuildingYn:item?.chgBuilding[0]?.bdstChgNm!==null?'Y':'N'
chBuildingYn:item?.chgBuilding[0]?.bdstChgNm!==null &&item?.chgBuilding.length>0?'Y':'N'
}))
.filter(
(item: customRswtBdst) =>
@@ -97,19 +98,14 @@ const cellClick=(index:number|undefined, headId: string)=>{
const excelClick = useCallback(
(returnType: ReturnType) => {
let con;
if (returnType.sigunValue != "0") {
con = returnType.sigunValue;
} else {
con = returnType.sidoValue;
}
rswtSttnSearch(1, "10000", con);
if(codeCityOrSgg)
rswtSttnSearch(1, "10000", codeCityOrSgg);
},
[rswtSttnSearch]
[rswtSttnSearch,codeCityOrSgg]
);
useEffect(() => {
if (codeData != null) rswtSttnSearch(pageNation, "20", codeData);
if (codeCityOrSgg != null) rswtSttnSearch(pageNation, "20", codeCityOrSgg);
}, [pageNation]);
return (
@@ -138,13 +134,8 @@ const cellClick=(index:number|undefined, headId: string)=>{
leftChildren={undefined}
queryClick={function (returnType: ReturnType): void {
// '{partValue: 'A', sidoValue: '0', sigunValue: '0', regionValue: '0', unitWaterShedValue: '0', …}'
let con;
if (returnType.sigunValue != "0") {
con = returnType.sigunValue;
} else {
con = returnType.sidoValue;
}
rswtSttnSearch(1, "20", con);
if(codeCityOrSgg)
rswtSttnSearch(1, "20", codeCityOrSgg);
}}
excelClick={excelClick}
initClick={function (): void {}}
@@ -2,7 +2,7 @@
import { useWrStore } from "@/app/store";
import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import type { rswtChkZodType, rswtrChkDetailsZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import {
excelArrayDownload,
excelDownload,
@@ -36,12 +36,13 @@ export default function Page() {
rainChkDetilUpdate,
rainChkDelete,
rainChkExcelDownload,
rainChkHeadChange,
rswtChkgdnInit,
rswtChkDetilUpdate,
rswtChkDetilsUpdate,
rswtChkDelete,
rswtrChkExcelDownload,
rswtChkPolAndGuide,
rswtChkHeadChange,
} = useWrStore((state) => {
return state;
});
@@ -50,11 +51,10 @@ export default function Page() {
const [updateRainDetail, setUpdateRainDetail] = useState<rainChkZodType[]>(
[]
);
const [updateRswtDetail, setUpdateRSwtDetail] = useState<rswtChkZodType[]>(
const [updateRswtDetail, setUpdateRSwtDetail] = useState<rswtrChkDetailsZodType[]>(
[]
);
const [deleteIdx, setDeleteIdx] = useState<number[]>([]);
const [deleteIdxRSwt, setDeleteIdxRswt] = useState<number[]>([]);
const [selFcltDiv, setSelFcltDiv] = useState("RNB");
const [isModal, setIsModal] = useState({
@@ -82,7 +82,6 @@ export default function Page() {
}, [rainChkgdn.isInit, rainChkInit]);
useEffect(() => {
console.log("rswtChkgdn.excelList ", rswtChkgdn.excelList);
if (rswtChkgdn.excelList[0]?.data.length > 1)
excelArrayDownload(
@@ -117,15 +116,27 @@ export default function Page() {
const handleClick = useCallback(
(data: any) => {
if (data) setIsModal({ open: true, data: data });
if (data) setIsModal({ open: !isModal.open, data: data });
},
[isModal]
);
useEffect(() => {
rainChkgdn.isSttn=false
rswtChkgdn.isSttn=false
if (!rainChkgdn.isSttn &&!rswtChkgdn.isSttn) {
rainChkHeadChange({rainChkgdn}, true);
rswtChkHeadChange({rswtChkgdn}, true);
}
}, [rainChkgdn.isSttn ,rswtChkgdn.isSttn]);
const clickDelete = (data: number[],selFcltDiv:string) => {
if (data.length > 0) {
if(selFcltDiv === "RNB"){
rainChkDelete(data);
@@ -138,7 +149,9 @@ export default function Page() {
if(selFcltDiv === "RNB"){
rainChkDetilUpdate(updateRainDetail)
}else{
rswtChkDetilUpdate(updateRswtDetail)
console.log("updateRswtDetail ", updateRswtDetail)
rswtChkDetilsUpdate(updateRswtDetail)
}
}
@@ -183,7 +196,7 @@ export default function Page() {
<Button
size={"sm"}
onClick={() => {
clickDelete(deleteIdx,selFcltDiv);
clickDelete( deleteIdx,selFcltDiv);
}}
>
삭제
@@ -227,7 +240,7 @@ export default function Page() {
) : (
<RswtChkgdTable
detaiRswtlUpdate={setUpdateRSwtDetail}
deleteRswtData={setDeleteIdxRswt}
deleteRswtData={setDeleteIdx}
handleRswtClick={handleClick}
/>
) }
@@ -32,22 +32,16 @@ export default function Page() {
code,
rainChkgdn,
rswtChkgdn,
rainChkInit,
rainChkDetilUpdate,
rainChkDelete,
rainChkExcelDownload,
rswtrChkExcelDownload,
rswtChkgdnInit
rainChkInit,
rswtChkgdnInit,
rainChkHeadChange,
rswtChkHeadChange
} = useWrStore((state) => {
return state;
});
const [isRegExcel, setIsRegExcel] = useState(false);
const [searchTxt, setSearchTxt] = useState<string>();
const [updateRainDetail, setUpdateRainDetail] = useState<rainChkZodType[]>(
[]
);
const [deleteIdx, setDeleteIdx] = useState<number[]>([]);
const [selFcltDiv, setSelFcltDiv] = useState("RNB");
const [isModal, setIsModal] = useState({
open: false,
@@ -60,64 +54,37 @@ export default function Page() {
useEffect(() => {
if (!rainChkgdn.isInit) {
rainChkInit("2024", "0");
setIsModal({ data: {}, open: rainChkgdn.isModalClose });
setIsRegExcel(false);
}
if (!rswtChkgdn.isInit) {
rswtChkgdnInit("2024", "0");
setIsModal({ data: {}, open: rainChkgdn.isModalClose });
setIsRegExcel(false);
setIsModal({ data: {}, open: false });
}
}, [rainChkgdn.isInit, rainChkInit]);
useEffect(() => {
console.log("rswtChkgdn.excelList ", rswtChkgdn.excelList);
useEffect(() => {
if (rswtChkgdn.excelList[0]?.data.length > 1)
excelArrayDownload(
"중수도_점검결과_이용량현황",
"sample_rs_chk.xlsx",
rswtChkgdn.excelList
);
}, [rswtChkgdn.excelList]);
useEffect(() => {
excelDownload(
rainChkgdn.excelList,
"빗물이용시설 지도점검",
"sample_rainy.xlsx",
"A1:AN1"
);
}, [rainChkgdn.excelList]);
const excelClick = useCallback(() => {
console.log("selFcltDiv ", selFcltDiv);
if (selFcltDiv === "RNB") {
rainChkExcelDownload(code.cityCd, code.sggCd);
} else {
rswtrChkExcelDownload(code.cityCd, code.sggCd);
if (!rswtChkgdn.isInit) {
rswtChkgdnInit("2024", "0");
setIsModal({ data: {}, open: false });
}
}, [
rainChkExcelDownload,
rswtrChkExcelDownload,
code.cityCd,
code.sggCd,
selFcltDiv,
]);
},[rswtChkgdn.isInit, rswtChkgdnInit])
useEffect(() => {
rainChkgdn.isSttn=true
rswtChkgdn.isSttn=true
if (rainChkgdn.isSttn &&rswtChkgdn.isSttn) {
rainChkHeadChange({rainChkgdn}, false);
rswtChkHeadChange({rswtChkgdn}, false);
}
}, [rainChkgdn.isSttn ,rswtChkgdn.isSttn]);
const handleClick = useCallback(
(data: any) => {
if (data) setIsModal({ open: true, data: data });
if (data) setIsModal({ open: !isModal.open, data: data });
},
[isModal]
);
const clickDelete = (data: number[]) => {
if (data.length > 0) {
rainChkDelete(data);
}
};
return (
<ContentsDiv>
@@ -158,7 +125,7 @@ export default function Page() {
</Button>
</div>
<div className="flex flex-row space-x-2 pt-3">
<Button color="green" size={"sm"} onClick={excelClick}>
<Button color="green" size={"sm"} onClick={() =>{}}>
양식받기
</Button>
</div>
@@ -172,16 +139,16 @@ export default function Page() {
<ListDiv>
{selFcltDiv === "RNB" ? (
<RainChkgdTable
deleteData={setDeleteIdx}
detailUp={setUpdateRainDetail}
deleteData={() => {}}
detailUp={() => {}}
handleClick={handleClick}
/>
) : (
<RswtChkgdTable detaiRswtlUpdate={function (data: rswtChkZodType[]): void {
throw new Error("Function not implemented.");
} } deleteRswtData={function (selectedIds: number[]): void {
throw new Error("Function not implemented.");
} } />
<RswtChkgdTable
detaiRswtlUpdate={() => {}}
deleteRswtData={() => {}}
handleRswtClick={handleClick}
/>
)}
</ListDiv>
</div>
@@ -192,14 +159,8 @@ export default function Page() {
setIsModal({ open: !open, data: {} });
}}
bodyClass={"w-[80vw] max-w-none"}
body={<ChkgdModal type={"RNB"} obj={isModal.data} />}
body={<ChkgdModal type={selFcltDiv} obj={isModal.data} />}
></UiModal>
<UiModal
open={isRegExcel}
onOpenChange={setIsRegExcel}
bodyClass={"w-[40vw] max-w-none"}
body={<ChkgdExcel type={selFcltDiv}></ChkgdExcel>}
/>
<Toaster position="top-center" />
</ContentsDiv>
);
@@ -86,6 +86,7 @@ export const buildingToExcelType = (
export const excelToRainChkData = (excelData: any, year: string) => {
const rainChkgdData: rainChkZodType[] = excelData.map((item: any) => {
if (item["점검일"] !== undefined) {
const makeGuidDetail = Array.from({ length: 12 }, (_, i) => {
let month = `${i + 1}`;
const splyData = item[`보급_${month}월`];
@@ -124,7 +125,7 @@ export const excelToRainChkData = (excelData: any, year: string) => {
},
],
};
});
}
}).filter((el: any) => el !== undefined);
return rainChkgdData;
};
@@ -113,7 +113,7 @@ export type splRuseWaterType = {
};
export const rainHeadNmExport: chHeadType[] = [
{ headNm: "useQuilty", text: "이용수질(필요시)", length: 4 },
{ headNm: "useQuilty", text: "이용수질(필요시)", length: 3 },
{ headNm: "feeHist", text: "과태료 부과내역", length: 3 },
{ headNm: "ruseWater", text: "연간보급수 이용량(m³)", length: 13 },
{ headNm: "detailQulity", text: "분기", length: 11 },
@@ -157,14 +157,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
type: "number",
edit: true,
},
{
id: "etc",
title: "기타",
upName: "useQuilty",
upSequnce: 4,
type: "number",
edit: true,
},
{
id: "vltnDt",
title: "부과일(위반일)",
@@ -225,53 +218,3 @@ export const splHeadListExport: TableUpperProps[] = [
{ id: "spl12", title: "12월", upName: "splWater", upSequnce: 13, edit: true },
];
export const rswtDetailHeadListExport: TableUpperProps[] = [
{ id: "utztnUsgCd", title: "이용용도" },
{
id: "grssClfgUswtr",
title: "총대장균군수",
upName: "detailQulity",
upSequnce: 2,
edit: true,
},
{
id: "combResdch",
title: "결합잔류염소",
upName: "detailQulity",
upSequnce: 3,
edit: true,
},
{
id: "trbt",
title: "탁도",
upName: "detailQulity",
upSequnce: 4,
edit: true,
},
{ id: "bod", title: "BOD", upName: "detailQulity", upSequnce: 5, edit: true },
{
id: "smll",
title: "냄새",
upName: "detailQulity",
upSequnce: 6,
edit: true,
},
{
id: "crmty",
title: "색도",
upName: "detailQulity",
upSequnce: 7,
edit: true,
},
{ id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8, edit: true },
{ id: "tph", title: "T-P", upName: "detailQulity", upSequnce: 9, edit: true },
{ id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10, edit: true },
{
id: "clIonQnt",
title: "염화물",
upName: "detailQulity",
upSequnce: 11,
edit: true,
},
];
@@ -3,25 +3,36 @@ import {
TEST_UUID,
type TableUpperProps,
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { deleteFectch, fetchType, getFetch, postFectch, putFectch } from "@/components/lib/api";
import {
deleteFectch,
fetchType,
getFetch,
postFectch,
putFectch,
} from "@/components/lib/api";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
import type { SelectDataType } from "@common/business_components/ui";
import { z } from "zod";
import { buildingToExcelType } from "./excel";
import { rainChkgdnHeadListExport, rainChkZod, rainHeadNmExport, rswtDetailHeadListExport, ruseHeadListExport, splHeadListExport, type chHeadType } from "./headList";
import {
rainChkgdnHeadListExport,
rainChkZod,
rainHeadNmExport,
ruseHeadListExport,
splHeadListExport,
type chHeadType,
} from "./headList";
export type rainChkZodType = z.infer<typeof rainChkZod>;
const fcltDiv = [
const fcltDiv = [
{ val: "RST", text: "중수도시설" },
{ val: "RNB", text: "빗물이용시설" },
];
const rainHeadNm=rainHeadNmExport;
const rainChkgdnHeadList=rainChkgdnHeadListExport;
const ruseHeadList=ruseHeadListExport;
const splHeadList=splHeadListExport;
const rswtDetailHeadList=rswtDetailHeadListExport;
const rainHeadNm = rainHeadNmExport;
const rainChkgdnHeadList = rainChkgdnHeadListExport;
const ruseHeadList = ruseHeadListExport;
const splHeadList = splHeadListExport;
const rainChk: rainChkZodType[] = [];
@@ -32,11 +43,11 @@ export type rainChkgdnState = {
rainHeadNm: chHeadType[];
ruseHeadList: TableUpperProps[];
splHeadList: TableUpperProps[];
rswtDetailHeadList: TableUpperProps[];
isInit: boolean;
isModalClose: boolean;
fcltDiv:SelectDataType[]
fcltDiv: SelectDataType[];
excelList: [];
isSttn: boolean;
};
};
@@ -44,9 +55,13 @@ type rainChkgdnActions = {
rainChkInit: (sggCd: string, searchTxt: string) => void;
rainChkDetilUpdate(rainChk: rainChkZodType[]): Promise<void>;
rainChkGuidUpdate(rainChk: rainChkZodType): Promise<void>;
rainChkExcelDownload(sidoCode: SelectDataType[], sggCode: SelectDataType[]): Promise<void>
rainChkExcelDataUPload(excelData: rainChkZodType[]): Promise<void>
rainChkDelete(chkgdnPks: number[]): Promise<void>
rainChkExcelDownload(
sidoCode: SelectDataType[],
sggCode: SelectDataType[]
): Promise<void>;
rainChkExcelDataUPload(excelData: rainChkZodType[]): Promise<void>;
rainChkDelete(chkgdnPks: number[]): Promise<void>;
rainChkHeadChange: (rainChkgdn: rainChkgdnState, isEdit :boolean) => void;
};
export type rainChkgdnType = rainChkgdnState & rainChkgdnActions;
@@ -58,16 +73,15 @@ export const rainChkgdnStateExport: rainChkgdnState = {
rainChk: rainChk,
splHeadList: splHeadList,
ruseHeadList: ruseHeadList,
rswtDetailHeadList: rswtDetailHeadList,
isInit: false,
isModalClose: false,
excelList: [],
fcltDiv:fcltDiv
fcltDiv: fcltDiv,
isSttn: false,
},
};
const makeMdfrChk = (data: rainChkZodType[], type: string, toDo: string) => {
const chData = data.map((item) => {
item.mdfr = TEST_UUID;
item.rgtr = TEST_UUID;
@@ -78,10 +92,10 @@ const makeMdfrChk = (data: rainChkZodType[], type: string, toDo: string) => {
});
} else {
}
})
return item;
});
return chData;
};
const initFetch = async (txt: string | undefined, sgg: string | undefined) => {
@@ -96,25 +110,33 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
set: any
) => {
return {
rainChkExcelDownload: async (sidoCode: SelectDataType[], sggCode: SelectDataType[]) => {
rainChkExcelDownload: async (
sidoCode: SelectDataType[],
sggCode: SelectDataType[]
) => {
// 로그인한 아이디의 시도 or 시군구로 들어가야하는데 현재는 그냥 0으로 하드코딩
const data = await getFetch(fetchType.WR, `/reuseFc/buildingFlg/${buildingType.RNB}/41`)
const data = await getFetch(
fetchType.WR,
`/reuseFc/buildingFlg/${buildingType.RNB}/41`
);
const excelList = buildingToExcelType(data, sidoCode, sggCode);
set((state: rainChkgdnState) => ({
rainChkgdn: {
...state.rainChkgdn,
excelList: excelList
excelList: excelList,
},
}));
},
rainChkExcelDataUPload: async (excelData: rainChkZodType[]) => {
try {
const res = await postFectch("/reuseChk/rainyExcel", excelData);
const res = await postFectch("/reuseChk/rainy", excelData);
if (res.ok) {
ToastFormUi({ body: "지도점검 등록이 완료되었습니다. ", title: '지도점검 등록' })
ToastFormUi({
body: "지도점검 등록이 완료되었습니다. ",
title: "지도점검 등록",
});
}
const rainChkRes = await initFetch('2024', '0');
const rainChkRes = await initFetch("2024", "0");
return set((state: rainChkgdnState) => ({
...state,
rainChkgdn: {
@@ -124,7 +146,10 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
}));
} catch (error) {
console.log(error);
ToastFormUi({ body: "지도점검 등록이 실패되었습니다.", title: '지도점검 등록' })
ToastFormUi({
body: "지도점검 등록이 실패되었습니다.",
title: "지도점검 등록",
});
}
},
rainChkInit: async (searchTxt: string, sggCd: string) => {
@@ -146,11 +171,14 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
try {
const chData = await makeMdfrChk(rainChk, "rain", "rainDetil");
const res = await postFectch("/reuseChk/rainyExcel", chData);
const res = await postFectch("/reuseChk/rainy", chData);
if (res.ok) {
ToastFormUi({ body: "지도점검 보급수 및 밋물이용량 수정이 완료되었습니다. ", title: '지도점검 수정' })
ToastFormUi({
body: "지도점검 보급수 및 밋물이용량 수정이 완료되었습니다. ",
title: "지도점검 수정",
});
}
const rainChkRes = await initFetch('2024', '0');
const rainChkRes = await initFetch("2024", "0");
return set((state: rainChkgdnState) => ({
...state,
rainChkgdn: {
@@ -168,9 +196,12 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
//const chData = await makeMdfrChk(rainChk, "guideDetails", "rainDetil");
const res = await putFectch("/reuseChk/rainy", rainChk);
if (res.ok) {
ToastFormUi({ body: "지도점검 수질 및 과태료 수정이 완료되었습니다. ", title: '지도점검 수정' })
ToastFormUi({
body: "지도점검 수질 및 과태료 수정이 완료되었습니다. ",
title: "지도점검 수정",
});
}
const rainChkRes = await initFetch('2024', '0');
const rainChkRes = await initFetch("2024", "0");
return set((state: rainChkgdnState) => ({
...state,
rainChkgdn: {
@@ -181,17 +212,18 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
} catch (error) {
console.log(error);
}
},
rainChkDelete: async (chkgdnPks: number[]) => {
try {
const res = await deleteFectch(`/reuseChk/rainy`, chkgdnPks);
if (res.ok) {
ToastFormUi({ body: "삭제가 완료되었습니다. ", title: '지도점검 삭제' })
ToastFormUi({
body: "삭제가 완료되었습니다. ",
title: "지도점검 삭제",
});
}
const rainChkRes = await initFetch('2024', '0');
const rainChkRes = await initFetch("2024", "0");
return set((state: rainChkgdnState) => ({
...state,
rainChkgdn: {
@@ -200,12 +232,40 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
},
}));
} catch (error) {
ToastFormUi({ body: "삭제를 실패했습니다.. ", title: '지도점검 삭제' })
ToastFormUi({ body: "삭제를 실패했습니다.. ", title: "지도점검 삭제" });
}
}
},
rainChkHeadChange: async (rainChkgdn: rainChkgdnState , isEdit :boolean) => {
try {
const rainChkgdnHeadList = rainChkgdn.rainChkgdn.rainChkgdnHeadList;
const splHeadList = rainChkgdn.rainChkgdn.splHeadList;
const ruseHeadList = rainChkgdn.rainChkgdn.ruseHeadList;
rainChkgdnHeadList.forEach(( head) => {
if(head.edit!== undefined)
head.edit=isEdit;
});
splHeadList.forEach((head) => {
if(head.edit!== undefined)
head.edit=isEdit;
});
ruseHeadList.forEach((head) => {
if(head.edit!== undefined)
head.edit=isEdit;
});
return set((state: rainChkgdnState) => ({
...state,
rainChkgdn: {
...state.rainChkgdn,
rainChkgdnHeadList: rainChkgdnHeadList,
splHeadList:splHeadList,
ruseHeadList:ruseHeadList
},
}));
} catch (error) {
console.log(error);
}
},
};
};
@@ -73,6 +73,19 @@ export const rswtrPolutionsZode = z.object({
edit:z.boolean().nullish()
});
export const rswtrDetailsZod = z.object({
chkgdnDtlPk: z.string().nullish(),
chkgdnFk: z.string().nullish(),
utztnUsgCd: z.string(),
vltnDt: z.string(),
vltnMttr: z.string(),
levyAmt: z.number(),
regDt: z.string().nullish(),
rgtr: z.string().nullish(),
mdfcnDt: z.string().nullish(),
mdfr: z.string().nullish(),
})
export const rswtChkgdZod = z.object({
chkgdnPk: z.number().nullish(),
bdstRuseFcltFk: z.number().nullish(),
@@ -90,21 +103,10 @@ export const rswtChkgdZod = z.object({
building: buildingZod,
guideDetails: z.array(guideDetail),
reuseBuilding: reuseBuildingZod,
rswtrDetail: z.array(
z.object({
chkgdnDtlPk: z.string().nullish(),
chkgdnFk: z.string().nullish(),
utztnUsgCd: z.string(),
vltnDt: z.string(),
vltnMttr: z.string(),
levyAmt: z.string(),
regDt: z.string().nullish(),
rgtr: z.string().nullish(),
mdfcnDt: z.string().nullish(),
mdfr: z.string().nullish(),
})
rswtrDetails: z.array(
rswtrDetailsZod
),
rswtrPollution: z.array(rswtrPolutionsZode),
rswtrPollutions: z.array(rswtrPolutionsZode),
});
export const rswtHeadNmExport: chHeadType[] = [
@@ -173,3 +175,56 @@ export const rswtChkHeadListExport: TableUpperProps[] = [
type: "number",
edit:true
}];
export const rswtDetailHeadListExport: TableUpperProps[] = [
{ id: "utztnUsgCd", title: "이용용도" },
{
id: "grssClfgUswtr",
title: "총대장균군수",
upName: "detailQulity",
upSequnce: 2,
edit: true,
},
{
id: "combResdch",
title: "결합잔류염소",
upName: "detailQulity",
upSequnce: 3,
edit: true,
},
{
id: "trbt",
title: "탁도",
upName: "detailQulity",
upSequnce: 4,
edit: true,
},
{ id: "bod", title: "BOD", upName: "detailQulity", upSequnce: 5, edit: true },
{
id: "smll",
title: "냄새",
upName: "detailQulity",
upSequnce: 6,
edit: true,
},
{
id: "crmty",
title: "색도",
upName: "detailQulity",
upSequnce: 7,
edit: true,
},
{ id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8, edit: true },
{ id: "tph", title: "T-P", upName: "detailQulity", upSequnce: 9, edit: true },
{ id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10, edit: true },
{
id: "clIonQnt",
title: "염화물",
upName: "detailQulity",
upSequnce: 11,
edit: true,
},
];
@@ -11,30 +11,37 @@ import {
fetchType,
getFetch,
postFectch,
putFectch,
} from "@/components/lib/api";
import { buildingType } from "@/app/store/common/code";
import { rswtMakeExcelSample } from "./excel";
import {
rswtChkgdZod,
rswtChkHeadListExport,
rswtDetailHeadListExport,
rswtHeadNmExport,
rswtrDetailsZod,
} from "./headList";
import { z } from "zod";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
import { type chHeadType } from "../rainChkgdn/headList";
const rswtChkHeadList = rswtChkHeadListExport;
const rswtDetailHeadList = rswtDetailHeadListExport;
const rswtHeadNm = rswtHeadNmExport;
export type rswtChkZodType = z.infer<typeof rswtChkgdZod>;
export type rswtrChkDetailsZodType = z.infer<typeof rswtrDetailsZod>;
export type rswtChkgdnState = {
rswtChkgdn: {
rswtChkHeadList: TableUpperProps[];
rswtDetailHeadList: TableUpperProps[];
rswtHeadNm: chHeadType[];
excelList: [typeof sheetParameter];
rswtChkRes: rswtChkZodType[];
rswtChkPolGuide: rswtChkZodType[];
isInit: boolean;
isSttn:boolean
};
};
@@ -46,9 +53,10 @@ type rswtChkgdnActions = {
): Promise<void>;
rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void;
rswtChkDelete: (chkgdnPks: number[]) => void;
rswtChkDetilUpdate: (rswtChk: rswtChkZodType[]) => void;
rswtChkDetilsUpdate: (rswtChkDetails: rswtrChkDetailsZodType[]) => void;
rswtChkPolAndGuide: (chkGdnPk: number) => void;
rwstUpdatePolAndGuide:(rswtChk: rswtChkZodType[]) => void;
rwstPolAndGuideUpdate: (rswtChk: rswtChkZodType[]) => void;
rswtChkHeadChange: (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => void;
};
export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions;
@@ -56,11 +64,13 @@ export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions;
export const rswtChkgdnStateExport: rswtChkgdnState = {
rswtChkgdn: {
rswtChkHeadList: rswtChkHeadList,
rswtDetailHeadList: rswtDetailHeadList,
rswtHeadNm: rswtHeadNm,
excelList: [{ data: [[]], headerNum: 0, headerRange: "A1:V3" }],
rswtChkRes: [],
rswtChkPolGuide: [],
isInit: false,
isSttn:false,
},
};
@@ -74,19 +84,18 @@ const initFetch = async (year: string | undefined, sgg: string | undefined) => {
return rswtChkRes;
};
const makeMdfrChk = (data: rswtChkZodType[], type: string) => {
const makeMdfrChk = (data: rswtChkZodType[] | rswtrChkDetailsZodType[]) => {
const chData = data.map((item) => {
item.mdfr = TEST_UUID;
item.rgtr = TEST_UUID;
if (type === "rswtrDetail") {
item.rswtrDetail.forEach((item) => {
item.mdfr = TEST_UUID;
item.rgtr = TEST_UUID;
if ("rswtrPollutions" in item) {
item?.rswtrPollutions.forEach((pollution) => {
pollution.mdfr = TEST_UUID;
pollution.rgtr = TEST_UUID;
});
}
}
return item;
}
);
});
return chData;
};
@@ -141,7 +150,6 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
rswtChkExceDataUpload: async (excelData: rswtChkZodType[]) => {
try {
const res = await postFectch("/reuseChk/reuseWater", excelData);
const rswtMessage: string[] = [];
if (res.ok) {
ToastFormUi({
body: "지도점검 등록이 완료되었습니다.",
@@ -153,18 +161,21 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
...state,
rswtChkgdn: {
...state.rswtChkgdn,
rswtMessage: rswtMessage,
},
}));
} catch (error) {
console.log(error);
}
},
rswtChkDetilUpdate: async (rswtChk: rswtChkZodType[]) => {
rswtChkDetilsUpdate: async (rswtChk: rswtrChkDetailsZodType[]) => {
try {
const chData = await makeMdfrChk(rswtChk, "rswtrDetail");
const chData = await makeMdfrChk(rswtChk);
const res = await postFectch("/reuseChk/reuseWater", chData);
console.log("chData ", chData);
console.log("rswtChk ", rswtChk);
const res = await putFectch("/reuseChk/reuseWater", chData);
if (res.ok) {
ToastFormUi({
body: "지도점검 과태료 수정 수정이 완료되었습니다. ",
@@ -222,11 +233,13 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
}));
} catch (error) {}
},
rwstUpdatePolAndGuide: async (rswtChk: rswtChkZodType[]) => {
rwstPolAndGuideUpdate: async (rswtChk: rswtChkZodType[]) => {
try {
const chData = await makeMdfrChk(rswtChk, "rswtrDetail");
console.log("chData" , chData)
const res = await postFectch("/reuseChk/reuseWater", chData);
const chData = await makeMdfrChk(rswtChk);
const res = await putFectch(
`/reuseChk/reuseWater/${rswtChk[0]?.chkgdnPk}`,
chData[0]
);
if (res.ok) {
ToastFormUi({
body: "지도점검 연간 수질 및 보급수/중수도 수정이 완료되었습니다. ",
@@ -243,8 +256,31 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
}));
} catch (error) {
console.log(error);
alert("수정에 실패하였습니다.");
ToastFormUi({
body: "지도점검 연간 수질 및 보급수/중수도 수정이 실패하였습니다.. ",
title: "지도점검 수정",
});
}
},
rswtChkHeadChange: async (rswtChkgdn: rswtChkgdnState, isEdit: boolean) => {
try {
const rswtChkHeadList = rswtChkgdn.rswtChkgdn.rswtChkHeadList;
const rswtDetailHeadList = rswtChkgdn.rswtChkgdn.rswtDetailHeadList;
rswtChkHeadList.forEach((head) => {
if (head.edit !== undefined) head.edit = isEdit;
});
rswtDetailHeadList.forEach((head) => {
if (head.edit !== undefined) head.edit = isEdit;
});
return set((state: rswtChkgdnState) => ({
...state,
rswtChkgdn: {
...state.rswtChkgdn,
rswtChkHeadList: rswtChkHeadList,
rswtDetailHeadList: rswtDetailHeadList,
},
}));
} catch (e) {}
},
};
};
@@ -0,0 +1,164 @@
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
export const rainChkgdnHeadSttnExport: TableUpperProps[] = [
{ id: 'order', title: "순번", rowSpan: true },
{ id: "checkBox", title: "체크박스", rowSpan: true },
{ id: "cityText", title: "시도", rowSpan: true },
{ id: "sggText", title: "시군구", rowSpan: true },
{ id: "bdstNm", title: "시설명", rowSpan: true },
{ id: "operMngCd", title: "운영관리형태", rowSpan: true },
{ id: "oilqMeasMthd", title: "유량측정방법", rowSpan: true },
{ id: "anlOperCst", title: "연간운영비(원/년)", rowSpan: true },
{ id: "dtfcltCpct", title: "빗물저류조용량(m³)", rowSpan: true },
{ id: "chckYmd", title: "점검일", rowSpan: true },
{ id: "utztnUsgCd", title: "이용용도" },
{ id: "totalSplyUswtrUtztnQnt", title: "연간보급수이용량(m³)" },
{ id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" },
{
id: "ph",
title: "PH",
upName: "useQuilty",
upSequnce: 1,
type: "number",
},
{
id: "trbt",
title: "탁도",
upName: "useQuilty",
upSequnce: 2,
type: "number",
},
{
id: "grssClfg",
title: "총대장균군수",
upName: "useQuilty",
upSequnce: 3,
type: "number",
},
{
id: "vltnDt",
title: "부과일(위반일)",
upName: "feeHist",
upSequnce: 1,
type: "text",
},
{
id: "vltnMttr",
title: "위반사항",
upName: "feeHist",
upSequnce: 2,
type: "text",
},
{
id: "levyAmt",
title: "부과금액(천원)",
upName: "feeHist",
upSequnce: 3,
type: "number",
},
];
export const ruseHeadListExport: TableUpperProps[] = [
{ id: "utztnUsgCd", title: "이용용도" },
{ id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 },
{ id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 },
{ id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 },
{ id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 },
{ id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 },
{ id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 },
{ id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 },
{ id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 },
{ id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 },
{ id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10 },
{ id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 },
{ id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 },
{ id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 },
];
export const splHeadListExport: TableUpperProps[] = [
{ id: "utztnUsgCd", title: "이용용도" },
{ id: "splTotal", title: "계", upName: "splWater", upSequnce: 1 },
{ id: "spl01", title: "1월", upName: "splWater", upSequnce: 2 },
{ id: "spl02", title: "2월", upName: "splWater", upSequnce: 3 },
{ id: "spl03", title: "3월", upName: "splWater", upSequnce: 4 },
{ id: "spl04", title: "4월", upName: "splWater", upSequnce: 5 },
{ id: "spl05", title: "5월", upName: "splWater", upSequnce: 6 },
{ id: "spl06", title: "6월", upName: "splWater", upSequnce: 7 },
{ id: "spl07", title: "7월", upName: "splWater", upSequnce: 8 },
{ id: "spl08", title: "8월", upName: "splWater", upSequnce: 9 },
{ id: "spl09", title: "9월", upName: "splWater", upSequnce: 10 },
{
id: "spl10",
title: "10월",
upName: "splWater",
upSequnce: 11,
},
{
id: "spl11",
title: "11월",
upName: "splWater",
upSequnce: 12,
},
{
id: "spl12",
title: "12월",
upName: "splWater",
upSequnce: 13,
},
];
export const rswtDetailHeadListExport: TableUpperProps[] = [
{ id: "utztnUsgCd", title: "이용용도" },
{
id: "grssClfgUswtr",
title: "총대장균군수",
upName: "detailQulity",
upSequnce: 2,
},
{
id: "combResdch",
title: "결합잔류염소",
upName: "detailQulity",
upSequnce: 3,
},
{
id: "trbt",
title: "탁도",
upName: "detailQulity",
upSequnce: 4,
},
{
id: "bod",
title: "BOD",
upName: "detailQulity",
upSequnce: 5,
},
{
id: "smll",
title: "냄새",
upName: "detailQulity",
upSequnce: 6,
},
{
id: "crmty",
title: "색도",
upName: "detailQulity",
upSequnce: 7,
},
{ id: "tn", title: "T-N", upName: "detailQulity", upSequnce: 8},
{
id: "tph",
title: "T-P",
upName: "detailQulity",
upSequnce: 9,
},
{ id: "ph", title: "PH", upName: "detailQulity", upSequnce: 10 },
{
id: "clIonQnt",
title: "염화물",
upName: "detailQulity",
upSequnce: 11,
},
];
@@ -0,0 +1,75 @@
import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import {
rainHeadNmExport,
rainChkgdnHeadListExport,
type chHeadType,
} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
import { type TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { getFetch } from "@/components/lib/api";
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
import type { SelectDataType } from "@common/business_components/ui";
const fcltDiv = [
{ val: "RST", text: "중수도시설" },
{ val: "RNB", text: "빗물이용시설" },
];
const rainHeadNm = rainHeadNmExport;
const rainChkgdnHeadList = rainChkgdnHeadListExport;
const rainChk: rainChkZodType[] = [];
export type rainChkSttnState = {
rainChkSttn: {
rainChkgdnHeadList: TableUpperProps[];
rainChkSttn: rainChkZodType[];
rainHeadNm: chHeadType[];
fcltDiv: SelectDataType[];
isInit: boolean;
};
};
type rainChkSttnActions = {
rainChkSttnInit: (searchTxt: string, sggCd: string) => void;
};
export type rainChkSttnType = rainChkSttnState & rainChkSttnActions;
export const rainChkSttnStateExport: rainChkSttnState = {
rainChkSttn: {
rainChkgdnHeadList: rainChkgdnHeadList,
rainHeadNm: rainHeadNm,
rainChkSttn: [],
fcltDiv: fcltDiv,
isInit: false,
},
};
const initFetch = async (txt: string | undefined, sgg: string | undefined) => {
const rainRes = await getFetch(
"wr",
`/reuseChk/rainy` + (txt ? `/${txt}` : "2024") + (sgg ? `/${sgg}` : "/0")
);
return rainRes;
};
export const rainChkSttnActionsExport: (set: any) => rainChkSttnActions = (
set: any
) => {
return {
rainChkSttnInit: async (searchTxt: string, sggCd: string) => {
try {
const rainChkRes = await initFetch(searchTxt, sggCd);
return set((state: rainChkSttnState) => ({
...state,
rainChkSttn: {
...state.rainChkSttn,
rainChkRes:rainChkRes
},
}));
} catch (error) {
console.log(error);
}
},
};
};
@@ -101,7 +101,7 @@ export type htdflFacState = {
};
};
type htdflFacSActions = {
initHtdfl: (code: string | number) => void;
initHtdfl: (code: string ) => void;
htdflBdstUpdate:(data: customHtdflBdst, code:string|number) => void;
htdflBdstReg:(data: customHtdflBdst, code:string|number) => void;
getHtdflBdstData:(pageNation:number, code:string|number) =>void;
@@ -154,7 +154,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
},
initHtdfl: async (code: string | number) => {
initHtdfl: async (code: string ) => {
try {
const htdflRes = await initFetch(code);
set((state: htdflFacState) => {
@@ -12,7 +12,7 @@ export const rswtZod = z.object({
bdstNm: z.string().default(""),
frstArchPrmsnDt: z.date().default(() => new Date()),
archChgPrmsnDt: z.coerce.date().nullish().default(null),
chBuildingYn :z.string().nullish(),
archArea: z.number().default(0),
archChgArea: z.number().default(0),
rgtr: z.string().nullish().default(null),
+81 -32
View File
@@ -1,14 +1,40 @@
import { createStore } from "zustand/vanilla";
import { codeActionExport, comCodeStateExport, getCityCd, getEnvPartCd, getMiddleRegionCd, getRegionCd, getSggCd, getUnitWaterShedCd, type comCodeState, type comCodeType } from "./common/code";
import {
codeActionExport,
comCodeStateExport,
getCityCd,
getEnvPartCd,
getMiddleRegionCd,
getRegionCd,
getSggCd,
getUnitWaterShedCd,
type comCodeState,
type comCodeType,
} from "./common/code";
import {
matDmdActionsExport,
matDmdStateExport,
type matDmdState,
type matDmdType,
} from "./matDmd";
import { rainChkgdnActionsExport, rainChkgdnStateExport, type rainChkgdnState, type rainChkgdnType } from "./prfmncReg/chkgdnReg/rainChkgdn";
import { rswtChkgdnActionsExport, rswtChkgdnStateExport, type rswtChkgdnState, type rswtChkgdnType } from "./prfmncReg/chkgdnReg/rswrtChkgdn";
import { bdstActionsExport, bdstStateExport, type bdstFulType, type bdstState } from "./ruseFcltMng/fcltReg/bdstReg";
import {
rainChkgdnActionsExport,
rainChkgdnStateExport,
type rainChkgdnState,
type rainChkgdnType,
} from "./prfmncReg/chkgdnReg/rainChkgdn";
import {
rswtChkgdnActionsExport,
rswtChkgdnStateExport,
type rswtChkgdnState,
type rswtChkgdnType,
} from "./prfmncReg/chkgdnReg/rswrtChkgdn";
import {
bdstActionsExport,
bdstStateExport,
type bdstFulType,
type bdstState,
} from "./ruseFcltMng/fcltReg/bdstReg";
import {
htdflFacActionsExport,
htdflFacStateExport,
@@ -33,38 +59,59 @@ import {
type rswtFacState,
type rswtFacType,
} from "./ruseFcltMng/fcltReg/rswtReg";
import { rainSttnActionsExport, rainSttnStateExport, type rainSttnState, type rainSttnType } from "./ruseFcltMng/fcltSttn/rainSttn";
import { rswtSttnActionsExport, rswtSttnStateExport, type rswtSttnState, type rswtSttnType } from "./ruseFcltMng/fcltSttn/rswtSttn";
import { htdflSttnActionsExport, htdflSttnStateExport, type htdflSttnState, type htdflSttnType } from "./ruseFcltMng/fcltSttn/htdflSttn";
import {
rainSttnActionsExport,
rainSttnStateExport,
type rainSttnState,
type rainSttnType,
} from "./ruseFcltMng/fcltSttn/rainSttn";
import {
rswtSttnActionsExport,
rswtSttnStateExport,
type rswtSttnState,
type rswtSttnType,
} from "./ruseFcltMng/fcltSttn/rswtSttn";
import {
htdflSttnActionsExport,
htdflSttnStateExport,
type htdflSttnState,
type htdflSttnType,
} from "./ruseFcltMng/fcltSttn/htdflSttn";
import {
rainChkSttnActionsExport,
rainChkSttnStateExport,
type rainChkSttnState,
type rainChkSttnType,
} from "./prfmncSttn/chkgdnSttn/rainChkgdnSttn";
export type WrStore = comCodeType&
export type WrStore = comCodeType &
pubFacType &
rainFacType &
rswtFacType &
matDmdType &
htdflFacType&
bdstFulType&
rainChkgdnType&
rswtChkgdnType&
rainSttnType&
rswtSttnType&
htdflSttnType
;
htdflFacType &
bdstFulType &
rainChkgdnType &
rswtChkgdnType &
rainSttnType &
rswtSttnType &
htdflSttnType &
rainChkSttnType;
export const StoreZus = (
initState: comCodeState&
export const StoreZus = (
initState: comCodeState &
rainFacState &
pubFacState &
rswtFacState &
matDmdState &
htdflFacState &
bdstState &
rainChkgdnState&
rswtChkgdnState&
rainSttnState&
rswtSttnState&
htdflSttnState
rainChkgdnState &
rswtChkgdnState &
rainSttnState &
rswtSttnState &
htdflSttnState &
rainChkSttnState
= {
...comCodeStateExport,
...pubFacStateExport,
@@ -77,16 +124,17 @@ export const StoreZus = (
...rswtChkgdnStateExport,
...rainSttnStateExport,
...rswtSttnStateExport,
...htdflSttnStateExport
...htdflSttnStateExport,
...rainChkSttnStateExport,
}
) => {
return createStore<WrStore>()((set) => {
getSggCd(set);
getCityCd(set);
getRegionCd(set);
getMiddleRegionCd(set);
getUnitWaterShedCd(set)
getEnvPartCd(set)
getSggCd(set);
getCityCd(set);
getRegionCd(set);
getMiddleRegionCd(set);
getUnitWaterShedCd(set);
getEnvPartCd(set);
return {
...initState,
...pubFacActionsExport(set),
@@ -100,7 +148,8 @@ export const StoreZus = (
...rswtChkgdnActionsExport(set),
...rainSttnActionsExport(set),
...rswtSttnActionsExport(set),
...htdflSttnActionsExport(set)
...htdflSttnActionsExport(set),
...rainChkSttnActionsExport(set)
};
});
};
+11 -7
View File
@@ -21,7 +21,6 @@ export const rainChkTableData = (chkData: rainChkZodType[]) => {
return acc;
}, {});
return selectTotal; // 모든 키: `${chkgdnFk}_${utztnUsgCd}` 형태
});
@@ -56,12 +55,12 @@ export const rswtChkTableData = (chkData: rswtChkZodType[]) => {
// 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
const makeRswtData: any[] = [];
chkData.forEach((root) => {
root.rswtrDetail.forEach((detail) => {
root.rswtrDetails.forEach((detail) => {
let flatRswtChk = {};
const findGuide = root.guideDetails.find(
(guide) => guide.utztnUsgCd === detail.utztnUsgCd
);
const findPoluttion = root.rswtrPollution.find(
const findPoluttion = root.rswtrPollutions.find(
(polution) => polution.utztnUsgCd === detail.utztnUsgCd
);
const operMngCd = root?.reuseBuilding.operMngCd;
@@ -79,7 +78,6 @@ export const rswtChkTableData = (chkData: rswtChkZodType[]) => {
return makeRswtData;
};
export const chRowspanTable = (
makeTableData: any[],
headList: TableUpperProps[],
@@ -92,6 +90,7 @@ export const chRowspanTable = (
selectedIds: number[],
handleCellClick: (index: number, headId: string) => void
) => {
let order =0
// rowspan된 셀 렌더링 여부 추적용
const renderedMap = new Map<string, Set<number>>();
return (
@@ -102,11 +101,13 @@ export const chRowspanTable = (
const key = head.id;
const isMerged = head.rowSpan;
const value = row[key];
// 병합 대상이면 중복 렌더링 여부 판단
if (isMerged) {
const renderedSet = renderedMap.get(key) ?? new Set<number>();
if (renderedSet.has(rowIndex)) return null; // 이미 렌더링된 셀은 skip
if (renderedSet.has(rowIndex)) {
return null; // 이미 렌더링된 셀은 skip
}
const rowspan = row.rowspan ?? 1;
for (let i = 0; i < rowspan; i++) {
@@ -119,13 +120,15 @@ export const chRowspanTable = (
rowSpan={rowspan}
className="align-middle text-center whitespace-nowrap"
>
{key === "order" ? (
{key === "chekcBox" ? (
<Checkbox
checked={selectedIds.includes(row.chkgdnPk)}
onCheckedChange={(checked) =>
toggleSelection(row.chkgdnPk, checked === true)
}
></Checkbox>
) : key === "order" ? (
++order
) : (
value
)}
@@ -154,6 +157,7 @@ export const chRowspanTable = (
)}
</TableCell>
);
})}
</TableRow>
))}
@@ -97,6 +97,10 @@ export default function ChkgdExcel({ type }: { type: string }) {
};
}
});
console.log("total data ", totalData)
console.log("polutionData data ", polutionData)
const guideKey = new Set(guideData.map(keyGenerator));
const onlypolution = polutionData.filter(
@@ -107,8 +111,7 @@ export default function ChkgdExcel({ type }: { type: string }) {
...totalData,
...onlypolution
]
setExcelRswtData(listTotalData);
setExcelRswtData(listTotalData);
}
});
}
@@ -10,9 +10,8 @@ import type { z } from "zod";
import React from "react";
export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
const { rainChkgdn, rainChkGuidUpdate ,rwstUpdatePolAndGuide } = useWrStore(
(state) => state
);
const { rainChkgdn, rswtChkgdn, rainChkGuidUpdate, rwstPolAndGuideUpdate } =
useWrStore((state) => state);
const [guidData, setGuidData] = useState<splRuseWaterType[]>();
const [polutionData, setPolutionData] = useState<Record<string, any[]>>({
@@ -28,12 +27,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
"4": [] as z.infer<typeof rswtrPolutionsZode>[],
});
const rswtnodeList = headMakeprfmnc(
rainChkgdn?.rswtDetailHeadList,
rainChkgdn?.rainHeadNm
);
const { rainChk, ruseHeadList, splHeadList } = rainChkgdn;
const [updateData, setUpdateData] = useState<splRuseWaterType[]>();
@@ -79,17 +72,19 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
}, []);
setGuidData(result);
if (obj.rswtrPollution) {
if (obj.rswtrPollutions) {
const resultPolution: Record<string, any[]> = {
"1": [],
"2": [],
"3": [],
"4": [],
};
obj.rswtrPollution.forEach((item: z.infer<typeof rswtrPolutionsZode>) => {
const nodeKey = String(item.node);
resultPolution[nodeKey]?.push(item);
});
obj.rswtrPollutions.forEach(
(item: z.infer<typeof rswtrPolutionsZode>) => {
const nodeKey = String(item.node);
resultPolution[nodeKey]?.push(item);
}
);
// 각 노드에 대해 합계/평균 추가
Object.entries(resultPolution).forEach(([nodeKey, items]) => {
@@ -135,7 +130,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
}
}, [obj]);
const setChGuidData = (data: splRuseWaterType[]) => {
if (data.length > 0) {
setUpdateData(data);
@@ -152,10 +146,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
);
const month = item.ym?.slice(4);
if (month === undefined || month === null) {
console.log("month ", month);
}
if (findObj) {
const ruseMonthKey = `ruse${month}` as keyof splRuseWaterType;
const splMonthKey = `spl${month}` as keyof splRuseWaterType;
@@ -172,39 +162,25 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
}
});
obj.guideDetails = realGuideDetail;
if(type ==='RNB'){
if (type === "RNB") {
rainChkGuidUpdate(obj);
}else{
const polution = Object.values(upPolutionData).flat() ;
obj.rswtrPollution = polution;
console.log("obj ", obj)
rwstUpdatePolAndGuide([obj]);
} else {
const polution = Object.values(upPolutionData)
.flat()
.filter((item) => item.utztnUsgCd !== "평균");
obj.rswtrPollutions = polution;
rwstPolAndGuideUpdate([obj]);
}
};
const getPolutionData = (data: z.infer<typeof rswtrPolutionsZode>[]) => {
console.log("data " ,data)
const getNode = Number(data[0]?.node)
const getPolutionData = (data: z.infer<typeof rswtrPolutionsZode>[]) => {
const getNode = Number(data[0]?.node);
setUpPolutionData((prevPolutionData) => ({
...prevPolutionData,
[getNode]: data,
}));
};
useEffect(() =>{
console.log('upPolutionData ', upPolutionData)
},[upPolutionData])
return (
<>
<div>
@@ -219,12 +195,15 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
</div>
<div className="flex justify-between">
<h3 className="text-2xl font-bold text-gray-900">
{"○" + "" + `(${"11"})`}
{"○" + "" + `(${obj.bdstNm})`}
</h3>
<Button className="" onClick={allDataUpdate}>
저장
</Button>
{!rainChkgdn.isSttn ? (
<Button className="" onClick={allDataUpdate}>
저장
</Button>
) : (
<></>
)}
</div>
<ScrollArea className="h-[60vh]">
@@ -269,7 +248,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
</div>
<GuideDetailsTable
chgRes={value}
headList={rainChkgdn?.rswtDetailHeadList}
headList={rswtChkgdn?.rswtDetailHeadList}
type={""}
setChGuidData={(data) => {
getPolutionData(data);
@@ -9,8 +9,9 @@ import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
import { useWrStore } from "@/app/store";
import { useEffect, useState } from "react";
import type { CommonTableProps } from "@/app/store/common/type/headder";
import { rainChkTableData } from "@/components/lib/func/TableData";
import { rainChkTableData, rswtChkTableData } from "@/components/lib/func/TableData";
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
export default function SttnDetailModal({
type,
@@ -19,7 +20,7 @@ export default function SttnDetailModal({
type: string;
formObj: any;
}) {
const { code, rainSttn, rswtSttn, rainSttnChkSearch } = useWrStore(
const { code, rainSttn, rswtSttn, rainSttnChkSearch,rswtChkPolAndGuide } = useWrStore(
(state) => state
);
const [detailData, setDetailData] = useState({
@@ -33,6 +34,7 @@ export default function SttnDetailModal({
rainSttnChkSearch(formObj.reuseBuilding[0].bdstRuseFcltPk);
} else if (type === "RST") {
// rswtChkPolAndGuide(formObj.reuseBuilding[0].bdstRuseFcltPk)
}
}, [type, formObj]);
@@ -62,7 +64,16 @@ export default function SttnDetailModal({
node:rainSttn.rainSttnDetailNodeList,
data: data,
});
} else if (type === "RST") {
} else if (type === "RST" && rswtSttn.rswtSttnRes) {
// const tableTotalData = rswtChkTableData(rswtSttn.rswtSttnRes as unknown as rswtChkZodType[]);
// setDetailData({
// head: rswtSttn.rswtSttHeadList,
// node:rswtSttn.rswtSttNodeList,
// // data: tableTotalData,
// });
}
}, [rainSttn.rainChkRes]);
@@ -50,8 +50,10 @@ export default function RainChkgdTable({
headId === "totalSplyUswtrUtztnQnt" ||
headId === "totalRuseFcltUtztnQnt"
) {
handleClick(makeTableData[index])
}
},[makeTableData, handleClick]);
@@ -1,27 +1,35 @@
"use client";
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
import { useWrStore } from "@/app/store";
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import type {
rswtrChkDetailsZodType,
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import { tableData } from "@/components/lib/func/commom";
import { chRowspanTable, rswtChkTableData } from "@/components/lib/func/TableData";
import {
chRowspanTable,
rswtChkTableData,
} from "@/components/lib/func/TableData";
import { Table, TableBody, TableHeader } from "@common/components/ui";
import { useCallback, useEffect, useState } from "react";
import { useCallback, useEffect, useState } from "react";
export default function RswtChkgdTable({
detaiRswtlUpdate,
handleRswtClick = () => {},
deleteRswtData,
}: {
detaiRswtlUpdate: (data: rswtChkZodType[]) => void;
detaiRswtlUpdate: (data: rswtrChkDetailsZodType[]) => void;
handleRswtClick?: (data: any) => void;
deleteRswtData: (selectedIds: number[]) => void;
}) {
const { code, rswtChkgdn, rswtChkgdnInit,rswtChkPolAndGuide } = useWrStore((state) => state);
const { code, rswtChkgdn, rswtChkgdnInit, rswtChkPolAndGuide } = useWrStore(
(state) => state
);
const [makeTableData, setMakeTableData] = useState<any[]>([]);
const [selectedIds, setSelectedIds] = useState<number[]>([]);
const [upRaintDetail, setUpRaintDetail] = useState<rswtChkZodType[]>([]);
const [upRswttDetail, setUpRswttDetail] = useState<rswtrChkDetailsZodType[]>(
[]
);
const toggleSelection = (pk: number, checked: boolean) => {
setSelectedIds((prev) =>
checked ? [...prev, pk] : prev.filter((item) => item !== pk)
@@ -41,93 +49,57 @@ export default function RswtChkgdTable({
const handleCellClick = useCallback(
(index: number, headId: string) => {
if (
headId === "splyUswtrUtztnQnt" ||
headId === "ruseFcltUtztnQnt"
) {
//handleRswtClick(makeTableData[index]);
rswtChkPolAndGuide(makeTableData[index].chkgdnPk)
if (headId === "splyUswtrUtztnQnt" || headId === "ruseFcltUtztnQnt") {
rswtChkPolAndGuide(makeTableData[index].chkgdnPk);
}
},
[makeTableData, handleRswtClick]
);
useEffect(() =>{
if(rswtChkgdn.rswtChkPolGuide.length > 0)
handleRswtClick(rswtChkgdn.rswtChkPolGuide[0])
},[rswtChkgdn.rswtChkPolGuide])
useEffect(() => {
if (rswtChkgdn.rswtChkPolGuide.length > 0)
handleRswtClick(rswtChkgdn.rswtChkPolGuide[0]);
}, [rswtChkgdn.rswtChkPolGuide]);
useEffect(() => {
//데이터를 평탄화 한것중에 체크박스 선택한 테이블만 선택
const selectedData = makeTableData.filter((item) =>selectedIds.includes(item.chkgdnPk));
if (selectedData.length > 0) {
const updateTableData = makeTableData
.map((rc) => {
const newRswtDetail = rc.rswtrDetail
.map((rd:any) => {
// 변경 데이터는 평탄화한 데이터 즉 루트에 변경되어 있음 이용용도까지 잇음 그걸로 찾기
const findRswt = selectedData.find(
(sd) =>
rd.chkgdnFk === sd.chkgdnPk && rd.utztnUsgCd === sd.utztnUsgCd
);
if (findRswt != undefined) {
console.log(findRswt)
return {
...rd,
vltnDt: findRswt.vltnDt,
vltnMttr: findRswt.vltnMttr,
levyAmt: Number(findRswt.levyAmt),
};
} else {
return undefined;
}
})
.filter(Boolean);
if (newRswtDetail[0] != undefined) {
return {
...rc,
rswtrDetail: newRswtDetail,
};
} else {
return undefined;
}
})
.filter(Boolean);
setUpRaintDetail(updateTableData as rswtChkZodType[]);
}
}, [makeTableData,selectedIds]);
useEffect(() => {
setSelectedIds([])// 셀렉트 초기화를 위한 작업
const tableTotalData = rswtChkTableData(rswtChkgdn.rswtChkRes)
const rswtChkData = tableTotalData.map((item: any) => {
const bud = tableData([item.building], { code });
useEffect(() => {
const selectedData = makeTableData
.map((item) => {
return {
...item,
...bud[0],
rowspan: item.rswtrDetail?.length,
chkgdnFk: item.chkgdnFk,
utztnUsgCd: item.utztnUsgCd,
vltnDt: item.vltnDt,
vltnMttr: item.vltnMttr,
levyAmt: Number(item.levyAmt),
};
});
setMakeTableData(rswtChkData);
}, [rswtChkgdn.rswtChkRes, code]);
})
.filter((item) => selectedIds.includes(item.chkgdnFk));
useEffect(() => {
detaiRswtlUpdate(upRaintDetail);
}, [upRaintDetail]);
useEffect(() =>{
if(selectedIds.length >0){
// 삭제를 위한 데이터 삽입
deleteRswtData(selectedIds )
}
},[selectedIds])
if (selectedData) setUpRswttDetail(selectedData);
}, [makeTableData, selectedIds]);
useEffect(() => {
setSelectedIds([]); // 셀렉트 초기화를 위한 작업
const tableTotalData = rswtChkTableData(rswtChkgdn.rswtChkRes);
const rswtChkData = tableTotalData.map((item: any) => {
const bud = tableData([item.building], { code });
return {
...item,
...bud[0],
rowspan: item.rswtrDetails?.length,
};
});
setMakeTableData(rswtChkData);
}, [rswtChkgdn.rswtChkRes, code]);
useEffect(() => {
detaiRswtlUpdate(upRswttDetail);
}, [upRswttDetail]);
useEffect(() => {
if (selectedIds.length > 0) {
// 삭제를 위한 데이터 삽입
deleteRswtData(selectedIds);
}
}, [selectedIds]);
return (
<>