[st] - 입력-반려/일괄반려, 관리-통계일정관리,검토이력조회, 버튼 권한체크
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { useCallback, useEffect, useRef, useState } from "react";
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
||||
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { RealGridReact } from "realgrid-react";
|
||||
import useSWR, { useSWRConfig } from "swr";
|
||||
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { useAlertStore, useStatisticsInputStatusConfirmGroupGate } from "@/shared/lib";
|
||||
import { statisticsInputSewSupplyRateApi } from "@/entities/statistics/api/input/statistics-input-sew-supply-rate-service";
|
||||
import { StatisticsInputStatusApi } from "@/entities/statistics/api/input/statistics-input-status-service";
|
||||
import { statisticsApi } from "@/entities/statistics/api/statistics-service";
|
||||
@@ -17,8 +18,8 @@ import type {
|
||||
StatsInputStatusListRequestParams,
|
||||
} from "@/entities/statistics/model/input/statistics-input-status-interface";
|
||||
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
|
||||
import { LoadingWithAnimation } from "@common/components";
|
||||
|
||||
import { LoadingWithAnimation } from "@common/components";
|
||||
import ApproveButton from "@/components/button/ApproveButton";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import type { DataCellClickCallbackParams } from "@/components/type/DataGrid.type";
|
||||
@@ -41,7 +42,9 @@ const getStatsInputStatusFetcher = async (
|
||||
|
||||
// 하수도 통계 관리 > 00. 통계 입력 현황
|
||||
const StatsInputStatusInp = () => {
|
||||
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const { confirm } = useConfirm();
|
||||
const activeTabId = useTabStore((state) => state.activeTabId);
|
||||
const [rowData, setRowData] = useState<Record<string, string | number>[]>(
|
||||
[],
|
||||
@@ -58,6 +61,8 @@ const StatsInputStatusInp = () => {
|
||||
const [exceptionHistoryContext, setExceptionHistoryContext] = useState<
|
||||
ExceptionProcessingHistoryQueryContext | null
|
||||
>(null);
|
||||
const [isApproveLoading, setIsApproveLoading] = useState(false);
|
||||
const confirmGroupToolbarAllowed = useStatisticsInputStatusConfirmGroupGate();
|
||||
|
||||
const swrKey = searchParams
|
||||
? (["stats-input-status", searchParams] as const)
|
||||
@@ -140,6 +145,7 @@ const StatsInputStatusInp = () => {
|
||||
inputPeriodCurrentRef.current = false;
|
||||
setExceptionHistoryOpen(false);
|
||||
setExceptionHistoryContext(null);
|
||||
setIsApproveLoading(false);
|
||||
};
|
||||
|
||||
const approveFunc = async () => {
|
||||
@@ -152,15 +158,20 @@ const StatsInputStatusInp = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// const hasInvalidStatus = rowData.some((row) =>
|
||||
// ["0", "1", "4"].includes(String(row.laeSbmsnSttsCd ?? "")),
|
||||
// );
|
||||
const hasInvalidStatus = rowData.some((row) =>
|
||||
["0", "1", "4"].includes(String(row.laeSbmsnSttsCd ?? "")),
|
||||
);
|
||||
|
||||
// if (hasInvalidStatus) {
|
||||
// alert("미작성이나 미제출, 혹은 보완요청(반려) 상태인 항목이 있습니다.");
|
||||
// return;
|
||||
// }
|
||||
if (hasInvalidStatus) {
|
||||
alert("미작성이나 미제출, 혹은 보완요청(반려) 상태인 항목이 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await confirm("조회된 통계 항목을 승인하시겠습니까?"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
setIsApproveLoading(true);
|
||||
try {
|
||||
const userInfo = await getUserInfo();
|
||||
const mdfrId = (userInfo.userUnqId ?? "").trim();
|
||||
@@ -186,7 +197,7 @@ const StatsInputStatusInp = () => {
|
||||
}
|
||||
|
||||
const response = await statisticsApi.approveStatsInputStatus({ list: approveItems }, "INPUT");
|
||||
if (response.status === "success") {
|
||||
if (response.resultCode.toLocaleLowerCase() === "success") {
|
||||
if (searchParams) {
|
||||
await mutate(["stats-input-status", searchParams]);
|
||||
}
|
||||
@@ -196,6 +207,8 @@ const StatsInputStatusInp = () => {
|
||||
}
|
||||
} catch {
|
||||
alert("승인 처리 중 오류가 발생했습니다.");
|
||||
} finally {
|
||||
setIsApproveLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -239,8 +252,21 @@ const StatsInputStatusInp = () => {
|
||||
const gugunOkOrNotDoList = doList.includes(lastSearchedValues?.bsnmCd || "")
|
||||
? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== "ALL")
|
||||
: true;
|
||||
|
||||
const allRowsLaeSbmsnApproved = useMemo(
|
||||
() =>
|
||||
rowData.length > 0 &&
|
||||
rowData.every((row) => String(row.laeSbmsnSttsCd ?? "") === "3"),
|
||||
[rowData],
|
||||
);
|
||||
|
||||
const showActionToolbarCard =
|
||||
hasCompletedSearch && rowData.length > 0 && gugunOkOrNotDoList && inputPeriodCurrentRef.current;
|
||||
hasCompletedSearch &&
|
||||
rowData.length > 0 &&
|
||||
gugunOkOrNotDoList &&
|
||||
inputPeriodCurrentRef.current &&
|
||||
!allRowsLaeSbmsnApproved &&
|
||||
confirmGroupToolbarAllowed;
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -253,7 +279,7 @@ const StatsInputStatusInp = () => {
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isLoading && (
|
||||
{(isLoading || isApproveLoading) && (
|
||||
<div className="[data-theme='black']:bg-transparent absolute inset-0 z-50 flex items-center justify-center rounded-lg p-10">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithAnimation color="primary" />
|
||||
|
||||
Reference in New Issue
Block a user