From cfb91d518518ab8d0c1d60c2734b44a7104df1af Mon Sep 17 00:00:00 2001 From: YangJinSoo94 Date: Thu, 24 Apr 2025 11:50:57 +0900 Subject: [PATCH] firstcommit --- .../src/ui/table/HeadMakeColSpan.tsx | 41 +++++++++++++++++ .../src/ui/table/index.tsx | 45 +++++++++---------- 2 files changed, 63 insertions(+), 23 deletions(-) create mode 100644 packages/common/business_components/src/ui/table/HeadMakeColSpan.tsx diff --git a/packages/common/business_components/src/ui/table/HeadMakeColSpan.tsx b/packages/common/business_components/src/ui/table/HeadMakeColSpan.tsx new file mode 100644 index 000000000..7fb626568 --- /dev/null +++ b/packages/common/business_components/src/ui/table/HeadMakeColSpan.tsx @@ -0,0 +1,41 @@ +import { TableHead, TableRow } from "@common/components/ui"; + +interface TableUpperProps { + id: string; + title: string; + upName?: string; + upSequnce?: number; + row? : number; + rowSpan?: number; + colSpan?: number; +} + +const HeadMakeColSpan = ({ upHeadList }: { upHeadList: TableUpperProps[] }) => { + const maxRow = upHeadList.reduce((max, head) => Math.max(max, head.row || 0), 0); + return ( + <> + {Array.from({ length: maxRow + 1 }, (_, rowIndex) => ( + + {upHeadList.map((head: TableUpperProps) => { + if (head.row === rowIndex) { + return ( + + {head.title} + + ); + } + return null; + })} + + ))} + + ); +} + +export { HeadMakeColSpan }; diff --git a/packages/common/business_components/src/ui/table/index.tsx b/packages/common/business_components/src/ui/table/index.tsx index 994b9a827..f4a2230e4 100644 --- a/packages/common/business_components/src/ui/table/index.tsx +++ b/packages/common/business_components/src/ui/table/index.tsx @@ -1,6 +1,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@common/components"; import { useEffect, useState } from "react"; import UiPageNations from "./uiPageNations"; +import { HeadMakeColSpan } from "./HeadMakeColSpan"; type UiTableProps = { headName: React.ReactNode | undefined; @@ -52,30 +53,28 @@ export function UiTable({ tableData, headlist, pageSize, total, children, headNa
- {children ? <>{children} : - {headlist?.map((head) => ( - {head.title} + + + + {tableData?.map((el: { [key: string]: string | number | boolean | object}, index) => ( + console.log(index), + + {headlist?.map((head) => ( + head.id&&head.id.length == 1 ? <> : + handleCellClick(index, head.id)} + key={head.id + index} + > + {typeof el[head.id] === 'number' ? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",") : String(el[head.id] ?? '')} + + ))} + ))} - } - - - {tableData?.map((el: { [key: string]: string | number | boolean | object}, index) => ( - - {headlist?.map((head) => ( - handleCellClick(index, head.id)} - key={head.id + index} - > - {typeof el[head.id] === 'number' ? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",") : String(el[head.id] ?? '')} - - ))} - - ))} - +
{total <= 0 ? <> : }