710 lines
37 KiB
TypeScript
710 lines
37 KiB
TypeScript
'use client';
|
|
|
|
import { useState, useMemo } from "react";
|
|
import {
|
|
Button,
|
|
DataTable,
|
|
Input,
|
|
Label,
|
|
Table,
|
|
TableBody,
|
|
TableCell,
|
|
TableHead,
|
|
TableRow,
|
|
LoadingWithAnimation,
|
|
} from "@common/components";
|
|
import { getCoreRowModel, type PaginationState, type RowSelectionState, useReactTable } from "@tanstack/react-table";
|
|
import { LinkApi, type Link, type LinkSearchParam, type LinkTable, type LinkTableColumns, type LinkTableColData, type LinkTableFormData, LinkTableColumnsSchema, LinkTableSchema } from "@/entities/link";
|
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
import { columns } from "../../linkParams/model/table-columns";
|
|
import { tableColumns } from "../model/table-columns";
|
|
import { LinkTableDialog } from "./link-table-dialog";
|
|
import { useForm } from "react-hook-form";
|
|
import { zodResolver } from "@hookform/resolvers/zod";
|
|
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
|
|
import { AUTH_USER_ID } from "@/shared/config";
|
|
import { getCookie } from "@common/components";
|
|
import { useAlertStore } from "@/shared/lib/use-alert-store";
|
|
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
|
import { ConfirmDialog } from "@/shared/ui/confirm-dialog";
|
|
import { FormItem, FormControl, FormField, Form } from "@/shared/ui/form";
|
|
import { useDataTable } from "@/shared/lib";
|
|
|
|
function LinkTablePage() {
|
|
const queryClient = useQueryClient();
|
|
|
|
const userUniqId = getCookie(AUTH_USER_ID) ?? "";
|
|
|
|
const [linkSn, setLinkSn] = useState<string>('');
|
|
const [linkNm, setLinkNm] = useState<string>('');
|
|
|
|
const [linkSearchParam, setLinkSearchParam] = useState<LinkSearchParam>({
|
|
linkSn: '',
|
|
linkNm: ''
|
|
});
|
|
|
|
const [selectedTableInfo, setSelectedTableInfo] = useState<LinkTable | null>(null);
|
|
const [tableColList, setTableColList] = useState<LinkTableColumns[]>([]);
|
|
const [dialogOpen, setDialogOpen] = useState<boolean>(false);
|
|
const [selectedColIds, setSelectedColIds] = useState<string[]>([]);
|
|
|
|
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
|
|
|
const [pagination, setPagination] = useState<PaginationState>({
|
|
pageIndex: 0,
|
|
pageSize: 100,
|
|
});
|
|
|
|
const { setMessage: alert } = useAlertStore((state) => state);
|
|
|
|
const { confirm } = useConfirm();
|
|
const [onConfirm, setOnConfirm] = useState<boolean>(false);
|
|
|
|
const handleConfirm = async (callback: () => Promise<void>) => {
|
|
setOnConfirm(true);
|
|
await callback();
|
|
setOnConfirm(false);
|
|
};
|
|
|
|
const query = useQuery({
|
|
queryKey: ['/api/link/getLinkList', linkSearchParam],
|
|
queryFn: () => LinkApi.getLinkList({
|
|
...linkSearchParam,
|
|
page: pagination.pageIndex,
|
|
size: pagination.pageSize,
|
|
}),
|
|
});
|
|
|
|
const { mutateAsync: insertLinkTableCol } = useMutation({
|
|
mutationFn: async (data: LinkTableColData) => await LinkApi.insertLinkTableCol({
|
|
...data,
|
|
mdfr: userUniqId,
|
|
}),
|
|
onSuccess: async () => {
|
|
if (selectedTableInfo) {
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableInfo`]
|
|
});
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableColList`]
|
|
});
|
|
|
|
const tableData = await LinkApi.getLinkTableInfo(selectedTableInfo.link_sn);
|
|
const tableColList = await LinkApi.getLinkTableColList(selectedTableInfo.link_sn);
|
|
|
|
setSelectedTableInfo(tableData);
|
|
setTableColList(tableColList.content);
|
|
setSelectedColIds([]);
|
|
setDialogOpen(false);
|
|
alert('저장되었습니다.');
|
|
}
|
|
}
|
|
});
|
|
|
|
const { mutateAsync: updateLinkTableCol } = useMutation({
|
|
mutationFn: async (data: LinkTableColData) => await LinkApi.updateLinkTableCol({
|
|
...data,
|
|
mdfr: userUniqId,
|
|
}),
|
|
onSuccess: async () => {
|
|
if (selectedTableInfo) {
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableInfo`]
|
|
});
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableColList`]
|
|
});
|
|
|
|
const tableData = await LinkApi.getLinkTableInfo(selectedTableInfo.link_sn);
|
|
const tableColList = await LinkApi.getLinkTableColList(selectedTableInfo.link_sn);
|
|
|
|
setSelectedTableInfo(tableData);
|
|
setTableColList(tableColList.content);
|
|
setSelectedColIds([]);
|
|
setDialogOpen(false);
|
|
alert('수정되었습니다.');
|
|
}
|
|
}
|
|
});
|
|
|
|
const { mutateAsync: deleteLinkTableCol } = useMutation({
|
|
mutationFn: async (data: string[]) => await LinkApi.deleteLinkTableCol(data),
|
|
onSuccess: async () => {
|
|
if (selectedTableInfo) {
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableInfo`]
|
|
});
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableColList`]
|
|
});
|
|
|
|
const tableData = await LinkApi.getLinkTableInfo(selectedTableInfo.link_sn);
|
|
const tableColList = await LinkApi.getLinkTableColList(selectedTableInfo.link_sn);
|
|
|
|
setSelectedTableInfo(tableData);
|
|
setTableColList(tableColList.content);
|
|
setSelectedColIds([]);
|
|
setDialogOpen(false);
|
|
alert('삭제되었습니다.');
|
|
}
|
|
}
|
|
});
|
|
|
|
const { mutateAsync: insertLinkTableInfo } = useMutation({
|
|
mutationFn: async (data: LinkTableFormData) => await LinkApi.insertLinkTableInfo(data),
|
|
onSuccess: async () => {
|
|
if (selectedTableInfo) {
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableInfo`]
|
|
});
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableColList`]
|
|
});
|
|
|
|
const tableData = await LinkApi.getLinkTableInfo(selectedTableInfo.link_sn);
|
|
const tableColList = await LinkApi.getLinkTableColList(selectedTableInfo.link_sn);
|
|
|
|
tableForm.reset({
|
|
link_sn: tableData.link_sn,
|
|
link_nm: tableData.link_nm,
|
|
tbl_sn: tableData.tbl_sn ?? "",
|
|
sou_tbl_nm: tableData.sou_tbl_nm ?? "",
|
|
sou_tbl_korn_nm: tableData.sou_tbl_korn_nm ?? "",
|
|
sou_tbl_expln: tableData.sou_tbl_expln ?? "",
|
|
trsf_tbl_expln: tableData.trsf_tbl_expln ?? "",
|
|
trsf_tbl_nm: tableData.trsf_tbl_nm ?? "",
|
|
trsf_tbl_korn_nm: tableData.trsf_tbl_korn_nm ?? "",
|
|
});
|
|
setSelectedTableInfo(tableData);
|
|
setTableColList(tableColList.content);
|
|
setSelectedColIds([]);
|
|
alert('저장되었습니다.');
|
|
}
|
|
}
|
|
});
|
|
|
|
const { mutateAsync: updateLinkTableInfo } = useMutation({
|
|
mutationFn: async (data: LinkTableFormData) => await LinkApi.updateLinkTableInfo(data),
|
|
onSuccess: async () => {
|
|
if (selectedTableInfo) {
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableInfo`]
|
|
});
|
|
await queryClient.invalidateQueries({
|
|
queryKey: [`${process.env.NEXT_PUBLIC_LINK_BACKEND_API_HOST}/getLinkTableColList`]
|
|
});
|
|
|
|
const tableData = await LinkApi.getLinkTableInfo(selectedTableInfo.link_sn);
|
|
const tableColList = await LinkApi.getLinkTableColList(selectedTableInfo.link_sn);
|
|
|
|
setSelectedTableInfo(tableData);
|
|
setTableColList(tableColList.content);
|
|
setSelectedColIds([]);
|
|
alert('수정되었습니다.');
|
|
}
|
|
}
|
|
});
|
|
|
|
const tableCol = useMemo(
|
|
() =>
|
|
tableColumns({ selectedColIds, setSelectedColIds }),
|
|
[selectedColIds]
|
|
);
|
|
|
|
const colTable = useReactTable({
|
|
data: tableColList,
|
|
columns: tableCol,
|
|
getCoreRowModel: getCoreRowModel(),
|
|
});
|
|
|
|
const form = useForm<LinkTableColData>({
|
|
resolver: zodResolver(LinkTableColumnsSchema),
|
|
defaultValues: {
|
|
pk_yn: "N"
|
|
}
|
|
});
|
|
|
|
const tableForm = useForm<LinkTableFormData>({
|
|
resolver: zodResolver(LinkTableSchema),
|
|
defaultValues: {},
|
|
});
|
|
|
|
const handleResetSearchParam = async () => {
|
|
setSelectedTableInfo(null);
|
|
setTableColList([]);
|
|
setLinkSn('');
|
|
setLinkNm('');
|
|
setLinkSearchParam({
|
|
...linkSearchParam,
|
|
linkSn: '',
|
|
linkNm: '',
|
|
});
|
|
};
|
|
|
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
|
e.preventDefault();
|
|
setSelectedTableInfo(null);
|
|
setTableColList([]);
|
|
|
|
setLinkSearchParam({
|
|
...linkSearchParam,
|
|
linkSn,
|
|
linkNm
|
|
});
|
|
};
|
|
|
|
const handleRowClick = async (data: Link) => {
|
|
const tableData = await LinkApi.getLinkTableInfo(data.link_sn);
|
|
const tableColList = await LinkApi.getLinkTableColList(data.link_sn);
|
|
|
|
setSelectedTableInfo(tableData);
|
|
setTableColList(tableColList.content);
|
|
setSelectedColIds([]);
|
|
|
|
tableForm.reset({
|
|
link_sn: tableData.link_sn,
|
|
link_nm: tableData.link_nm,
|
|
tbl_sn: tableData.tbl_sn ?? "",
|
|
sou_tbl_nm: tableData.sou_tbl_nm ?? "",
|
|
sou_tbl_korn_nm: tableData.sou_tbl_korn_nm ?? "",
|
|
sou_tbl_expln: tableData.sou_tbl_expln ?? "",
|
|
trsf_tbl_expln: tableData.trsf_tbl_expln ?? "",
|
|
trsf_tbl_nm: tableData.trsf_tbl_nm ?? "",
|
|
trsf_tbl_korn_nm: tableData.trsf_tbl_korn_nm ?? "",
|
|
});
|
|
};
|
|
|
|
const handleColumnRowClick = async (data: LinkTableColumns) => {
|
|
const colInfo = await LinkApi.getLinkTableColInfo({ colSn: data.col_sn, tblSn: data.tbl_sn });
|
|
|
|
if (colInfo) {
|
|
let newData = { ...colInfo };
|
|
|
|
if (colInfo.mdfr) {
|
|
const userName = await fetchUserInfo();
|
|
newData = {
|
|
...colInfo,
|
|
mdfr: userName,
|
|
};
|
|
}
|
|
|
|
form.reset(newData);
|
|
|
|
}
|
|
setDialogOpen(true)
|
|
};
|
|
|
|
const fetchUserInfo = async () => {
|
|
const userData = await getUserInfo();
|
|
return userData.userName;
|
|
};
|
|
|
|
const handleDeleteParam = async () => {
|
|
if (selectedColIds.length === 0) {
|
|
alert('삭제할 컬럼을 선택해 주세요.');
|
|
} else {
|
|
await handleConfirm(async () => {
|
|
if (await confirm('선택한 컬럼 정보를 삭제하시겠습니까?')) {
|
|
deleteLinkTableCol(selectedColIds);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
const handleTableSubmit = async (data: LinkTableFormData) => {
|
|
const regTblInfo = await LinkApi.countLinkTblNm(data.trsf_tbl_nm);
|
|
const confirmMsg = (regTblInfo.count > 0 && data.trsf_tbl_nm !== selectedTableInfo?.trsf_tbl_nm) ? `이미 사용중인 테이블 명입니다. 해당 테이블 명으로 ${!data.tbl_sn ? '저장' : '수정'}하시겠습니까?` : `${!data.tbl_sn ? '저장' : '수정'}하시겠습니까?`;
|
|
if (!data.tbl_sn) {
|
|
await handleConfirm(async () => {
|
|
if (await confirm(confirmMsg)) {
|
|
insertLinkTableInfo({
|
|
...data,
|
|
mdfr: userUniqId,
|
|
tbl_sn: (regTblInfo.count > 0) ? regTblInfo.tbl_sn : "",
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
await handleConfirm(async () => {
|
|
if (await confirm(confirmMsg)) {
|
|
updateLinkTableInfo({
|
|
...data,
|
|
tbl_sn: (regTblInfo.count > 0) ? regTblInfo.tbl_sn : "",
|
|
mdfr: userUniqId,
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
};
|
|
|
|
const { tableComponent } = useDataTable({
|
|
query,
|
|
tableOptions: {
|
|
columns,
|
|
state: {
|
|
pagination,
|
|
rowSelection,
|
|
},
|
|
manualPagination: true,
|
|
enableMultiRowSelection: true,
|
|
getCoreRowModel: getCoreRowModel(),
|
|
onPaginationChange: setPagination,
|
|
onRowSelectionChange: setRowSelection,
|
|
},
|
|
dataTableOptions: {
|
|
onRowClick: handleRowClick,
|
|
viewPagination: true,
|
|
},
|
|
});
|
|
|
|
return (
|
|
<div className="card card-border !mt-6">
|
|
<div className="card card-border">
|
|
<form className="flex items-center gap-2 p-2" onSubmit={handleSubmit}>
|
|
<Label htmlFor="liSnSearchInput" className="mr-2 text-label">
|
|
일련번호
|
|
</Label>
|
|
<Input
|
|
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem] mr-4"
|
|
id="liSnSearchInput"
|
|
value={linkSn}
|
|
onChange={(e) => setLinkSn(e.target.value)}
|
|
autoComplete="off"
|
|
/>
|
|
<Label htmlFor="liNmSearchInput" className="mr-2 text-label">
|
|
연계 명
|
|
</Label>
|
|
<Input
|
|
className="h-[3.2rem] w-[24rem] rounded-sm !text-[1.3rem] mr-2"
|
|
id="liNmSearchInput"
|
|
value={linkNm}
|
|
onChange={(e) => setLinkNm(e.target.value)}
|
|
autoComplete="off"
|
|
/>
|
|
<Button color="green" className="h-[3.2rem]" type="button" onClick={handleResetSearchParam}>
|
|
초기화
|
|
</Button>
|
|
<Button className="h-[3.2rem]" type="submit">
|
|
조회
|
|
</Button>
|
|
</form>
|
|
</div>
|
|
<div className="card !mb-0 flex h-[calc(100vh-28rem)] gap-5 !p-0">
|
|
<div className="card card-border w-1/2 !mx-0 flex flex-col">
|
|
<div className="card-header">
|
|
<h3 className="text-2xl font-medium text-label">연계 목록</h3>
|
|
</div>
|
|
<div className="card !m-[1.2rem] overflow-auto !p-0 h-full">
|
|
{!query.isLoading ?
|
|
<div>{tableComponent}</div>
|
|
:
|
|
<div className="[data-theme='black']:bg-transparent rounded-lg p-10 flex justify-center items-center h-full">
|
|
<div className="relative size-[5rem]">
|
|
<LoadingWithAnimation color="primary" />
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
<div className="card card-border w-1/2 !mx-0 flex flex-col">
|
|
<div className="card-header">
|
|
<h3 className="text-2xl font-medium text-label">연계 테이블 정보</h3>
|
|
</div>
|
|
<div className="card !m-[1.2rem] !p-0 h-full overflow-auto flex flex-col">
|
|
<Form {...tableForm}>
|
|
<form onSubmit={tableForm.handleSubmit(handleTableSubmit)}>
|
|
{selectedTableInfo &&
|
|
<div className="flex justify-end mb-2">
|
|
<Button className="h-[3.2rem]" type="submit" color={selectedTableInfo.tbl_sn ? "green" : "primary"}>
|
|
{selectedTableInfo.tbl_sn ? "수정" : "저장"}
|
|
</Button>
|
|
</div>
|
|
}
|
|
<Table variant="secondary" className="flex-none">
|
|
<colgroup>
|
|
<col width="20%" />
|
|
<col width="80%" />
|
|
</colgroup>
|
|
<TableBody>
|
|
<TableRow>
|
|
<TableHead>연계 일련번호</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="link_sn"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
disabled
|
|
/>
|
|
</FormControl>
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>연계 명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="link_nm"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
disabled
|
|
/>
|
|
</FormControl>
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>원천 테이블 명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="sou_tbl_nm"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
placeholder={!field.value ? "-" : ""}
|
|
autoComplete="off"
|
|
/>
|
|
</FormControl>
|
|
{tableForm.formState.errors.sou_tbl_nm && (
|
|
<p className="text-red-500 text-base pt-2">
|
|
{tableForm.formState.errors.sou_tbl_nm.message}
|
|
</p>
|
|
)}
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>원천 테이블 한글명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="sou_tbl_korn_nm"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
placeholder={!field.value ? "-" : ""}
|
|
autoComplete="off"
|
|
/>
|
|
</FormControl>
|
|
{tableForm.formState.errors.sou_tbl_korn_nm && (
|
|
<p className="text-red-500 text-base pt-2">
|
|
{tableForm.formState.errors.sou_tbl_korn_nm.message}
|
|
</p>
|
|
)}
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>원천 테이블 설명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="sou_tbl_expln"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
placeholder={!field.value ? "-" : ""}
|
|
autoComplete="off"
|
|
/>
|
|
</FormControl>
|
|
{tableForm.formState.errors.sou_tbl_expln && (
|
|
<p className="text-red-500 text-base pt-2">
|
|
{tableForm.formState.errors.sou_tbl_expln.message}
|
|
</p>
|
|
)}
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>* 변환 테이블 명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="trsf_tbl_nm"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
placeholder={!field.value ? "-" : ""}
|
|
autoComplete="off"
|
|
/>
|
|
</FormControl>
|
|
{tableForm.formState.errors.trsf_tbl_nm && (
|
|
<p className="text-red-500 text-base pt-2">
|
|
{tableForm.formState.errors.trsf_tbl_nm.message}
|
|
</p>
|
|
)}
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>* 변환 테이블 한글명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="trsf_tbl_korn_nm"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
placeholder={!field.value ? "-" : ""}
|
|
autoComplete="off"
|
|
/>
|
|
</FormControl>
|
|
{tableForm.formState.errors.trsf_tbl_korn_nm && (
|
|
<p className="text-red-500 text-base pt-2">
|
|
{tableForm.formState.errors.trsf_tbl_korn_nm.message}
|
|
</p>
|
|
)}
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
<TableRow>
|
|
<TableHead>변환 테이블 설명</TableHead>
|
|
<TableCell className="!p-2">
|
|
{selectedTableInfo ?
|
|
<FormField
|
|
control={tableForm.control}
|
|
name="trsf_tbl_expln"
|
|
render={({ field }) => (
|
|
<FormItem>
|
|
<FormControl>
|
|
<Input
|
|
{...field}
|
|
value={field.value ?? ""}
|
|
className="!text-[1.3rem] w-[400px]"
|
|
placeholder={!field.value ? "-" : ""}
|
|
autoComplete="off"
|
|
/>
|
|
</FormControl>
|
|
{tableForm.formState.errors.trsf_tbl_expln && (
|
|
<p className="text-red-500 text-base pt-2">
|
|
{tableForm.formState.errors.trsf_tbl_expln.message}
|
|
</p>
|
|
)}
|
|
</FormItem>
|
|
)}
|
|
/>
|
|
:
|
|
<span className="px-2 py-[1.2rem]">-</span>
|
|
}
|
|
</TableCell>
|
|
</TableRow>
|
|
</TableBody>
|
|
</Table>
|
|
</form>
|
|
</Form>
|
|
{selectedTableInfo ?
|
|
<>
|
|
<div className="mb-2 mt-14 flex justify-end items-center flex-none">
|
|
{tableColList.length > 0 &&
|
|
<Button color="red" className="h-[3.2rem] mr-2" type="button" onClick={handleDeleteParam}>
|
|
행 삭제
|
|
</Button>
|
|
}
|
|
{selectedTableInfo.tbl_sn &&
|
|
<LinkTableDialog dialogOpen={dialogOpen} onOpenChange={setDialogOpen} form={form} tableInfo={selectedTableInfo} insertLinkTableCol={insertLinkTableCol} updateLinkTableCol={updateLinkTableCol} />
|
|
}
|
|
</div>
|
|
{selectedTableInfo.tbl_sn ?
|
|
(tableColList.length > 0 ?
|
|
<div className="flex-1 overflow-auto min-h-[300px]">
|
|
<DataTable table={colTable} onRowClick={handleColumnRowClick} />
|
|
</div>
|
|
:
|
|
<div className="flex items-center justify-center h-20 text-gray-500 text-3xl">
|
|
등록된 테이블 컬럼이 없습니다.
|
|
</div>)
|
|
:
|
|
<div className="flex items-center justify-center h-20 text-gray-500 text-3xl">
|
|
테이블 정보를 등록해주세요.
|
|
</div>
|
|
}
|
|
</>
|
|
:
|
|
<div className="flex items-center justify-center text-gray-500 text-3xl mt-14 flex-1">
|
|
연계 데이터를 선택해주세요.
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<ConfirmDialog isOpen={onConfirm} />
|
|
</div >
|
|
)
|
|
};
|
|
|
|
export { LinkTablePage }; |