feat: 조직도 소속원 폼 작업
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import dayjs from "dayjs";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Checkbox } from "@common/components/ui";
|
||||
import type { SearchUser } from "@/entities/user-organization";
|
||||
|
||||
export const columns: ColumnDef<SearchUser>[] = [
|
||||
{
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={table.getIsAllPageRowsSelected()}
|
||||
onCheckedChange={(checked) =>
|
||||
table.toggleAllPageRowsSelected(!!checked)
|
||||
}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={(checked) => row.toggleSelected(!!checked)}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
accessorKey: "userNm",
|
||||
header: "이름",
|
||||
},
|
||||
{
|
||||
accessorKey: "ogdpSeNm",
|
||||
header: "소속",
|
||||
},
|
||||
{
|
||||
accessorKey: "regDt",
|
||||
header: "등록일",
|
||||
cell: ({ row }) => dayjs(row.original.regDt).format("YYYY-MM-DD HH:mm:ss"),
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,91 @@
|
||||
import dayjs from "dayjs";
|
||||
import type { UseFormReturn } from "react-hook-form";
|
||||
import type { ColumnDef } from "@tanstack/react-table";
|
||||
import { Checkbox, Select } from "@common/components/ui";
|
||||
import type {
|
||||
User,
|
||||
UserOrganizationFormData,
|
||||
} from "@/entities/user-organization";
|
||||
|
||||
export const createColumns = (
|
||||
form: UseFormReturn<UserOrganizationFormData>,
|
||||
renderJobPositionSelect: (
|
||||
props: React.ComponentPropsWithoutRef<typeof Select>,
|
||||
) => React.ReactNode,
|
||||
renderJobGradeSelect: (
|
||||
props: React.ComponentPropsWithoutRef<typeof Select>,
|
||||
) => React.ReactNode,
|
||||
): ColumnDef<User>[] => {
|
||||
return [
|
||||
{
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
<Checkbox
|
||||
checked={table.getIsAllPageRowsSelected()}
|
||||
onCheckedChange={(checked) =>
|
||||
table.toggleAllPageRowsSelected(!!checked)
|
||||
}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
cell: ({ row }) => (
|
||||
<Checkbox
|
||||
checked={row.getIsSelected()}
|
||||
onCheckedChange={(checked) => row.toggleSelected(!!checked)}
|
||||
className="h-4 w-4 rounded border-gray-300"
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "no",
|
||||
header: "NO",
|
||||
cell: ({ row }) => row.index + 1,
|
||||
},
|
||||
{
|
||||
accessorKey: "userUnqNm",
|
||||
header: "이름",
|
||||
},
|
||||
{
|
||||
accessorKey: "jbpsSeCd",
|
||||
header: "직위",
|
||||
cell: ({ row }) =>
|
||||
renderJobPositionSelect({
|
||||
defaultValue: row.original.jbpsSeCd,
|
||||
value: form.watch(`userOrganization.${row.index}.jbpsSeCd`),
|
||||
onValueChange: (value) => {
|
||||
const mode = form.watch(`userOrganization.${row.index}.mode`);
|
||||
if (mode === "R")
|
||||
form.setValue(`userOrganization.${row.index}.mode`, "U");
|
||||
form.setValue(`userOrganization.${row.index}.jbpsSeCd`, value);
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
accessorKey: "jbgdSeCd",
|
||||
header: "직급",
|
||||
cell: ({ row }) =>
|
||||
renderJobGradeSelect({
|
||||
defaultValue: row.original.jbgdSeCd,
|
||||
value: form.watch(`userOrganization.${row.index}.jbgdSeCd`),
|
||||
onValueChange: (value) => {
|
||||
const mode = form.watch(`userOrganization.${row.index}.mode`);
|
||||
if (mode === "R")
|
||||
form.setValue(`userOrganization.${row.index}.mode`, "U");
|
||||
form.setValue(`userOrganization.${row.index}.jbgdSeCd`, value);
|
||||
},
|
||||
}),
|
||||
},
|
||||
{
|
||||
accessorKey: "mdfrNm",
|
||||
header: "최종수정자",
|
||||
},
|
||||
{
|
||||
accessorKey: "mdfcnDt",
|
||||
header: "최종수정일",
|
||||
cell: ({ row }) => {
|
||||
if (!row.original.mdfcnDt) return "";
|
||||
return dayjs(row.original.mdfcnDt).format("YYYY-MM-DD");
|
||||
},
|
||||
},
|
||||
];
|
||||
};
|
||||
Reference in New Issue
Block a user