하수재이용 시설 등록 결함대장 수정 11번 까지
iipbs_wr / build (push) Waiting to run

This commit is contained in:
leedj312
2025-06-30 20:18:18 +09:00
parent 9304cf4f8e
commit 31e2e3dea1
8 changed files with 329 additions and 171 deletions
@@ -31,7 +31,7 @@ import { PbnstBuseForm } from "@/components/ui/form/fcltReg/pbnstReg/buseReg/bug
import { PbnstRegModal } from "@/components/ui/modal/fcltReg/pbnstRegModal/pbnstRegModal";
import toast, { Toaster } from "react-hot-toast"; // toast 이미 import 되어 있음
import { writeRgtrAndMdfr } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg";
import { set, useFieldArray, useForm, type FieldErrors } from "react-hook-form"; // FieldErrors 타입 추가
import { useFieldArray, useForm, type FieldErrors } from "react-hook-form"; // FieldErrors 타입 추가
import { zodResolver } from "@hookform/resolvers/zod";
import { z } from "zod";
@@ -57,8 +57,8 @@ export default function PublicReuseFaciltyInsert() {
const [searchTxt, setSearchTxt] = useState<string>();
const [bdstTable, setbdstTable] = useState<pubHasuType[]>();
const [selectRow, setSelectRow] = useState<pubHasuType>();
const [pageNation, setPageNation] = useState<number>(1);
const [testMonth, setTestMonth] = useState<string>("202406");
const form = useForm<{
items: z.infer<typeof pbnstRegZod>[];
}>({
@@ -74,6 +74,8 @@ export default function PublicReuseFaciltyInsert() {
control: form.control,
name: `items`,
});
const formWatch = form.watch("items");
useEffect(() => {
if (!pbnst.isInit) {
pubHasuInit("1", "41");
@@ -159,18 +161,9 @@ export default function PublicReuseFaciltyInsert() {
}
};
useEffect(() => {
console.log("bdstTable ", bdstTable);
}, [bdstTable]);
useEffect(() => {
if (code.sggCd.length && pbnstHasuRes.length > 0) {
setbdstTable(tableData(pbnstHasuRes, { code }));
// if (searchFclts) { // 왜 오류가 발생할까?
// setbdstTable(tableData(searchFclts, { code }));
// } else if (code.sggCd.length > 0 && pbnstHasuRes.length > 0) {
// }
}
}, [code, pbnstHasuRes]);
@@ -180,6 +173,8 @@ export default function PublicReuseFaciltyInsert() {
setSelectRow(pbnstHasuRes?.[val]);
if (selectRow) {
pbnstRegClick(selectRow);
} else {
console.error("선택된 행이 없습니다.");
}
};
@@ -261,7 +256,7 @@ export default function PublicReuseFaciltyInsert() {
<SearchFormLeft>
<SearchInput
className={"col-span-3 my-7 !text-3xl"}
label="건물명"
label="시설명"
textValue={searchTxt || ""}
setText={(e) => {
setSearchTxt(e);
@@ -323,45 +318,76 @@ export default function PublicReuseFaciltyInsert() {
</div>
<ListDiv className="col-span-2 pr-6 ">
<ScrollArea className="h-[60vh]">
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
<TabsList className="">
<TabsTrigger className="!text-xl" value="mng">
시설정보
</TabsTrigger>
<TabsTrigger className="!text-xl" value="buse">
차수별정보
</TabsTrigger>
<Button
{formWatch && formWatch[0]?.pbnstRuseFcltPk ? (
<Tabs defaultValue="mng" onValueChange={handleTabChange}>
<TabsList className="">
<TabsTrigger className="!text-xl" value="mng">
시설정보
</TabsTrigger>
<TabsTrigger className="!text-xl" value="buse">
차수별정보
</TabsTrigger>
<Button
size={"sm"}
onClick={form.handleSubmit(onSubmit, onInvalid)}
className="!justify-end" // 저장 버튼 위치 조정
>
저장
</Button>
</TabsList>
<TabsContent className="max-h-full" value="mng">
<PbnstMngForm
formType="update"
form={form}
setIndexMng={(index: number) => {
console.log("setIndexMng", index);
setIndexMng(index);
}}
indexMng={indexMng}
/>
</TabsContent>
<TabsContent className="max-h-full" value="buse">
<PbnstBuseForm
formType="update"
form={form}
setIndexBiz={(index: number) => {
setIndexBiz(index);
}}
indexMng={indexMng}
indexBiz={indexBiz}
/>
</TabsContent>
</Tabs>
) : (
<>
<div className="card-header text-2xl">
등록된 재이용시설 정보가 없습니다.
</div>
<div className="!mx-[1.6rem] !p-0r flex flex-col items-center justify-center h-64 border rounded-md">
<p className="text-3xl mb-4">
신규등록 버튼을 클릭하여 재이용시설을 등록해주세요.
</p>
<Button
size={"sm"}
onClick={form.handleSubmit(onSubmit, onInvalid)}
className="!justify-end" // 저장 버튼 위치 조정
className=""
onClick={() => {
// pbnstMngData([] as customPbnst[]);
if (!selectRow) {
toast.error(
"하수리시시설을 테이블을 선택하고 등록버튼을 눌러주세요"
);
return;
} else {
appendPbnstRuseFclt();
}
}}
>
저장
신규등록
</Button>
</TabsList>
<TabsContent className="max-h-full" value="mng">
<PbnstMngForm
formType="update"
form={form}
setIndexMng={(index: number) => {
console.log("setIndexMng", index);
setIndexMng(index);
}}
indexMng={indexMng}
/>
</TabsContent>
<TabsContent className="max-h-full" value="buse">
<PbnstBuseForm
formType="update"
form={form}
setIndexBiz={(index: number) => {
setIndexBiz(index);
}}
indexMng={indexMng}
indexBiz={indexBiz}
/>
</TabsContent>
</Tabs>
</div>
</>
)}
</ScrollArea>
</ListDiv>
<UiModal
+34
View File
@@ -10,6 +10,32 @@ const yn: SelectDataType[] = [
{ val: 'N', text: 'N' },
]
//처리장연계/자체+연계/자체처리
const erctUswtrPrcsMeth : SelectDataType[]= [
{ val: '처리장연계', text: '처리장연계' },
{ val: '자체+연계', text: '자체+연계' },
{ val: '자체처리', text: '자체처리' },
]
const rusePrcsMthdCd : SelectDataType[] = [
{ val: '물리학적처리', text: '물리학적처리' },
{ val: '생물학적처리', text: '생물학적처리' },
]
const ruseSeCd : SelectDataType[] = [
{ val: '신규', text: '신규' },
{ val: '증설', text: '증설' },
{ val: '관로', text: '관로' },
{ val: '감량', text: '감량' },
{ val: '개량', text: '개량' },
]
const ruseBizMthdCd: SelectDataType[] = [
{ val: '재정', text: '재정' },
{ val: '민간투자', text: '민간투자' },
{ val: '자체', text: '자체' },
]
//공통 건축물 용도
const bdstUsgCd: SelectDataType[] = [
{ val: '-1', text: "확인불가" },
@@ -174,6 +200,10 @@ export type comCodeState = {
HTB:string
}
ruseMngMtd:SelectDataType[]
ruseSeCd: SelectDataType[];
ruseBizMthdCd: SelectDataType[];
rusePrcsMthdCd: SelectDataType[];
erctUswtrPrcsMeth: SelectDataType[];
};
};
@@ -323,6 +353,10 @@ export const comCodeStateExport: comCodeState = {
dmdUszCd:dmdUszCd,
buildingType:buildingType,
ruseMngMtd:ruseMngMtd,
ruseSeCd:ruseSeCd,
ruseBizMthdCd: ruseBizMthdCd,
rusePrcsMthdCd:rusePrcsMthdCd,
erctUswtrPrcsMeth:erctUswtrPrcsMeth
},
};
@@ -31,8 +31,8 @@ export const pbnstMngUpHeadListExport: TableUpperProps[] = [
export const pplInstlsHeadListExport: TableUpperProps[] = [
{ id: "choose", title: "선택", type: "checkbox" },
{ id: "ppMqlt", title: "관재질", type: "select", selectData: "pplQulity" },
{ id: "pdmt", title: "관경", type: "select", selectData: "pplLenght" },
{ id: "cpct", title: "연장", edit: true, type: "number" },
{ id: "pdmt", title: "관경(mm)", type: "select", selectData: "pplLenght" },
{ id: "cpct", title: "연장(m)", edit: true, type: "number" },
];
export const pbnstDemandHeadListExport: TableUpperProps[] = [
@@ -69,20 +69,21 @@ export type formDetailType = {
id: string;
lable: string;
type?: string;
selectData?: string; // select box일 경우
option?:string
};
export const wasteWaterFcltINfo: formDetailType[] = [
{ id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부", type: "selectYn" },
{ id: "tmsInstlYn", lable: "Tms설치여부", type: "selectYn" },
{ id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부", type: "selectYn" },
{ id: "wwtEmsnFcltPrmsnYn", lable: "폐수배출물신고 허가여부", type: "select" , selectData: "yn"},
{ id: "tmsInstlYn", lable: "Tms설치여부", type: "select" , selectData: "yn" },
{ id: "pbnstDrngInflwExclYn", lable: "공공하수도유입제외 허가여부", type: "select" , selectData: "yn" },
];
export const concentratedWaterInfo: formDetailType[] = [
{ id: "erctWtrOcrnCpct", lable: "눙축수 발생량(m³/일)", type: "number" },
{ id: "erctUswtrLinkSpt", lable: "눙축수연계지점" },
{ id: "erctUswtrFcltCpct", lable: "시설용량(m³/일)", type: "number" },
{ id: "erctUswtrPrcsMeth", lable: "눙축수처리방식" },
{ id: "erctUswtrPrcsMeth", lable: "눙축수처리방식", type : "select", selectData: "erctUswtrPrcsMeth" },
{ id: "erctUswtrPrcsMsrcCd", lable: "눙축수처리공법" },
];
@@ -90,8 +91,8 @@ export const ruseFcltinfo: formDetailType[] = [
{ id: "rprcsFcltCpct", lable: "시설용량(m³/일)", type: "number" },
{ id: "majorPrcsMsrcCd", lable: "주처리공법" },
{ id: "addr", lable: "위치(주소)" },
{ id: "rprcsMthdCd", lable: "재처리방식" },
{ id: "inoutYn", lable: "위치(처리장 내외)" ,type: "selectYn" }, // 머가 내? 외?,
{ id: "rprcsMthdCd", lable: "재처리방식", type: "select", selectData: "rusePrcsMthdCd" },
{ id: "inoutYn", lable: "위치(처리장 내외)" ,type: "select" , selectData: "yn"}, // 머가 내? 외?,
{ id: "mainSplyPumpCpct", lable: "메인공급펌프 용량", type: "number" },
];
@@ -100,12 +101,12 @@ export const businessMoneyInfo: formDetailType[] = [
{ id: "lcep", lable: "지방비", type: "number" },
{ id: "cusrAlotm", lable: "민간투자비", type: "number" },
{ id: "etc", lable: "기타" },
{ id: "totalMoney", lable: "합계", type: "number" ,option:"readOnly" },
{ id: "totalMoney", lable: "합계", type: "number" ,option:"disabled" },
];
export const businessSttnInfo: formDetailType[] = [
{ id: "seCd", lable: "구분" },
{ id: "bizMthdCd", lable: "사업방식" },
{ id: "seCd", lable: "구분", type: "select", selectData: "ruseSeCd" },
{ id: "bizMthdCd", lable: "사업방식", type: "select", selectData: "ruseBizMthdCd" },
{ id: "bizCmcnDay", lable: "사업준공일", type: "date" },
{ id: "instlAprvSncnDt", lable: "설치승인인가일", type: "date" },
];
@@ -118,15 +119,15 @@ export const ruseFcltIntakeList: formDetailType[] = [
];
export const ruseWaterQulityList: formDetailType[] = [
{ id: "bod", lable: "BOD(mg/L)", type: "number" },
{ id: "grssClfg", lable: "총대장균군수(개/mg)", type: "number" },
{ id: "combResdch", lable: "결합잔류염소(mh/L)", type: "number" },
{ id: "trbt", lable: "탁도(NTU)", type: "number" },
{ id: "smll", lable: "냄새", type: "number" },
{ id: "crmty", lable: "색도", type: "number" },
{ id: "tn", lable: "총질소(mg/L)", type: "number" },
{ id: "tph", lable: "총인(mg/L)", type: "number" },
{ id: "ph", lable: "수소이온농도", type: "number" },
{ id: "clIonQnt", lable: "염화물(mg/L)", type: "number" },
{ id: "cdtnv", lable: "전기전도도(μs/cm)​", type: "number" },
{ id: "bod", lable: "BOD(mg/L)", type: "text" },
{ id: "grssClfg", lable: "총대장균군수(개/mg)", type: "text" },
{ id: "combResdch", lable: "결합잔류염소(mh/L)", type: "text" },
{ id: "trbt", lable: "탁도(NTU)", type: "text" },
{ id: "smll", lable: "냄새", type: "text" },
{ id: "crmty", lable: "색도", type: "text" },
{ id: "tn", lable: "총질소(mg/L)", type: "text" },
{ id: "tph", lable: "총인(mg/L)", type: "text" },
{ id: "ph", lable: "수소이온농도", type: "text" },
{ id: "clIonQnt", lable: "염화물(mg/L)", type: "text" },
{ id: "cdtnv", lable: "전기전도도(μs/cm)​", type: "text" },
];
@@ -52,6 +52,7 @@ export type pubFacState = {
fcOrgwtsHeadList: TableUpperProps[];
pbnstMngRegData: customPbnst[];
pbnsUpdateIndex: pbnstInsertIndex;
fcOrgwtsNmList:pubHasuType[];
dmdComList: any[];
};
};
@@ -70,6 +71,7 @@ type pubFacActions = {
pbnstRuseFcltUpdate: (ruseRes: customPbnst[]) => void;
pbnstRuseBizUpdate: (ruseRes: fcBizType[]) => void;
pubHasuSearch :(page: string, sggOrCity: string , searchTxt:string) => void
getFcOrgwts: (fcltPkList: string[], size:number) => void;
};
export type pubFacType = pubFacState & pubFacActions;
@@ -90,6 +92,7 @@ export const pubFacStateExport: pubFacState = {
pbnstBizCycle: [{ text: "없음", val: "1" }],
pbnstMngRegData: [],
pbnsUpdateIndex: {} as pbnstInsertIndex,
fcOrgwtsNmList:[],
dmdComList: [],
},
};
@@ -398,6 +401,25 @@ export const pubFacActionsExport: (set: any) => pubFacActions = (set: any) => {
} catch (e) {
console.log(e);
}
},getFcOrgwts : async (fcltPkList: string[] ,size:number) => {
let url = `/prcsFclt/ruseInfo/1/${size}/A/0/0/1/SW`;
const fcOrgwtsNmList = await postFectch(
url,
fcltPkList,
fetchType.COMMON
);
return set((state: pubFacState) => ({
...state,
pbnst: {
...state.pbnst,
fcOrgwtsNmList:fcOrgwtsNmList.data??[]
},
}));
}
};
};
@@ -14,10 +14,10 @@ export type selectLabel = {
val: string;
};
export type pbnstInsertIndex ={
mng:number,
biz:number
}
export type pbnstInsertIndex = {
mng: number;
biz: number;
};
export type publicReuseFacilityType = {
sido: string;
@@ -45,20 +45,20 @@ export type ruseFcltType = {
};
export type PbnstDemandComType = {
dmdInfoPk : string | '';
bzmnNo : string | '';
dmdCoNm : string | '';
daddr : string | '';
telno : string | '';
rgtr : string | '';
useUsgCd : string | '';
ctpvCd : string | '';
sggCd : string | '';
dmdAplyPswd: string | '';
dmdInfoPk: string | "";
bzmnNo: string | "";
dmdCoNm: string | "";
daddr: string | "";
telno: string | "";
rgtr: string | "";
useUsgCd: string | "";
ctpvCd: string | "";
sggCd: string | "";
dmdAplyPswd: string | "";
splyCpct: number | 0;
splyFmYn:string|'Y'
// dmdInfoFk:string|''
}
splyFmYn: string | "Y";
// dmdInfoFk:string|''
};
const pubHasuZod = z.object({
choose: z.boolean().default(false),
@@ -68,23 +68,27 @@ const pubHasuZod = z.object({
bscFctNm: z.string().default(""),
efflWqltStndrdNm: z.string().default(""),
fctCpc: z.number().default(0),
addr:z.string().nullish()
addr: z.string().nullish(),
});
export type pubHasuType = z.infer<typeof pubHasuZod>;
const zDate = z.preprocess((v) => (v ? new Date(v as string) : undefined), z.date()).nullish() ;
const zDate = z
.preprocess((v) => (v ? new Date(v as string) : undefined), z.date())
.nullish();
const zDateNullish = zDate.nullish();
const zDateDefaultNow = zDate.default(new Date());
const zNum = z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number());
const zNum = z.preprocess(
(v) => (v !== null && v !== undefined ? Number(v) : v),
z.number()
);
const zNumNullish = zNum.nullish();
const zNumDefaultZero = zNum.default(0).nullish();
const pplInstlSchema = z.object({
ruseFcltBizFk: zNumNullish,
choose: z.boolean().default(false),
pdmt: z.string().default(''),
pdmt: z.string().default(""),
ppMqlt: z.string().default(""),
cpct: zNumDefaultZero,
});
@@ -115,22 +119,23 @@ export const fcOperSchema = z.object({
});
const fcOrgwtSchema = z.object({
pbnstRuseFcltBizFk:zNumNullish,
pbnstRuseFcltBizFk: zNumNullish,
swtrmtFcltFk: z.string().nullish(),
orgwtWtritQnt: zNum,
tmsYn: z.enum(["Y", "N"]).default("N"),
dschgFmYn: z.enum(["Y", "N"]).default("N"),
dtlPstnExpln: z.string().default(''),
dtlPstnExpln: z.string().default(""),
regDt: zDateNullish,
rgtr: z.string().default(''),
rgtr: z.string().default(""),
mdfcnDt: zDateNullish,
mdfr: z.string().default(''),
mdfr: z.string().default(""),
choose: z.boolean().default(false),
ruseUtztnFcltNm:z.string().nullish()
});
const dmdColist = z.object({
dmdInfoPk: z.string().default(''),
dmdCoNm: z.string().default(''),
dmdInfoPk: z.string().default(""),
dmdCoNm: z.string().default(""),
daddr: z.string(),
useUsgCd: z.string().nullish(),
splyBgngDay: zDateDefaultNow,
@@ -155,11 +160,11 @@ export const fcBizSchema = z.object({
gvsbs: zNumDefaultZero,
lcep: zNumDefaultZero,
cusrAlotm: zNumDefaultZero,
etc: z.string().default(''),
etc: z.string().default(""),
totalMoney: zNumNullish.default(0),
rprcsFcltCpct: zNumDefaultZero,
majorPrcsMsrcCd: z.string().default(""),
addr: z.string().default(''),
addr: z.string().default(""),
rprcsMthdCd: z.string().default(""),
inoutYn: z.enum(["Y", "N"]).default("Y"),
mainSplyPumpCpct: zNumNullish,
@@ -171,17 +176,29 @@ export const fcBizSchema = z.object({
wwtEmsnFcltPrmsnYn: z.string().default("Y"),
tmsInstlYn: z.string().default("Y"),
pbnstDrngInflwExclYn: z.string().default("Y"),
bod: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "BOD 값은 5자리 미만이어야 합니다.")).nullish(),
grssClfg: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "총대장균군 값은 5자리 미만이어야 합니다.")).nullish(),
combResdch: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "결합잔류염소 값은 5자리 미만이어야 합니다.")).nullish(),
trbt: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "탁도 값은 5자리 미만이어야 합니다.")).nullish(),
clIonQnt: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "염소이온량 값은 5자리 미만이어야 합니다.")).nullish(),
smll: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "냄새 값은 5자리 미만이어야 합니다.")).nullish(),
crmty: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "색도 값은 5자리 미만이어야 합니다.")).nullish(),
tph: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "총인 값은 5자리 미만이어야 합니다.")).nullish(),
tn: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "총질소 값은 5자리 미만이어야 합니다.")).nullish(),
ph: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "수소이온농도 값은 5자리 미만이어야 합니다.")).nullish(),
cdtnv: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "전기전도도 값은 5자리 미만이어야 합니다.")).nullish(),
// bod: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "BOD 값은 5자리 미만이어야 합니다.")).nullish(),
// grssClfg: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "총대장균군 값은 5자리 미만이어야 합니다.")).nullish(),
// combResdch: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "결합잔류염소 값은 5자리 미만이어야 합니다.")).nullish(),
// trbt: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "탁도 값은 5자리 미만이어야 합니다.")).nullish(),
// clIonQnt: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "염소이온량 값은 5자리 미만이어야 합니다.")).nullish(),
// smll: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "냄새 값은 5자리 미만이어야 합니다.")).nullish(),
// crmty: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "색도 값은 5자리 미만이어야 합니다.")).nullish(),
// tph: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "총인 값은 5자리 미만이어야 합니다.")).nullish(),
// tn: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "총질소 값은 5자리 미만이어야 합니다.")).nullish(),
// ph: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "수소이온농도 값은 5자리 미만이어야 합니다.")).nullish(),
// cdtnv: z.preprocess((v) => (v !== null && v !== undefined ? Number(v) : v), z.number().max(9999, "전기전도도 값은 5자리 미만이어야 합니다.")).nullish(),
bod: z.string().nullish(),
grssClfg: z.string().nullish(),
combResdch: z.string().nullish(),
trbt: z.string().nullish(),
clIonQnt: z.string().nullish(),
smll: z.string().nullish(),
crmty: z.string().nullish(),
tph: z.string().nullish(),
tn: z.string().nullish(),
ph: z.string().nullish(),
cdtnv: z.string().nullish(),
designCst: zNumNullish,
cstrnSpvsCst: zNumNullish,
fcltSbsdCst: zNumNullish,
@@ -217,7 +234,7 @@ export const fcBizSchema = z.object({
});
export const pbnstRegZod = z.object({
pbnstRuseFcltPk: z.string().default(''),
pbnstRuseFcltPk: z.string().default(""),
swtrmtFcltFk: z.string().default(""),
ruseUtztnFcltNm: z.string().default(""),
fcltCpct: zNumDefaultZero,
@@ -232,9 +249,9 @@ export const pbnstRegZod = z.object({
fcOpers: z.array(fcOperSchema).default([]).nullish(),
});
export const pbnstRegArrayZod = z.array(pbnstRegZod)
export const pbnstRegArrayZod = z.array(pbnstRegZod);
export type PbnstRegArrrayType = z.infer<typeof pbnstRegArrayZod>
export type PbnstRegArrrayType = z.infer<typeof pbnstRegArrayZod>;
export type fcBizType = z.infer<typeof fcBizSchema>;
export type fcOrgwtType = z.infer<typeof fcOrgwtSchema>;
@@ -56,14 +56,14 @@ export function PbnstBuseForm({
pbnst,
demandCompList,
getDemandCompList,
getFcOrgwts,
regDemandCompany,
} = useWrStore((state) => state);
const { pbnstBizCycle, pbnstRes } = pbnst;
const { fcOrgwtsNmList } = pbnst;
const { fields: fcBizs, append: appendBiz } = useFieldArray({
control: form.control,
name: `items.${indexMng}.fcBizs`,
});
const [bizCycle, setBizCycle] = useState("1");
const [ppiSelectList, setPpiSelectList] =
useState<[{ name: string; val: SelectDataType[] }]>();
const [ppiYn, setPpiYn] = useState("Y");
@@ -76,25 +76,72 @@ export function PbnstBuseForm({
>([{ text: "없음", val: 0 }]);
const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false);
const [sumCpct, setSumCpct] = useState<number>(0);
const [getDmdList, setGetFmdList] = useState<number>(0);
const [isDmdModal, setIsDmdModal] = useState<{
isMoal: boolean;
data: DemandCompType;
}>({ isMoal: false, data: {} as DemandCompType });
useEffect(() => {
const total =
const etc= isNaN(Number(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.etc`)))
let total =
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.gvsbs`) ?? 0) +
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.lcep`) ?? 0) +
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`) ?? 0);
(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`) ?? 0)
if( !etc ) {
total+=Number(form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.etc`))
}
form.setValue(`items.${indexMng}.fcBizs.${indexBiz}.totalMoney`, total);
}, [
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.gvsbs`),
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.lcep`),
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.cusrAlotm`),
form.getValues(`items.${indexMng}.fcBizs.${indexBiz}.etc`)
]);
const fcOrgwts = form.watch( `items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts`)
useEffect(() =>{
console.log('fcOrgwts ', fcOrgwts)
if(fcOrgwts&&fcOrgwts?.length>0){
const swtrmtFcltFkList = fcOrgwts.map((item) => item.swtrmtFcltFk);
console.log('swtrmtFcltFkList ', swtrmtFcltFkList)
if(swtrmtFcltFkList.length > 0){
getFcOrgwts(swtrmtFcltFkList.filter((item): item is string => item != null), fcOrgwts?.length)
}
}
},[fcOrgwts])
useEffect(() =>{
if (fcOrgwtsNmList && fcOrgwtsNmList.length > 0) {
console.log('fcOrgwtsNmList ', fcOrgwtsNmList)
console.log('fcOrgwts ', fcOrgwts)
fcOrgwts?.forEach((item, index) => {
const orgwtNm = fcOrgwtsNmList.find(
(orgwt) => orgwt.bscFctCd === item.swtrmtFcltFk
)?.bscFctNm;
console.log('orgwtNm ', orgwtNm)
if (orgwtNm) {
form.setValue(
`items.${indexMng}.fcBizs.${indexBiz}.fcOrgwts.${index}.ruseUtztnFcltNm`,
orgwtNm
);
}
});
}
},[fcOrgwtsNmList,fcOrgwts])
// fcBizs 데이터가 변경될 때마다 차수 선택 목록을 업데이트합니다.
useEffect(() => {
const cycleLength = fcBizs.length;
@@ -29,6 +29,10 @@ import { TEST_UUID } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { Label } from "@common/business_components/ui/form/lib/label";
import React from "react";
import RuseMngTableForm from "@/components/ui/table/pbnstReg/ruseMngTableForm/ruseMngTableForm";
import {
handleCommaNumberChange,
formatCommaNumber,
} from "@/components/lib/func/commom";
export type FilesType = {
atflCd: string;
file: File;
@@ -46,13 +50,9 @@ export function PbnstMngForm({
indexMng: number;
setIndexMng: (index: number) => void;
}) {
const {
code,
pbnst,
pbnstInsert,
fileDelete,
fileDownLoad,
} = useWrStore((state) => state);
const { code, pbnst, pbnstInsert, fileDelete, fileDownLoad } = useWrStore(
(state) => state
);
const { pbnstRes } = pbnst;
const [regFileList, setRegFileList] = useState<fcFileType[] | null>(null);
@@ -215,16 +215,14 @@ export function PbnstMngForm({
useEffect(() => {
if (pbnst.pbnstRes && pbnst.pbnstRes?.length >= 0) {
const fcltNmList = pbnst.pbnstRes?.map((item, index) => ({
text: item.ruseUtztnFcltNm,
val: String(index),
}));
console.log(' fcltNmList ', fcltNmList)
console.log(" fcltNmList ", fcltNmList);
if (fcltNmList) setFcltNm(fcltNmList);
}else{
} else {
setFcltNm(null);
}
}, [pbnst.pbnstRes]);
@@ -253,16 +251,14 @@ export function PbnstMngForm({
}
}, [code]);
useEffect(() =>{
// console.log(' fcltNm ', watchedItem?.ruseUtztnFcltNm)
},[watchedItem])
useEffect(() => {
// console.log(' fcltNm ', watchedItem?.ruseUtztnFcltNm)
}, [watchedItem]);
useEffect(() => {
console.log(" form indexMng ", indexMng);
}, [indexMng]);
}, [indexMng]);
return (
<div className=" !mx-[1.6rem] !p-0r">
<div>
@@ -297,8 +293,6 @@ export function PbnstMngForm({
render={({ field }) => (
<FormUi label="">
<Input
className="!text-2xl"
placeholder=""
type="text"
@@ -379,11 +373,12 @@ export function PbnstMngForm({
<Input
key={`items.${indexMng}.fcltCpct`}
placeholder=""
type="number"
type="text"
onChange={(e) => {
field.onChange(Number(e.target.value));
if (formType !== "sttn")
handleCommaNumberChange(e, field.onChange);
}}
value={field.value ?? 0}
value={formatCommaNumber(field.value)}
readOnly={formType === "sttn" ? true : false}
/>
</FormUi>
@@ -401,11 +396,12 @@ export function PbnstMngForm({
<Input
key={`items.${indexMng}.ruseCpct`}
placeholder=""
type="number"
type="text"
onChange={(e) => {
field.onChange(Number(e.target.value));
if (formType !== "sttn")
handleCommaNumberChange(e, field.onChange);
}}
value={field.value ?? 0}
value={formatCommaNumber(field.value)}
readOnly={formType === "sttn" ? true : false}
/>
</FormUi>
@@ -422,11 +418,12 @@ export function PbnstMngForm({
<Input
key={`items.${indexMng}.splyExtraCpct`}
placeholder=""
type="number"
type="text"
onChange={(e) => {
field.onChange(Number(e.target.value));
if (formType !== "sttn")
handleCommaNumberChange(e, field.onChange);
}}
value={field.value ?? 0}
value={formatCommaNumber(field.value)}
readOnly={formType === "sttn" ? true : false}
/>
</FormUi>
@@ -2,17 +2,14 @@
import { useWrStore } from "@/app/store";
import type { formDetailType } from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/headList";
import { formH1Class } from "@/components/lib/class/comClass";
import { safeDate } from "@/components/lib/func/commom";
import { formatCommaNumber, handleCommaNumberChange, safeDate } from "@/components/lib/func/commom";
import {
DatePicker,
FormField,
FormUi,
SearchInputSelect,
SelectBox,
type SelectDataType,
} from "@common/business_components/ui";
import { Input } from "@common/components/ui";
import { useState } from "react";
export default function MngRegFormDetail({
formList,
@@ -55,9 +52,7 @@ export default function MngRegFormDetail({
name={fieldId}
render={({ field }) => (
<FormUi label={formHead.lable}>
{formHead.type === "select" ? (
<Input placeholder="" type="text" {...field} />
) : formHead.type === "date" ? (
{formHead.type === "date" ? (
<DatePicker
mode={"single"}
className={"rounded-lg !w-full"}
@@ -67,35 +62,54 @@ export default function MngRegFormDetail({
field.onChange(date),
}}
selectClass={"w-full"}
disabled={formHead.option === "disabled" ? true : false}
/>
) : formHead.type === "number" ? (
<Input
placeholder=""
type="number"
value={field.value ?? 0}
type="text"
onChange={(e) => {
field.onChange(Number(e.target.value));
handleCommaNumberChange(
e,
field.onChange
);
}}
readOnly={formHead.option === "readOnly"?true:false}
/>
) : formHead.type === "selectYn" ? (
<SelectBox
label={""}
selectClass={""}
className="w-full"
selectArray={code.yn}
onSelectValue={(val: string | number) =>
field.onChange(val)
}
value={field.value ?? "Y"}
value={formatCommaNumber(field.value)}
readOnly={formHead.option === "readOnly" ? true : false}
disabled={formHead.option === "disabled" ? true : false}
/>
) : formHead.type === "select" ? (
(() => {
const potentialOptions = formHead.selectData
? code[formHead.selectData as keyof typeof code]
: [];
return (
<SelectBox
label={""}
selectClass={""}
className="w-full"
selectArray={
Array.isArray(potentialOptions)
? potentialOptions
: []
}
onSelectValue={field.onChange}
value={field.value.trim()}
readOnly={formHead.option === "readOnly"}
/>
);
})()
) : (
<Input
placeholder=""
type="text"
value={field.value ?? ""}
onChange={field.onChange}
readOnly={formHead.option === "readOnly"?true:false}
readOnly={formHead.option === "readOnly" ? true : false}
disabled={formHead.option === "disabled" ? true : false}
/>
)}
</FormUi>