빗물지도점검 등록 테스트 중
This commit is contained in:
@@ -38,8 +38,10 @@ export default function Home() {
|
||||
}>({ isOpen: false, chgBuilding: [] });
|
||||
|
||||
useEffect(() => {
|
||||
setIsNewReg( false)
|
||||
if (!rain.isInit) {
|
||||
initRain('41');
|
||||
|
||||
}
|
||||
}, [rain.isInit, initRain]);
|
||||
|
||||
|
||||
@@ -7,8 +7,50 @@ import {
|
||||
import type { pubHasuType } from "../../ruseFcltMng/fcltReg/pbnstReg/type";
|
||||
import type { DemandCompType } from "@common/business_components/ui/sdmInsertForm/form";
|
||||
import type { conCostFeeType, rateFeeType } from "./type";
|
||||
|
||||
|
||||
export const comFcltStateExport: comFcltState = {
|
||||
searchFclts: [] as pubHasuType[],
|
||||
demandCompList: [],
|
||||
dmdIsSucees: '',
|
||||
checkDemand: {
|
||||
index: 0,
|
||||
dmdInfoPk: "",
|
||||
dmdInfoFk: "",
|
||||
bzmnNo: "",
|
||||
dmdCoNm: "",
|
||||
daddr: "",
|
||||
telno: "",
|
||||
rgtr: "",
|
||||
useUsgCd: "",
|
||||
ctpvCd: "",
|
||||
sggCd: "",
|
||||
dmdAplyPswd: "",
|
||||
wntUntprc: 0,
|
||||
dmndTmng: "",
|
||||
dmndQty: 0,
|
||||
grssClfg: 0,
|
||||
tn: 0,
|
||||
combResdch: 0,
|
||||
tph: 0,
|
||||
trbt: 0,
|
||||
ph: 0,
|
||||
blgcOxygDmndQnt: 0,
|
||||
clIonQnt: 0,
|
||||
smll: 0,
|
||||
cdtnv: 0,
|
||||
crmty: 0,
|
||||
rmrk: "",
|
||||
reqDt: ""
|
||||
},
|
||||
constCostRes:[],
|
||||
rateFeeRes:[],
|
||||
};
|
||||
|
||||
export type comFcltType = comFcltState & comFcltActions;
|
||||
|
||||
export type comFcltState = {
|
||||
searchFclts: pubHasuType;
|
||||
searchFclts: pubHasuType[];
|
||||
demandCompList: DemandCompType[];
|
||||
dmdIsSucees: string;
|
||||
checkDemand: DemandCompType;
|
||||
@@ -16,7 +58,7 @@ export type comFcltState = {
|
||||
rateFeeRes:rateFeeType[],
|
||||
|
||||
};
|
||||
export type comFcltActions = {
|
||||
type comFcltActions = {
|
||||
getSwtrmtFcltNm: (searchNm: string) => void;
|
||||
getDemandCompList: (searchNm: string, cnt: number) => void;
|
||||
regDemandCompany: (data: DemandCompType) => void;
|
||||
@@ -25,7 +67,7 @@ export type comFcltActions = {
|
||||
getRateFee: (year: string) => void;
|
||||
};
|
||||
|
||||
export const searchActions: (set: any) => comFcltActions = (set: any) => {
|
||||
export const comFcltSearchAction: (set: any) => comFcltActions = (set: any) => {
|
||||
return {
|
||||
getSwtrmtFcltNm: async (searchNm: string) => {
|
||||
const fcltNm = await getFetch(
|
||||
|
||||
@@ -2,19 +2,15 @@ import type { TableUpperProps } from "@/app/store/common/type/header";
|
||||
import { getFetch, postFectch, putFectch } from "@/components/lib/api";
|
||||
import { z } from "zod";
|
||||
import { makeMdfr, makeRstr } from "../bdstReg";
|
||||
|
||||
const validationMessages = {
|
||||
required: (field: string) => `${field}을(를) 입력해주세요.`,
|
||||
requiredSelect: (field: string) => `${field}을(를) 선택해주세요.`,
|
||||
yearFormat: '4자리 연도만 입력하세요',
|
||||
};
|
||||
import toast from "react-hot-toast";
|
||||
import { baseReuseBuildingSchema, chgBuildingSchema, validationMessages } from "./type";
|
||||
|
||||
export const TEST_UUID= '2d4b151d-1828-41e0-91d9-4cd28ea1cc7e'
|
||||
|
||||
const rainyObjSchema = z.object({
|
||||
bdstReuseFcltFk: z.number().nullish(),
|
||||
pntfColKnd: z.string().default(""),
|
||||
pntfColArea: z.number().default(0),
|
||||
pntfColKnd: z.string().min(1, { message: validationMessages.requiredSelect("종류") }),
|
||||
pntfColArea: z.number().positive({ message: validationMessages.required("면적(m³)") }),
|
||||
dtfcltCpct: z.number().default(0),
|
||||
filtrTrtmfctYn: z.string().default("Y"),
|
||||
filtrTrtmfctCpct: z.number().nullish().default(0),
|
||||
@@ -23,55 +19,15 @@ const rainyObjSchema = z.object({
|
||||
oilqMeasMthd: z.string().default("").nullish(),
|
||||
rgtr:z.string().nullish(),
|
||||
mdfr:z.string().nullish(),
|
||||
}).refine((data) => data.pntfColKnd.length > 0, {
|
||||
message: validationMessages.requiredSelect("종류"),
|
||||
path: ["pntfColKnd"],
|
||||
}).refine((data) => data.pntfColArea > 0, {
|
||||
message: validationMessages.required("면적(m³)"),
|
||||
path: ["pntfColArea"],
|
||||
});
|
||||
|
||||
const reuseBuildingSchema = z.object({
|
||||
bdstRuseFcltPk: z.number().nullish(),
|
||||
bdstInfoFk:z.number().nullish(),
|
||||
instlCmptnDt: z.coerce.date().default(() => new Date()),
|
||||
instlCst: z.number().nullish(),
|
||||
operMngCd: z.string().optional().default(""),
|
||||
anlOperCst: z.number().default(0),
|
||||
instlCstSprtYn: z.string().default("Y"),
|
||||
instlCstSprtAmt: z.number().nullish(),
|
||||
grntchBdstCertYn: z.string().default("Y"),
|
||||
grntchBdstCertYr: z.string().default("")
|
||||
.refine((year)=> year.length===0 || /^\d{4}$/.test(year),{
|
||||
message: validationMessages.yearFormat
|
||||
}),
|
||||
grntchBdstCertNo: z.string().default(""),
|
||||
grntchBdstCertGrd: z.string().default(""),
|
||||
crgRdctYn: z.string().default("N").nullish(), /// 안쓰는 값
|
||||
crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
|
||||
crgRdctAmt: z.number().default(0), // 안쓰는 값
|
||||
ruseFcltFlg: z.string().default(""),
|
||||
bdstUsgCd: z.number().default(0),
|
||||
lawTrgtYn: z.string().default("Y"),
|
||||
rgtr:z.string().nullish(),
|
||||
mdfr:z.string().nullish(),
|
||||
rainyObj: rainyObjSchema.default({})
|
||||
}).refine((data) => data.bdstUsgCd > 0, {
|
||||
message: validationMessages.requiredSelect("건축물용도"),
|
||||
path: ["bdstUsgCd"],
|
||||
}) ;
|
||||
|
||||
const chgBuildingSchema = z.object({
|
||||
bdstInfoFk: z.number().nullish(),
|
||||
archChgPrmsnDt: z.coerce.date({required_error: validationMessages.required("허가일")}),
|
||||
archChgArea: z.string().default("-"),
|
||||
bdstChgNm: z.string().default(""),
|
||||
rgtr:z.string().nullish(),
|
||||
mdfr:z.string().nullish(),
|
||||
}).refine(data => data.bdstChgNm.length > 0, {
|
||||
message: validationMessages.requiredSelect("구분"),
|
||||
path: ["bdstChgNm"]
|
||||
});
|
||||
|
||||
|
||||
|
||||
const rainBuildingSchema = baseReuseBuildingSchema.extend({
|
||||
rainyObj: rainyObjSchema,
|
||||
})
|
||||
|
||||
export const rainZod = z.object({
|
||||
bdstInfoPk: z.number().optional(),
|
||||
@@ -85,7 +41,7 @@ export const rainZod = z.object({
|
||||
archChgArea: z.number().default(0),
|
||||
rgtr:z.string().nullish(),
|
||||
mdfr:z.string().nullish(),
|
||||
reuseBuilding: z.array(reuseBuildingSchema).default([]),
|
||||
reuseBuilding: z.array(rainBuildingSchema).default([]),
|
||||
chgBuilding: z.array(chgBuildingSchema).default([])
|
||||
})
|
||||
|
||||
@@ -219,15 +175,18 @@ export const rainFacActionsExport: (set: any) => rainFacSActions = (
|
||||
bdstInfoFk: chPK,
|
||||
})
|
||||
);
|
||||
const chch= postFectch("/reuseFc/chgBuilding", makeCh);
|
||||
const chch= postFectch("/reuseFc/chgBuilding", makeCh);
|
||||
return chch;
|
||||
}).then((chch: any) => {
|
||||
if(chch.ok) {
|
||||
alert("등록이 완료되었습니다.");
|
||||
|
||||
console.log('chch ', chch)
|
||||
if(chch.status ===200) {
|
||||
toast.success("등록이 완료되었습니다.");
|
||||
|
||||
}
|
||||
})
|
||||
}else{
|
||||
alert("등록이 완료되었습니다.");
|
||||
toast.success("등록이 완료되었습니다.");
|
||||
}
|
||||
}
|
||||
const rainRes = await initFetch(code);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { z } from "zod";
|
||||
|
||||
|
||||
export const validationMessages = {
|
||||
required: (field: string) => `${field}을(를) 입력해주세요.`,
|
||||
requiredSelect: (field: string) => `${field}을(를) 선택해주세요.`,
|
||||
yearFormat: '4자리 연도만 입력하세요',
|
||||
};
|
||||
|
||||
export const baseReuseBuildingSchema = z.object({
|
||||
bdstRuseFcltPk: z.number().nullish(),
|
||||
bdstInfoFk: z.number().nullish(),
|
||||
instlCmptnDt: z.coerce.date().default(() => new Date()),
|
||||
instlCst: z.number().nullish(),
|
||||
operMngCd: z.string().optional().default(""),
|
||||
anlOperCst: z.number().default(0),
|
||||
instlCstSprtYn: z.string().default("Y"),
|
||||
instlCstSprtAmt: z.number().nullish(),
|
||||
grntchBdstCertYn: z.string().default("Y"),
|
||||
grntchBdstCertYr: z.string().default("").refine(
|
||||
(year) => year.length === 0 || /^\d{4}$/.test(year),
|
||||
{
|
||||
message: validationMessages.yearFormat,
|
||||
}
|
||||
),
|
||||
grntchBdstCertNo: z.string().default(""),
|
||||
grntchBdstCertGrd: z.string().default(""),
|
||||
crgRdctYn: z.string().default("N").nullish(), /// 안쓰는 값
|
||||
crgRdctBss: z.string().default("").nullish(), /// 안쓰는 값
|
||||
crgRdctAmt: z.number().default(0), // 안쓰는 값
|
||||
ruseFcltFlg: z.string().default(""),
|
||||
bdstUsgCd: z.number().min(1, { message: validationMessages.requiredSelect("건축물용도") }).default(0),
|
||||
lawTrgtYn: z.string().default("Y"),
|
||||
rgtr: z.string().nullish(),
|
||||
mdfr: z.string().nullish(),
|
||||
});
|
||||
|
||||
export const chgBuildingSchema = z.object({
|
||||
bdstInfoFk: z.number().nullish(),
|
||||
archChgPrmsnDt: z.coerce.date({required_error: validationMessages.required("허가일")}),
|
||||
archChgArea: z.string().default("-"),
|
||||
bdstChgNm: z.string().min(1, { message: validationMessages.requiredSelect("구분") }),
|
||||
rgtr:z.string().nullish(),
|
||||
mdfr:z.string().nullish(),
|
||||
});
|
||||
@@ -86,7 +86,7 @@ import {
|
||||
import { rswtChkStateExport, rswtChkSttnActionsExport, type rswtChkSttnState, type rswtChkSttnType } from "./prfmncSttn/chkgdnSttn/rswtChkgdnSttn";
|
||||
import { pbnstSttnActionsExport, pbnstSttnStateExport, type pbnstSttnState, type pbnstSttnType } from "./ruseFcltMng/fcltSttn/pbnstSttn";
|
||||
import { coSttnActionsExport, coSttnStateExport, type coSttnState, type coSttnType } from "./matDmd/coSttn"; // 옮겨야함
|
||||
import { searchActions, type comFcltActions, type comFcltState } from "./common/searchCode";
|
||||
import { comFcltStateExport, comFcltSearchAction, type comFcltState, type comFcltType } from "./common/searchCode";
|
||||
import { pbnstPrfmncActionsExport, pbnstPrfmncStateExport, type pbnstPrfmncState, type pbnstPrfmncType } from "./prfmncReg/pbnstPrfmncReg";
|
||||
import { coRvwActionsExport, coRvwStateExport, type coRvwState, type coRvwType } from "./matDmd/coMatRvw";
|
||||
import { ruseHstryActionsExport, ruseHstryStateExport, type ruseHstryState, type ruseHstryType } from "./matDmd/ruseRvwHstry";
|
||||
@@ -113,7 +113,6 @@ export type WrStore = comCodeType &
|
||||
rainChkSttnType&
|
||||
rswtChkSttnType&
|
||||
pbnstSttnType&
|
||||
comFcltActions&comFcltState&
|
||||
coSttnType& // 옮겨야함
|
||||
ldrmntType& // 옮겨야함
|
||||
pbnstPrfmncType&
|
||||
@@ -124,7 +123,8 @@ export type WrStore = comCodeType &
|
||||
ruseCaseType&
|
||||
rainStatType&
|
||||
rswtStatType&
|
||||
matStatType
|
||||
matStatType&
|
||||
comFcltType
|
||||
;
|
||||
|
||||
export const StoreZus = (
|
||||
@@ -141,6 +141,7 @@ export const StoreZus = (
|
||||
rswtSttnState &
|
||||
htdflSttnState &
|
||||
rainChkSttnState&
|
||||
comFcltState&
|
||||
rswtChkSttnState &
|
||||
pbnstSttnState&
|
||||
coSttnState& // 옮겨야함
|
||||
@@ -180,7 +181,8 @@ export const StoreZus = (
|
||||
...ruseCaseStateExport,
|
||||
...rainStatExport,
|
||||
...rswtStatExport,
|
||||
...matStatExport
|
||||
...matStatExport,
|
||||
...comFcltStateExport
|
||||
}
|
||||
) => {
|
||||
return createStore<WrStore>()((set) => {
|
||||
@@ -192,7 +194,7 @@ export const StoreZus = (
|
||||
getEnvPartCd(set);
|
||||
return {
|
||||
...initState,
|
||||
...searchActions(set),
|
||||
...comFcltSearchAction(set),
|
||||
...pubFacActionsExport(set),
|
||||
...rainFacActionsExport(set),
|
||||
...rswtFacActionsExport(set),
|
||||
|
||||
@@ -171,7 +171,7 @@ export default function BdstReg({ form }: { form: any }) {
|
||||
<FormUi label="위치">
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
placeholder=""
|
||||
type="search"
|
||||
{...field}
|
||||
/>
|
||||
@@ -193,7 +193,7 @@ export default function BdstReg({ form }: { form: any }) {
|
||||
onSelectValue={(val) => {
|
||||
field.onChange(Number(val));
|
||||
}}
|
||||
value={field.value}
|
||||
value={field.value??code.bdstUsgCd[0]?.val}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -208,7 +208,7 @@ export default function BdstReg({ form }: { form: any }) {
|
||||
<DatePicker
|
||||
mode={"single"}
|
||||
field={{
|
||||
value: field.value || new Date(),
|
||||
value: field.value?? new Date(),
|
||||
onChange: (date: Date | undefined) => field.onChange(date),
|
||||
}}
|
||||
selectClass={'w-full'}
|
||||
@@ -226,7 +226,7 @@ export default function BdstReg({ form }: { form: any }) {
|
||||
<Input
|
||||
className={selectClass}
|
||||
placeholder="1,000,000"
|
||||
type="number"
|
||||
type="text"
|
||||
onChange={(e) => {
|
||||
handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
@@ -250,7 +250,7 @@ export default function BdstReg({ form }: { form: any }) {
|
||||
onSelectValue={(val) => {
|
||||
field.onChange(val);
|
||||
}}
|
||||
value={field.value}
|
||||
value={field.value??code.yn[0]?.val }
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
|
||||
@@ -46,32 +46,40 @@ export default function RainRegForm({
|
||||
]);
|
||||
|
||||
const cleanRainData = (raw: any): z.infer<typeof rainZod> => {
|
||||
const buildings =
|
||||
raw?.reuseBuilding && raw.reuseBuilding.length > 0
|
||||
? raw.reuseBuilding
|
||||
: [{}];
|
||||
return {
|
||||
...raw,
|
||||
frstArchPrmsnDt: new Date(raw?.frstArchPrmsnDt || null),
|
||||
frstArchPrmsnDt: raw?.frstArchPrmsnDt
|
||||
? new Date(raw.frstArchPrmsnDt)
|
||||
: new Date(), // raw?.frstArchPrmsnDt가 유효하지 않으면 현재 날짜로 초기화
|
||||
archChgPrmsnDt: raw?.archChgPrmsnDt
|
||||
? new Date(raw?.archChgPrmsnDt)
|
||||
: null,
|
||||
reuseBuilding: (raw?.reuseBuilding || []).map((item: any) => ({
|
||||
reuseBuilding: buildings.map((item: any) => ({
|
||||
...item,
|
||||
instlCmptnDt: new Date(item?.instlCmptnDt),
|
||||
instlCmptnDt: item?.instlCmptnDt
|
||||
? new Date(item.instlCmptnDt)
|
||||
: new Date(), // item?.instlCmptnDt가 유효하지 않으면 현재 날짜로 초기화
|
||||
operMngCd: item?.operMngCd ?? "", // null → ""
|
||||
grntchBdstCertYr:
|
||||
typeof item?.grntchBdstCertYr === "string"
|
||||
? item?.grntchBdstCertYr
|
||||
: "", // null → ""
|
||||
instlCstSprtYn:
|
||||
item?.instlCstSprtYn ?? "Y", // null → "N"
|
||||
// Ensure enum fields are null if empty string to trigger Zod default
|
||||
instlCstSprtYn: item?.instlCstSprtYn ?? "Y", // null → "Y"
|
||||
grntchBdstCertYn:item?.grntchBdstCertYn??"Y",
|
||||
rainyObj: {
|
||||
...item?.rainyObj,
|
||||
filtrTrtmfctYn: item?.rainyObj?.filtrTrtmfctYn ??"Y"
|
||||
filtrTrtmfctYn: item?.rainyObj?.filtrTrtmfctYn ?? "Y",
|
||||
},
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
if (grntchBdstCertYn === "N") {
|
||||
form.setValue("reuseBuilding.0.grntchBdstCertYr", "");
|
||||
form.setValue("reuseBuilding.0.grntchBdstCertNo", "");
|
||||
@@ -84,6 +92,9 @@ export default function RainRegForm({
|
||||
}
|
||||
}, [grntchBdstCertYn, instlCstSprtYn, filtrTrtmfctYn]);
|
||||
|
||||
|
||||
|
||||
|
||||
// form 값이 변경될 때마다 로그 출력
|
||||
useEffect(() => {
|
||||
const subscription = form.watch((value) => {
|
||||
@@ -148,9 +159,8 @@ export default function RainRegForm({
|
||||
value:
|
||||
field.value && !isNaN(new Date(field.value).getTime())
|
||||
? new Date(field.value)
|
||||
: new Date(), // Provide a default Date value
|
||||
onChange: (date) => field.onChange(date),
|
||||
|
||||
: new Date(),
|
||||
onChange: (date: Date | undefined) => field.onChange(date),
|
||||
}}
|
||||
selectClass={"w-full"}
|
||||
readOnly={readonly}
|
||||
@@ -247,7 +257,7 @@ export default function RainRegForm({
|
||||
label={""}
|
||||
selectArray={code.yn}
|
||||
onSelectValue={readonly ? () => { } : field.onChange}
|
||||
value={field.value || code.yn[0]?.val}
|
||||
value={field.value ?? code.yn[0]?.val}
|
||||
readOnly={readonly}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -268,7 +278,8 @@ export default function RainRegForm({
|
||||
if (!readonly) handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={filtrTrtmfctYn === "Y"}
|
||||
readOnly={readonly }
|
||||
disabled={filtrTrtmfctYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -286,7 +297,8 @@ export default function RainRegForm({
|
||||
type="text"
|
||||
value={field.value ?? ""}
|
||||
onChange={field.onChange}
|
||||
readOnly={filtrTrtmfctYn === "Y" }
|
||||
readOnly={readonly }
|
||||
disabled={filtrTrtmfctYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
@@ -335,7 +347,7 @@ export default function RainRegForm({
|
||||
if (!readonly) handleCommaNumberChange(e, field.onChange);
|
||||
}}
|
||||
value={formatCommaNumber(field.value)}
|
||||
readOnly={instlCstSprtYn === "Y"}
|
||||
readOnly={instlCstSprtYn !== "Y"}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
|
||||
@@ -14,7 +14,6 @@ const {bdst,rain} = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
const { bdstChgHeadList } = bdst;
|
||||
console.log("chgBuilding", chgBuilding);
|
||||
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user