중복 타입 제거 및 실적등록 완료

This commit is contained in:
leedj312
2025-06-07 08:05:04 +09:00
parent 89709aacd3
commit e0c235e26b
48 changed files with 657 additions and 250 deletions
+63 -2
View File
@@ -1,6 +1,6 @@
import type { TableUpperProps } from "@/app/store/common/type/header";
import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { Checkbox, Input, TableCell, TableRow } from "@common/components/ui";
export const rainChkTableData = (chkData: rainChkZodType[]) => {
@@ -101,7 +101,7 @@ export const chRowspanTable = (
.map((head) => {
const key = head.id;
const isMerged = head.rowSpan;
const isMerged = head.mergeCell;
const value = row[key];
// 병합 대상이면 중복 렌더링 여부 판단
if (isMerged) {
@@ -184,4 +184,65 @@ export const headVisibleChange = (headList: TableUpperProps[], isEdit: boolean)
}
});
}
const handleChange = (
rowIndex: number,
field: any,
value: string | number,
setInputData: (data:any) => void
) => {
if(Number(value) < 0 ||! Number(value)){
value = 0;
}else{
value = Number(value);
}
setInputData((prevData:any) =>
prevData?.map((row:any, index: number) => {
if (index === rowIndex) {
return {
...row,
[field ]: value,
};
}
return row;
})
);
};
;
export const InputTableBody = (chgRes: any[] | [] ,headList:TableUpperProps[], setInputData: (data: any[]) => void) => {
return (
<>
{chgRes.map((data, dataIndex) => (
<TableRow key={dataIndex + "row"}>
{headList.map((head, 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-xl h-10 w-full`}
onChange={(e) =>
handleChange(dataIndex, head.id, e.target.value,setInputData)
}
value={data[head.id as keyof any] ?? ""}
/> : (
<div
className={`
${head.id !== "utztnUsgCd" ? "text-right" : "text-center"}
!text-xl w-full h-10
`}
>
{data[head.id as keyof any] ?? ""}
</div>
)
}
</TableCell>
))}
</TableRow>
))}
</>
);
}
@@ -8,7 +8,7 @@ import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgd
import type { rswtrPolutionsZode } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/headList";
import type { z } from "zod";
import React from "react";
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { TableUpperProps } from "@/app/store/common/type/header";
export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
const {
@@ -32,9 +32,10 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
},
});
const onSubmit = (values: z.infer<typeof pbnPrfRegExcelZod>) => {
console.log(values);
prfmnRegData(excelData )
if (excelData) {
prfmnRegData(excelData as unknown as PrfType);
}
};
@@ -64,7 +65,7 @@ export default function PbnPrfExcelModal({ data }: { data: FcPrfType }) {
if (file)
filePicked(file, 0).then((res) => {
if (res !== undefined)
setExcelData(excelToPbnPrfData(res as any, form.getValues("ym"),form.getValues('pbnstRuseFcltFk') ))
setExcelData(excelToPbnPrfData(res as unknown as JSON[], form.getValues("ym"),form.getValues('pbnstRuseFcltFk') ) as PrfType[])
});
}
}, [files]);
@@ -1,7 +1,7 @@
"use client";
import { useWrStore } from "@/app/store";
import type { pubHasuType, fcBizType, fcOrgwtType,} from "@/app/store/ruseFcltMng/fcltReg/pbnstReg/type";
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { TableUpperProps } from "@/app/store/common/type/header";
import { tableData } from "@/components/lib/func/commom";
import RuseMngTable from "@/components/ui/table/pbnstReg/ruseMngTable/ruseMngTable";
import { Title, UiTable } from "@common/business_components/ui";
@@ -1,6 +1,6 @@
"use client";
import { useWrStore } from "@/app/store";
import type { CommonTableProps } from "@/app/store/common/type/headder";
import type { CommonTableProps } from "@/app/store/common/type/header";
import { Title } from "@common/business_components/ui";
import { useEffect, useState } from "react";
@@ -8,7 +8,7 @@ import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
import type { customHtdflBdst } from "@/app/store/ruseFcltMng/fcltReg/htdflReg";
import { useWrStore } from "@/app/store";
import { useEffect, useState } from "react";
import type { CommonTableProps } from "@/app/store/common/type/headder";
import type { CommonTableProps } from "@/app/store/common/type/header";
import { rainChkTableData, rswtChkTableData } from "@/components/lib/func/TableData";
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
@@ -1,9 +1,10 @@
"use client";
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
import { useWrStore } from "@/app/store";
import type { TableUpperProps } from "@/app/store/common/type/header";
import type {
} from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import { InputTableBody } from "@/components/lib/func/TableData";
import {
Input,
Table,
@@ -12,7 +13,7 @@ import {
TableHeader,
TableRow,
} from "@common/components/ui";
import { useEffect, useState } from "react";
import { useEffect, useState, type Dispatch, type SetStateAction } from "react";
export function GuideDetailsTable({
chgRes,
@@ -26,80 +27,26 @@ export function GuideDetailsTable({
setChGuidData: (chgRes: any[]) => void;
}) {
const { code, rainChkgdn } = useWrStore((state) => state);
const [guidData, setGuidData] = useState<any[]>();
const [inputData, setInputData] = useState<any[]>();
const handleChange = (
rowIndex: number,
field: any,
value: string | number
) => {
if(Number(value) < 0 ||! Number(value)){
value = 0;
}else{
value = Number(value);
}
setGuidData((prevData) =>
prevData?.map((row, index) => {
if (index === rowIndex) {
return {
...row,
[field as any]: value,
};
}
return row;
})
);
};
const tableBody = (chgRes: any[] | []) => {
return (
<>
{chgRes.map((data, dataIndex) => (
<TableRow key={dataIndex + "row"}>
{headList.map((head, 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-xl h-10 w-full`}
onChange={(e) =>
handleChange(dataIndex, head.id, e.target.value)
}
value={data[head.id as keyof any] ?? ""}
/> : (
<div
className={`
${head.id !== "utztnUsgCd" ? "text-right" : "text-center"}
!text-xl w-full h-10
`}
>
{data[head.id as keyof any] ?? ""}
</div>
)
}
</TableCell>
))}
</TableRow>
))}
</>
);
};
useEffect(() => {
setGuidData(chgRes);
setInputData(chgRes);
}, [chgRes]);
useEffect(() => {
setChGuidData(guidData??[] );
setChGuidData(inputData??[] );
}, [guidData]);
}, [inputData]);
return (
<>
<div className={`card !m-[1.2rem] !p-0r `}>
<Table variant="secondary">
<TableHeader className="font-bold">{headMakeprfmnc(headList, rainChkgdn?.rainHeadNm)}</TableHeader>
<TableBody >
{tableBody(guidData ?? [])}
{InputTableBody(inputData ?? [],headList, setInputData) }
</TableBody>
</Table>
</div>
@@ -3,7 +3,7 @@ import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead"
import { useWrStore } from "@/app/store";
import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
import type { chHeadType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { TableUpperProps } from "@/app/store/common/type/header";
import { tableData } from "@/components/lib/func/commom";
import {
chRowspanTable,
@@ -6,7 +6,7 @@ import type {
rswtChkZodType,
rswtrChkDetailsZodType,
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
import type { TableUpperProps } from "@/app/store/ruseFcltMng/fcltReg/rainReg";
import type { TableUpperProps } from "@/app/store/common/type/header";
import { tableData } from "@/components/lib/func/commom";
import {
chRowspanTable,