온배수 완료
This commit is contained in:
@@ -21,9 +21,10 @@ import type { chgBuilding } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
|
||||
import BdstChgModal from "@/components/ui/modal/fcltReg/bdstChgModal/bdstChgModal";
|
||||
import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
|
||||
import { BdstReg } from "@/components/ui/modal/fcltReg/bdstRegModal/bdstRegModal";
|
||||
import { Toaster } from "react-hot-toast";
|
||||
|
||||
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 +43,27 @@ export default function Home() {
|
||||
|
||||
useEffect(() => {
|
||||
if (!htdfl.isInit) {
|
||||
initHtdflReg('41')
|
||||
}
|
||||
}, [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]);
|
||||
|
||||
@@ -79,7 +89,7 @@ export default function Home() {
|
||||
// setBdstChgProps({ isOpen: true, chgBuilding: chgBuilding });
|
||||
// };
|
||||
useEffect(() => {
|
||||
getHtdflBdstData(pageNation, "0");
|
||||
getHtdflBdstData(pageNation, "41");
|
||||
}, [pageNation]);
|
||||
|
||||
return (
|
||||
@@ -104,7 +114,12 @@ export default function Home() {
|
||||
<Button
|
||||
size={"sm"}
|
||||
onClick={() => {
|
||||
initHtdfl(searchTxt || "");
|
||||
if(searchTxt&&searchTxt.length>0){
|
||||
htdflNmSearch(String(41),searchTxt)
|
||||
}else{
|
||||
initHtdflReg(String(41) );
|
||||
|
||||
}
|
||||
}}
|
||||
>
|
||||
조회
|
||||
@@ -160,7 +175,8 @@ export default function Home() {
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* <UiModal
|
||||
<Toaster position="top-center" />
|
||||
{/* <UiModal
|
||||
bodyClass={""}
|
||||
open={bdstChgProps.isOpen}
|
||||
body={
|
||||
|
||||
@@ -76,7 +76,7 @@ export const hdtflZod = z.object({
|
||||
.date()
|
||||
.default(() => new Date())
|
||||
.nullish(),
|
||||
archArea: z.number().default(0),
|
||||
archArea: z.string().default(''),
|
||||
archChgArea: z.number().nullish().default(0),
|
||||
rgtr: z.string().nullish().default(null),
|
||||
mdfr: z.string().nullish().default(null),
|
||||
@@ -99,7 +99,8 @@ export type htdflFacState = {
|
||||
};
|
||||
};
|
||||
type htdflFacSActions = {
|
||||
initHtdfl: (code: string) => void;
|
||||
initHtdflReg: (code: string) => void;
|
||||
htdflNmSearch: (code: string | number, fcltNm:string) => void;
|
||||
htdflBdstUpdate: (data: customHtdflBdst, code: string | number) => void;
|
||||
htdflBdstReg: (data: customHtdflBdst, code: string | number) => void;
|
||||
getHtdflBdstData: (pageNation: number, code: string | number) => void;
|
||||
@@ -116,8 +117,16 @@ export const htdflFacStateExport: htdflFacState = {
|
||||
},
|
||||
};
|
||||
|
||||
const initFetch = async (code: string | number) => {
|
||||
const rswtRes = await getFetch("wr", `/drain/facilityList/1/20/${code}`);
|
||||
const initFetch = async (code: string) => {
|
||||
|
||||
|
||||
console.log(' initFetch code ', code)
|
||||
let url = `/drain/facilityList/1/20`
|
||||
|
||||
url+=`/${code}`
|
||||
|
||||
|
||||
const rswtRes = await getFetch("wr", url);
|
||||
return rswtRes;
|
||||
};
|
||||
export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
@@ -142,9 +151,9 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
initHtdfl: async (code: string) => {
|
||||
initHtdflReg: async (code: string) => {
|
||||
try {
|
||||
const htdflRes = await initFetch(code);
|
||||
const htdflRes = await initFetch( String(code));
|
||||
set((state: htdflFacState) => {
|
||||
return {
|
||||
...state,
|
||||
@@ -162,17 +171,18 @@ 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) {
|
||||
|
||||
if (res.status) {
|
||||
toast.success("온배수 건축물 수정이 완료되었습니다.");
|
||||
}
|
||||
|
||||
const htdflRes = await initFetch(code);
|
||||
const htdflRes = await getFetch(
|
||||
"wr",
|
||||
`/drain/facilityList/1/20/${code}`
|
||||
);
|
||||
set((state: htdflFacState) => ({
|
||||
...state,
|
||||
htdfl: {
|
||||
@@ -195,7 +205,7 @@ export const htdflFacActionsExport: (set: any) => htdflFacSActions = (
|
||||
if (res.status ===200) {
|
||||
toast.success("온배수 건축물 등록이 완료되었습니다.");
|
||||
}
|
||||
const htdflRes = await initFetch(code);
|
||||
const htdflRes = await initFetch(String(code));
|
||||
set((state: htdflFacState) => ({
|
||||
...state,
|
||||
htdfl: {
|
||||
@@ -208,6 +218,23 @@ 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);
|
||||
}
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ import { makeMdfr, makeRstr } from "../bdstReg";
|
||||
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("처리시설 용량") }),
|
||||
filtrTrtmfctCpct: z.number({ required_error: validationMessages.required("처리시설 용량") }),
|
||||
filtrTrtmfctProcs: z.string({ required_error: validationMessages.required("주요처리공정") }).min(1, { message: validationMessages.required("주요처리공정") }),
|
||||
filtrTrtmfctUsgCd: z.string().default("").nullish(),
|
||||
rswtrUsqty: z.number().default(0),
|
||||
|
||||
@@ -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={{
|
||||
|
||||
@@ -58,8 +58,6 @@ export default function HtdflRegForm({
|
||||
if (setIsModal) setIsModal(false);
|
||||
} else {
|
||||
|
||||
console.log(' isModal ' ,isModal)
|
||||
console.log(' values ' ,values)
|
||||
htdflBdstUpdate(values, "41");
|
||||
}
|
||||
};
|
||||
|
||||
@@ -62,7 +62,11 @@ export default function RswtrRegForm({
|
||||
rswtBdstUpdate(values, "41");
|
||||
}
|
||||
};
|
||||
const cleanRswtData = (raw: any): z.infer<typeof rswtZod> => {
|
||||
|
||||
const filtrTrtmfctCpct = form.watch('reuseBuilding.0.rswtrObj.filtrTrtmfctCpct')
|
||||
const cleanRswtData = (raw: any): z.infer<typeof rswtZod> => {
|
||||
|
||||
console.log('raw ', raw)
|
||||
return {
|
||||
...raw,
|
||||
frstArchPrmsnDt: raw?.frstArchPrmsnDt
|
||||
@@ -82,11 +86,20 @@ export default function RswtrRegForm({
|
||||
rswtrObj: {
|
||||
...item?.rswtrObj,
|
||||
filtrTrtmfctYn: item?.rainyObj?.filtrTrtmfctYn ?? "Y",
|
||||
filtrTrtmfctCpct: item?.rswtrObj?.filtrTrtmfctCpct ?? null,
|
||||
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(' filtrTrtmfctCpct ', filtrTrtmfctCpct)
|
||||
},[filtrTrtmfctCpct])
|
||||
|
||||
useEffect(() => {
|
||||
console.log("form errors:", form.formState.errors);
|
||||
}, [form.formState.errors]);
|
||||
@@ -227,6 +240,8 @@ export default function RswtrRegForm({
|
||||
onFocus={() => {
|
||||
// 입력 시 자동으로 확인불가 해제
|
||||
if (isUnknown && !readonly) {
|
||||
|
||||
console.log('value')
|
||||
field.onChange(""); // 초기화
|
||||
}
|
||||
}}
|
||||
|
||||
@@ -148,7 +148,7 @@ export function BdstReg<T extends MoType>({ moType,setIsModal,isModal }: BdstReg
|
||||
<RainRegForm rainForm={rainBdstForm as customRainBdst} isModal={isModal} setIsModal={setIsModal} />
|
||||
:moType==='RST'
|
||||
? <RswtrRegForm rswtForm={rainBdstForm as customRswtBdst} isModal={isModal} setIsModal={(open) =>{setIsModal}}></RswtrRegForm>
|
||||
:<HtdflRegForm htdflForm={rainBdstForm as unknown as customHtdflBdst} isModal={true} setIsModal={(open) =>{setIsModal}}></HtdflRegForm>
|
||||
:<HtdflRegForm htdflForm={rainBdstForm as unknown as customHtdflBdst} isModal={true} setIsModal={(open) =>{setIsModal && setIsModal(open)}}></HtdflRegForm>
|
||||
}
|
||||
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user