코드 관리 페이지 추가
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
import dayjs from "dayjs";
|
||||
import { type ColumnDef} from "@tanstack/react-table";
|
||||
import { Button } from "@common/components";
|
||||
import type { UpCode } from "@/entities/code/model/upcode-interface";
|
||||
import type { LwpoCode } from "@/entities/code/model/lwpocode-interface";
|
||||
|
||||
type UpCodeTableMeta = {
|
||||
onManagementClick?: (row: UpCode) => void;
|
||||
};
|
||||
|
||||
type LwpoCodeTableMeta = {
|
||||
onManagementClick?: (row: LwpoCode) => void;
|
||||
};
|
||||
|
||||
export const upCodecolumns: ColumnDef<UpCode, UpCodeTableMeta>[] = [
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row, table }) => {
|
||||
const isSelected = row.getIsSelected();
|
||||
if (isSelected) {
|
||||
return "▶";
|
||||
}
|
||||
const totalRows = table.getRowCount();
|
||||
const currentPage = table.getState().pagination.pageIndex;
|
||||
const pageSize = table.getState().pagination.pageSize;
|
||||
return totalRows - (currentPage * pageSize + row.index);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "upCd",
|
||||
header: "상위코드",
|
||||
},
|
||||
{
|
||||
accessorKey: "upCdNm",
|
||||
header: "상위코드명",
|
||||
},
|
||||
{
|
||||
accessorKey: "cdSe",
|
||||
header: "코드구분",
|
||||
},
|
||||
{
|
||||
accessorKey: "useYn",
|
||||
header: "사용여부",
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => {
|
||||
const date = dayjs(row.original.regDt);
|
||||
return date.format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "management",
|
||||
header: "관리",
|
||||
cell: ({ row, table }) => {
|
||||
const onManagementClick = (table.options.meta as UpCodeTableMeta)?.onManagementClick;
|
||||
return (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onManagementClick?.(row.original);
|
||||
}}
|
||||
>
|
||||
관리
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const lowCodecolumns: ColumnDef<LwpoCode, LwpoCodeTableMeta>[] = [
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row, table }) => {
|
||||
const totalRows = table.getRowCount();
|
||||
const currentPage = table.getState().pagination.pageIndex;
|
||||
const pageSize = table.getState().pagination.pageSize;
|
||||
return totalRows - (currentPage * pageSize + row.index);
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: "lwpoCd",
|
||||
header: "하위코드",
|
||||
},
|
||||
{
|
||||
accessorKey: "lwpoCdNm",
|
||||
header: "하위코드명",
|
||||
},
|
||||
{
|
||||
accessorKey: "useYn",
|
||||
header: "사용 여부",
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => {
|
||||
const date = dayjs(row.original.regDt);
|
||||
return date.format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "management",
|
||||
header: "관리",
|
||||
cell: ({ row, table }) => {
|
||||
const onManagementClick = (table.options.meta as LwpoCodeTableMeta)?.onManagementClick;
|
||||
return (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onManagementClick?.(row.original);
|
||||
}}
|
||||
>
|
||||
관리
|
||||
</Button>
|
||||
);
|
||||
},
|
||||
},
|
||||
];
|
||||
Reference in New Issue
Block a user