[as] feat: 내행정지원 페이지
This commit is contained in:
@@ -5,11 +5,12 @@ import type { PageResponse } from "@/shared/model";
|
||||
import type {
|
||||
ElaprApproverChangeRequestDto,
|
||||
ElaprApproverInsertRequestDto,
|
||||
ElaprPrgrsSttsMyDocSearchParams,
|
||||
ElaprMyDocSearchDto,
|
||||
ElaprPrgrsSttsResponseDto,
|
||||
ElaprPrgrsSttsSaveRequestDto,
|
||||
ElaprPrgrsSttsService,
|
||||
ElaprProcessRequestDto,
|
||||
MyAdssDocResponseDto,
|
||||
} from "../model/elapr-prgrs-stts-interface";
|
||||
|
||||
const BASE = ENDPOINT.AS_ELAPR_SERVICE.ELAPR_PRGRS_STTS;
|
||||
@@ -83,9 +84,9 @@ async function insertApprover(
|
||||
}
|
||||
|
||||
async function findMyElaperDocList(
|
||||
params: ElaprPrgrsSttsMyDocSearchParams,
|
||||
): Promise<PageResponse<ElaprPrgrsSttsResponseDto>> {
|
||||
const response = await client.get<PageResponse<ElaprPrgrsSttsResponseDto>>(`${BASE}/my/doc`, {
|
||||
params: ElaprMyDocSearchDto,
|
||||
): Promise<PageResponse<MyAdssDocResponseDto>> {
|
||||
const response = await client.get<PageResponse<MyAdssDocResponseDto>>(`${BASE}/my/doc`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
|
||||
@@ -12,7 +12,7 @@ import type { ElaprDmndSaveRequestDto, ElaprDmndSearchDto } from "../model/elapr
|
||||
import type {
|
||||
ElaprApproverChangeRequestDto,
|
||||
ElaprApproverInsertRequestDto,
|
||||
ElaprPrgrsSttsMyDocSearchParams,
|
||||
ElaprMyDocSearchDto,
|
||||
ElaprPrgrsSttsSaveRequestDto,
|
||||
ElaprProcessRequestDto,
|
||||
} from "../model/elapr-prgrs-stts-interface";
|
||||
@@ -261,7 +261,7 @@ export function useElaprPrgrsStts(elaprPrgrsId: string | null | undefined) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useElaprPrgrsSttsMyDocPage(params: ElaprPrgrsSttsMyDocSearchParams) {
|
||||
export function useElaprPrgrsSttsMyDocPage(params: ElaprMyDocSearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...elaprPrgrsSttsBaseKey, "findMyElaperDocList", params],
|
||||
queryFn: () => elaprPrgrsSttsService.findMyElaperDocList(params),
|
||||
|
||||
@@ -92,13 +92,14 @@ export type {
|
||||
export type {
|
||||
ElaprApproverChangeRequestDto,
|
||||
ElaprApproverInsertRequestDto,
|
||||
ElaprPrgrsSttsMyDocSearchParams,
|
||||
ElaprMyDocSearchDto,
|
||||
ElaprPrgrsSttsResponseDto,
|
||||
ElaprPrgrsSttsSaveMode,
|
||||
ElaprPrgrsSttsSaveRequestDto,
|
||||
ElaprPrgrsSttsSearchDto,
|
||||
ElaprPrgrsSttsService,
|
||||
ElaprProcessRequestDto,
|
||||
MyAdssDocResponseDto,
|
||||
} from "./model/elapr-prgrs-stts-interface";
|
||||
export { ELAPR_PRGRS_STTS_SAVE_MODE } from "./model/elapr-prgrs-stts-interface";
|
||||
export type {
|
||||
|
||||
@@ -44,8 +44,30 @@ export interface ElaprPrgrsSttsSearchDto {
|
||||
atrzPrgrsSttsComCd?: string;
|
||||
}
|
||||
|
||||
/** 백엔드 ElaprPrgrsSttsSearchDto + Pageable */
|
||||
export interface ElaprPrgrsSttsMyDocSearchParams extends ElaprPrgrsSttsSearchDto, PageableParams {}
|
||||
/** 백엔드 MyAdssDocResponseDto */
|
||||
export interface MyAdssDocResponseDto {
|
||||
docNo: string;
|
||||
docTtl?: string;
|
||||
docSeComCd?: string;
|
||||
docSeComNm?: string;
|
||||
reqDt?: string;
|
||||
prgrsSttsComCd?: string;
|
||||
prgrsSttsComNm?: string;
|
||||
cmptnExpctDt?: string;
|
||||
picNm?: string;
|
||||
picTelno?: string;
|
||||
chgCycl?: number;
|
||||
/** 등록자 UUID */
|
||||
rgtr?: string;
|
||||
}
|
||||
|
||||
/** 백엔드 ElaprMyDocSearchDto + Pageable */
|
||||
export interface ElaprMyDocSearchDto extends PageableParams {
|
||||
startDate?: string;
|
||||
endDate?: string;
|
||||
docSeComCd?: string;
|
||||
prgrsSttsComCd?: string;
|
||||
}
|
||||
|
||||
/** 백엔드 ElaprProcessRequestDto */
|
||||
export interface ElaprProcessRequestDto {
|
||||
@@ -86,6 +108,6 @@ export interface ElaprPrgrsSttsService {
|
||||
body: ElaprApproverInsertRequestDto,
|
||||
): Promise<ElaprPrgrsSttsResponseDto>;
|
||||
findMyElaperDocList(
|
||||
params: ElaprPrgrsSttsMyDocSearchParams,
|
||||
): Promise<PageResponse<ElaprPrgrsSttsResponseDto>>;
|
||||
params: ElaprMyDocSearchDto,
|
||||
): Promise<PageResponse<MyAdssDocResponseDto>>;
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { MyPbadmsSprtListPage } from "./ui/my-pbadms-sprt-list-page";
|
||||
@@ -0,0 +1,46 @@
|
||||
import type { MyAdssDocResponseDto } from "@/entities/elapr";
|
||||
|
||||
function canEditByDocSe(
|
||||
docSeComCd: string,
|
||||
prgrsSttsComCd: string | undefined,
|
||||
rgtr: string | undefined,
|
||||
loggedInUserUnqId: string | undefined,
|
||||
): boolean {
|
||||
if (!loggedInUserUnqId || !rgtr || rgtr !== loggedInUserUnqId) return false;
|
||||
|
||||
if (docSeComCd === "CNFM") return prgrsSttsComCd === "CV";
|
||||
|
||||
if (docSeComCd === "INSTL" || docSeComCd === "FNRS" || docSeComCd === "SEWER")
|
||||
return prgrsSttsComCd === "SV" || prgrsSttsComCd === "SL";
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function resolveMyPbadmsSprtDetailPath(
|
||||
row: MyAdssDocResponseDto,
|
||||
loggedInUserUnqId: string | undefined,
|
||||
): string | null {
|
||||
const { docNo, docSeComCd, prgrsSttsComCd, rgtr, chgCycl } = row;
|
||||
if (!docNo || !docSeComCd) return null;
|
||||
|
||||
const canEdit = canEditByDocSe(docSeComCd, prgrsSttsComCd, rgtr, loggedInUserUnqId);
|
||||
|
||||
switch (docSeComCd) {
|
||||
case "FNRS":
|
||||
return canEdit ? `/fnrs-cnsltn/${docNo}/edit` : `/fnrs-cnsltn/${docNo}`;
|
||||
case "INSTL":
|
||||
return canEdit ? `/instl-sncn/${docNo}/edit` : `/instl-sncn/${docNo}`;
|
||||
case "CNFM":
|
||||
return canEdit ? `/design-cnstn/${docNo}/edit` : `/design-cnstn/${docNo}`;
|
||||
case "SEWER": {
|
||||
const cycl = chgCycl ?? 1;
|
||||
return canEdit
|
||||
? `/sewer-bsc-plan/${docNo}/edit?chgCycl=${cycl}`
|
||||
: `/sewer-bsc-plan/${docNo}?chgCycl=${cycl}`;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export { resolveMyPbadmsSprtDetailPath };
|
||||
@@ -0,0 +1,67 @@
|
||||
"use client";
|
||||
|
||||
import { createColumnHelper } from "@tanstack/react-table";
|
||||
|
||||
import { dayjs } from "@/shared/lib";
|
||||
import type { MyAdssDocResponseDto } from "@/entities/elapr";
|
||||
|
||||
const columnHelper = createColumnHelper<MyAdssDocResponseDto>();
|
||||
|
||||
function formatOptional(value: string | number | undefined | null) {
|
||||
if (value === undefined || value === null) return "-";
|
||||
const text = String(value).trim();
|
||||
return text ? text : "-";
|
||||
}
|
||||
|
||||
function formatDate(value: string | undefined) {
|
||||
return value ? dayjs(value).format("YYYY-MM-DD") : "-";
|
||||
}
|
||||
|
||||
interface CreateMyPbadmsSprtColumnsOptions {
|
||||
pageIndex: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export function createMyPbadmsSprtColumns({
|
||||
pageIndex,
|
||||
pageSize,
|
||||
}: CreateMyPbadmsSprtColumnsOptions) {
|
||||
return [
|
||||
columnHelper.display({
|
||||
id: "no",
|
||||
header: "No",
|
||||
meta: { align: "center" },
|
||||
cell: ({ row }) => pageIndex * pageSize + row.index + 1,
|
||||
}),
|
||||
columnHelper.accessor("docSeComNm", {
|
||||
header: "구분",
|
||||
meta: { align: "center" },
|
||||
cell: ({ row }) => formatOptional(row.original.docSeComNm || row.original.docSeComCd),
|
||||
}),
|
||||
columnHelper.accessor("reqDt", {
|
||||
header: "신청일",
|
||||
meta: { align: "center" },
|
||||
cell: ({ getValue }) => formatDate(getValue()),
|
||||
}),
|
||||
columnHelper.accessor("prgrsSttsComNm", {
|
||||
header: "진행상태",
|
||||
meta: { align: "center" },
|
||||
cell: ({ getValue }) => formatOptional(getValue()),
|
||||
}),
|
||||
columnHelper.accessor("cmptnExpctDt", {
|
||||
header: "완료(예정)일",
|
||||
meta: { align: "center" },
|
||||
cell: ({ getValue }) => formatDate(getValue()),
|
||||
}),
|
||||
columnHelper.accessor("picNm", {
|
||||
header: "담당자",
|
||||
meta: { align: "center" },
|
||||
cell: ({ getValue }) => formatOptional(getValue()),
|
||||
}),
|
||||
columnHelper.accessor("picTelno", {
|
||||
header: "담당자연락처",
|
||||
meta: { align: "center" },
|
||||
cell: ({ getValue }) => formatOptional(getValue()),
|
||||
}),
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import type { PaginationState } from "@tanstack/react-table";
|
||||
|
||||
import { dayjs } from "@/shared/lib";
|
||||
import { useCodeList } from "@/entities/code";
|
||||
import type { ElaprMyDocSearchDto } from "@/entities/elapr";
|
||||
import {
|
||||
Button,
|
||||
InputDatePicker,
|
||||
Label,
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@common/components";
|
||||
|
||||
import { MyPbadmsSprtList } from "./my-pbadms-sprt-list";
|
||||
|
||||
const DEFAULT_PAGE_INDEX = 0;
|
||||
const DEFAULT_PAGE_SIZE = 10;
|
||||
const ALL_SELECT_VALUE = "__ALL__";
|
||||
|
||||
function defaultStartDate() {
|
||||
return dayjs().subtract(1, "month").toDate();
|
||||
}
|
||||
|
||||
function defaultEndDate() {
|
||||
return dayjs().toDate();
|
||||
}
|
||||
|
||||
function formatDateParam(date: Date | null | undefined) {
|
||||
return date ? dayjs(date).format("YYYY-MM-DD") : "";
|
||||
}
|
||||
|
||||
function buildDefaultSearchParams(): ElaprMyDocSearchDto {
|
||||
return {
|
||||
startDate: formatDateParam(defaultStartDate()),
|
||||
endDate: formatDateParam(defaultEndDate()),
|
||||
docSeComCd: "",
|
||||
prgrsSttsComCd: "",
|
||||
page: DEFAULT_PAGE_INDEX,
|
||||
size: DEFAULT_PAGE_SIZE,
|
||||
};
|
||||
}
|
||||
|
||||
function MyPbadmsSprtListPage() {
|
||||
const [startDate, setStartDate] = useState<Date | null>(defaultStartDate);
|
||||
const [endDate, setEndDate] = useState<Date | null>(defaultEndDate);
|
||||
const [docSeComCd, setDocSeComCd] = useState("");
|
||||
const [prgrsSttsComCd, setPrgrsSttsComCd] = useState("");
|
||||
const [pagination, setPagination] = useState<PaginationState>({
|
||||
pageIndex: DEFAULT_PAGE_INDEX,
|
||||
pageSize: DEFAULT_PAGE_SIZE,
|
||||
});
|
||||
const [searchParams, setSearchParams] = useState<ElaprMyDocSearchDto>(buildDefaultSearchParams);
|
||||
|
||||
const { data: docSeCodes, isPending: isDocSeLoading } = useCodeList("ASDOCSE");
|
||||
const prgrsSttsUpCd = docSeComCd ? `${docSeComCd}STTS` : undefined;
|
||||
const { data: prgrsSttsCodes, isPending: isPrgrsSttsLoading } = useCodeList(prgrsSttsUpCd);
|
||||
|
||||
const isPrgrsSttsDisabled = !docSeComCd || isPrgrsSttsLoading;
|
||||
|
||||
const prgrsSttsOptions = useMemo(
|
||||
() => (docSeComCd ? (prgrsSttsCodes ?? []) : []),
|
||||
[docSeComCd, prgrsSttsCodes],
|
||||
);
|
||||
|
||||
const handleDocSeChange = (value: string) => {
|
||||
const nextDocSeComCd = value === ALL_SELECT_VALUE ? "" : value;
|
||||
setDocSeComCd(nextDocSeComCd);
|
||||
setPrgrsSttsComCd("");
|
||||
};
|
||||
|
||||
const handleSearch = (event: React.FormEvent<HTMLFormElement>) => {
|
||||
event.preventDefault();
|
||||
setPagination((prev) => ({ ...prev, pageIndex: DEFAULT_PAGE_INDEX }));
|
||||
setSearchParams({
|
||||
startDate: formatDateParam(startDate),
|
||||
endDate: formatDateParam(endDate),
|
||||
docSeComCd,
|
||||
prgrsSttsComCd,
|
||||
page: DEFAULT_PAGE_INDEX,
|
||||
size: pagination.pageSize,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-4 px-[1.8rem] pb-6">
|
||||
<section className="card card-border mx-0 bg-background">
|
||||
<form className="flex flex-wrap items-center gap-4 p-2" onSubmit={handleSearch}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Label className="whitespace-nowrap">기간</Label>
|
||||
<InputDatePicker
|
||||
value={startDate}
|
||||
onChange={(date) => setStartDate(date ?? null)}
|
||||
className="w-[12rem]"
|
||||
/>
|
||||
<span className="text-muted-foreground">~</span>
|
||||
<InputDatePicker
|
||||
value={endDate}
|
||||
onChange={(date) => setEndDate(date ?? null)}
|
||||
className="w-[12rem]"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Label htmlFor="docSeComCd" className="whitespace-nowrap">
|
||||
구분
|
||||
</Label>
|
||||
<Select
|
||||
value={docSeComCd || ALL_SELECT_VALUE}
|
||||
onValueChange={handleDocSeChange}
|
||||
disabled={isDocSeLoading}
|
||||
>
|
||||
<SelectTrigger id="docSeComCd" className="w-[12rem]">
|
||||
<SelectValue placeholder={isDocSeLoading ? "로딩 중…" : "전체"} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value={ALL_SELECT_VALUE}>전체</SelectItem>
|
||||
{docSeCodes?.map((item) => (
|
||||
<SelectItem key={item.lwpoCd} value={item.lwpoCd}>
|
||||
{item.lwpoCdNm}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
<Label htmlFor="prgrsSttsComCd" className="whitespace-nowrap">
|
||||
진행상태
|
||||
</Label>
|
||||
<Select
|
||||
value={prgrsSttsComCd || ALL_SELECT_VALUE}
|
||||
onValueChange={(value) =>
|
||||
setPrgrsSttsComCd(value === ALL_SELECT_VALUE ? "" : value)
|
||||
}
|
||||
disabled={isPrgrsSttsDisabled}
|
||||
>
|
||||
<SelectTrigger id="prgrsSttsComCd" className="w-[12rem]">
|
||||
<SelectValue placeholder={docSeComCd ? "전체" : "구분 선택"} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value={ALL_SELECT_VALUE}>전체</SelectItem>
|
||||
{prgrsSttsOptions.map((item) => (
|
||||
<SelectItem key={item.lwpoCd} value={item.lwpoCd}>
|
||||
{item.lwpoCdNm}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
<Button type="submit">검색</Button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<MyPbadmsSprtList
|
||||
searchParams={searchParams}
|
||||
pagination={pagination}
|
||||
onPaginationChange={setPagination}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export { MyPbadmsSprtListPage };
|
||||
@@ -0,0 +1,89 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
import { useRouter } from "next/navigation";
|
||||
|
||||
import { getCoreRowModel, type PaginationState } from "@tanstack/react-table";
|
||||
|
||||
import { useDataTable, useUserStore } from "@/shared/lib";
|
||||
import {
|
||||
type ElaprMyDocSearchDto,
|
||||
type MyAdssDocResponseDto,
|
||||
useElaprPrgrsSttsMyDocPage,
|
||||
} from "@/entities/elapr";
|
||||
|
||||
import { resolveMyPbadmsSprtDetailPath } from "../lib/resolve-detail-path";
|
||||
import { createMyPbadmsSprtColumns } from "../model/my-pbadms-sprt-table-columns";
|
||||
|
||||
interface MyPbadmsSprtListProps {
|
||||
searchParams: ElaprMyDocSearchDto;
|
||||
pagination: PaginationState;
|
||||
onPaginationChange: (pagination: PaginationState) => void;
|
||||
}
|
||||
|
||||
function toOptionalParam(value: string | undefined) {
|
||||
const trimmed = value?.trim();
|
||||
return trimmed ? trimmed : undefined;
|
||||
}
|
||||
|
||||
function MyPbadmsSprtList({ searchParams, pagination, onPaginationChange }: MyPbadmsSprtListProps) {
|
||||
const router = useRouter();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
|
||||
const queryParams = useMemo(
|
||||
(): ElaprMyDocSearchDto => ({
|
||||
startDate: toOptionalParam(searchParams.startDate),
|
||||
endDate: toOptionalParam(searchParams.endDate),
|
||||
docSeComCd: toOptionalParam(searchParams.docSeComCd),
|
||||
prgrsSttsComCd: toOptionalParam(searchParams.prgrsSttsComCd),
|
||||
page: pagination.pageIndex,
|
||||
size: pagination.pageSize,
|
||||
sort: searchParams.sort,
|
||||
}),
|
||||
[searchParams, pagination],
|
||||
);
|
||||
|
||||
const pageQuery = useElaprPrgrsSttsMyDocPage(queryParams);
|
||||
const columns = useMemo(
|
||||
() =>
|
||||
createMyPbadmsSprtColumns({
|
||||
pageIndex: pagination.pageIndex,
|
||||
pageSize: pagination.pageSize,
|
||||
}),
|
||||
[pagination.pageIndex, pagination.pageSize],
|
||||
);
|
||||
|
||||
const handleRowClick = (row: MyAdssDocResponseDto) => {
|
||||
const path = resolveMyPbadmsSprtDetailPath(row, userInfo?.userUnqId);
|
||||
if (path) router.push(path);
|
||||
};
|
||||
|
||||
const { tableComponent } = useDataTable({
|
||||
query: pageQuery,
|
||||
tableOptions: {
|
||||
columns,
|
||||
state: { pagination },
|
||||
onPaginationChange: (updater) => {
|
||||
const next = typeof updater === "function" ? updater(pagination) : updater;
|
||||
onPaginationChange(next);
|
||||
},
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
manualPagination: true,
|
||||
},
|
||||
dataTableOptions: {
|
||||
viewPagination: true,
|
||||
onRowClick: handleRowClick,
|
||||
},
|
||||
});
|
||||
|
||||
return (
|
||||
<section className="card card-border mx-0 bg-background pb-8 pt-0">
|
||||
<div className="card-header flex items-center justify-between">
|
||||
<h3 className="text-2xl font-semibold">내 신청 목록</h3>
|
||||
</div>
|
||||
{tableComponent}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export { MyPbadmsSprtList };
|
||||
@@ -5,16 +5,11 @@ import { useMenuStore } from "../lib/use-menu-store";
|
||||
function PageLayout({ children }: { children: React.ReactNode }) {
|
||||
const currentMenuInfo = useMenuStore((state) => state.currentMenuInfo);
|
||||
|
||||
const menuPaths = currentMenuInfo?.menuPath
|
||||
?.split(">")
|
||||
.map((path) => path.trim());
|
||||
const menuPaths = currentMenuInfo?.menuPath?.split(">").map((path) => path.trim());
|
||||
|
||||
return (
|
||||
<div className="bg-container h-auto min-h-full pb-2">
|
||||
<PageTitle
|
||||
title={currentMenuInfo?.menuKornNm ?? ""}
|
||||
menuPaths={menuPaths ?? []}
|
||||
/>
|
||||
<div className="h-auto min-h-full bg-container pb-2">
|
||||
<PageTitle title={currentMenuInfo?.menuKornNm ?? ""} menuPaths={menuPaths ?? []} />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user