중수도 지도점검 업데이트 해야함
This commit is contained in:
@@ -111,22 +111,6 @@ export type splRuseWaterType = {
|
||||
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 },
|
||||
@@ -149,14 +133,21 @@ 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" ,edit:true},
|
||||
{
|
||||
id: "ph",
|
||||
title: "PH",
|
||||
upName: "useQuilty",
|
||||
upSequnce: 1,
|
||||
type: "number",
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "trbt",
|
||||
title: "탁도",
|
||||
upName: "useQuilty",
|
||||
upSequnce: 2,
|
||||
type: "number",
|
||||
edit:true
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "grssClfg",
|
||||
@@ -164,7 +155,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "useQuilty",
|
||||
upSequnce: 3,
|
||||
type: "number",
|
||||
edit:true
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "etc",
|
||||
@@ -172,7 +163,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "useQuilty",
|
||||
upSequnce: 4,
|
||||
type: "number",
|
||||
edit:true
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "vltnDt",
|
||||
@@ -180,7 +171,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "feeHist",
|
||||
upSequnce: 1,
|
||||
type: "text",
|
||||
edit:true
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "vltnMttr",
|
||||
@@ -188,7 +179,7 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "feeHist",
|
||||
upSequnce: 2,
|
||||
type: "text",
|
||||
edit:true
|
||||
edit: true,
|
||||
},
|
||||
{
|
||||
id: "levyAmt",
|
||||
@@ -196,42 +187,42 @@ export const rainChkgdnHeadListExport: TableUpperProps[] = [
|
||||
upName: "feeHist",
|
||||
upSequnce: 3,
|
||||
type: "number",
|
||||
edit:true
|
||||
edit: true,
|
||||
},
|
||||
];
|
||||
|
||||
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 },
|
||||
{ id: "ruseTotal", title: "계", upName: "ruseWater", upSequnce: 1 },
|
||||
{ id: "ruse01", title: "1월", upName: "ruseWater", upSequnce: 2 , edit: true },
|
||||
{ id: "ruse02", title: "2월", upName: "ruseWater", upSequnce: 3 , edit: true },
|
||||
{ id: "ruse03", title: "3월", upName: "ruseWater", upSequnce: 4 , edit: true },
|
||||
{ id: "ruse04", title: "4월", upName: "ruseWater", upSequnce: 5 , edit: true },
|
||||
{ id: "ruse05", title: "5월", upName: "ruseWater", upSequnce: 6 , edit: true },
|
||||
{ id: "ruse06", title: "6월", upName: "ruseWater", upSequnce: 7 , edit: true },
|
||||
{ id: "ruse07", title: "7월", upName: "ruseWater", upSequnce: 8 , edit: true },
|
||||
{ id: "ruse08", title: "8월", upName: "ruseWater", upSequnce: 9 , edit: true },
|
||||
{ id: "ruse09", title: "9월", upName: "ruseWater", upSequnce: 10, edit: true },
|
||||
{ id: "ruse10", title: "10월", upName: "ruseWater", upSequnce: 11 , edit: true },
|
||||
{ id: "ruse11", title: "11월", upName: "ruseWater", upSequnce: 12 , edit: true },
|
||||
{ id: "ruse12", title: "12월", upName: "ruseWater", upSequnce: 13 , edit: true },
|
||||
];
|
||||
|
||||
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 },
|
||||
{ id: "splTotal", title: "계", upName: "splWater", upSequnce: 1},
|
||||
{ id: "spl01", title: "1월", upName: "splWater", upSequnce: 2, edit: true },
|
||||
{ id: "spl02", title: "2월", upName: "splWater", upSequnce: 3, edit: true },
|
||||
{ id: "spl03", title: "3월", upName: "splWater", upSequnce: 4, edit: true },
|
||||
{ id: "spl04", title: "4월", upName: "splWater", upSequnce: 5, edit: true },
|
||||
{ id: "spl05", title: "5월", upName: "splWater", upSequnce: 6, edit: true },
|
||||
{ id: "spl06", title: "6월", upName: "splWater", upSequnce: 7, edit: true },
|
||||
{ id: "spl07", title: "7월", upName: "splWater", upSequnce: 8, edit: true },
|
||||
{ id: "spl08", title: "8월", upName: "splWater", upSequnce: 9, edit: true },
|
||||
{ id: "spl09", title: "9월", upName: "splWater", upSequnce: 10, edit: true },
|
||||
{ id: "spl10", title: "10월", upName: "splWater", upSequnce: 11, edit: true },
|
||||
{ id: "spl11", title: "11월", upName: "splWater", upSequnce: 12, edit: true },
|
||||
{ id: "spl12", title: "12월", upName: "splWater", upSequnce: 13, edit: true },
|
||||
];
|
||||
|
||||
export const rswtDetailHeadListExport: TableUpperProps[] = [
|
||||
|
||||
@@ -2,6 +2,22 @@ import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import { z } from "zod";
|
||||
import { guideDetail, type chHeadType } from "../rainChkgdn/headList";
|
||||
|
||||
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;
|
||||
edit?:boolean
|
||||
};
|
||||
const reuseBuildingZod = z.object({
|
||||
bdstRuseFcltPk: z.number().nullish(),
|
||||
bdstInfoFk: z.number().nullish(),
|
||||
@@ -54,6 +70,7 @@ export const rswtrPolutionsZode = z.object({
|
||||
rgtr: z.string().nullish(),
|
||||
mdfcnDt: z.string().nullish(),
|
||||
mdfr: z.string().nullish(),
|
||||
edit:z.boolean().nullish()
|
||||
});
|
||||
|
||||
export const rswtChkgdZod = z.object({
|
||||
|
||||
@@ -33,7 +33,7 @@ export type rswtChkgdnState = {
|
||||
rswtHeadNm: chHeadType[];
|
||||
excelList: [typeof sheetParameter];
|
||||
rswtChkRes: rswtChkZodType[];
|
||||
rswtChkPolGuide:rswtChkZodType[];
|
||||
rswtChkPolGuide: rswtChkZodType[];
|
||||
isInit: boolean;
|
||||
};
|
||||
};
|
||||
@@ -47,7 +47,8 @@ type rswtChkgdnActions = {
|
||||
rswtChkExceDataUpload: (excelData: rswtChkZodType[]) => void;
|
||||
rswtChkDelete: (chkgdnPks: number[]) => void;
|
||||
rswtChkDetilUpdate: (rswtChk: rswtChkZodType[]) => void;
|
||||
rswtChkPolAndGuide:(chkGdnPk:number)=>void;
|
||||
rswtChkPolAndGuide: (chkGdnPk: number) => void;
|
||||
rwstUpdatePolAndGuide:(rswtChk: rswtChkZodType[]) => void;
|
||||
};
|
||||
|
||||
export type rswtChkgdnType = rswtChkgdnState & rswtChkgdnActions;
|
||||
@@ -58,7 +59,7 @@ export const rswtChkgdnStateExport: rswtChkgdnState = {
|
||||
rswtHeadNm: rswtHeadNm,
|
||||
excelList: [{ data: [[]], headerNum: 0, headerRange: "A1:V3" }],
|
||||
rswtChkRes: [],
|
||||
rswtChkPolGuide:[],
|
||||
rswtChkPolGuide: [],
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
@@ -73,7 +74,7 @@ const initFetch = async (year: string | undefined, sgg: string | undefined) => {
|
||||
return rswtChkRes;
|
||||
};
|
||||
|
||||
const makeMdfrChk = (data: rswtChkZodType[], type: string, toDo: string) => {
|
||||
const makeMdfrChk = (data: rswtChkZodType[], type: string) => {
|
||||
const chData = data.map((item) => {
|
||||
item.mdfr = TEST_UUID;
|
||||
item.rgtr = TEST_UUID;
|
||||
@@ -82,10 +83,10 @@ const makeMdfrChk = (data: rswtChkZodType[], type: string, toDo: string) => {
|
||||
item.mdfr = TEST_UUID;
|
||||
item.rgtr = TEST_UUID;
|
||||
});
|
||||
} else {
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
return item;
|
||||
}
|
||||
);
|
||||
return chData;
|
||||
};
|
||||
|
||||
@@ -161,7 +162,7 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
},
|
||||
rswtChkDetilUpdate: async (rswtChk: rswtChkZodType[]) => {
|
||||
try {
|
||||
const chData = await makeMdfrChk(rswtChk, "rain", "rainDetil");
|
||||
const chData = await makeMdfrChk(rswtChk, "rswtrDetail");
|
||||
|
||||
const res = await postFectch("/reuseChk/reuseWater", chData);
|
||||
if (res.ok) {
|
||||
@@ -204,14 +205,14 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
} catch (error) {
|
||||
ToastFormUi({ body: "삭제를 실패했습니다.. ", title: "지도점검 삭제" });
|
||||
}
|
||||
}, rswtChkPolAndGuide: async (chkGdnPk: number) => {
|
||||
},
|
||||
rswtChkPolAndGuide: async (chkGdnPk: number) => {
|
||||
try {
|
||||
const rswtChkPolGuide = await getFetch(
|
||||
"wr",
|
||||
`/reuseChk/reuseWater/${chkGdnPk}`
|
||||
);
|
||||
|
||||
|
||||
return set((state: rswtChkgdnState) => ({
|
||||
...state,
|
||||
rswtChkgdn: {
|
||||
@@ -219,7 +220,30 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
rswtChkPolGuide: rswtChkPolGuide,
|
||||
},
|
||||
}));
|
||||
} catch (error) {}
|
||||
},
|
||||
rwstUpdatePolAndGuide: async (rswtChk: rswtChkZodType[]) => {
|
||||
try {
|
||||
const chData = await makeMdfrChk(rswtChk, "rswtrDetail");
|
||||
console.log("chData" , chData)
|
||||
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("수정에 실패하였습니다.");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
@@ -15,7 +15,10 @@ import { useEffect, useState } from "react";
|
||||
import { useForm, useWatch, type UseFormReturn } from "react-hook-form";
|
||||
import { z } from "zod";
|
||||
import BdstReg from "../bdstReg/bdstReg";
|
||||
import { formatCommaNumber, handleCommaNumberChange } from "@/components/lib/func/commom";
|
||||
import {
|
||||
formatCommaNumber,
|
||||
handleCommaNumberChange,
|
||||
} from "@/components/lib/func/commom";
|
||||
|
||||
export default function RainRegForm({
|
||||
rainForm,
|
||||
@@ -24,7 +27,9 @@ export default function RainRegForm({
|
||||
rainForm: customRainBdst;
|
||||
isModal: boolean;
|
||||
}) {
|
||||
const { code, rainBdstReg, rainBdstUpdate, rain } = useWrStore((state) => state);
|
||||
const { code, rainBdstReg, rainBdstUpdate, rain } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const { rainFcltCd } = code;
|
||||
const defaultValues: z.infer<typeof rainZod> = rainZod.parse({});
|
||||
|
||||
@@ -39,43 +44,47 @@ export default function RainRegForm({
|
||||
"reuseBuilding.0.rainyObj.filtrTrtmfctYn",
|
||||
]);
|
||||
|
||||
const cleanRainData =(raw: any): z.infer<typeof rainZod> =>{
|
||||
return {
|
||||
...raw,
|
||||
frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt||null),
|
||||
archChgPrmsnDt: raw?.archChgPrmsnDt ? new Date(raw?.archChgPrmsnDt) : null,
|
||||
reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({
|
||||
...item,
|
||||
instlCmptnDt: new Date(item?.instlCmptnDt),
|
||||
operMngCd: item?.operMngCd ?? "", // null → ""
|
||||
grntchBdstCertYr: typeof item?.grntchBdstCertYr === "string"
|
||||
const cleanRainData = (raw: any): z.infer<typeof rainZod> => {
|
||||
return {
|
||||
...raw,
|
||||
frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt || null),
|
||||
archChgPrmsnDt: raw?.archChgPrmsnDt
|
||||
? new Date(raw?.archChgPrmsnDt)
|
||||
: null,
|
||||
reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({
|
||||
...item,
|
||||
instlCmptnDt: new Date(item?.instlCmptnDt),
|
||||
operMngCd: item?.operMngCd ?? "", // null → ""
|
||||
grntchBdstCertYr:
|
||||
typeof item?.grntchBdstCertYr === "string"
|
||||
? item?.grntchBdstCertYr
|
||||
: "", // null → ""
|
||||
rainObj: {
|
||||
...item?.rainObj
|
||||
}
|
||||
}))
|
||||
};
|
||||
rainObj: {
|
||||
...item?.rainObj,
|
||||
},
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (grntchBdstCertYn === "N") {
|
||||
form.setValue("reuseBuilding.0.grntchBdstCertYr", "");
|
||||
form.setValue("reuseBuilding.0.grntchBdstCertNo", "");
|
||||
form.setValue("reuseBuilding.0.grntchBdstCertGrd", "");
|
||||
} else if (instlCstSprtYn === "N") {
|
||||
form.setValue("reuseBuilding.0.instlCstSprtAmt", 0);
|
||||
} else if (filtrTrtmfctYn === "N") {
|
||||
form.setValue("reuseBuilding.0.rainyObj.filtrTrtmfctCpct", 0);
|
||||
form.setValue("reuseBuilding.0.rainyObj.filtrTrtmfctPrs", "");
|
||||
}
|
||||
|
||||
useEffect(() =>{
|
||||
if(grntchBdstCertYn ==='N'){
|
||||
form.setValue('reuseBuilding.0.grntchBdstCertYr' ,"" )
|
||||
form.setValue('reuseBuilding.0.grntchBdstCertNo' ,"" )
|
||||
form.setValue('reuseBuilding.0.grntchBdstCertGrd' ,"" )
|
||||
|
||||
}else if(instlCstSprtYn ==='N'){
|
||||
form.setValue('reuseBuilding.0.instlCstSprtAmt' ,0 )
|
||||
}else if(filtrTrtmfctYn ==='N'){
|
||||
form.setValue('reuseBuilding.0.rainyObj.filtrTrtmfctCpct' ,0 )
|
||||
form.setValue('reuseBuilding.0.rainyObj.filtrTrtmfctPrs' ,"" )
|
||||
}
|
||||
},[grntchBdstCertYn,instlCstSprtYn ,filtrTrtmfctYn])
|
||||
|
||||
}, [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctYn]);
|
||||
|
||||
// form 값이 변경될 때마다 로그 출력
|
||||
useEffect(() => {
|
||||
const subscription = form.watch((value) => {});
|
||||
const subscription = form.watch((value) => {
|
||||
});
|
||||
|
||||
|
||||
return () => subscription.unsubscribe();
|
||||
}, [form]);
|
||||
|
||||
@@ -83,26 +92,19 @@ useEffect(() =>{
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
|
||||
|
||||
|
||||
|
||||
const onSubmit =(values: z.infer<typeof rainZod>)=> {
|
||||
const onSubmit = (values: z.infer<typeof rainZod>) => {
|
||||
if (isModal) {
|
||||
rainBdstReg(values ,'41');
|
||||
rainBdstReg(values, "41");
|
||||
} else {
|
||||
rainBdstUpdate(values, '41');
|
||||
}
|
||||
}
|
||||
|
||||
rainBdstUpdate(values, "41");
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if(rainZod)
|
||||
form.reset( cleanRainData(rainForm))
|
||||
if (rainZod) form.reset(cleanRainData(rainForm));
|
||||
}, [rainForm]);
|
||||
|
||||
|
||||
|
||||
const inputClass = '!text-lg'
|
||||
const inputClass = "!text-lg";
|
||||
|
||||
return (
|
||||
<div className="">
|
||||
@@ -137,7 +139,7 @@ useEffect(() =>{
|
||||
name="reuseBuilding.0.instlCmptnDt"
|
||||
render={({ field }) => (
|
||||
<FormUi label="설치완료일">
|
||||
<DatePicker
|
||||
<DatePicker
|
||||
mode="single"
|
||||
field={{
|
||||
value:
|
||||
@@ -146,7 +148,7 @@ useEffect(() =>{
|
||||
: new Date(), // Provide a default Date value
|
||||
onChange: (date) => field.onChange(date),
|
||||
}}
|
||||
selectClass={'w-full'}
|
||||
selectClass={"w-full"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -160,11 +162,13 @@ useEffect(() =>{
|
||||
render={({ field }) => (
|
||||
<FormUi label="설치비">
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type="text"
|
||||
onChange={(e) => {handleCommaNumberChange(e, field.onChange) }}
|
||||
value={formatCommaNumber(field.value)}
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(field.value)}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -193,7 +197,6 @@ useEffect(() =>{
|
||||
selectArray={rainFcltCd}
|
||||
onSelectValue={field.onChange}
|
||||
value={field.value ?? rainFcltCd[0]?.val}
|
||||
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -209,7 +212,9 @@ useEffect(() =>{
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type="text"
|
||||
onChange={(e) => {handleCommaNumberChange(e, field.onChange) }}
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(field.value)}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -250,10 +255,11 @@ useEffect(() =>{
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type="text"
|
||||
onChange={(e) => {handleCommaNumberChange(e, field.onChange) }}
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={filtrTrtmfctYn!=='Y'}
|
||||
|
||||
readOnly={filtrTrtmfctYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -268,10 +274,10 @@ useEffect(() =>{
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type=""
|
||||
value={field.value ?? ""}
|
||||
type=""
|
||||
value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
readOnly={filtrTrtmfctYn!=='Y'}
|
||||
readOnly={filtrTrtmfctYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -300,7 +306,6 @@ useEffect(() =>{
|
||||
selectArray={code.yn}
|
||||
onSelectValue={field.onChange}
|
||||
value={field.value ?? code.yn[0]?.val}
|
||||
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -316,9 +321,11 @@ useEffect(() =>{
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type="text"
|
||||
onChange={(e) => {handleCommaNumberChange(e, field.onChange) }}
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={instlCstSprtYn !== 'Y'}
|
||||
readOnly={instlCstSprtYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -354,10 +361,14 @@ useEffect(() =>{
|
||||
name="reuseBuilding.0.grntchBdstCertYr"
|
||||
render={({ field }) => (
|
||||
<FormUi label="인증년도">
|
||||
<Input className={selectClass} placeholder="2024" type="" value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
|
||||
readOnly={grntchBdstCertYn!=='Y'}/>
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="2024"
|
||||
type=""
|
||||
value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
readOnly={grntchBdstCertYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
@@ -374,7 +385,7 @@ useEffect(() =>{
|
||||
type=""
|
||||
value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
readOnly={grntchBdstCertYn!=='Y'}
|
||||
readOnly={grntchBdstCertYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -386,10 +397,14 @@ useEffect(() =>{
|
||||
name="reuseBuilding.0.grntchBdstCertGrd"
|
||||
render={({ field }) => (
|
||||
<FormUi label="인증등급">
|
||||
<Input className={selectClass} placeholder="A" type="" value={field.value ?? ""}
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="A"
|
||||
type=""
|
||||
value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
readOnly={grntchBdstCertYn!=='Y'}
|
||||
/>
|
||||
readOnly={grntchBdstCertYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
|
||||
@@ -1,27 +1,33 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { ScrollArea, Title, UiTable } from "@common/business_components/ui";
|
||||
import { ScrollArea, Title } from "@common/business_components/ui";
|
||||
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 {
|
||||
polutionType,
|
||||
splRuseWaterType,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList";
|
||||
import type { z } from "zod";
|
||||
import React from "react";
|
||||
|
||||
export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
const { rainChkgdn, rainChkDetilUpdate, rainChkGuidUpdate } = useWrStore(
|
||||
const { rainChkgdn, rainChkGuidUpdate ,rwstUpdatePolAndGuide } = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const [guidData, setGuidData] = useState<splRuseWaterType[]>();
|
||||
|
||||
const [polutionData, setPolutionData] = useState<Record<string, any[]>>({
|
||||
"1": [],
|
||||
"2": [],
|
||||
"3": [],
|
||||
"4": [],
|
||||
"1": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
"2": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
"3": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
"4": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
});
|
||||
const [upPolutionData, setUpPolutionData] = useState<Record<string, any[]>>({
|
||||
"1": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
"2": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
"3": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
"4": [] as z.infer<typeof rswtrPolutionsZode>[],
|
||||
});
|
||||
|
||||
|
||||
const rswtnodeList = headMakeprfmnc(
|
||||
rainChkgdn?.rswtDetailHeadList,
|
||||
@@ -80,7 +86,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
"3": [],
|
||||
"4": [],
|
||||
};
|
||||
obj.rswtrPollution.forEach((item: any) => {
|
||||
obj.rswtrPollution.forEach((item: z.infer<typeof rswtrPolutionsZode>) => {
|
||||
const nodeKey = String(item.node);
|
||||
resultPolution[nodeKey]?.push(item);
|
||||
});
|
||||
@@ -106,6 +112,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
|
||||
const average = {
|
||||
utztnUsgCd: "평균",
|
||||
edit: false,
|
||||
grssClfgUswtr: total.grssClfgUswtr / onlyData.length,
|
||||
combResdch: total.combResdch / onlyData.length,
|
||||
trbt: total.trbt / onlyData.length,
|
||||
@@ -128,7 +135,6 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
}
|
||||
}, [obj]);
|
||||
|
||||
const cellClick = (val: number | undefined, headId: string) => {};
|
||||
|
||||
const setChGuidData = (data: splRuseWaterType[]) => {
|
||||
if (data.length > 0) {
|
||||
@@ -136,7 +142,7 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
}
|
||||
};
|
||||
|
||||
const guidDataUpdate = () => {
|
||||
const allDataUpdate = () => {
|
||||
const realGuideDetail = obj.guideDetails;
|
||||
|
||||
if (updateData === undefined || updateData.length === 0) return;
|
||||
@@ -167,18 +173,37 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
});
|
||||
obj.guideDetails = realGuideDetail;
|
||||
|
||||
rainChk.map((item: any) => {
|
||||
if (item.chkgdnPk === obj.chkgdnPk) {
|
||||
item.guideDetails = realGuideDetail;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
rainChkGuidUpdate(obj);
|
||||
if(type ==='RNB'){
|
||||
|
||||
rainChkGuidUpdate(obj);
|
||||
}else{
|
||||
|
||||
|
||||
const polution = Object.values(upPolutionData).flat() ;
|
||||
obj.rswtrPollution = polution;
|
||||
|
||||
console.log("obj ", obj)
|
||||
rwstUpdatePolAndGuide([obj]);
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log("/polutionData ", polutionData);
|
||||
}, [polutionData]);
|
||||
|
||||
|
||||
const getPolutionData = (data: z.infer<typeof rswtrPolutionsZode>[]) => {
|
||||
console.log("data " ,data)
|
||||
const getNode = Number(data[0]?.node)
|
||||
setUpPolutionData((prevPolutionData) => ({
|
||||
...prevPolutionData,
|
||||
[getNode]: data,
|
||||
}));
|
||||
|
||||
};
|
||||
|
||||
useEffect(() =>{
|
||||
console.log('upPolutionData ', upPolutionData)
|
||||
},[upPolutionData])
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -197,23 +222,32 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
{"○" + "" + `(${"11"})`}
|
||||
</h3>
|
||||
|
||||
<Button className="" onClick={guidDataUpdate}>
|
||||
<Button className="" onClick={allDataUpdate}>
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<ScrollArea className="h-[60vh]">
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{`연간보급수이용량`}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={guidData}
|
||||
chgRes={guidData || []}
|
||||
headList={ruseHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
setChGuidData(data);
|
||||
}}
|
||||
/>
|
||||
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{type === "RNB" ? `연간빗물 이용량` : "연간중수도 이용량"}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={guidData}
|
||||
chgRes={guidData || []}
|
||||
headList={splHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
@@ -221,60 +255,29 @@ export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
}}
|
||||
/>
|
||||
|
||||
{type !== "RNB" ? (
|
||||
<div>
|
||||
<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);
|
||||
}}
|
||||
/>
|
||||
<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);
|
||||
}}
|
||||
/>
|
||||
<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);
|
||||
}}
|
||||
/>
|
||||
<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);
|
||||
}}
|
||||
/>
|
||||
{type !== "RNB" && polutionData !== undefined ? (
|
||||
<div key={"polutionData"}>
|
||||
{Object.entries(polutionData).map(([key, value]) => {
|
||||
const keyNum = Number(key);
|
||||
|
||||
return (
|
||||
<React.Fragment key={`polutionData_fragment_${keyNum}`}>
|
||||
<div className="card-header">
|
||||
<h3 className="text-2xl font-medium text-label">
|
||||
{`연간이용수질 ${keyNum}분기`}
|
||||
</h3>
|
||||
</div>
|
||||
<GuideDetailsTable
|
||||
chgRes={value}
|
||||
headList={rainChkgdn?.rswtDetailHeadList}
|
||||
type={""}
|
||||
setChGuidData={(data) => {
|
||||
getPolutionData(data);
|
||||
}}
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<></>
|
||||
|
||||
@@ -3,7 +3,6 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"
|
||||
import { useWrStore } from "@/app/store";
|
||||
import type {
|
||||
} 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,
|
||||
@@ -13,7 +12,7 @@ import {
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from "@common/components/ui";
|
||||
import { use, useEffect, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function GuideDetailsTable({
|
||||
chgRes,
|
||||
@@ -22,7 +21,7 @@ export function GuideDetailsTable({
|
||||
setChGuidData,
|
||||
}: {
|
||||
chgRes: any[];
|
||||
headList: TableUpperProps[];
|
||||
headList: TableUpperProps[];
|
||||
type: string;
|
||||
setChGuidData: (chgRes: any[]) => void;
|
||||
}) {
|
||||
@@ -58,14 +57,25 @@ export function GuideDetailsTable({
|
||||
{chgRes.map((data, dataIndex) => (
|
||||
<TableRow key={dataIndex + "row"}>
|
||||
{headList.map((head, headIndex) => (
|
||||
<TableCell key={head.id + headIndex}>
|
||||
<TableCell key={head.id + headIndex} className="w-36" >
|
||||
{head.edit ===true && data.edit !==false?
|
||||
<Input
|
||||
className={`${head.id !== "utztnUsgCd" ? "text-right" : "text-center"} text-3xl`}
|
||||
className={`${head.id !== "utztnUsgCd" ? "text-right" : "text-center"} !text-2xl h-10 w-full`}
|
||||
onChange={(e) =>
|
||||
(dataIndex, head.id as any, e.target.value)
|
||||
handleChange(dataIndex, head.id, e.target.value)
|
||||
}
|
||||
value={data[head.id as keyof any] || ""}
|
||||
/>
|
||||
/> : (
|
||||
<div
|
||||
className={`
|
||||
${head.id !== "utztnUsgCd" ? "text-right" : "text-center"}
|
||||
!text-2xl w-full h-10
|
||||
`}
|
||||
>
|
||||
{data[head.id as keyof any] || ""}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</TableCell>
|
||||
))}
|
||||
</TableRow>
|
||||
|
||||
Reference in New Issue
Block a user