결함대장 수정중
This commit is contained in:
@@ -23,7 +23,7 @@ import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
|
||||
import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
|
||||
|
||||
export default function Home() {
|
||||
const { code, htdfl, initHtdfl, getHtdflBdstData } = useWrStore(
|
||||
const { code, htdfl, initHtdflReg, getHtdflBdstData ,htdflNmSearch} = useWrStore(
|
||||
(state) => state
|
||||
);
|
||||
const [searchTxt, setSearchTxt] = useState("");
|
||||
@@ -42,18 +42,27 @@ export default function Home() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!htdfl.isInit) {
|
||||
initHtdflReg('0')
|
||||
}
|
||||
}, [htdfl.isInit, initHtdfl]);
|
||||
}, [htdfl.isInit, initHtdflReg]);
|
||||
useEffect(() => {
|
||||
if (code.sggCd.length > 0) {
|
||||
if (htdflRes&&htdflRes.length>0) {
|
||||
|
||||
console.log('htdflRes ', htdflRes)
|
||||
const htdflData = tableData(htdflRes, { code }).map(
|
||||
(item: customHtdflBdst) => {
|
||||
let archArea = item?.archArea.split('.')[0]!=='-1'?item?.archArea.split('.')[0]:'확인불가'
|
||||
|
||||
return {
|
||||
...item,
|
||||
archArea:archArea
|
||||
|
||||
};
|
||||
}
|
||||
);
|
||||
setbdstTable(htdflData);
|
||||
}else{
|
||||
setbdstTable([]);
|
||||
}
|
||||
}, [code, htdflRes]);
|
||||
|
||||
@@ -104,7 +113,15 @@ export default function Home() {
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={() => {
|
||||
initHtdfl(searchTxt || "");
|
||||
console.log(' 조회가 없어11')
|
||||
if(searchTxt&&searchTxt.length>0){
|
||||
htdflNmSearch(String(0),searchTxt)
|
||||
}else{
|
||||
|
||||
console.log(' 조회가 없어')
|
||||
initHtdflReg(String(0) );
|
||||
|
||||
}
|
||||
}}
|
||||
>
|
||||
조회
|
||||
|
||||
@@ -51,8 +51,12 @@ export default function Home() {
|
||||
if (code.sggCd.length > 0) {
|
||||
const rainData = tableData(rainRes, { code }).map(
|
||||
(item: customRainBdst) => {
|
||||
|
||||
let archArea = item?.archArea.split('.')[0]!=='-1'?item?.archArea.split('.')[0]:'확인불가'
|
||||
|
||||
return {
|
||||
...item,
|
||||
archArea:archArea,
|
||||
bdstChgYn: item.chgBuilding.length > 0 ? "Y" : "N",
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
import ListDiv from "@common/business_components/ui/list_div";
|
||||
import { Button } from "@common/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
|
||||
export default function Home() {
|
||||
const { code, rswt, initRswt, rswtBdstSearch, getRswtBdstData } = useWrStore(
|
||||
@@ -45,8 +46,12 @@ export default function Home() {
|
||||
if (code.sggCd.length > 0 && rswtRes?.length > 0) {
|
||||
const rswtData = tableData(rswtRes, { code })?.map(
|
||||
(item: customRswtBdst) => {
|
||||
|
||||
let archArea = item?.archArea.split('.')[0]!=='-1'?item?.archArea.split('.')[0]:'확인불가'
|
||||
|
||||
return {
|
||||
...item,
|
||||
archArea:archArea,
|
||||
bdstChgYn: item.chgBuilding[0]?.bdstChgNm != null ? "Y" : "N",
|
||||
bdstUsgCd: item.reuseBuilding[0]?.bdstUsgCd,
|
||||
};
|
||||
@@ -168,7 +173,8 @@ export default function Home() {
|
||||
setBdstChgProps({ ...bdstChgProps, isOpen: open });
|
||||
}}
|
||||
/>
|
||||
</ContentsDiv>
|
||||
<Toaster position="top-center" />
|
||||
</ContentsDiv>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
year: string,
|
||||
sggCd: string
|
||||
) => {
|
||||
set((state: rainChkgdnType) => ({ rainChkgdn: { ...state.rainChkgdn, isLoading: true } }));
|
||||
// set((state: rainChkgdnType) => ({ rainChkgdn: { ...state.rainChkgdn, isLoading: true } }));
|
||||
try {
|
||||
const rainChkRes = await initFetch(pageNo, cnt, year, sggCd);
|
||||
set((state: rainChkgdnState) => ({
|
||||
@@ -214,17 +214,17 @@ export const rainChkgdnActionsExport: (set: any) => rainChkgdnActions = (
|
||||
...state.rainChkgdn,
|
||||
rainChk: rainChkRes.data,
|
||||
rainChkCount: rainChkRes.count,
|
||||
isInit: true, // 무한 루프 방지를 위해 isInit을 true로 설정
|
||||
isInit: false, // 무한 루프 방지를 위해 isInit을 true로 설정
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
// 에러가 발생하더라도 무한 루프에 빠지지 않도록 isInit을 true로 설정합니다.
|
||||
set((state: rainChkgdnType) => ({
|
||||
rainChkgdn: { ...state.rainChkgdn, isInit: true },
|
||||
}));
|
||||
// set((state: rainChkgdnType) => ({
|
||||
// rainChkgdn: { ...state.rainChkgdn, isInit: true },
|
||||
// }));
|
||||
} finally {
|
||||
set((state: rainChkgdnType) => ({ rainChkgdn: { ...state.rainChkgdn, isLoading: false } }));
|
||||
// set((state: rainChkgdnType) => ({ rainChkgdn: { ...state.rainChkgdn, isLoading: false } }));
|
||||
}
|
||||
},
|
||||
rainChkNmSearch: async (
|
||||
|
||||
@@ -183,7 +183,6 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
year: string,
|
||||
sggCd: string
|
||||
) => {
|
||||
set((state: rswtChkgdnType) => ({ rswtChkgdn: { ...state.rswtChkgdn, isLoading: true } }));
|
||||
try {
|
||||
const rswtChkRes = await initFetch(pageNo, cnt, year, sggCd);
|
||||
|
||||
@@ -198,11 +197,7 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
}));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
set((state: rswtChkgdnType) => ({
|
||||
rswtChkgdn: { ...state.rswtChkgdn, isInit: true },
|
||||
}));
|
||||
} finally {
|
||||
set((state: rswtChkgdnType) => ({ rswtChkgdn: { ...state.rswtChkgdn, isLoading: false } }));
|
||||
}
|
||||
},
|
||||
rswtChkNmSearch: async (
|
||||
@@ -230,7 +225,6 @@ export const rswtChkgdnActionsExport: (set: any) => rswtChkgdnActions = (
|
||||
...state.rswtChkgdn,
|
||||
rswtChkRes: rswtChkRes.data,
|
||||
rswtChkCount: rswtChkRes.count,
|
||||
isInit: false,
|
||||
},
|
||||
}));
|
||||
} catch (error) {
|
||||
|
||||
@@ -76,8 +76,7 @@ export const hdtflZod = z.object({
|
||||
.date()
|
||||
.default(() => new Date())
|
||||
.nullish(),
|
||||
archArea: z.number().default(0),
|
||||
archChgArea: z.number().nullish().default(0),
|
||||
archArea: z.string().default(''),
|
||||
rgtr: z.string().nullish().default(null),
|
||||
mdfr: z.string().nullish().default(null),
|
||||
reuseBuilding: z
|
||||
@@ -99,7 +98,8 @@ export type htdflFacState = {
|
||||
};
|
||||
};
|
||||
type htdflFacSActions = {
|
||||
initHtdfl: (code: string) => void;
|
||||
initHtdflReg: (code: string) => void;
|
||||
htdflNmSearch: (code: string, fcltNm:string) => void;
|
||||
htdflBdstUpdate: (data: customHtdflBdst, code: string | number) => void;
|
||||
htdflBdstReg: (data: customHtdflBdst, code: string | number) => void;
|
||||
getHtdflBdstData: (pageNation: number, code: string | number) => void;
|
||||
@@ -142,9 +142,11 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
initHtdfl: async (code: string) => {
|
||||
initHtdflReg: async (code: string) => {
|
||||
try {
|
||||
const htdflRes = await initFetch(code);
|
||||
|
||||
console.log('htdflRes ', htdflRes)
|
||||
set((state: htdflFacState) => {
|
||||
return {
|
||||
...state,
|
||||
@@ -162,10 +164,8 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
htdflBdstUpdate: async (data: customHtdflBdst, code: string | number) => {
|
||||
try {
|
||||
|
||||
console.log('data ', data)
|
||||
|
||||
const chData = await makeMdfr(data);
|
||||
console.log('chData ', chData)
|
||||
|
||||
const res = await putFectch("/drain/facility", chData);
|
||||
if (res.ok) {
|
||||
@@ -208,6 +208,22 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
toast.error("온배수 건축물 등록 오류입니다..");
|
||||
|
||||
}
|
||||
}
|
||||
},htdflNmSearch :async(code:string | number, fcltNm:string) =>{
|
||||
try {
|
||||
const htdflRes = await getFetch("wr", `/drain/facilityList/1/20/${code}/${fcltNm}`);
|
||||
set((state: htdflFacState) => {
|
||||
return {
|
||||
...state,
|
||||
htdfl: {
|
||||
...state.htdfl,
|
||||
htdflRes: htdflRes,
|
||||
isInit: false,
|
||||
},
|
||||
};
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ export const rainZod = z.object({
|
||||
bdstNm: z.string().default(""),
|
||||
frstArchPrmsnDt: z.date().default(() => new Date()),
|
||||
archChgPrmsnDt: z.coerce.date().nullish().default(null),
|
||||
archArea: z.number().default(0),
|
||||
archArea: z.string().default(''),
|
||||
archChgArea: z.number().default(0),
|
||||
rgtr:z.string().nullish(),
|
||||
mdfr:z.string().nullish(),
|
||||
|
||||
@@ -25,9 +25,9 @@ export const baseReuseBuildingSchema = z.object({
|
||||
{
|
||||
message: validationMessages.yearFormat,
|
||||
}
|
||||
),
|
||||
grntchBdstCertNo: z.string().default(""),
|
||||
grntchBdstCertGrd: z.string().default(""),
|
||||
).nullish(),
|
||||
grntchBdstCertNo: z.string().default("").nullish(),
|
||||
grntchBdstCertGrd: z.string().default("").nullish(),
|
||||
crgRdctYn: z.string().default("N").nullish(), /// 안쓰는 값
|
||||
crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
|
||||
crgRdctAmt: z.number().default(0), // 안쓰는 값
|
||||
|
||||
@@ -5,11 +5,12 @@ import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import { z } from "zod";
|
||||
import { baseReuseBuildingSchema, chgBuildingSchema, validationMessages } from "../rainReg/type";
|
||||
import { makeMdfr, makeRstr } from "../bdstReg";
|
||||
import toast from "react-hot-toast";
|
||||
|
||||
const rswtrObjSchema = z.object({
|
||||
bdstRuseFcltFk: z.number().nullish(),
|
||||
wtrUsqty: z.number({ required_error: validationMessages.required("물사용량(m³)") }).positive({ message: validationMessages.required("물사용량(m³)") }),
|
||||
oblgTrgtWtrUsqty: z.number().nullish().default(0),
|
||||
// wtrUsqty: z.number({ required_error: validationMessages.required("물사용량(m³)") }).positive({ message: validationMessages.required("물사용량(m³)") }),
|
||||
//oblgTrgtWtrUsqty: z.number().nullish().default(0),
|
||||
orgwtKndCd: z.string({ required_error: validationMessages.requiredSelect("원수 종류") }).min(1, { message: validationMessages.requiredSelect("원수 종류") }),
|
||||
filtrTrtmfctCpct: z.number({ required_error: validationMessages.required("처리시설 용량") }).positive({ message: validationMessages.required("처리시설 용량") }),
|
||||
filtrTrtmfctProcs: z.string({ required_error: validationMessages.required("주요처리공정") }).min(1, { message: validationMessages.required("주요처리공정") }),
|
||||
@@ -36,8 +37,7 @@ export const rswtZod = z.object({
|
||||
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),
|
||||
archArea: z.string().default(''),
|
||||
rgtr: z.string().nullish().default(null),
|
||||
mdfr: z.string().nullish().default(null),
|
||||
bdstUsgText: z.string().default(""),
|
||||
@@ -152,8 +152,8 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
try {
|
||||
const chData = await makeMdfr(data);
|
||||
const res = await putFectch("/reuseFc/waterreuseFc", chData);
|
||||
if (res.ok) {
|
||||
alert("등록이 완료되었습니다.");
|
||||
if (res.status === 200) {
|
||||
toast.success("중수도 시설 수정이 완료되었습니다.");
|
||||
const rswtRes = await initFetch(code);
|
||||
set((state: rswtFacState) => ({
|
||||
...state,
|
||||
@@ -165,10 +165,8 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
}));
|
||||
}
|
||||
} catch (errorUpdate) {
|
||||
alert(
|
||||
"업데이트 오류입니다. " +
|
||||
(errorUpdate instanceof Error ? errorUpdate.message : "")
|
||||
);
|
||||
toast.error("중수도 시설 수정 오류입니다.");
|
||||
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
@@ -193,11 +191,11 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
})
|
||||
.then((chch: any) => {
|
||||
if (chch.ok) {
|
||||
alert("등록이 완료되었습니다.");
|
||||
toast.success("중수도 시설이 등록이 되었습니다.");
|
||||
}
|
||||
});
|
||||
} else {
|
||||
alert("등록이 완료되었습니다.");
|
||||
toast.success("중수도 시설이 등록이 되었습니다.");
|
||||
}
|
||||
}
|
||||
const rainRes = await initFetch(code);
|
||||
@@ -211,7 +209,7 @@ export const rswtFacActionsExport: (set: any) => rswtFacSActions = (
|
||||
}));
|
||||
} catch (e) {
|
||||
console.log("e", e);
|
||||
alert("등록 오류입니다.");
|
||||
toast.success("중수도 시설이 등록 오류입니다.");
|
||||
} finally {
|
||||
}
|
||||
},
|
||||
|
||||
@@ -89,7 +89,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1 className={formH1Class}>건축물 기본 정보</h1>
|
||||
<h1 className={formH1Class}> { type !== "HTB"?"건축물 기본 정보": '발전소 기본 정보'}</h1>
|
||||
<div className="grid grid-cols-6 gap-2 mt-4">
|
||||
<div className="col-span-3">
|
||||
<FormField
|
||||
@@ -140,10 +140,10 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
control={form.control}
|
||||
name="bdstNm"
|
||||
render={({ field }) => (
|
||||
<FormUi label="건축물명">
|
||||
<FormUi label={ type !== "HTB"?"건축물명": '발전소명'}>
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="건축물 명 입력하세요"
|
||||
placeholder= {type !== "HTB"?"건축물 명 입력하세요":'발전소명 입력하세요' }
|
||||
type="text"
|
||||
{...field}
|
||||
/>
|
||||
@@ -156,7 +156,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
control={form.control}
|
||||
name="daddr"
|
||||
render={({ field }) => (
|
||||
<FormUi label="건축물 주소">
|
||||
<FormUi label= { type !== "HTB"?"건축물 주소": '발전소 주소'} >
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="위치를 입력해주세요"
|
||||
@@ -173,7 +173,7 @@ export default function BdstReg({ form, type }: { form: any; type?: string }) {
|
||||
control={form.control}
|
||||
name="frstArchPrmsnDt"
|
||||
render={({ field }) => (
|
||||
<FormUi label="최초건축허가일">
|
||||
<FormUi label= { type !== "HTB"?"최초건축허가일": '준공년도'} >
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
field={{
|
||||
|
||||
@@ -54,6 +54,7 @@ export default function RainRegForm({
|
||||
raw?.reuseBuilding && raw.reuseBuilding.length > 0
|
||||
? raw.reuseBuilding
|
||||
: [{}];
|
||||
|
||||
return {
|
||||
...raw,
|
||||
frstArchPrmsnDt: raw?.frstArchPrmsnDt
|
||||
|
||||
@@ -59,10 +59,16 @@ export default function RswtrRegForm({
|
||||
rswtBdstReg(values, "41");
|
||||
if (setIsModal) setIsModal(false);
|
||||
} else {
|
||||
|
||||
|
||||
rswtBdstUpdate(values, "41");
|
||||
}
|
||||
};
|
||||
const cleanRswtData = (raw: any): z.infer<typeof rswtZod> => {
|
||||
|
||||
const filtrTrtmfctCpct = form.watch('reuseBuilding.0.filtrTrtmfctCpct')
|
||||
const cleanRswtData = (raw: any): z.infer<typeof rswtZod> => {
|
||||
|
||||
console.log('raw ', raw)
|
||||
return {
|
||||
...raw,
|
||||
frstArchPrmsnDt: raw?.frstArchPrmsnDt
|
||||
@@ -82,11 +88,17 @@ export default function RswtrRegForm({
|
||||
rswtrObj: {
|
||||
...item?.rswtrObj,
|
||||
filtrTrtmfctYn: item?.rainyObj?.filtrTrtmfctYn ?? "Y",
|
||||
filtrTrtmfctCpct:item.rswtrObj.filtrTrtmfctCpct || 0,
|
||||
filtrTrtmfctProcs:item.rswtrObj.filtrTrtmfctProcs||code.rswtPrscCdMthdCd[0]?.val,
|
||||
orgwtKndCd:item?.rswtrObj.orgwtKndCd || code.orgwtKndCd[0]?.val ,
|
||||
},
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() =>{
|
||||
console.log(' formform ', form.watch())
|
||||
},[form.formState])
|
||||
useEffect(() => {
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
@@ -253,7 +265,7 @@ export default function RswtrRegForm({
|
||||
selectClass={selectClass}
|
||||
selectArray={code.orgwtKndCd}
|
||||
onSelectValue={readonly ? () => {} : field.onChange}
|
||||
value={field.value ?? code.orgwtKndCd[0]?.val}
|
||||
value={field.value || code.orgwtKndCd[0]?.val}
|
||||
readOnly={readonly}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -272,7 +284,7 @@ export default function RswtrRegForm({
|
||||
label={""}
|
||||
selectArray={code.rswtPrscCdMthdCd}
|
||||
onSelectValue={readonly ? () => {} : field.onChange}
|
||||
value={field.value ?? code.rswtPrscCdMthdCd[0]?.val}
|
||||
value={field.value || code.rswtPrscCdMthdCd[0]?.val}
|
||||
readOnly={readonly}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -433,9 +445,6 @@ export default function RswtrRegForm({
|
||||
}
|
||||
}}
|
||||
disabled={grntchBdstCertYn !== "Y"}
|
||||
|
||||
|
||||
|
||||
/>
|
||||
</FormUi>
|
||||
)}}
|
||||
|
||||
Reference in New Issue
Block a user