온배수 현황 및 중수도 지도점검 작업중
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
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";
|
||||
|
||||
@@ -7,9 +8,9 @@ import { Checkbox, Input, TableCell, TableRow } from "@common/components/ui";
|
||||
|
||||
|
||||
|
||||
export const rightTableData = (rainChk: rainChkZodType[]) => {
|
||||
export const rainChkTableData = (chkData: rainChkZodType[]) => {
|
||||
// 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
|
||||
const maketotal = rainChk.map((item: rainChkZodType) => {
|
||||
const maketotal = chkData.map((item: rainChkZodType) => {
|
||||
const selectTotal = item.guideDetails.reduce((acc: any, cur: any) => {
|
||||
const code = cur.utztnUsgCd;
|
||||
const fk = cur.chkgdnFk;
|
||||
@@ -36,7 +37,7 @@ export const rightTableData = (rainChk: rainChkZodType[]) => {
|
||||
// 3. rainyDetails에 누계 정보 주입
|
||||
|
||||
const updatedRainyDetails: any[] = [];
|
||||
rainChk.forEach((rd: rainChkZodType) => {
|
||||
chkData.forEach((rd: rainChkZodType) => {
|
||||
rd.rainyDetails.forEach((rainyItem: any) => {
|
||||
const key = `${rainyItem.chkgdnFk}_${rainyItem.utztnUsgCd}`;
|
||||
const totals = flatTotalMap[key] || {
|
||||
@@ -57,6 +58,110 @@ export const rightTableData = (rainChk: rainChkZodType[]) => {
|
||||
return updatedRainyDetails;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export const rswtChkTableData = (chkData: rswtChkZodType[]) => {
|
||||
// 1. chkgdnFk + utztnUsgCd 기준 누계 정보 만들기
|
||||
const maketotal = makeTotalChk(chkData)
|
||||
|
||||
// 2. 누계 정보들을 하나의 객체로 합치기 (평탄화)
|
||||
const flatTotalMap = Object.assign({}, ...maketotal);
|
||||
|
||||
// 3. rainyDetails에 누계 정보 주입
|
||||
|
||||
const updatedRainyDetails: any[] = [];
|
||||
// chkData.forEach((rd: rswtChkZodType) => {
|
||||
// rd.rswtrDetails.forEach((rswtItem: any) => {
|
||||
// const keyGuide = `${rswtItem.chkgdnFk}_${rswtItem.utztnUsgCd}_guide`;
|
||||
// const keyPolution = `${rswtItem.chkgdnFk}_${rswtItem.utztnUsgCd}_poliution`;
|
||||
// const totalsGuide = flatTotalMap[keyGuide] || {
|
||||
// totalSplyUswtrUtztnQnt: 0,
|
||||
// totalRuseFcltUtztnQnt: 0,
|
||||
// };
|
||||
|
||||
// updatedRainyDetails.push({
|
||||
// ...rd,
|
||||
// ...rd.building,
|
||||
// ...rswtItem,
|
||||
// ...totalsGuide,
|
||||
// averCombResdch:totalsGuide.averCombResdch/rswtItem
|
||||
// totalsGuide.averTrbt:0,
|
||||
// totalsGuide.averBod:0,
|
||||
// totalsGuide.averSmll:0,
|
||||
// totalsGuide.averCrmty:0,
|
||||
// totalsGuide.averTph:0,
|
||||
// totalsGuide.averTn:0,
|
||||
// totalsGuide.averPh:0,
|
||||
// totalsGuide.averClIonQnt:0,
|
||||
// rowspan: rd.rswtrDetails?.length,
|
||||
// });
|
||||
// });
|
||||
// });
|
||||
|
||||
return updatedRainyDetails;
|
||||
};
|
||||
|
||||
const makeTotalChk=(chkData: rswtChkZodType[])=>{
|
||||
const maketotal = chkData.map((item: rswtChkZodType) => {
|
||||
const selectTotalWater = item.guideDetails.reduce((acc: any, cur: any) => {
|
||||
const code = cur.utztnUsgCd;
|
||||
const fk = cur.chkgdnFk;
|
||||
const flg = 'guide'
|
||||
|
||||
const key = `${fk}_${code}_${flg}`;
|
||||
acc[key] = acc[key] || {
|
||||
totalSplyUswtrUtztnQnt: 0,
|
||||
totalRuseFcltUtztnQnt: 0,
|
||||
};
|
||||
|
||||
acc[key].totalSplyUswtrUtztnQnt += cur.splyUswtrUtztnQnt;
|
||||
acc[key].totalRuseFcltUtztnQnt += cur.ruseFcltUtztnQnt;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
const selectAverPolution = item.rswtrPolutions.reduce((acc: any, cur: any) => {
|
||||
const code = cur.utztnUsgCd;
|
||||
const fk = cur.chkgdnFk;
|
||||
const flg = 'poliution'
|
||||
|
||||
const key = `${fk}_${code}_${flg}`;
|
||||
acc[key] = acc[key] || {
|
||||
averCombResdch:0,
|
||||
averTrbt:0,
|
||||
averBod:0,
|
||||
averSmll:0,
|
||||
averCrmty:0,
|
||||
averTph:0,
|
||||
averTn:0,
|
||||
averPh:0,
|
||||
averClIonQnt:0,
|
||||
node:0
|
||||
};
|
||||
|
||||
acc[key].averCombResdch+=cur.combResdch
|
||||
acc[key].averTrbt+=cur.trbt
|
||||
acc[key].averBod+=cur.bod
|
||||
acc[key].averSmll+=cur.smll
|
||||
acc[key].averCrmty+=cur.crmty
|
||||
acc[key].averTph+=cur.tph
|
||||
acc[key].averTn+=cur.tn
|
||||
acc[key].averPh+=cur.ph
|
||||
acc[key].averClIonQnt+=cur.clIonQnt
|
||||
acc[key].nod+=1
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
|
||||
return {...selectTotalWater, ...selectAverPolution}; // 모든 키: `${chkgdnFk}_${utztnUsgCd}` 형태
|
||||
});
|
||||
return maketotal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
export const chRowspanTable = (
|
||||
makeTableData: any[],
|
||||
headList: TableUpperProps[],
|
||||
@@ -90,7 +195,6 @@ export const chRowspanTable = (
|
||||
renderedSet.add(rowIndex + i);
|
||||
}
|
||||
renderedMap.set(key, renderedSet);
|
||||
|
||||
return (
|
||||
<TableCell
|
||||
key={key}
|
||||
|
||||
@@ -3,6 +3,8 @@ import {
|
||||
filePickedBlob,
|
||||
type SelectDataType,
|
||||
type ReturnType,
|
||||
filePickedBlobArray,
|
||||
sheetParameter,
|
||||
} from "@common/business_components/ui";
|
||||
import type { RefObject } from "react";
|
||||
|
||||
@@ -62,7 +64,8 @@ export const excelDownload = (
|
||||
excelList: [][],
|
||||
fileNm: string,
|
||||
sampleFile: string,
|
||||
headerRange = "A1:V3"
|
||||
headerRange = "A1:V3",
|
||||
writeLine=4
|
||||
) => {
|
||||
if (excelList.length === 0) return;
|
||||
fetch(`/${sampleFile}`, {}).then(async (response) => {
|
||||
@@ -72,10 +75,29 @@ export const excelDownload = (
|
||||
// 받은 파일 바인너리 처리
|
||||
const blobRet = await response.arrayBuffer();
|
||||
// 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
|
||||
await filePickedBlob(blobRet, excelList, fileNm, 4, headerRange);
|
||||
await filePickedBlob(blobRet, excelList, fileNm, writeLine, headerRange);
|
||||
});
|
||||
};
|
||||
|
||||
export const excelArrayDownload = (
|
||||
fileNm: string,
|
||||
sampleFile: string,
|
||||
sheetArray:[typeof sheetParameter]
|
||||
) => {
|
||||
if (!sheetArray) return;
|
||||
fetch(`/${sampleFile}`, {}).then(async (response) => {
|
||||
if (!response.ok) {
|
||||
throw Error(response.statusText);
|
||||
}
|
||||
// 받은 파일 바인너리 처리
|
||||
const blobRet = await response.arrayBuffer();
|
||||
// 버퍼에 있는 엑셀데이터 전달 후 json으로 변환
|
||||
await filePickedBlobArray(blobRet, fileNm, sheetArray);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// onchange 텍스트를 숫자로 and ,제거
|
||||
export const handleCommaNumberChange = (
|
||||
e: React.ChangeEvent<HTMLInputElement>,
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { rainRegExcel, type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import { type rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import { excelToRainChkData } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/excel";
|
||||
import { chkgdRegExcel } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import {
|
||||
excelToRswtGuideData,
|
||||
excelToRswtPolution,
|
||||
} from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn/excel";
|
||||
import { ToastFormUi } from "@/components/ui/toast/toastFromUi";
|
||||
import {
|
||||
filePicked,
|
||||
filePickedArray,
|
||||
FileUpload,
|
||||
Form,
|
||||
FormField,
|
||||
FormUi,
|
||||
Title
|
||||
Title,
|
||||
} from "@common/business_components/ui";
|
||||
import { Button, Input } from "@common/components/ui";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
@@ -17,107 +24,199 @@ import { useForm } from "react-hook-form";
|
||||
import type { z } from "zod";
|
||||
|
||||
export default function ChkgdExcel({ type }: { type: string }) {
|
||||
const { rainChkExcelDataUPload } = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
const {
|
||||
rswtChkgdn,
|
||||
rainChkExcelDataUPload,
|
||||
rswtChkExceDataUpload,
|
||||
} = useWrStore((state) => {
|
||||
return state;
|
||||
});
|
||||
const [files, setFiles] = useState<File[] | null>(null);
|
||||
const [excelData , setExcelData] = useState<rainChkZodType[]>()
|
||||
const defaultValues: z.infer<typeof rainRegExcel> = rainRegExcel.parse({});
|
||||
const [excelData, setExcelData] = useState<
|
||||
rswtChkZodType[] | rainChkZodType[]
|
||||
>();
|
||||
const [excelRswtData, setExcelRswtData] = useState<rswtChkZodType[]>();
|
||||
|
||||
const form = useForm<z.infer<typeof rainRegExcel>>({
|
||||
resolver: zodResolver(rainRegExcel),
|
||||
const defaultValues: z.infer<typeof chkgdRegExcel> = chkgdRegExcel.parse({});
|
||||
|
||||
const form = useForm<z.infer<typeof chkgdRegExcel>>({
|
||||
resolver: zodResolver(chkgdRegExcel),
|
||||
defaultValues: defaultValues,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (files) {
|
||||
const file = files[0];
|
||||
if(form.getValues("chckYr").length<1 ){
|
||||
ToastFormUi({body:"파일업로드 이전에 등록년도를 작성해주세요 " ,title:'지도점검 등록'})
|
||||
setFiles(null)
|
||||
return
|
||||
}
|
||||
if (file)
|
||||
if (files) {
|
||||
const file = files[0];
|
||||
if (form.getValues("chckYr").length < 1) {
|
||||
ToastFormUi({
|
||||
body: "파일업로드 이전에 등록년도를 작성해주세요 ",
|
||||
title: "지도점검 등록",
|
||||
});
|
||||
setFiles(null);
|
||||
return;
|
||||
}
|
||||
if (file)
|
||||
if (type === "RNB") {
|
||||
filePicked(file, 0).then((res) => {
|
||||
if (res !== undefined)
|
||||
setExcelData(excelToRainChkData(res, form.getValues("chckYr")))
|
||||
setExcelData(excelToRainChkData(res, form.getValues("chckYr")));
|
||||
});
|
||||
}
|
||||
} else if (type === "RST") {
|
||||
filePickedArray(file, 0).then((res) => {
|
||||
if (res && res?.length > 1) {
|
||||
const excelArray = [];
|
||||
const guideData = excelToRswtGuideData(
|
||||
res[0],
|
||||
form.getValues("chckYr")
|
||||
);
|
||||
const polutionData = excelToRswtPolution(
|
||||
res[1],
|
||||
form.getValues("chckYr")
|
||||
);
|
||||
|
||||
|
||||
const keyGenerator = (item: rswtChkZodType) =>
|
||||
`${item.bdstRuseFcltFk}|${item.chckYmd}|${item.utztnUsgCd}`;
|
||||
const totalData: rswtChkZodType[] = guideData.map((guide) => {
|
||||
const fusion = polutionData.find(
|
||||
(polution) =>
|
||||
guide.bdstRuseFcltFk === polution.bdstRuseFcltFk &&
|
||||
guide.chckYmd === polution.chckYmd &&
|
||||
guide.utztnUsgCd === polution.utztnUsgCd
|
||||
);
|
||||
|
||||
if (fusion) {
|
||||
return {
|
||||
...guide,
|
||||
rswtrPolutions: fusion?.rswtrPolutions,
|
||||
rswtrDetails:fusion?.rswtrDetails
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
...guide,
|
||||
};
|
||||
}
|
||||
});
|
||||
const guideKey = new Set(guideData.map(keyGenerator));
|
||||
|
||||
const onlypolution = polutionData.filter(
|
||||
(item) => !guideKey.has(keyGenerator(item))
|
||||
);
|
||||
|
||||
const listTotalData:rswtChkZodType[] =[
|
||||
...totalData,
|
||||
...onlypolution
|
||||
]
|
||||
|
||||
setExcelRswtData(listTotalData);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, [files]);
|
||||
|
||||
const onSubmit =(values: z.infer<typeof rainRegExcel>)=> {
|
||||
if(values.chckYr ===''){
|
||||
ToastFormUi({body:"등록년도를 작성해주세요" ,title:'지도점검 등록'})
|
||||
return
|
||||
}else if(excelData ===undefined || excelData?.length === 0 ){
|
||||
ToastFormUi({body:"빈 파일 및 파일 오류 입니다." ,title:'지도점검 등록'})
|
||||
return
|
||||
}
|
||||
if (excelData) {
|
||||
rainChkExcelDataUPload(excelData);
|
||||
}
|
||||
|
||||
function findMatchingItems<T>(
|
||||
arrayA: T[],
|
||||
arrayB: T[],
|
||||
keySelector: (item: T) => string,
|
||||
condition?: (item: T) => boolean
|
||||
): T[] {
|
||||
const bKeySet = new Set(arrayB.map(keySelector));
|
||||
return arrayA.filter(
|
||||
(item) =>
|
||||
(!condition || condition(item)) && bKeySet.has(keySelector(item))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const onSubmit = (values: z.infer<typeof chkgdRegExcel>) => {
|
||||
if (values.chckYr === "") {
|
||||
ToastFormUi({ body: "등록년도를 작성해주세요", title: "지도점검 등록" });
|
||||
return;
|
||||
}
|
||||
|
||||
if (type === "RNB") {
|
||||
if (excelData === undefined || excelData?.length === 0) {
|
||||
ToastFormUi({
|
||||
body: "빈 파일 및 파일 오류 입니다.",
|
||||
title: "지도점검 등록",
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
rainChkExcelDataUPload(excelData as rainChkZodType[]);
|
||||
}
|
||||
} else if (type === "RST") {
|
||||
if (excelRswtData === undefined || excelRswtData?.length === 0) {
|
||||
ToastFormUi({
|
||||
body: "빈 파일 및 파일 오류 입니다.",
|
||||
title: "중수지도점검 등록",
|
||||
});
|
||||
return;
|
||||
} else {
|
||||
rswtChkExceDataUpload(excelRswtData as rswtChkZodType[]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)}>
|
||||
<div>
|
||||
<Title
|
||||
title={
|
||||
type === "RNB"
|
||||
? "빗물 이용시설"
|
||||
: "중수도 이용시설" + "점검 결과등록"
|
||||
}
|
||||
></Title>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<h3 className="text-2xl font-bold text-gray-900">
|
||||
{"○점검정보 입력"}
|
||||
</h3>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)}>
|
||||
<div>
|
||||
<Title
|
||||
title={
|
||||
type === "RNB"
|
||||
? "빗물 이용시설"
|
||||
: "중수도 이용시설" + "점검 결과등록"
|
||||
}
|
||||
></Title>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<h3 className="text-2xl font-bold text-gray-900">
|
||||
{"○점검정보 입력"}
|
||||
</h3>
|
||||
|
||||
<Button className="" type="submit">
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
<Button className="" type="submit">
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chckYr"
|
||||
render={({ field }) => (
|
||||
<FormUi label="등록년도">
|
||||
<Input
|
||||
className={`text-3xl`}
|
||||
type="text"
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
<div>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="chckYr"
|
||||
render={({ field }) => (
|
||||
<FormUi label="등록년도">
|
||||
<Input
|
||||
className={`text-3xl`}
|
||||
type="text"
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
/>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="file"
|
||||
render={({ field }) => (
|
||||
<FormUi label="점검결과 파일">
|
||||
<FileUpload
|
||||
files={files || []}
|
||||
setFiles={(files: File[] | null ) => {
|
||||
if(files) setFiles(files)
|
||||
} }
|
||||
fileTypes="xlsx"
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="file"
|
||||
render={({ field }) => (
|
||||
<FormUi label="점검결과 파일">
|
||||
<FileUpload
|
||||
files={files || []}
|
||||
setFiles={(files: File[] | null) => {
|
||||
if (files) setFiles(files);
|
||||
}}
|
||||
fileTypes="xlsx"
|
||||
></FileUpload>
|
||||
</FormUi>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import { useWrStore } from "@/app/store";
|
||||
import { ScrollArea, Title, UiTable } from "@common/business_components/ui";
|
||||
import { Button } from "@common/components/ui";
|
||||
import { useEffect, useState } from "react";
|
||||
import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn";
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { GuideDetailsTable } from "@/components/ui/table/chkgdTable/guideDetailTable/guideDetailTable";
|
||||
import type { splRuseWaterType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn/headList";
|
||||
|
||||
export default function ChkgdModal({ type, obj }: { type: string; obj: any }) {
|
||||
const { rainChkgdn, rainChkDetilUpdate, rainChkGuidUpdate } = useWrStore(
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { customRswtBdst } from "@/app/store/ruseFcltMng/fcltReg/rswtReg";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { useEffect, useState } from "react";
|
||||
import type { CommonTableProps } from "@/app/store/common/type/headder";
|
||||
import { rightTableData } from "@/components/lib/func/TableData";
|
||||
import { rainChkTableData } from "@/components/lib/func/TableData";
|
||||
import { HeadMakeColSpan } from "@common/business_components/ui/table/HeadMakeColSpan";
|
||||
|
||||
export default function SttnDetailModal({
|
||||
@@ -40,7 +40,7 @@ export default function SttnDetailModal({
|
||||
formObj.reuseBuilding[0] &&
|
||||
rainSttn.rainChkRes?.bdstRuseFcltFk
|
||||
) {
|
||||
const tableTotalData = rightTableData([rainSttn.rainChkRes]);
|
||||
const tableTotalData = rainChkTableData([rainSttn.rainChkRes]);
|
||||
const data = tableTotalData.map((item) => {
|
||||
const obj = {
|
||||
totalSplyUswtrUtztnQnt: item.totalSplyUswtrUtztnQnt,
|
||||
@@ -72,7 +72,7 @@ export default function SttnDetailModal({
|
||||
return (
|
||||
|
||||
<div>
|
||||
<Title title={"빗물이용시설 상세정보"}></Title>
|
||||
<Title title={type === "RNB" ?"빗물이용시설 상세정보":"중수도시설 상세정보"}></Title>
|
||||
<ScrollArea className={detailData.data.length>0?"h-[80vh]":"h-[70vh]"} >
|
||||
{type === "RNB" ? (
|
||||
<RainRegForm rainForm={formObj as customRainBdst} isModal={false} />
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { rainChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rainChkgdn"
|
||||
import { tableData } from "@/components/lib/func/commom";
|
||||
import {
|
||||
chRowspanTable,
|
||||
rightTableData
|
||||
rainChkTableData
|
||||
} from "@/components/lib/func/TableData";
|
||||
import {
|
||||
Table,
|
||||
@@ -66,13 +66,11 @@ export default function RainChkgdTable({
|
||||
rowspan: item.rainyDetails?.length,
|
||||
};
|
||||
});
|
||||
const tableTotalData = rightTableData(rainChg)
|
||||
const tableTotalData = rainChkTableData(rainChg)
|
||||
setMakeTableData(tableTotalData);
|
||||
}, [rainChkgdn.rainChk, code]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
//데이터를 평탄화 한것중에 체크박스 선택한 테이블만 선택
|
||||
const selectedData = makeTableData.filter((item) =>selectedIds.includes(item.chkgdnPk));
|
||||
|
||||
@@ -132,10 +130,6 @@ export default function RainChkgdTable({
|
||||
}
|
||||
},[selectedIds])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
},[])
|
||||
|
||||
|
||||
return (
|
||||
<Table variant="secondary">
|
||||
|
||||
@@ -1,30 +1,79 @@
|
||||
'use client'
|
||||
"use client";
|
||||
|
||||
import { headMakeprfmnc } from "@/app/ruseFcltMng/prfmncReg/chkgdnReg/TableHead";
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { UiTable } from "@common/business_components/ui";
|
||||
import type { rswtChkZodType } from "@/app/store/prfmncReg/chkgdnReg/rswrtChkgdn";
|
||||
import { chRowspanTable } from "@/components/lib/func/TableData";
|
||||
import { Table, TableBody, TableHeader } from "@common/components/ui";
|
||||
import { useCallback, useState } from "react";
|
||||
|
||||
export default function RswtChkgdTable() {
|
||||
export default function RswtChkgdTable({
|
||||
detaiRswtlUpdate,
|
||||
handleRswtClick = () => {},
|
||||
deleteRswtData,
|
||||
}: {
|
||||
detaiRswtlUpdate: (data: rswtChkZodType[]) => void;
|
||||
handleRswtClick?: (data: any) => void;
|
||||
deleteRswtData: (selectedIds: number[]) => void;
|
||||
}) {
|
||||
const { code, rswtChkgdn, rswtChkgdnInit } = useWrStore((state) => state);
|
||||
|
||||
const { rswtChkgdn} = useWrStore((state) => state);
|
||||
const nodeList = headMakeprfmnc(rswtChkgdn?.rswtChkgdnHeadList , rswtChkgdn?.rswtHeadNm );
|
||||
|
||||
const [makeTableData, setMakeTableData] = useState<any[]>([]);
|
||||
const [selectedIds, setSelectedIds] = useState<number[]>([]);
|
||||
const [upRaintDetail, setUpRaintDetail] = useState<rswtChkZodType[]>([]);
|
||||
const toggleSelection = (pk: number, checked: boolean) => {
|
||||
setSelectedIds((prev) =>
|
||||
checked ? [...prev, pk] : prev.filter((item) => item !== pk)
|
||||
);
|
||||
};
|
||||
const handleChange = (
|
||||
rowIndex: number,
|
||||
field: keyof (typeof makeTableData)[0],
|
||||
value: string | number
|
||||
) => {
|
||||
setMakeTableData((prev) =>
|
||||
prev.map((row, idx) => {
|
||||
return idx === rowIndex ? { ...row, [field]: value } : row;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
return(
|
||||
|
||||
<>
|
||||
<UiTable
|
||||
tableData={[]}
|
||||
headlist={rswtChkgdn.rswtChkgdnHeadList}
|
||||
pageSize={100}
|
||||
total={10}
|
||||
headName={"지도점검 결과등록"}
|
||||
cellClick={() => { } } onPageChange={function (page: number): void {
|
||||
throw new Error("Function not implemented.");
|
||||
} } >
|
||||
{nodeList}
|
||||
</UiTable>
|
||||
</>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
const handleCellClick = useCallback(
|
||||
(index: number, headId: string) => {
|
||||
if (
|
||||
headId === "totalSplyUswtrUtztnQnt" ||
|
||||
headId === "totalRuseFcltUtztnQnt"
|
||||
) {
|
||||
handleRswtClick(makeTableData[index]);
|
||||
}
|
||||
},
|
||||
[makeTableData, handleRswtClick]
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<Table variant="secondary">
|
||||
<TableHeader className="font-bold">
|
||||
{headMakeprfmnc(rswtChkgdn?.rswtChkHeadList, rswtChkgdn?.rswtHeadNm)}
|
||||
</TableHeader>
|
||||
|
||||
<TableBody>
|
||||
{chRowspanTable(
|
||||
makeTableData,
|
||||
rswtChkgdn.rswtChkHeadList,
|
||||
handleChange,
|
||||
toggleSelection,
|
||||
selectedIds,
|
||||
handleCellClick
|
||||
)}
|
||||
</TableBody>
|
||||
</Table>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user