@@ -36,9 +36,12 @@ export default function Page() {
|
||||
rainChkDetilUpdate,
|
||||
rainChkDelete,
|
||||
rainChkExcelDownload,
|
||||
rswtrChkExcelDownload,
|
||||
|
||||
rswtChkgdnInit
|
||||
rswtChkgdnInit,
|
||||
rswtChkDetilUpdate,
|
||||
rswtChkDelete,
|
||||
rswtrChkExcelDownload,
|
||||
rswtChkPolAndGuide,
|
||||
} = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
@@ -47,7 +50,12 @@ export default function Page() {
|
||||
const [updateRainDetail, setUpdateRainDetail] = useState<rainChkZodType[]>(
|
||||
[]
|
||||
);
|
||||
const [updateRswtDetail, setUpdateRSwtDetail] = useState<rswtChkZodType[]>(
|
||||
[]
|
||||
);
|
||||
const [deleteIdx, setDeleteIdx] = useState<number[]>([]);
|
||||
const [deleteIdxRSwt, setDeleteIdxRswt] = useState<number[]>([]);
|
||||
|
||||
const [selFcltDiv, setSelFcltDiv] = useState("RNB");
|
||||
const [isModal, setIsModal] = useState({
|
||||
open: false,
|
||||
@@ -57,6 +65,8 @@ export default function Page() {
|
||||
if (searchTxt) rainChkInit(searchTxt, "0");
|
||||
};
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (!rainChkgdn.isInit) {
|
||||
rainChkInit("2024", "0");
|
||||
@@ -92,7 +102,6 @@ export default function Page() {
|
||||
}, [rainChkgdn.excelList]);
|
||||
|
||||
const excelClick = useCallback(() => {
|
||||
console.log("selFcltDiv ", selFcltDiv);
|
||||
if (selFcltDiv === "RNB") {
|
||||
rainChkExcelDownload(code.cityCd, code.sggCd);
|
||||
} else {
|
||||
@@ -113,11 +122,26 @@ export default function Page() {
|
||||
[isModal]
|
||||
);
|
||||
|
||||
const clickDelete = (data: number[]) => {
|
||||
|
||||
|
||||
|
||||
const clickDelete = (data: number[],selFcltDiv:string) => {
|
||||
if (data.length > 0) {
|
||||
rainChkDelete(data);
|
||||
if(selFcltDiv === "RNB"){
|
||||
rainChkDelete(data);
|
||||
}else{
|
||||
rswtChkDelete(data)
|
||||
}
|
||||
}
|
||||
};
|
||||
const chkUpdateTable =(selFcltDiv:string) =>{
|
||||
if(selFcltDiv === "RNB"){
|
||||
rainChkDetilUpdate(updateRainDetail)
|
||||
}else{
|
||||
rswtChkDetilUpdate(updateRswtDetail)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
<ContentsDiv>
|
||||
@@ -159,7 +183,7 @@ export default function Page() {
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={() => {
|
||||
clickDelete(deleteIdx);
|
||||
clickDelete(deleteIdx,selFcltDiv);
|
||||
}}
|
||||
>
|
||||
삭제
|
||||
@@ -167,7 +191,7 @@ export default function Page() {
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={() => {
|
||||
rainChkDetilUpdate(updateRainDetail as rainChkZodType[]);
|
||||
chkUpdateTable(selFcltDiv)
|
||||
}}
|
||||
>
|
||||
저장
|
||||
@@ -201,12 +225,12 @@ export default function Page() {
|
||||
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={setUpdateRSwtDetail}
|
||||
deleteRswtData={setDeleteIdxRswt}
|
||||
handleRswtClick={handleClick}
|
||||
/>
|
||||
) }
|
||||
</ListDiv>
|
||||
</div>
|
||||
</div>
|
||||
@@ -216,7 +240,7 @@ 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}
|
||||
|
||||
@@ -1,28 +1,24 @@
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
|
||||
|
||||
export const chkgdRegExcel = z.object({
|
||||
bdstInfoPk: z.number().default(111111111),
|
||||
chckYr: z.string()
|
||||
.default("")
|
||||
.refine(
|
||||
(year) => year.length === 0 || /^\d{4}$/.test(year),
|
||||
{ message: "4자리 연도만 입력하세요" }
|
||||
)
|
||||
.refine(
|
||||
(year) => {
|
||||
if (year.length === 0) return true; // 빈 문자열은 통과
|
||||
const numYear = Number(year);
|
||||
return !isNaN(numYear) && numYear <= new Date().getFullYear();
|
||||
},
|
||||
{ message: "현재 년도보다 높은 수를 입력할 수 없습니다." }
|
||||
),
|
||||
file: z.instanceof(File).optional(),
|
||||
});
|
||||
|
||||
bdstInfoPk: z.number().default(111111111),
|
||||
chckYr: z
|
||||
.string()
|
||||
.default("")
|
||||
.refine((year) => year.length === 0 || /^\d{4}$/.test(year), {
|
||||
message: "4자리 연도만 입력하세요",
|
||||
})
|
||||
.refine(
|
||||
(year) => {
|
||||
if (year.length === 0) return true; // 빈 문자열은 통과
|
||||
const numYear = Number(year);
|
||||
return !isNaN(numYear) && numYear <= new Date().getFullYear();
|
||||
},
|
||||
{ message: "현재 년도보다 높은 수를 입력할 수 없습니다." }
|
||||
),
|
||||
file: z.instanceof(File).optional(),
|
||||
});
|
||||
|
||||
export const guideDetail = z.object({
|
||||
chkgdnFk: z.number().nullable(),
|
||||
@@ -32,7 +28,7 @@ export const guideDetail = z.object({
|
||||
splyUswtrUtztnQnt: z.number(),
|
||||
ruseFcltUtztnQnt: z.number(),
|
||||
flg: z.string(),
|
||||
})
|
||||
});
|
||||
export const rainChkZod = z.object({
|
||||
chkgdnPk: z.number().nullable(),
|
||||
bdstRuseFcltFk: z.number(),
|
||||
@@ -44,22 +40,22 @@ export const rainChkZod = z.object({
|
||||
mdfcnDt: z.string().nullable(),
|
||||
mdfr: z.string().nullable(),
|
||||
flg: z.string().nullable(),
|
||||
guideDetails: z.array(
|
||||
guideDetail
|
||||
),
|
||||
building: z.object({
|
||||
bdstInfoPk: z.number(),
|
||||
ctpvCd: z.number(),
|
||||
sggCd: z.number(),
|
||||
daddr: z.string().nullable(),
|
||||
bdstNm: z.string(),
|
||||
frstArchPrmsnDt: z.string().nullable(),
|
||||
archArea: z.number(),
|
||||
regDt: z.string().nullable(),
|
||||
rgtr: z.string().nullable(),
|
||||
mdfcnDt: z.string().nullable(),
|
||||
mdfr: z.string().nullable(),
|
||||
}).nullable(),
|
||||
guideDetails: z.array(guideDetail),
|
||||
building: z
|
||||
.object({
|
||||
bdstInfoPk: z.number(),
|
||||
ctpvCd: z.number(),
|
||||
sggCd: z.number(),
|
||||
daddr: z.string().nullable(),
|
||||
bdstNm: z.string(),
|
||||
frstArchPrmsnDt: z.string().nullable(),
|
||||
archArea: z.number(),
|
||||
regDt: z.string().nullable(),
|
||||
rgtr: z.string().nullable(),
|
||||
mdfcnDt: z.string().nullable(),
|
||||
mdfr: z.string().nullable(),
|
||||
})
|
||||
.nullable(),
|
||||
rainyDetails: z.array(
|
||||
z.object({
|
||||
chkgdnFk: z.number().nullable(),
|
||||
@@ -79,58 +75,67 @@ export const rainChkZod = z.object({
|
||||
),
|
||||
});
|
||||
|
||||
|
||||
|
||||
export type chHeadType = {
|
||||
headNm: string;
|
||||
text: string;
|
||||
length: number;
|
||||
rows?: number;
|
||||
};
|
||||
|
||||
|
||||
|
||||
headNm: string;
|
||||
text: string;
|
||||
length: number;
|
||||
rows?: number;
|
||||
};
|
||||
|
||||
export type splRuseWaterType = {
|
||||
utztnUsgCd: string;
|
||||
splTotal: number;
|
||||
spl01: number;
|
||||
spl02: number;
|
||||
spl03: number;
|
||||
spl04: number;
|
||||
spl05: number;
|
||||
spl06: number;
|
||||
spl07: number;
|
||||
spl08: number;
|
||||
spl09: number;
|
||||
spl10: number;
|
||||
spl11: number;
|
||||
spl12: number;
|
||||
ruseTotal: number;
|
||||
ruse01: number;
|
||||
ruse02: number;
|
||||
ruse03: number;
|
||||
ruse04: number;
|
||||
ruse05: number;
|
||||
ruse06: number;
|
||||
ruse07: number;
|
||||
ruse08: number;
|
||||
ruse09: number;
|
||||
ruse10: number;
|
||||
ruse11: number;
|
||||
ruse12: number;
|
||||
};
|
||||
|
||||
utztnUsgCd: string;
|
||||
splTotal: number;
|
||||
spl01: number;
|
||||
spl02: number;
|
||||
spl03: number;
|
||||
spl04: number;
|
||||
spl05: number;
|
||||
spl06: number;
|
||||
spl07: number;
|
||||
spl08: number;
|
||||
spl09: number;
|
||||
spl10: number;
|
||||
spl11: number;
|
||||
spl12: number;
|
||||
ruseTotal: number;
|
||||
ruse01: number;
|
||||
ruse02: number;
|
||||
ruse03: number;
|
||||
ruse04: number;
|
||||
ruse05: number;
|
||||
ruse06: number;
|
||||
ruse07: number;
|
||||
ruse08: number;
|
||||
ruse09: number;
|
||||
ruse10: number;
|
||||
ruse11: number;
|
||||
ruse12: number;
|
||||
};
|
||||
export type polutionType = {
|
||||
chkgdnDtlFk:number;
|
||||
utztnUsgCd: string;
|
||||
node: number;
|
||||
grssClfgUswtr: number;
|
||||
combResdch: number;
|
||||
trbt: number;
|
||||
bod: number;
|
||||
smll: number;
|
||||
crmty: number;
|
||||
tph: number;
|
||||
tn: number;
|
||||
ph: number;
|
||||
clIonQnt: number;
|
||||
};
|
||||
|
||||
|
||||
export const rainHeadNmExport: chHeadType[] = [
|
||||
{ headNm: "useQuilty", text: "이용수질(필요시)", length: 4 },
|
||||
{ headNm: "feeHist", text: "과태료 부과내역", length: 3 },
|
||||
{ headNm: "ruseWater", text: "연간보급수 이용량(m³)", length: 13 },
|
||||
{ headNm: "detailQulity", text: "분기", length: 11 },
|
||||
{ headNm: "splWater", text: "연간빗물 이용량(m³)", length: 13 },
|
||||
|
||||
];
|
||||
|
||||
|
||||
export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
{ id: "order", title: "순번", rowSpan: true },
|
||||
{ id: "cityText", title: "시도", rowSpan: true },
|
||||
@@ -144,13 +149,14 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
{ id: "utztnUsgCd", title: "이용용도" },
|
||||
{ id: "totalSplyUswtrUtztnQnt", title: "연간보급수이용량(m³)" },
|
||||
{ id: "totalRuseFcltUtztnQnt", title: "연간빗물이용량(m³)" },
|
||||
{ id: "ph", title: "PH", upName: "useQuilty", upSequnce: 1, type: "number" },
|
||||
{ id: "ph", title: "PH", upName: "useQuilty", upSequnce: 1, type: "number" ,edit:true},
|
||||
{
|
||||
id: "trbt",
|
||||
title: "탁도",
|
||||
upName: "useQuilty",
|
||||
upSequnce: 2,
|
||||
type: "number",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "grssClfg",
|
||||
@@ -158,6 +164,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "useQuilty",
|
||||
upSequnce: 3,
|
||||
type: "number",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "etc",
|
||||
@@ -165,6 +172,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "useQuilty",
|
||||
upSequnce: 4,
|
||||
type: "number",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "vltnDt",
|
||||
@@ -172,6 +180,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "feeHist",
|
||||
upSequnce: 1,
|
||||
type: "text",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "vltnMttr",
|
||||
@@ -179,6 +188,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "feeHist",
|
||||
upSequnce: 2,
|
||||
type: "text",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "levyAmt",
|
||||
@@ -186,6 +196,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "feeHist",
|
||||
upSequnce: 3,
|
||||
type: "number",
|
||||
edit:true
|
||||
},
|
||||
];
|
||||
|
||||
@@ -224,16 +235,10 @@ export const splHeadListExport: TableUpperProps[] = [
|
||||
];
|
||||
|
||||
export const rswtDetailHeadListExport: TableUpperProps[] = [
|
||||
{ id: "utztnUsgTest", title: "이용용도" },
|
||||
{ id: "utztnUsgCd", title: "이용용도" },
|
||||
|
||||
{
|
||||
id: "avre",
|
||||
title: "평균",
|
||||
upName: "detailQulity",
|
||||
upSequnce: 1,
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "grssClfg",
|
||||
id: "grssClfgUswtr",
|
||||
title: "총대장균군수",
|
||||
upName: "detailQulity",
|
||||
upSequnce: 2,
|
||||
@@ -279,4 +284,3 @@ export const rswtDetailHeadListExport: TableUpperProps[] = [
|
||||
edit: true,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -70,10 +70,11 @@ const makeMdfrChk = (data: rainChkZodType[], type: string, toDo: string) => {
|
||||
|
||||
const chData = data.map((item) => {
|
||||
item.mdfr = TEST_UUID;
|
||||
|
||||
item.rgtr = TEST_UUID;
|
||||
if (type === "rainyDetails") {
|
||||
item.rainyDetails.forEach((item) => {
|
||||
item.mdfr = TEST_UUID;
|
||||
item.rgtr = TEST_UUID;
|
||||
});
|
||||
} else {
|
||||
}
|
||||
@@ -145,7 +146,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
try {
|
||||
const chData = await makeMdfrChk(rainChk, "rain", "rainDetil");
|
||||
|
||||
const res = await postFectch("/reuseChk/rainyExcel", rainChk);
|
||||
const res = await postFectch("/reuseChk/rainyExcel", chData);
|
||||
if (res.ok) {
|
||||
ToastFormUi({ body: "지도점검 보급수 및 밋물이용량 수정이 완료되었습니다. ", title: '지도점검 수정' })
|
||||
}
|
||||
|
||||
@@ -2,29 +2,59 @@ import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { z } from "zod";
|
||||
import { guideDetail, type chHeadType } from "../rainChkgdn/headList";
|
||||
|
||||
const reuseBuildingZod = z.object({
|
||||
bdstRuseFcltPk: z.number().nullish(),
|
||||
bdstInfoFk: z.number().nullish(),
|
||||
instlCmptnDt: z.string().nullable(), // Assuming it's a date string or null
|
||||
instlCst: z.number(),
|
||||
operMngCd: z.string().nullable(),
|
||||
instlCstSprtYn: z.string().nullable(), // Assuming 'Y'/'N' or similar, or null
|
||||
instlCstSprtAmt: z.number(),
|
||||
grntchBdstCertYn: z.string().nullable(),
|
||||
grntchBdstCertYr: z.string().nullable(), // Could be z.number().nullable() if it's strictly a year number
|
||||
grntchBdstCertNo: z.string().nullable(),
|
||||
grntchBdstCertGrd: z.string().nullable(),
|
||||
crgRdctYn: z.string().nullable(),
|
||||
crgRdctBss: z.string().nullable(),
|
||||
crgRdctAmt: z.number(),
|
||||
ruseFcltFlg: z.string().nullable(),
|
||||
bdstUsgCd: z.number(),
|
||||
lawTrgtYn: z.string().nullable(), // Assuming 'Y'/'N' or similar, or null
|
||||
rgtr: z.string(), // Assuming this is a UUID
|
||||
mdfr: z.string(), // Assuming this is a UUID
|
||||
});
|
||||
|
||||
const buildingZod = z.object({
|
||||
bdstInfoPk: z.number().nullable(),
|
||||
ctpvCd: z.number(),
|
||||
sggCd: z.number(),
|
||||
daddr: z.string().nullable(),
|
||||
bdstNm: z.string(),
|
||||
frstArchPrmsnDt: z.string().nullable(), // Assuming it's a date string or null
|
||||
archArea: z.number(),
|
||||
rgtr: z.string(), // Assuming this is a UUID
|
||||
mdfr: z.string(), // Assuming this is a UUID
|
||||
});
|
||||
|
||||
|
||||
|
||||
const rswtrPolutionsZode =z.object({
|
||||
export const rswtrPolutionsZode = z.object({
|
||||
chkgdnDtlFk: z.string().nullish(),
|
||||
utztnUsgCd: z.string(),
|
||||
node: z.string(),
|
||||
grssClfgUswtr: z.string(),
|
||||
combResdch: z.string(),
|
||||
trbt: z.string(),
|
||||
bod: z.string(),
|
||||
smll: z.string(),
|
||||
crmty: z.string(),
|
||||
tph: z.string(),
|
||||
tn: z.string(),
|
||||
ph: z.string(),
|
||||
clIonQnt: z.string(),
|
||||
regDt: z.string(),
|
||||
rgtr: z.string(),
|
||||
mdfcnDt: z.string(),
|
||||
mdfr: z.string(),
|
||||
})
|
||||
utztnUsgCd: z.string().nullish(),
|
||||
node: z.string().nullish(),
|
||||
grssClfgUswtr: z.number(),
|
||||
combResdch: z.number(),
|
||||
trbt: z.number(),
|
||||
bod: z.number(),
|
||||
smll: z.number(),
|
||||
crmty: z.number(),
|
||||
tph: z.number(),
|
||||
tn: z.number(),
|
||||
ph: z.number(),
|
||||
clIonQnt: 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(),
|
||||
@@ -37,15 +67,13 @@ export const rswtChkgdZod = z.object({
|
||||
rgtr: z.string().nullish(),
|
||||
mdfcnDt: z.string().nullish(),
|
||||
mdfr: z.string().nullish(),
|
||||
flg: z.string().nullish(),
|
||||
anlOperCst:z.number(),
|
||||
oilqMeasMthd: z.string().nullish(),
|
||||
anlOperCst: z.number().nullish(),
|
||||
operMngCd: z.string().nullish(),
|
||||
utztnUsgCd: z.string(),
|
||||
guideDetails: z.array(
|
||||
guideDetail
|
||||
),
|
||||
rswtrDetails: z.array(
|
||||
building: buildingZod,
|
||||
guideDetails: z.array(guideDetail),
|
||||
reuseBuilding: reuseBuildingZod,
|
||||
rswtrDetail: z.array(
|
||||
z.object({
|
||||
chkgdnDtlPk: z.string().nullish(),
|
||||
chkgdnFk: z.string().nullish(),
|
||||
@@ -59,9 +87,7 @@ export const rswtChkgdZod = z.object({
|
||||
mdfr: z.string().nullish(),
|
||||
})
|
||||
),
|
||||
rswtrPolutions: z.array(
|
||||
rswtrPolutionsZode
|
||||
),
|
||||
rswtrPollution: z.array(rswtrPolutionsZode),
|
||||
});
|
||||
|
||||
export const rswtHeadNmExport: chHeadType[] = [
|
||||
@@ -70,40 +96,63 @@ export const rswtHeadNmExport: chHeadType[] = [
|
||||
];
|
||||
|
||||
export const rswtChkHeadListExport: TableUpperProps[] = [
|
||||
{ id: "cityText", title: "시도" },
|
||||
{ id: "sggText", title: "시군구" },
|
||||
{ id: "bdstNm", title: "시설명" },
|
||||
{ id: "operMngCd", title: "운영관리형태" },
|
||||
{ id: "yearFee", title: "연간운영비(원/년)" },
|
||||
{ id: "rainDtnbaOpct", title: "처리용량(m³)" },
|
||||
{ id: "checkDay", title: "점검일" },
|
||||
{ id: "checkPoint", title: "채수지점" },
|
||||
{ id: "utztnUsg", title: "이용용도" },
|
||||
{ id: "splyUswtrUtztnQnt", title: "연간보급수이용량(m³)" },
|
||||
{ id: "rswtUsg", title: "연간중수도이용량(m³)" },
|
||||
{ id: "order", title: "순번", rowSpan: true },
|
||||
{ id: "cityText", title: "시도" ,rowSpan: true },
|
||||
{ id: "sggText", title: "시군구",rowSpan: true },
|
||||
{ id: "bdstNm", title: "시설명" ,rowSpan: true},
|
||||
{ id: "operMngCd", title: "운영관리형태" ,rowSpan: true},
|
||||
{ id: "anlOperCst", title: "연간운영비(원/년)" ,rowSpan: true},
|
||||
{ id: "prcsCpct", title: "처리용량(m³)" ,rowSpan: true},
|
||||
{ id: "spwtPositn", title: "채수지점" ,rowSpan: true},
|
||||
{ id: "chckYmd", title: "점검일" ,rowSpan: true},
|
||||
{ id: "utztnUsgCd", title: "이용용도" },
|
||||
{ id: "splyUswtrUtztnQnt", title: "연간보급수이용량(m³)" ,type: "number"},
|
||||
{ id: "ruseFcltUtztnQnt", title: "연간중수도이용량(m³)",type: "number"},
|
||||
|
||||
{
|
||||
id: "grssClfgUswtr",
|
||||
title: "총대장균군수",
|
||||
upName: "useQuilty",
|
||||
upSequnce: 1,
|
||||
type: "number"
|
||||
},
|
||||
{
|
||||
id: "combResdch",
|
||||
title: "결합잔류염소",
|
||||
upName: "useQuilty",
|
||||
upSequnce: 2,
|
||||
type: "number"
|
||||
},
|
||||
{ id: "trbt", title: "탁도", upName: "useQuilty", upSequnce: 3 },
|
||||
{ id: "bod", title: "BOD", upName: "useQuilty", upSequnce: 4 },
|
||||
{ id: "smll", title: "냄새", upName: "useQuilty", upSequnce: 5 },
|
||||
{ id: "crmty", title: "색도", upName: "useQuilty", upSequnce: 6 },
|
||||
{ id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7 },
|
||||
{ id: "tph", title: "T-P", upName: "useQuilty", upSequnce: 8 },
|
||||
{ id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9 },
|
||||
{ id: "clIonQnt", title: "염화물", upName: "useQuilty", upSequnce: 10 },
|
||||
{ id: "trbt", title: "탁도", upName: "useQuilty", upSequnce: 3 ,type: "number"},
|
||||
{ id: "bod", title: "BOD", upName: "useQuilty", upSequnce: 4 ,type: "number"},
|
||||
{ id: "smll", title: "냄새", upName: "useQuilty", upSequnce: 5 ,type: "number"},
|
||||
{ id: "crmty", title: "색도", upName: "useQuilty", upSequnce: 6 ,type: "number"},
|
||||
{ id: "tn", title: "T-N", upName: "useQuilty", upSequnce: 7 ,type: "number"},
|
||||
{ id: "tph", title: "T-P", upName: "useQuilty", upSequnce: 8 ,type: "number"},
|
||||
{ id: "ph", title: "PH", upName: "useQuilty", upSequnce: 9,type: "number" },
|
||||
{ id: "clIonQnt", title: "염화물", upName: "useQuilty", upSequnce: 10 ,type: "number"},
|
||||
|
||||
{ id: "dayFee", title: "부과일(위반일)", upName: "feeHist", upSequnce: 1 },
|
||||
{ id: "guilty", title: "위반사항", upName: "feeHist", upSequnce: 2 },
|
||||
{ id: "fee", title: "부과금액(천원)", upName: "feeHist", upSequnce: 3 },
|
||||
];
|
||||
{
|
||||
id: "vltnDt",
|
||||
title: "부과일(위반일)",
|
||||
upName: "feeHist",
|
||||
upSequnce: 1,
|
||||
type: "text",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "vltnMttr",
|
||||
title: "위반사항",
|
||||
upName: "feeHist",
|
||||
upSequnce: 2,
|
||||
type: "text",
|
||||
edit:true
|
||||
},
|
||||
{
|
||||
id: "levyAmt",
|
||||
title: "부과금액(천원)",
|
||||
upName: "feeHist",
|
||||
upSequnce: 3,
|
||||
type: "number",
|
||||
edit:true
|
||||
}];
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import {
|
||||
TEST_UUID,
|
||||
type TableUpperProps,
|
||||
} from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import type {
|
||||
SelectDataType,
|
||||
sheetParameter,
|
||||
} from "@common/business_components";
|
||||
import { fetchType, getFetch, postFectch } from "@/components/lib/api";
|
||||
import {
|
||||
deleteFectch,
|
||||
fetchType,
|
||||
getFetch,
|
||||
postFectch,
|
||||
} from "@/components/lib/api";
|
||||
import { buildingType } from "@/app/store/common/code";
|
||||
import { rswtMakeExcelSample } from "./excel";
|
||||
import {
|
||||
@@ -15,8 +23,8 @@ import { z } from "zod";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import { type chHeadType } from "../rainChkgdn/headList";
|
||||
|
||||
const rswtChkHeadList= rswtChkHeadListExport
|
||||
const rswtHeadNm =rswtHeadNmExport
|
||||
const rswtChkHeadList = rswtChkHeadListExport;
|
||||
const rswtHeadNm = rswtHeadNmExport;
|
||||
export type rswtChkZodType = z.infer<typeof rswtChkgdZod>;
|
||||
|
||||
export type rswtChkgdnState = {
|
||||
@@ -24,18 +32,22 @@ export type rswtChkgdnState = {
|
||||
rswtChkHeadList: TableUpperProps[];
|
||||
rswtHeadNm: chHeadType[];
|
||||
excelList: [typeof sheetParameter];
|
||||
rswtChkRes:rswtChkZodType[]
|
||||
rswtChkRes: rswtChkZodType[];
|
||||
rswtChkPolGuide:rswtChkZodType[];
|
||||
isInit: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
type rswtChkgdnActions = {
|
||||
rswtChkgdnInit: (year: string, sggCd: string) => void;
|
||||
rswtChkgdnInit: (year: string, sggCd: string) => void;
|
||||
rswtrChkExcelDownload(
|
||||
sidoCode: SelectDataType[],
|
||||
sggCode: SelectDataType[]
|
||||
): Promise<void>;
|
||||
rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void;
|
||||
rswtChkDelete: (chkgdnPks: number[]) => void;
|
||||
rswtChkDetilUpdate: (rswtChk: rswtChkZodType[]) => void;
|
||||
rswtChkPolAndGuide:(chkGdnPk:number)=>void;
|
||||
};
|
||||
|
||||
export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions;
|
||||
@@ -45,20 +57,37 @@ export const rswtChkgdnStateExport: rswtChkgdnState = {
|
||||
rswtChkHeadList: rswtChkHeadList,
|
||||
rswtHeadNm: rswtHeadNm,
|
||||
excelList: [{ data: [[]], headerNum: 0, headerRange: "A1:V3" }],
|
||||
rswtChkRes:[],
|
||||
rswtChkRes: [],
|
||||
rswtChkPolGuide:[],
|
||||
isInit: false,
|
||||
|
||||
},
|
||||
};
|
||||
|
||||
const initFetch = async (year: string | undefined, sgg: string | undefined) => {
|
||||
const rswtChkRes = await getFetch(
|
||||
"wr",
|
||||
`/reuseChk/reuseWater/` + (year ? `${year}` : "2024") + (sgg ? `/${sgg}` : "/0")
|
||||
`/reuseChk/reuseWater/` +
|
||||
(year ? `${year}` : "2024") +
|
||||
(sgg ? `/${sgg}` : "/0")
|
||||
);
|
||||
return rswtChkRes;
|
||||
};
|
||||
|
||||
const makeMdfrChk = (data: rswtChkZodType[], type: string, toDo: string) => {
|
||||
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;
|
||||
});
|
||||
} else {
|
||||
}
|
||||
});
|
||||
|
||||
return chData;
|
||||
};
|
||||
|
||||
export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
set: any
|
||||
@@ -94,14 +123,14 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
},
|
||||
rswtChkgdnInit: async (year: string, sggCd: string) => {
|
||||
try {
|
||||
const rswtChkRes = await initFetch( '2024',sggCd);
|
||||
const rswtChkRes = await initFetch("2024", sggCd);
|
||||
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtChkRes: rswtChkRes,
|
||||
isInit:false,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
@@ -124,12 +153,74 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtMessage: rswtMessage,
|
||||
// rainChk: rainChkRes,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
rswtChkDetilUpdate: async (rswtChk: rswtChkZodType[]) => {
|
||||
try {
|
||||
const chData = await makeMdfrChk(rswtChk, "rain", "rainDetil");
|
||||
|
||||
const res = await postFectch("/reuseChk/reuseWater", chData);
|
||||
if (res.ok) {
|
||||
ToastFormUi({
|
||||
body: "지도점검 과태료 수정 수정이 완료되었습니다. ",
|
||||
title: "지도점검 수정",
|
||||
});
|
||||
}
|
||||
const rswtChkRes = await initFetch("2024", "0");
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtChkRes: rswtChkRes,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
alert("수정에 실패하였습니다.");
|
||||
}
|
||||
},
|
||||
rswtChkDelete: async (chkgdnPks: number[]) => {
|
||||
try {
|
||||
const res = await deleteFectch(`/reuseChk/reuseWater`, chkgdnPks);
|
||||
|
||||
if (res.ok) {
|
||||
ToastFormUi({
|
||||
body: "삭제가 완료되었습니다. ",
|
||||
title: "지도점검 삭제",
|
||||
});
|
||||
}
|
||||
const rswtChkRes = await initFetch("2024", "0");
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtChkRes: rswtChkRes,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
ToastFormUi({ body: "삭제를 실패했습니다.. ", title: "지도점검 삭제" });
|
||||
}
|
||||
}, rswtChkPolAndGuide: async (chkGdnPk: number) => {
|
||||
try {
|
||||
const rswtChkPolGuide = await getFetch(
|
||||
"wr",
|
||||
`/reuseChk/reuseWater/${chkGdnPk}`
|
||||
);
|
||||
|
||||
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
...state.rswtChkgdn,
|
||||
rswtChkPolGuide: rswtChkPolGuide,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -3,11 +3,6 @@ import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { Checkbox, Input, TableCell, TableRow } from "@common/components/ui";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const rainChkTableData = (chkData: rainChkZodType[]) => {
|
||||
// 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
|
||||
const maketotal = chkData.map((item: rainChkZodType) => {
|
||||
@@ -29,7 +24,6 @@ export const rainChkTableData = (chkData: rainChkZodType[]) => {
|
||||
|
||||
return selectTotal; // 모든 키: `${chkgdnFk}_${utztnUsgCd}` 형태
|
||||
});
|
||||
|
||||
|
||||
// 2. 누계 정보들을 하나의 객체로 합치기 (평탄화)
|
||||
const flatTotalMap = Object.assign({}, ...maketotal);
|
||||
@@ -58,189 +52,111 @@ export const rainChkTableData = (chkData: rainChkZodType[]) => {
|
||||
return updatedRainyDetails;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const rswtChkTableData = (chkData: rswtChkZodType[]) => {
|
||||
// 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
|
||||
const maketotal = makeTotalChk(chkData)
|
||||
|
||||
// 2. 누계 정보들을 하나의 객체로 합치기 (평탄화)
|
||||
const flatTotalMap = Object.assign({}, ...maketotal);
|
||||
|
||||
// 3. rainyDetails에 누계 정보 주입
|
||||
|
||||
const updatedRainyDetails: any[] = [];
|
||||
// chkData.forEach((rd: rswtChkZodType) => {
|
||||
// rd.rswtrDetails.forEach((rswtItem: any) => {
|
||||
// const keyGuide = `${rswtItem.chkgdnFk}_${rswtItem.utztnUsgCd}_guide`;
|
||||
// const keyPolution = `${rswtItem.chkgdnFk}_${rswtItem.utztnUsgCd}_poliution`;
|
||||
// const totalsGuide = flatTotalMap[keyGuide] || {
|
||||
// totalSplyUswtrUtztnQnt: 0,
|
||||
// totalRuseFcltUtztnQnt: 0,
|
||||
// };
|
||||
|
||||
// updatedRainyDetails.push({
|
||||
// ...rd,
|
||||
// ...rd.building,
|
||||
// ...rswtItem,
|
||||
// ...totalsGuide,
|
||||
// averCombResdch:totalsGuide.averCombResdch/rswtItem
|
||||
// totalsGuide.averTrbt:0,
|
||||
// totalsGuide.averBod:0,
|
||||
// totalsGuide.averSmll:0,
|
||||
// totalsGuide.averCrmty:0,
|
||||
// totalsGuide.averTph:0,
|
||||
// totalsGuide.averTn:0,
|
||||
// totalsGuide.averPh:0,
|
||||
// totalsGuide.averClIonQnt:0,
|
||||
// rowspan: rd.rswtrDetails?.length,
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
return updatedRainyDetails;
|
||||
};
|
||||
|
||||
const makeTotalChk=(chkData: rswtChkZodType[])=>{
|
||||
const maketotal = chkData.map((item: rswtChkZodType) => {
|
||||
const selectTotalWater = item.guideDetails.reduce((acc: any, cur: any) => {
|
||||
const code = cur.utztnUsgCd;
|
||||
const fk = cur.chkgdnFk;
|
||||
const flg = 'guide'
|
||||
|
||||
const key = `${fk}_${code}_${flg}`;
|
||||
acc[key] = acc[key] || {
|
||||
totalSplyUswtrUtztnQnt: 0,
|
||||
totalRuseFcltUtztnQnt: 0,
|
||||
const makeRswtData: any[] = [];
|
||||
chkData.forEach((root) => {
|
||||
root.rswtrDetail.forEach((detail) => {
|
||||
let flatRswtChk = {};
|
||||
const findGuide = root.guideDetails.find(
|
||||
(guide) => guide.utztnUsgCd === detail.utztnUsgCd
|
||||
);
|
||||
const findPoluttion = root.rswtrPollution.find(
|
||||
(polution) => polution.utztnUsgCd === detail.utztnUsgCd
|
||||
);
|
||||
const operMngCd = root?.reuseBuilding.operMngCd;
|
||||
flatRswtChk = {
|
||||
...root,
|
||||
...detail,
|
||||
...findGuide,
|
||||
...findPoluttion,
|
||||
...flatRswtChk,
|
||||
operMngCd: operMngCd,
|
||||
};
|
||||
|
||||
acc[key].totalSplyUswtrUtztnQnt += cur.splyUswtrUtztnQnt;
|
||||
acc[key].totalRuseFcltUtztnQnt += cur.ruseFcltUtztnQnt;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
const selectAverPolution = item.rswtrPolutions.reduce((acc: any, cur: any) => {
|
||||
const code = cur.utztnUsgCd;
|
||||
const fk = cur.chkgdnFk;
|
||||
const flg = 'poliution'
|
||||
|
||||
const key = `${fk}_${code}_${flg}`;
|
||||
acc[key] = acc[key] || {
|
||||
averCombResdch:0,
|
||||
averTrbt:0,
|
||||
averBod:0,
|
||||
averSmll:0,
|
||||
averCrmty:0,
|
||||
averTph:0,
|
||||
averTn:0,
|
||||
averPh:0,
|
||||
averClIonQnt:0,
|
||||
node:0
|
||||
};
|
||||
|
||||
acc[key].averCombResdch+=cur.combResdch
|
||||
acc[key].averTrbt+=cur.trbt
|
||||
acc[key].averBod+=cur.bod
|
||||
acc[key].averSmll+=cur.smll
|
||||
acc[key].averCrmty+=cur.crmty
|
||||
acc[key].averTph+=cur.tph
|
||||
acc[key].averTn+=cur.tn
|
||||
acc[key].averPh+=cur.ph
|
||||
acc[key].averClIonQnt+=cur.clIonQnt
|
||||
acc[key].nod+=1
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
return {...selectTotalWater, ...selectAverPolution}; // 모든 키: `${chkgdnFk}_${utztnUsgCd}` 형태
|
||||
makeRswtData.push(flatRswtChk);
|
||||
});
|
||||
});
|
||||
return maketotal;
|
||||
}
|
||||
|
||||
return makeRswtData;
|
||||
};
|
||||
|
||||
|
||||
export const chRowspanTable = (
|
||||
makeTableData: any[],
|
||||
headList: TableUpperProps[],
|
||||
handleChange: (
|
||||
rowIndex: number,
|
||||
field: keyof (typeof makeTableData)[0],
|
||||
value: string | number
|
||||
) => void,
|
||||
toggleSelection: (pk: number, checked: boolean) => void,
|
||||
selectedIds: number[],
|
||||
handleCellClick: (index: number, headId: string) => void
|
||||
) => {
|
||||
// rowspan된 셀 렌더링 여부 추적용
|
||||
const renderedMap = new Map<string, Set<number>>();
|
||||
return (
|
||||
<>
|
||||
{makeTableData.map((row, rowIndex) => (
|
||||
<TableRow key={rowIndex}>
|
||||
{headList.map((head) => {
|
||||
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
|
||||
|
||||
const rowspan = row.rowspan ?? 1;
|
||||
for (let i = 0; i < rowspan; i++) {
|
||||
renderedSet.add(rowIndex + i);
|
||||
}
|
||||
renderedMap.set(key, renderedSet);
|
||||
return (
|
||||
<TableCell
|
||||
key={key}
|
||||
rowSpan={rowspan}
|
||||
className="align-middle text-center whitespace-nowrap"
|
||||
>
|
||||
{key === "order" ? (
|
||||
<Checkbox
|
||||
checked={selectedIds.includes(row.chkgdnPk)}
|
||||
onCheckedChange={(checked) =>
|
||||
toggleSelection(row.chkgdnPk, checked === true)
|
||||
}
|
||||
></Checkbox>
|
||||
) : (
|
||||
value
|
||||
)}
|
||||
</TableCell>
|
||||
);
|
||||
makeTableData: any[],
|
||||
headList: TableUpperProps[],
|
||||
handleChange: (
|
||||
rowIndex: number,
|
||||
field: keyof (typeof makeTableData)[0],
|
||||
value: string | number
|
||||
) => void,
|
||||
toggleSelection: (pk: number, checked: boolean) => void,
|
||||
selectedIds: number[],
|
||||
handleCellClick: (index: number, headId: string) => void
|
||||
) => {
|
||||
// rowspan된 셀 렌더링 여부 추적용
|
||||
const renderedMap = new Map<string, Set<number>>();
|
||||
return (
|
||||
<>
|
||||
{makeTableData.map((row, rowIndex) => (
|
||||
<TableRow key={rowIndex}>
|
||||
{headList.map((head) => {
|
||||
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
|
||||
|
||||
const rowspan = row.rowspan ?? 1;
|
||||
for (let i = 0; i < rowspan; i++) {
|
||||
renderedSet.add(rowIndex + i);
|
||||
}
|
||||
|
||||
// 기본 셀
|
||||
renderedMap.set(key, renderedSet);
|
||||
return (
|
||||
<TableCell
|
||||
key={key}
|
||||
className="text-center whitespace-nowrap"
|
||||
onClick={() => handleCellClick(rowIndex, head.id)}
|
||||
rowSpan={rowspan}
|
||||
className="align-middle text-center whitespace-nowrap"
|
||||
>
|
||||
{key === "totalSplyUswtrUtztnQnt" ||
|
||||
key === "totalRuseFcltUtztnQnt" ||
|
||||
key === "utztnUsgCd" ? (
|
||||
`${value}`
|
||||
{key === "order" ? (
|
||||
<Checkbox
|
||||
checked={selectedIds.includes(row.chkgdnPk)}
|
||||
onCheckedChange={(checked) =>
|
||||
toggleSelection(row.chkgdnPk, checked === true)
|
||||
}
|
||||
></Checkbox>
|
||||
) : (
|
||||
<Input
|
||||
className={`${head.type === "number" ? "text-right" : "text-center"} !text-xl`}
|
||||
type={head.type}
|
||||
onChange={(e) => {
|
||||
handleChange(rowIndex, head.id, e.target.value);
|
||||
}}
|
||||
value={value}
|
||||
/>
|
||||
value
|
||||
)}
|
||||
</TableCell>
|
||||
);
|
||||
})}
|
||||
</TableRow>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
// 기본 셀
|
||||
return (
|
||||
<TableCell
|
||||
key={key}
|
||||
className="text-center whitespace-nowrap"
|
||||
onClick={() => handleCellClick(rowIndex, head.id)}
|
||||
>
|
||||
{head.edit === true ? (
|
||||
<Input
|
||||
className={`${head.type === "number" ? "text-right" : "text-center"} !text-xl`}
|
||||
type={head.type}
|
||||
onChange={(e) => {
|
||||
handleChange(rowIndex, head.id, e.target.value);
|
||||
}}
|
||||
value={value}
|
||||
/>
|
||||
) : (
|
||||
`${value}`
|
||||
)}
|
||||
</TableCell>
|
||||
);
|
||||
})}
|
||||
</TableRow>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -4,13 +4,25 @@ import { Button } from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { GuideDetailsTable } from "@/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable";
|
||||
import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type {
|
||||
polutionType,
|
||||
splRuseWaterType,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
const { rainChkgdn, rainChkDetilUpdate, rainChkGuidUpdate } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const [guidData, setGuidData] = useState<splRuseWaterType[]>();
|
||||
const [polutionData, setPolutionData] = useState<Record<string, any[]>>({
|
||||
"1": [],
|
||||
"2": [],
|
||||
"3": [],
|
||||
"4": [],
|
||||
});
|
||||
|
||||
const rswtnodeList = headMakeprfmnc(
|
||||
rainChkgdn?.rswtDetailHeadList,
|
||||
rainChkgdn?.rainHeadNm
|
||||
@@ -19,6 +31,19 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
const { rainChk, ruseHeadList, splHeadList } = rainChkgdn;
|
||||
const [updateData, setUpdateData] = useState<splRuseWaterType[]>();
|
||||
|
||||
const initStats = (): z.infer<typeof rswtrPolutionsZode> => ({
|
||||
grssClfgUswtr: 0,
|
||||
combResdch: 0,
|
||||
trbt: 0,
|
||||
bod: 0,
|
||||
smll: 0,
|
||||
crmty: 0,
|
||||
tph: 0,
|
||||
tn: 0,
|
||||
ph: 0,
|
||||
clIonQnt: 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const result = obj.guideDetails?.reduce((acc: any, cur: any) => {
|
||||
const code = cur.utztnUsgCd;
|
||||
@@ -47,6 +72,60 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
return acc;
|
||||
}, []);
|
||||
setGuidData(result);
|
||||
|
||||
if (obj.rswtrPollution) {
|
||||
const resultPolution: Record<string, any[]> = {
|
||||
"1": [],
|
||||
"2": [],
|
||||
"3": [],
|
||||
"4": [],
|
||||
};
|
||||
obj.rswtrPollution.forEach((item: any) => {
|
||||
const nodeKey = String(item.node);
|
||||
resultPolution[nodeKey]?.push(item);
|
||||
});
|
||||
|
||||
// 각 노드에 대해 합계/평균 추가
|
||||
Object.entries(resultPolution).forEach(([nodeKey, items]) => {
|
||||
const onlyData = items as z.infer<typeof rswtrPolutionsZode>[];
|
||||
if (onlyData.length === 0) return;
|
||||
|
||||
const total = initStats();
|
||||
onlyData.forEach((item) => {
|
||||
total.grssClfgUswtr += item.grssClfgUswtr;
|
||||
total.combResdch += item.combResdch;
|
||||
total.trbt += item.trbt;
|
||||
total.bod += item.bod;
|
||||
total.smll += item.smll;
|
||||
total.crmty += item.crmty;
|
||||
total.tph += item.tph;
|
||||
total.tn += item.tn;
|
||||
total.ph += item.ph;
|
||||
total.clIonQnt += item.clIonQnt;
|
||||
});
|
||||
|
||||
const average = {
|
||||
utztnUsgCd: "평균",
|
||||
grssClfgUswtr: total.grssClfgUswtr / onlyData.length,
|
||||
combResdch: total.combResdch / onlyData.length,
|
||||
trbt: total.trbt / onlyData.length,
|
||||
bod: total.bod / onlyData.length,
|
||||
smll: total.smll / onlyData.length,
|
||||
crmty: total.crmty / onlyData.length,
|
||||
tph: total.tph / onlyData.length,
|
||||
tn: total.tn / onlyData.length,
|
||||
ph: total.ph / onlyData.length,
|
||||
clIonQnt: total.clIonQnt / onlyData.length,
|
||||
};
|
||||
|
||||
if (!resultPolution[nodeKey]) {
|
||||
resultPolution[nodeKey] = [];
|
||||
}
|
||||
resultPolution[nodeKey].push(average);
|
||||
});
|
||||
|
||||
setPolutionData(resultPolution);
|
||||
}
|
||||
}, [obj]);
|
||||
|
||||
const cellClick = (val: number | undefined, headId: string) => {};
|
||||
@@ -93,11 +172,14 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
item.guideDetails = realGuideDetail;
|
||||
}
|
||||
});
|
||||
console.log("realGuideDetail", rainChk);
|
||||
|
||||
rainChkGuidUpdate(obj);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log("/polutionData ", polutionData);
|
||||
}, [polutionData]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
@@ -141,69 +223,58 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
|
||||
{type !== "RNB" ? (
|
||||
<div>
|
||||
<UiTable
|
||||
headName={"연간이용수질(1분기)"}
|
||||
tableData={[]}
|
||||
headlist={rainChkgdn?.rswtDetailHeadList}
|
||||
pageSize={0}
|
||||
total={0}
|
||||
cellClick={(val, headId) => {
|
||||
cellClick(val, headId);
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{"연간이용수질 1분기"}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={polutionData[1]}
|
||||
headList={rainChkgdn?.rswtDetailHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
setChGuidData(data);
|
||||
}}
|
||||
onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
/>
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{"연간이용수질 2분기"}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={polutionData[2]}
|
||||
headList={rainChkgdn?.rswtDetailHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
setChGuidData(data);
|
||||
}}
|
||||
>
|
||||
{rswtnodeList}
|
||||
</UiTable>
|
||||
|
||||
<UiTable
|
||||
headName={"연간이용수질(2분기)"}
|
||||
tableData={[]}
|
||||
headlist={rainChkgdn?.rswtDetailHeadList}
|
||||
pageSize={0}
|
||||
total={0}
|
||||
cellClick={(val, headId) => {
|
||||
cellClick(val, headId);
|
||||
/>
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{"연간이용수질 3분기"}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={polutionData[3]}
|
||||
headList={rainChkgdn?.rswtDetailHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
setChGuidData(data);
|
||||
}}
|
||||
onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
/>
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{"연간이용수질 4분기"}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={polutionData[4]}
|
||||
headList={rainChkgdn?.rswtDetailHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
setChGuidData(data);
|
||||
}}
|
||||
>
|
||||
{rswtnodeList}
|
||||
</UiTable>
|
||||
|
||||
<UiTable
|
||||
headName={"연간이용수질(3분기)"}
|
||||
tableData={[]}
|
||||
headlist={rainChkgdn?.rswtDetailHeadList}
|
||||
pageSize={0}
|
||||
total={0}
|
||||
cellClick={(val, headId) => {
|
||||
cellClick(val, headId);
|
||||
}}
|
||||
onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}}
|
||||
>
|
||||
{rswtnodeList}
|
||||
</UiTable>
|
||||
|
||||
<UiTable
|
||||
headName={"연간이용수질(4분기)"}
|
||||
tableData={[]}
|
||||
headlist={rainChkgdn?.rswtDetailHeadList}
|
||||
pageSize={0}
|
||||
total={0}
|
||||
cellClick={(val, headId) => {
|
||||
cellClick(val, headId);
|
||||
}}
|
||||
onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
}}
|
||||
>
|
||||
{rswtnodeList}
|
||||
</UiTable>
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type {
|
||||
splRuseWaterType,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import {
|
||||
Input,
|
||||
@@ -21,18 +21,18 @@ export function GuideDetailsTable({
|
||||
type,
|
||||
setChGuidData,
|
||||
}: {
|
||||
chgRes: splRuseWaterType[];
|
||||
chgRes: any[];
|
||||
headList: TableUpperProps[];
|
||||
type: string;
|
||||
setChGuidData: (chgRes: splRuseWaterType[]) => void;
|
||||
setChGuidData: (chgRes: any[]) => void;
|
||||
}) {
|
||||
const { code, rainChkgdn } = useWrStore((state) => state);
|
||||
const [guidData, setGuidData] = useState<splRuseWaterType[]>();
|
||||
const [guidData, setGuidData] = useState<any[]>();
|
||||
|
||||
|
||||
const handleChange = (
|
||||
rowIndex: number,
|
||||
field: splRuseWaterType,
|
||||
field: any,
|
||||
value: string | number
|
||||
) => {
|
||||
if(Number(value) < 0 ||! Number(value)){
|
||||
@@ -52,7 +52,7 @@ export function GuideDetailsTable({
|
||||
})
|
||||
);
|
||||
};
|
||||
const tableBody = (chgRes: splRuseWaterType[] | []) => {
|
||||
const tableBody = (chgRes: any[] | []) => {
|
||||
return (
|
||||
<>
|
||||
{chgRes.map((data, dataIndex) => (
|
||||
@@ -62,9 +62,9 @@ export function GuideDetailsTable({
|
||||
<Input
|
||||
className={`${head.id !== "utztnUsgCd" ? "text-right" : "text-center"} text-3xl`}
|
||||
onChange={(e) =>
|
||||
handleChange(dataIndex, head.id as any, e.target.value)
|
||||
(dataIndex, head.id as any, e.target.value)
|
||||
}
|
||||
value={data[head.id as keyof splRuseWaterType] || ""}
|
||||
value={data[head.id as keyof any] || ""}
|
||||
/>
|
||||
</TableCell>
|
||||
))}
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import { chRowspanTable } from "@/components/lib/func/TableData";
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import { chRowspanTable, rswtChkTableData } from "@/components/lib/func/TableData";
|
||||
import { Table, TableBody, TableHeader } from "@common/components/ui";
|
||||
import { useCallback, useState } from "react";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
export default function RswtChkgdTable({
|
||||
detaiRswtlUpdate,
|
||||
@@ -16,7 +17,7 @@ export default function RswtChkgdTable({
|
||||
handleRswtClick?: (data: any) => void;
|
||||
deleteRswtData: (selectedIds: number[]) => void;
|
||||
}) {
|
||||
const { code, rswtChkgdn, rswtChkgdnInit } = useWrStore((state) => state);
|
||||
const { code, rswtChkgdn, rswtChkgdnInit,rswtChkPolAndGuide } = useWrStore((state) => state);
|
||||
|
||||
const [makeTableData, setMakeTableData] = useState<any[]>([]);
|
||||
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
||||
@@ -38,22 +39,94 @@ export default function RswtChkgdTable({
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
const handleCellClick = useCallback(
|
||||
(index: number, headId: string) => {
|
||||
if (
|
||||
headId === "totalSplyUswtrUtztnQnt" ||
|
||||
headId === "totalRuseFcltUtztnQnt"
|
||||
headId === "splyUswtrUtztnQnt" ||
|
||||
headId === "ruseFcltUtztnQnt"
|
||||
) {
|
||||
handleRswtClick(makeTableData[index]);
|
||||
//handleRswtClick(makeTableData[index]);
|
||||
rswtChkPolAndGuide(makeTableData[index].chkgdnPk)
|
||||
}
|
||||
},
|
||||
[makeTableData, handleRswtClick]
|
||||
);
|
||||
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 });
|
||||
return {
|
||||
...item,
|
||||
...bud[0],
|
||||
rowspan: item.rswtrDetail?.length,
|
||||
};
|
||||
});
|
||||
setMakeTableData(rswtChkData);
|
||||
}, [rswtChkgdn.rswtChkRes, code]);
|
||||
|
||||
useEffect(() => {
|
||||
detaiRswtlUpdate(upRaintDetail);
|
||||
}, [upRaintDetail]);
|
||||
|
||||
useEffect(() =>{
|
||||
if(selectedIds.length >0){
|
||||
// 삭제를 위한 데이터 삽입
|
||||
deleteRswtData(selectedIds )
|
||||
}
|
||||
},[selectedIds])
|
||||
|
||||
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user