[st] feat: 입력 저장/제출 로직 수정, 통계입력관리, 검토 반려/제출
This commit is contained in:
@@ -18,6 +18,7 @@ import {
|
||||
type CheckInputPeriodItem,
|
||||
getVerificationPeriodActionBlockedMessage,
|
||||
isInputPeriodCurrent,
|
||||
type SewerageSupplyRateVerificationResult,
|
||||
} from '@/entities/statistics/model/input/statistics-sewage-supply-rate-input-interface';
|
||||
import type { StatisticsInputSubmitInfoFormData } from '@/entities/statistics/model/statistics-input-submit-info-schema';
|
||||
import type { cancelSubmitRequest, ImrStatusResponse, SewerageStatusInfo } from '@/entities/statistics/model/statistics-interface';
|
||||
@@ -46,6 +47,10 @@ import { PublicSewageFactInpColumnList } from '@/components/util/column/input/Pu
|
||||
import { toGridRows } from '@/components/util/grid/gridFunction';
|
||||
import { useAdminStore } from '@/store/admin-store';
|
||||
|
||||
type GridRowWithVerification = Record<string, string | number> & {
|
||||
verificationResult?: SewerageSupplyRateVerificationResult;
|
||||
};
|
||||
|
||||
type TabToolbarSnapshot = {
|
||||
showSaveInToolbar: boolean;
|
||||
showEnterableToolbarButtons: boolean;
|
||||
@@ -1105,6 +1110,32 @@ const PublicSewageFacilityInp = () => {
|
||||
}
|
||||
showHeaderCheckbox={false}
|
||||
enableSort={false}
|
||||
cellStyleCallback={({ row, fieldName }) => {
|
||||
const verification = (row as GridRowWithVerification).verificationResult;
|
||||
if (!verification) return;
|
||||
const errors = verification[fieldName];
|
||||
if (Array.isArray(errors) && errors.length > 0) {
|
||||
const hasImr = errors.some((e) => e.vrfcCd === "IMR");
|
||||
return hasImr ? "rg-cell-verify-error-imr" : "rg-cell-verify-error";
|
||||
}
|
||||
}}
|
||||
cellTooltipCallback={({ row, fieldName }) => {
|
||||
const verification = (row as GridRowWithVerification).verificationResult;
|
||||
if (!verification) return;
|
||||
const errors = verification[fieldName];
|
||||
if (Array.isArray(errors) && errors.length > 0) {
|
||||
return errors
|
||||
.map((e) => {
|
||||
const prefix =
|
||||
e.vrfcCd === "IMR" ? "IMR검증 - " : "일반검증 - ";
|
||||
const comp = e.compVlCn ?? "";
|
||||
const now = e.nowVlCn ?? "";
|
||||
return `${prefix}${e.rsnExpln}(검증 기준값: ${comp} / 현재 입력값: ${now})`;
|
||||
})
|
||||
.filter(Boolean)
|
||||
.join("\n");
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</TabsContent>
|
||||
);
|
||||
@@ -1128,6 +1159,11 @@ const PublicSewageFacilityInp = () => {
|
||||
open={verificationResultDialogOpen}
|
||||
onOpenChange={setVerificationResultDialogOpen}
|
||||
queryContext={verificationQueryContext}
|
||||
onExceptionSubmitted={async () => {
|
||||
const ctx = lastSearchedValues ?? searchValues;
|
||||
if (!ctx || !searchParamRef.current) return;
|
||||
await loadPublicSewageFacilityActiveTabData(activeTab, searchParamRef.current, ctx);
|
||||
}}
|
||||
/>
|
||||
<MainFacilityMappingSaveDialog
|
||||
key={`main-facility-mapping-save-${mainFacilityMappingSaveDialogKey}`}
|
||||
|
||||
@@ -910,14 +910,14 @@ const SewagePipeInp = () => {
|
||||
return;
|
||||
}
|
||||
if (!isException) {
|
||||
const currentData = getTabGridRowsForVerification(tabKey);
|
||||
const rowsWithVerificationErrors = currentData.filter((d) =>
|
||||
hasRegionalFactVerificationErrors((d as GridRowWithVerification).verificationResult),
|
||||
);
|
||||
if (rowsWithVerificationErrors.length > 0) {
|
||||
alert("데이터에 오류가 있습니다.\n수정 후 제출해주세요.");
|
||||
return;
|
||||
}
|
||||
// const currentData = getTabGridRowsForVerification(tabKey);
|
||||
// const rowsWithVerificationErrors = currentData.filter((d) =>
|
||||
// hasRegionalFactVerificationErrors((d as GridRowWithVerification).verificationResult),
|
||||
// );
|
||||
// if (rowsWithVerificationErrors.length > 0) {
|
||||
// alert("데이터에 오류가 있습니다.\n수정 후 제출해주세요.");
|
||||
// return;
|
||||
// }
|
||||
if (await confirm("제출 하시겠습니까?")) {
|
||||
setIsExceptionSubmitFlow(false);
|
||||
setShowDailog(true);
|
||||
@@ -2052,6 +2052,12 @@ const SewagePipeInp = () => {
|
||||
}
|
||||
: null
|
||||
}
|
||||
onExceptionSubmitted={async () => {
|
||||
const values = lastSearchedValues ?? searchValues;
|
||||
if (!values?.year || !values?.sido || !values?.bsnmCd) return;
|
||||
const refreshedParam = buildSewagePipeSearchParam(values);
|
||||
await loadSewagePipeActiveTabData(activeTab, refreshedParam, values, true, false);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -104,6 +104,14 @@ function getSewerageSupplyRateParams(
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeGridString(value: unknown): string | null {
|
||||
if (typeof value !== "string") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return value.trim() === "" ? null : value;
|
||||
}
|
||||
|
||||
// 하수도 통계 관리 > 01. 하수도 보급률
|
||||
const SeweragePenetrationRateInp = () => {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
@@ -378,15 +386,15 @@ const SeweragePenetrationRateInp = () => {
|
||||
|
||||
const submitFunc = async (isException: boolean) => {
|
||||
if (!isException) {
|
||||
const isError = rowData.filter((d) =>
|
||||
hasVerificationErrors((d as GridRowWithVerification).verificationResult)
|
||||
);
|
||||
// const isError = rowData.filter((d) =>
|
||||
// hasVerificationErrors((d as GridRowWithVerification).verificationResult)
|
||||
// );
|
||||
|
||||
if (isError.length > 0) {
|
||||
alert(`데이터에 오류가 있습니다.
|
||||
수정 후 제출해주세요.`);
|
||||
return;
|
||||
}
|
||||
// if (isError.length > 0) {
|
||||
// alert(`데이터에 오류가 있습니다.
|
||||
// 수정 후 제출해주세요.`);
|
||||
// return;
|
||||
// }
|
||||
if (await confirm('제출 하시겠습니까?')) {
|
||||
setIsExceptionSubmitFlow(false);
|
||||
setShowDailog(true);
|
||||
@@ -438,11 +446,12 @@ const SeweragePenetrationRateInp = () => {
|
||||
};
|
||||
|
||||
const convertedData: SewerageSupplyRateSaveItem[] = currentData.map((d) => ({
|
||||
sggNm: (d.sggNm as string) || null,
|
||||
admdstCd: d.admdstCd as string,
|
||||
admdstNm: d.admdstNm as string,
|
||||
trbtrNm: d.trbtrNm as string,
|
||||
spcCtpnRgnCn: d.spcCtpnRgnCn === '해당없음' ? null : (d.spcCtpnRgnCn as string | null),
|
||||
sggNm: normalizeGridString(d.sggNm),
|
||||
admdstCd: normalizeGridString(d.admdstCd),
|
||||
admdstNm: normalizeGridString(d.admdstNm),
|
||||
trbtrNm: normalizeGridString(d.trbtrNm),
|
||||
spcCtpnRgnCn:
|
||||
d.spcCtpnRgnCn === '해당없음' ? null : normalizeGridString(d.spcCtpnRgnCn),
|
||||
ts1SwtrmtPpltnCnt: formatNumber(d.ts1SwtrmtPpltnCnt, 'ts1SwtrmtPpltnCnt'),
|
||||
ts2SwtrmtPpltnCnt: formatNumber(d.ts2SwtrmtPpltnCnt, 'ts2SwtrmtPpltnCnt'),
|
||||
ts3SwtrmtPpltnCnt: formatNumber(d.ts3SwtrmtPpltnCnt, 'ts3SwtrmtPpltnCnt'),
|
||||
@@ -455,7 +464,7 @@ const SeweragePenetrationRateInp = () => {
|
||||
drtwPrcsPpltnCnt: formatNumber(d.drtwPrcsPpltnCnt, 'drtwPrcsPpltnCnt'),
|
||||
spctnkPpltnCnt: formatNumber(d.spctnkPpltnCnt, 'spctnkPpltnCnt'),
|
||||
staaExcpArea: formatNumber(d.staaExcpArea, 'staaExcpArea'),
|
||||
rmrk: (d.rmrk as string) ?? '',
|
||||
rmrk: normalizeGridString(d.rmrk),
|
||||
wholPpltnCnt: formatNumber(d.wholPpltnCnt, 'wholPpltnCnt'),
|
||||
wholArea: formatNumber(d.wholArea, 'wholArea'),
|
||||
wholSwtrmtPpltnCnt: formatNumber(d.wholSwtrmtPpltnCnt, 'wholSwtrmtPpltnCnt'),
|
||||
@@ -584,11 +593,14 @@ const SeweragePenetrationRateInp = () => {
|
||||
|
||||
const convertedData: SewerageSupplyRateSaveItem[] = currentData.map((d) => ({
|
||||
// 행정구역
|
||||
sggNm: (d.sggNm as string) || null, // 시군구
|
||||
admdstCd: d.admdstCd as string, // 행정코드
|
||||
admdstNm: d.admdstNm as string, // 행정구역명
|
||||
trbtrNm: d.trbtrNm as string, // 지류
|
||||
spcCtpnRgnCn: d.spcCtpnRgnCn === '해당없음' ? null : (d.spcCtpnRgnCn as string | null), // 특별대책지역
|
||||
sggNm: normalizeGridString(d.sggNm), // 시군구
|
||||
admdstCd: normalizeGridString(d.admdstCd), // 행정코드
|
||||
admdstNm: normalizeGridString(d.admdstNm), // 행정구역명
|
||||
trbtrNm: normalizeGridString(d.trbtrNm), // 지류
|
||||
spcCtpnRgnCn:
|
||||
d.spcCtpnRgnCn === '해당없음'
|
||||
? null
|
||||
: normalizeGridString(d.spcCtpnRgnCn), // 특별대책지역
|
||||
// 공공하수처리인구(명) - 물리적/생물학적/고도처리
|
||||
ts1SwtrmtPpltnCnt: formatNumber(d.ts1SwtrmtPpltnCnt, 'ts1SwtrmtPpltnCnt'), // 물리적처리
|
||||
ts2SwtrmtPpltnCnt: formatNumber(d.ts2SwtrmtPpltnCnt, 'ts2SwtrmtPpltnCnt'), // 생물학적처리
|
||||
@@ -604,7 +616,7 @@ const SeweragePenetrationRateInp = () => {
|
||||
drtwPrcsPpltnCnt: formatNumber(d.drtwPrcsPpltnCnt, 'drtwPrcsPpltnCnt'), // 오수처리인구
|
||||
spctnkPpltnCnt: formatNumber(d.spctnkPpltnCnt, 'spctnkPpltnCnt'), // 정화조인구
|
||||
staaExcpArea: formatNumber(d.staaExcpArea, 'staaExcpArea'), // 하수처리구역 외 면적(㎢)
|
||||
rmrk: (d.rmrk as string) ?? '', // 비고
|
||||
rmrk: normalizeGridString(d.rmrk), // 비고
|
||||
// 합계·소계(계산필드 저장용)
|
||||
wholPpltnCnt: formatNumber(d.wholPpltnCnt, 'wholPpltnCnt'), // 총인구(명)
|
||||
wholArea: formatNumber(d.wholArea, 'wholArea'), // 총면적(㎢)
|
||||
@@ -819,6 +831,11 @@ const SeweragePenetrationRateInp = () => {
|
||||
}
|
||||
: null
|
||||
}
|
||||
onExceptionSubmitted={async () => {
|
||||
const values = lastSearchedValues ?? searchValues;
|
||||
if (!values) return;
|
||||
await handleSearch(values);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
import { RealGridReact } from "realgrid-react";
|
||||
import useSWR, { useSWRConfig } from "swr";
|
||||
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
@@ -13,6 +14,7 @@ import RejectButton from "@/components/button/RejectButton";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { doList } from "@/components/util/column/input/DoList";
|
||||
import { StatsInputStatusInpColumn } from "@/components/util/column/input/StatsInputStatusInpColumn";
|
||||
import { toGridRows } from "@/components/util/grid/gridFunction";
|
||||
import { useTabStore } from "@/store/tab-store";
|
||||
@@ -32,6 +34,10 @@ const StatsInputStatusInp = () => {
|
||||
);
|
||||
const [searchParams, setSearchParams] =
|
||||
useState<StatsInputStatusListRequestParams | null>(null);
|
||||
const [lastSearchedValues, setLastSearchedValues] =
|
||||
useState<SearchFormValues | null>(null);
|
||||
const [hasCompletedSearch, setHasCompletedSearch] = useState(false);
|
||||
const gridRef = useRef<RealGridReact | null>(null);
|
||||
|
||||
const swrKey = searchParams
|
||||
? (["stats-input-status", searchParams] as const)
|
||||
@@ -45,12 +51,16 @@ const StatsInputStatusInp = () => {
|
||||
onSuccess: (data) => {
|
||||
if (data.status === "success" && data.data) {
|
||||
setRowData(toGridRows(data.data));
|
||||
setHasCompletedSearch(true);
|
||||
} else {
|
||||
setHasCompletedSearch(false);
|
||||
setRowData([]);
|
||||
alert(data.message ?? "조회에 실패했습니다.");
|
||||
}
|
||||
},
|
||||
onError: () => {
|
||||
alert("데이터 조회 중 오류가 발생했습니다.");
|
||||
setHasCompletedSearch(false);
|
||||
setRowData([]);
|
||||
},
|
||||
},
|
||||
@@ -73,6 +83,8 @@ const StatsInputStatusInp = () => {
|
||||
sggNm: values.gugun === "ALL" ? "" : values.gugun,
|
||||
statsYr: values.year ?? "",
|
||||
};
|
||||
setHasCompletedSearch(false);
|
||||
setLastSearchedValues(values);
|
||||
setSearchParams(params);
|
||||
mutate(["stats-input-status", params]);
|
||||
};
|
||||
@@ -80,6 +92,8 @@ const StatsInputStatusInp = () => {
|
||||
const handleReset = () => {
|
||||
setSearchParams(null);
|
||||
setRowData([]);
|
||||
setLastSearchedValues(null);
|
||||
setHasCompletedSearch(false);
|
||||
};
|
||||
|
||||
const rejectFunc = () => {
|
||||
@@ -87,19 +101,44 @@ const StatsInputStatusInp = () => {
|
||||
};
|
||||
|
||||
const approveFunc = () => {
|
||||
const checkedRows =
|
||||
gridRef.current?.gridView?.getCheckedRows?.(true, false, true) ?? [];
|
||||
|
||||
if (rowData.length === 0 || checkedRows.length !== rowData.length) {
|
||||
alert('모든 통계 항목을 체크해주세요.');
|
||||
return;
|
||||
}
|
||||
|
||||
const hasInvalidStatus = rowData.some((row) =>
|
||||
["0", "1", "4"].includes(String(row.laeSbmsnSttsCd ?? "")),
|
||||
);
|
||||
|
||||
if (hasInvalidStatus) {
|
||||
alert("미작성이나 미제출, 혹은 보완요청(반려) 상태인 항목이 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
// 승인 요청 로직
|
||||
};
|
||||
|
||||
const gugunOkOrNotDoList = doList.includes(lastSearchedValues?.bsnmCd || "")
|
||||
? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== "ALL")
|
||||
: true;
|
||||
const showActionToolbarCard =
|
||||
hasCompletedSearch && rowData.length > 0 && gugunOkOrNotDoList;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="relative">
|
||||
<SearchForm onSubmit={handleSearch} onReset={handleReset} />
|
||||
<div className="card !py-0">
|
||||
<div className="m-[0.6rem] flex items-center justify-end gap-[0.6rem]">
|
||||
<RejectButton rejectFunc={rejectFunc} />
|
||||
<ApproveButton approveFunc={approveFunc} />
|
||||
{showActionToolbarCard && (
|
||||
<div className="card !py-0">
|
||||
<div className="m-[0.6rem] flex items-center justify-end gap-[0.6rem]">
|
||||
<RejectButton rejectFunc={rejectFunc} />
|
||||
<ApproveButton approveFunc={approveFunc} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{isLoading && (
|
||||
<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]">
|
||||
@@ -115,6 +154,27 @@ const StatsInputStatusInp = () => {
|
||||
setRowData={setRowData}
|
||||
isExcelImport={false}
|
||||
showHeaderCheckbox={true}
|
||||
getGridRef={gridRef}
|
||||
cellStyleCallback={({ row, fieldName }) => {
|
||||
if (fieldName !== "laeSbmsnSttsNm") {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const statusCd = String(row.laeSbmsnSttsCd ?? "");
|
||||
if (statusCd === "0" || statusCd === "1") {
|
||||
return "rg-cell-stats-status-pending";
|
||||
}
|
||||
if (statusCd === "2") {
|
||||
return "rg-cell-stats-status-submitted";
|
||||
}
|
||||
if (statusCd === "3") {
|
||||
return "rg-cell-stats-status-approved";
|
||||
}
|
||||
if (statusCd === "4") {
|
||||
return "rg-cell-stats-status-rejected";
|
||||
}
|
||||
return undefined;
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -33,7 +33,7 @@ function rowSeTypeToCode(row: Record<string, string | number>): "INPT" | "VRFC"
|
||||
return "INPT";
|
||||
}
|
||||
|
||||
function parseYmdToDate(ymd: unknown): Date | undefined {
|
||||
function parseYmdToDate(ymd: string): Date | undefined {
|
||||
const s = String(ymd ?? "").replace(/\D/g, "");
|
||||
if (s.length !== 8) return undefined;
|
||||
const y = Number(s.slice(0, 4));
|
||||
@@ -47,6 +47,12 @@ function parseYmdToDate(ymd: unknown): Date | undefined {
|
||||
return dt;
|
||||
}
|
||||
|
||||
function formatYmdForDisplay(ymd: string): string {
|
||||
const s = String(ymd ?? "").replace(/\D/g, "");
|
||||
if (s.length !== 8) return String(ymd ?? "");
|
||||
return `${s.slice(0, 4)}-${s.slice(4, 6)}-${s.slice(6, 8)}`;
|
||||
}
|
||||
|
||||
const StatisticsInputManagement = () => {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
@@ -71,16 +77,17 @@ const StatisticsInputManagement = () => {
|
||||
setIsLoading(true);
|
||||
const params: StatsInputPeriodListRequest = {
|
||||
statsYr: values.year,
|
||||
seType:
|
||||
values.clsfCd && values.clsfCd !== "ALL"
|
||||
? values.clsfCd
|
||||
: "",
|
||||
...(values.clsfCd && values.clsfCd !== "ALL"
|
||||
? { seType: values.clsfCd }
|
||||
: {}),
|
||||
};
|
||||
const res = await statisticsApi.getStatsInputPeriodList(params);
|
||||
if (res.status === "success" && Array.isArray(res.data)) {
|
||||
const rowsForGrid = res.data.map((row) => ({
|
||||
...row,
|
||||
seType: seTypeToDisplayLabel(row.seType),
|
||||
inptBgngYmd: formatYmdForDisplay(row.inptBgngYmd),
|
||||
inptEndYmd: formatYmdForDisplay(row.inptEndYmd),
|
||||
}));
|
||||
setRowData(toGridRows(rowsForGrid));
|
||||
} else {
|
||||
@@ -112,27 +119,47 @@ const StatisticsInputManagement = () => {
|
||||
setPeriodDialogOpen(true);
|
||||
};
|
||||
|
||||
const handleRowClick = (row: Record<string, string | number>) => {
|
||||
const inptYmdSnRaw = row.inptYmdSn;
|
||||
const inptYmdSnNum =
|
||||
typeof inptYmdSnRaw === "number"
|
||||
? inptYmdSnRaw
|
||||
: parseInt(String(inptYmdSnRaw ?? ""), 10);
|
||||
const handleRowClick = async (row: Record<string, string | number>) => {
|
||||
const seCdRaw = row.seCd;
|
||||
const seCdNum =
|
||||
typeof seCdRaw === "number"
|
||||
? seCdRaw
|
||||
: parseInt(String(seCdRaw ?? ""), 10);
|
||||
setPeriodDialogMode("edit");
|
||||
setPeriodDialogInitial({
|
||||
statsYr: String(row.statsYr ?? ""),
|
||||
seType: rowSeTypeToCode(row),
|
||||
inptYmdSn: Number.isFinite(inptYmdSnNum) ? inptYmdSnNum : 0,
|
||||
seCd: Number.isFinite(seCdNum) ? seCdNum : 0,
|
||||
inptBgngYmd: parseYmdToDate(row.inptBgngYmd),
|
||||
inptEndYmd: parseYmdToDate(row.inptEndYmd),
|
||||
});
|
||||
setPeriodDialogOpen(true);
|
||||
const seCd = Number.isFinite(seCdNum) ? seCdNum : 0;
|
||||
const statsYr = String(row.statsYr ?? "");
|
||||
const seType = rowSeTypeToCode(row);
|
||||
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const res = await statisticsApi.getStatsInputPeriodDetail({
|
||||
statsYr,
|
||||
seType,
|
||||
seCd,
|
||||
});
|
||||
|
||||
if (res.status !== "success" || !res.data) {
|
||||
alert(res.message || "상세 정보를 조회하지 못했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
const detail = res.data;
|
||||
setPeriodDialogMode("edit");
|
||||
setPeriodDialogInitial({
|
||||
statsYr: String(detail.statsYr ?? statsYr),
|
||||
seType: detail.seType === "VRFC" ? "VRFC" : "INPT",
|
||||
seCd:
|
||||
typeof detail.seCd === "number" && Number.isFinite(detail.seCd)
|
||||
? detail.seCd
|
||||
: seCd,
|
||||
inptBgngYmd: parseYmdToDate(detail.inptBgngYmd),
|
||||
inptEndYmd: parseYmdToDate(detail.inptEndYmd),
|
||||
});
|
||||
setPeriodDialogOpen(true);
|
||||
} catch {
|
||||
alert("상세 정보 조회 중 오류가 발생했습니다.");
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const columns: ColumnConfig[] = [
|
||||
@@ -166,13 +193,6 @@ const StatisticsInputManagement = () => {
|
||||
header: { text: "종료일" },
|
||||
editable: false,
|
||||
},
|
||||
{
|
||||
name: "inptYmdSn",
|
||||
fieldName: "inptYmdSn",
|
||||
header: { text: "inptYmdSn" },
|
||||
visible: false,
|
||||
editable: false,
|
||||
},
|
||||
];
|
||||
|
||||
const columnLayout = [
|
||||
|
||||
@@ -33,7 +33,6 @@ import { getUserInfo } from "../../../../../../packages/common/components/src/ap
|
||||
export type StatisticsInputPeriodDialogValues = {
|
||||
statsYr: string;
|
||||
seType: "INPT" | "VRFC";
|
||||
inptYmdSn: number;
|
||||
seCd: number;
|
||||
inptBgngYmd: Date | undefined;
|
||||
inptEndYmd: Date | undefined;
|
||||
@@ -138,22 +137,17 @@ export function StatisticsInputPeriodDialog({
|
||||
try {
|
||||
setIsSubmitting(true);
|
||||
const userInfo = await getUserInfo();
|
||||
const inptYmdSn =
|
||||
mode === "create"
|
||||
? 0
|
||||
: (initial && Number.isFinite(initial.inptYmdSn) ? initial.inptYmdSn : 0);
|
||||
const param: StatsInputPeriodSaveRequest = {
|
||||
statsYr: yr,
|
||||
seType,
|
||||
inptYmdSn,
|
||||
seCd: seCdParsed,
|
||||
inptBgngYmd: bgng,
|
||||
inptEndYmd: end,
|
||||
rgtrId: userInfo.userUnqId,
|
||||
};
|
||||
const res = isCreate
|
||||
? await statisticsApi.saveStatsInputPeriod(param)
|
||||
: await statisticsApi.updateStatsInputPeriod(param);
|
||||
if (!isCreate) {
|
||||
param.seCd = seCdParsed;
|
||||
}
|
||||
const res = await statisticsApi.saveStatsInputPeriod(param);
|
||||
if (res.status === "success") {
|
||||
alert(`${isCreate ? '등록 되었습니다.' : '수정 되었습니다.'}`);
|
||||
onOpenChange(false);
|
||||
@@ -192,8 +186,6 @@ export function StatisticsInputPeriodDialog({
|
||||
const param: StatsInputPeriodDeleteRequest = {
|
||||
statsYr: yr,
|
||||
seType: initial.seType,
|
||||
inptYmdSn:
|
||||
Number.isFinite(initial.inptYmdSn) ? initial.inptYmdSn : 0,
|
||||
seCd,
|
||||
inptBgngYmd: bgng,
|
||||
inptEndYmd: end,
|
||||
@@ -253,7 +245,7 @@ export function StatisticsInputPeriodDialog({
|
||||
<Select
|
||||
value={seType ?? undefined}
|
||||
onValueChange={(v) => setSeType(v as "INPT" | "VRFC")}
|
||||
disabled={isSubmitting}
|
||||
disabled={isSubmitting || mode === "edit"}
|
||||
>
|
||||
<SelectTrigger className="w-full">
|
||||
<SelectValue placeholder="선택" />
|
||||
|
||||
@@ -91,7 +91,7 @@ const PublicSewageFacilityRvw = () => {
|
||||
sggNm: values.gugun === "ALL" ? "" : values.gugun,
|
||||
sewerBzmnCd: values.bsnmCd,
|
||||
statsYr: values.year,
|
||||
fctName: values.fctName,
|
||||
swtrmtFcltNm: values.fctName,
|
||||
});
|
||||
|
||||
if (response.status === "success" && response.data) {
|
||||
|
||||
@@ -99,12 +99,12 @@ export function ReturnReasonDialog({
|
||||
};
|
||||
|
||||
const response = await statisticsApi.saveReviewReturn(param);
|
||||
if (response.status !== "success") {
|
||||
if (response.resultCode.toLowerCase() !== "success") {
|
||||
alert(response.message || "반려 처리 중 오류가 발생했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
alert(response.message || "반려 처리 되었습니다.");
|
||||
alert("반려 처리 되었습니다.");
|
||||
await onSave?.();
|
||||
resetForm();
|
||||
onOpenChange(false);
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
|
||||
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
Input,
|
||||
Label,
|
||||
LoadingWithAnimation,
|
||||
Textarea,
|
||||
} from "@common/components";
|
||||
|
||||
import { statisticsApi } from "@/entities/statistics/api/statistics-service";
|
||||
import type {
|
||||
ReviewerInfoRequest,
|
||||
ReviewerInfoResponse,
|
||||
ReviewSubmitRequest,
|
||||
} from "@/entities/statistics/model/statistics-interface";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
|
||||
export interface ReviewSubmitDialogProps {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
context: ReviewerInfoRequest | null;
|
||||
onSubmitted?: () => void | Promise<void>;
|
||||
}
|
||||
|
||||
export function ReviewSubmitDialog({
|
||||
open,
|
||||
onOpenChange,
|
||||
context,
|
||||
onSubmitted,
|
||||
}: ReviewSubmitDialogProps) {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const [reviewerInfo, setReviewerInfo] =
|
||||
useState<ReviewerInfoResponse["data"] | null>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) {
|
||||
setReviewerInfo(null);
|
||||
setIsLoading(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (context == null) {
|
||||
setReviewerInfo(null);
|
||||
return;
|
||||
}
|
||||
|
||||
let cancelled = false;
|
||||
|
||||
const loadReviewerInfo = async () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
const response = await statisticsApi.getReviewerInfo(context);
|
||||
|
||||
if (cancelled) return;
|
||||
|
||||
if (response.status !== "success" || !response.data) {
|
||||
alert("제출 정보를 불러오지 못했습니다.");
|
||||
setReviewerInfo(null);
|
||||
return;
|
||||
}
|
||||
|
||||
setReviewerInfo(response.data);
|
||||
} catch {
|
||||
if (!cancelled) {
|
||||
alert("제출 정보를 불러오지 못했습니다.");
|
||||
setReviewerInfo(null);
|
||||
}
|
||||
} finally {
|
||||
if (!cancelled) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void loadReviewerInfo();
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [open, context, alert]);
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (context == null || reviewerInfo == null) {
|
||||
alert("제출 정보를 확인한 뒤 다시 시도해주세요.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
setIsSubmitting(true);
|
||||
|
||||
const userInfo = await getUserInfo();
|
||||
const submitParam: ReviewSubmitRequest = {
|
||||
statsYr: context.statsYr,
|
||||
sewerBzmnCd: context.sewerBzmnCd,
|
||||
statsCd: context.statsCd,
|
||||
mdfrId: userInfo.userUnqId,
|
||||
splmntOpnnCn: reviewerInfo.splmntOpnnCn ?? "",
|
||||
wrterOpnnCn: reviewerInfo.wrterOpnnCn ?? "",
|
||||
};
|
||||
|
||||
const response = await statisticsApi.submitReview(submitParam);
|
||||
if (response.status !== "success") {
|
||||
alert(response.message || "제출에 실패했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
alert(response.message || "제출되었습니다.");
|
||||
onOpenChange(false);
|
||||
await onSubmitted?.();
|
||||
} catch {
|
||||
alert("제출 중 오류가 발생했습니다.");
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="max-w-[64rem]" aria-describedby={undefined}>
|
||||
<DialogHeader>
|
||||
<DialogTitle>제출 정보</DialogTitle>
|
||||
</DialogHeader>
|
||||
{(isLoading || isSubmitting) && (
|
||||
<div className="absolute inset-0 z-50 flex items-center justify-center rounded-lg p-10 [data-theme='black']:bg-transparent">
|
||||
<div className="relative size-[5rem]">
|
||||
<LoadingWithAnimation color="primary" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
<div className="grid grid-cols-2 gap-4 py-2">
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label className="text-label">검토자명</Label>
|
||||
<Input value={reviewerInfo?.userNm ?? "-"} readOnly />
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label className="text-label">연락처</Label>
|
||||
<Input value={reviewerInfo?.telOffrm ?? "-"} readOnly />
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label className="text-label">부서</Label>
|
||||
<Input value={reviewerInfo?.dpmNm ?? "-"} readOnly />
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<Label className="text-label">직책</Label>
|
||||
<Input value={reviewerInfo?.cps ?? "-"} readOnly />
|
||||
</div>
|
||||
<div className="col-span-2 flex flex-col gap-2">
|
||||
<Label className="text-label">검토의견</Label>
|
||||
<Textarea
|
||||
value={reviewerInfo?.splmntOpnnCn ?? "-"}
|
||||
readOnly
|
||||
className="min-h-[10rem] p-2 resize-none !text-xl"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-span-2 flex flex-col gap-2">
|
||||
<Label className="text-label">처리내역</Label>
|
||||
<Textarea
|
||||
value={reviewerInfo?.wrterOpnnCn ?? "-"}
|
||||
readOnly
|
||||
className="min-h-[10rem] p-2 resize-none !text-xl"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
color="primary"
|
||||
onClick={() => void handleConfirm()}
|
||||
disabled={isLoading || isSubmitting || reviewerInfo == null}
|
||||
>
|
||||
제출
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
color="gray"
|
||||
onClick={() => onOpenChange(false)}
|
||||
disabled={isLoading || isSubmitting}
|
||||
>
|
||||
취소
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
|
||||
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { useAlertStore, useUserStore } from "@/shared/lib";
|
||||
import { statisticsManagementApi } from "@/entities/statistics/api/statistics-management-service";
|
||||
import { statisticsApi } from "@/entities/statistics/api/statistics-service";
|
||||
import type {
|
||||
SewagePipeReviewRequestParams,
|
||||
StatsStatusInfo,
|
||||
} from "@/entities/statistics/model/statistics-sewage-pipe-review-interface";
|
||||
import type { ReviewOpinionSaveRequest } from "@/entities/statistics/model/statistics-interface";
|
||||
import type {
|
||||
ReviewerInfoRequest,
|
||||
ReviewOpinionSaveRequest,
|
||||
} from "@/entities/statistics/model/statistics-interface";
|
||||
import { LoadingWithAnimation, Tabs, TabsContent, TabsList, TabsTrigger } from "@common/components";
|
||||
|
||||
import SubmitButton from "@/components/button/SumitButton";
|
||||
@@ -18,17 +19,57 @@ import ReviewOpinionButton from "@/components/button/ReviewOpinionButton";
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import { ReturnReasonDialog } from "@/components/statistics/review/ReturnReasonDialog";
|
||||
import { ReviewSubmitDialog } from "@/components/statistics/review/ReviewSubmitDialog";
|
||||
import {
|
||||
ReviewOpinionDialog,
|
||||
type ReviewOpinionDialogContext,
|
||||
} from "@/components/statistics/review/ReviewOpinionDialog";
|
||||
import type { ColumnInfo } from "@/components/type/DataGrid.type";
|
||||
import type {
|
||||
ColumnConfig,
|
||||
ColumnInfo,
|
||||
ColumnInfoList,
|
||||
ColumnLayoutItem,
|
||||
} from "@/components/type/DataGrid.type";
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
import { SewagePipeColumnInfoListRvw } from "@/components/util/column/review/SewagePipeRvwColumn";
|
||||
import { toGridRows } from "@/components/util/grid/gridFunction";
|
||||
|
||||
const firstTabKey = SewagePipeColumnInfoListRvw[0]?.tabKey ?? "ST00020001";
|
||||
|
||||
function cloneColumnLayoutItem(item: ColumnLayoutItem): ColumnLayoutItem {
|
||||
if (typeof item === "string") return item;
|
||||
if ("column" in item) {
|
||||
return {
|
||||
column: item.column,
|
||||
...(item.footerUserSpans && {
|
||||
footerUserSpans: item.footerUserSpans.map((span) => ({ ...span })),
|
||||
}),
|
||||
};
|
||||
}
|
||||
return {
|
||||
...item,
|
||||
header: { ...item.header },
|
||||
items: item.items.map((child) =>
|
||||
typeof child === "string" ? child : cloneColumnLayoutItem(child),
|
||||
),
|
||||
...(item.footerUserSpans && {
|
||||
footerUserSpans: item.footerUserSpans.map((span) => ({ ...span })),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
function cloneColumnConfig(col: ColumnConfig): ColumnConfig {
|
||||
return {
|
||||
...col,
|
||||
header: { ...col.header },
|
||||
...(col.footer && {
|
||||
footer: Array.isArray(col.footer)
|
||||
? col.footer.map((item) => ({ ...item }))
|
||||
: { ...col.footer },
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchSewagePipeReviewTab(
|
||||
tabKey: string,
|
||||
searchParam: SewagePipeReviewRequestParams,
|
||||
@@ -45,6 +86,9 @@ async function fetchSewagePipeReviewTab(
|
||||
if (tabKey === "ST00020004") {
|
||||
return statisticsManagementApi.getSewagePipeDiamList(searchParam);
|
||||
}
|
||||
if (tabKey === "ST00020005") {
|
||||
return await statisticsManagementApi.getSewagePipeManholeList(searchParam);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -65,6 +109,8 @@ function extractReviewRowsFromResponseData(
|
||||
return Array.isArray(d.pipeTypeList) ? (d.pipeTypeList as object[]) : [];
|
||||
case "ST00020004":
|
||||
return Array.isArray(d.pipeDiamList) ? (d.pipeDiamList as object[]) : [];
|
||||
case "ST00020005":
|
||||
return Array.isArray(d.manholeList) ? (d.manholeList as object[]) : [];
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -79,12 +125,13 @@ function extractStatsStatusInfo(data: unknown): StatsStatusInfo | null {
|
||||
// 하수도 통계 검토 02.하수관로
|
||||
const SewagePipeRvw = () => {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const { confirm } = useConfirm();
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const [rowDataMap, setRowDataMap] = useState<Map<string, Record<string, string | number>[]>>(new Map());
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [activeTab, setActiveTab] = useState<string>(firstTabKey);
|
||||
const [reviewOpinionOpen, setReviewOpinionOpen] = useState(false);
|
||||
const [returnDialogOpen, setReturnDialogOpen] = useState(false);
|
||||
const [submitDialogOpen, setSubmitDialogOpen] = useState(false);
|
||||
const [lastSearchValues, setLastSearchValues] = useState<SearchFormValues | null>(null);
|
||||
/** 탭별 조회 응답의 statsStatusInfo — 활성 탭에 맞춰 버튼 노출 (SewagePipeInp의 tabStatusInfoMap과 동일 패턴) */
|
||||
const [tabStatsStatusInfoMap, setTabStatsStatusInfoMap] = useState<
|
||||
@@ -98,6 +145,17 @@ const SewagePipeRvw = () => {
|
||||
() => tabStatsStatusInfoMap.get(activeTab) ?? {},
|
||||
[tabStatsStatusInfoMap, activeTab],
|
||||
);
|
||||
const columnInfo = useMemo<ColumnInfoList[]>(
|
||||
() =>
|
||||
SewagePipeColumnInfoListRvw.map((tab) => ({
|
||||
...tab,
|
||||
columns: (tab.columns ?? []).map((col) => cloneColumnConfig(col)),
|
||||
columnLayout: (tab.columnLayout ?? []).map((item) =>
|
||||
cloneColumnLayoutItem(item),
|
||||
),
|
||||
})),
|
||||
[],
|
||||
);
|
||||
const reviewOpinionContext = useMemo<ReviewOpinionDialogContext | null>(() => {
|
||||
if (lastSearchValues == null) return null;
|
||||
return {
|
||||
@@ -108,6 +166,25 @@ const SewagePipeRvw = () => {
|
||||
}, [activeStatsStatusInfo.statsCd, lastSearchValues]);
|
||||
const latestReviewOpinion = activeStatsStatusInfo.splmntOpnnCn ?? "";
|
||||
const latestProcessHistory = activeStatsStatusInfo.wrterOpnnCn ?? "";
|
||||
const submitDialogContext = useMemo<ReviewerInfoRequest | null>(() => {
|
||||
if (lastSearchValues == null) return null;
|
||||
|
||||
const statsYr = lastSearchValues.year ?? "";
|
||||
const sewerBzmnCd = lastSearchValues.bsnmCd ?? "";
|
||||
const statsCd = activeStatsStatusInfo.statsCd ?? "";
|
||||
const instSeCd = userInfo?.instSeCd ?? "";
|
||||
|
||||
if (!statsYr || !sewerBzmnCd || !statsCd || !instSeCd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
statsYr,
|
||||
sewerBzmnCd,
|
||||
statsCd,
|
||||
instSeCd,
|
||||
};
|
||||
}, [activeStatsStatusInfo.statsCd, lastSearchValues, userInfo?.instSeCd]);
|
||||
|
||||
const { showReviewOpinionButton, showReturnButton, showSubmitButton } = useMemo(() => {
|
||||
const statsStatusInfo = activeStatsStatusInfo;
|
||||
@@ -135,6 +212,7 @@ const SewagePipeRvw = () => {
|
||||
setTabStatsStatusInfoMap(new Map());
|
||||
setReviewOpinionOpen(false);
|
||||
setReturnDialogOpen(false);
|
||||
setSubmitDialogOpen(false);
|
||||
setLastSearchValues(null);
|
||||
searchParamRef.current = null;
|
||||
searchDoneRef.current = false;
|
||||
@@ -235,37 +313,13 @@ const SewagePipeRvw = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const submitFunc = async () => {
|
||||
if (reviewOpinionContext == null) {
|
||||
const submitFunc = () => {
|
||||
if (submitDialogContext == null) {
|
||||
alert("조회 후 제출할 수 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await confirm("제출 하시겠습니까?"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const userInfo = await getUserInfo();
|
||||
const response = await statisticsApi.submitReview({
|
||||
statsYr: reviewOpinionContext.statsYr,
|
||||
sewerBzmnCd: reviewOpinionContext.sewerBzmnCd,
|
||||
statsCd: reviewOpinionContext.statsCd,
|
||||
mdfrId: userInfo.userUnqId,
|
||||
});
|
||||
|
||||
if (response.status !== "success") {
|
||||
alert(response.message || "제출에 실패했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
alert(response.message || "제출되었습니다.");
|
||||
if (lastSearchValues != null) {
|
||||
await handleSearch(lastSearchValues);
|
||||
}
|
||||
} catch {
|
||||
alert("제출 중 오류가 발생했습니다.");
|
||||
}
|
||||
setSubmitDialogOpen(true);
|
||||
};
|
||||
|
||||
const reviewOpinionFunc = async () => {
|
||||
@@ -344,7 +398,7 @@ const SewagePipeRvw = () => {
|
||||
)}
|
||||
{showReturnButton && <ReturnButton returnFunc={returnFunc} />}
|
||||
{showSubmitButton && (
|
||||
<SubmitButton submitFunc={submitFunc} />
|
||||
<SubmitButton submitFunc={() => submitFunc()} />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
@@ -365,13 +419,13 @@ const SewagePipeRvw = () => {
|
||||
variant="default"
|
||||
>
|
||||
<TabsList>
|
||||
{SewagePipeColumnInfoListRvw.map((info) => (
|
||||
{columnInfo.map((info) => (
|
||||
<TabsTrigger key={info.tabKey} value={info.tabKey}>
|
||||
{info.tabLabel || info.tabKey}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
{SewagePipeColumnInfoListRvw.map((info) => {
|
||||
{columnInfo.map((info) => {
|
||||
const tabKey = info.tabKey;
|
||||
if (!info.columns || !info.columnLayout) {
|
||||
return null;
|
||||
@@ -419,6 +473,16 @@ const SewagePipeRvw = () => {
|
||||
initialProcessHistory={latestProcessHistory}
|
||||
onSave={saveReviewOpinion}
|
||||
/>
|
||||
<ReviewSubmitDialog
|
||||
open={submitDialogOpen}
|
||||
onOpenChange={setSubmitDialogOpen}
|
||||
context={submitDialogContext}
|
||||
onSubmitted={async () => {
|
||||
if (lastSearchValues != null) {
|
||||
await handleSearch(lastSearchValues);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ReturnReasonDialog
|
||||
open={returnDialogOpen}
|
||||
onOpenChange={setReturnDialogOpen}
|
||||
|
||||
@@ -6,13 +6,15 @@ import ReturnButton from "@/components/button/ReturnButton";
|
||||
import SubmitButton from "@/components/button/SumitButton";
|
||||
import { LoadingWithAnimation } from "@common/components";
|
||||
import { ReturnReasonDialog } from "@/components/statistics/review/ReturnReasonDialog";
|
||||
import { ReviewSubmitDialog } from "@/components/statistics/review/ReviewSubmitDialog";
|
||||
|
||||
import { getUserInfo } from "../../../../../../packages/common/components/src/api";
|
||||
import { useAlertStore } from "@/shared/lib";
|
||||
import { useConfirm } from "@frontend-opensource/use-react-hooks";
|
||||
import { useAlertStore, useUserStore } from "@/shared/lib";
|
||||
import { SeweragePenetrationRateInfoList } from "@/components/util/column/review/SeweragePenetrationRateRvwColumn";
|
||||
import type { SewerageSupplyRateReviewItem, statsStatusInfo } from "@/entities/statistics/model/statistics-sewerage-penetration-review-interface";
|
||||
import type { ReviewOpinionSaveRequest } from "@/entities/statistics/model/statistics-interface";
|
||||
import type {
|
||||
ReviewOpinionSaveRequest,
|
||||
ReviewerInfoRequest,
|
||||
} from "@/entities/statistics/model/statistics-interface";
|
||||
import { statisticsApi } from "@/entities/statistics/api/statistics-service";
|
||||
import { statisticsManagementApi } from "@/entities/statistics/api/statistics-management-service";
|
||||
import type { SearchFormValues } from "@/components/type/SearchForm.type";
|
||||
@@ -25,17 +27,18 @@ import {
|
||||
// 하수도 통계 검토 01.하수도 보급률
|
||||
const SeweragePenetrationRateRvw = () => {
|
||||
const { setMessage: alert } = useAlertStore((state) => state);
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const [rowData, setRowData] = useState<Record<string, string | number>[]>([]);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [statsStatusInfo, setStatsStatusInfo] = useState<statsStatusInfo>({});
|
||||
const [reviewOpinionOpen, setReviewOpinionOpen] = useState(false);
|
||||
const [returnDialogOpen, setReturnDialogOpen] = useState(false);
|
||||
const [submitDialogOpen, setSubmitDialogOpen] = useState(false);
|
||||
const [reviewOpinionContext, setReviewOpinionContext] =
|
||||
useState<ReviewOpinionDialogContext | null>(null);
|
||||
const [latestReviewOpinion, setLatestReviewOpinion] = useState("");
|
||||
const [latestProcessHistory, setLatestProcessHistory] = useState("");
|
||||
const [lastSearchValues, setLastSearchValues] = useState<SearchFormValues | null>(null);
|
||||
const { confirm } = useConfirm();
|
||||
|
||||
const columnInfo = useMemo(() => {
|
||||
const { columns, columnLayout, fixedColumns, rowStartNum } = SeweragePenetrationRateInfoList;
|
||||
@@ -66,6 +69,24 @@ const SeweragePenetrationRateRvw = () => {
|
||||
const showActionBar =
|
||||
showReviewOpinionButton || showReturnButton || showSubmitButton;
|
||||
|
||||
const submitDialogContext = useMemo<ReviewerInfoRequest | null>(() => {
|
||||
if (reviewOpinionContext == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const instSeCd = userInfo?.instSeCd ?? "";
|
||||
if (!instSeCd) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
statsYr: reviewOpinionContext.statsYr,
|
||||
sewerBzmnCd: reviewOpinionContext.sewerBzmnCd,
|
||||
statsCd: reviewOpinionContext.statsCd,
|
||||
instSeCd,
|
||||
};
|
||||
}, [reviewOpinionContext, userInfo?.instSeCd]);
|
||||
|
||||
const handleReset = () => {
|
||||
setRowData([]);
|
||||
setStatsStatusInfo({});
|
||||
@@ -129,37 +150,13 @@ const SeweragePenetrationRateRvw = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const submitFunc = async () => {
|
||||
if (reviewOpinionContext == null) {
|
||||
const submitFunc = () => {
|
||||
if (submitDialogContext == null) {
|
||||
alert("조회 후 제출할 수 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(await confirm("제출 하시겠습니까?"))) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const userInfo = await getUserInfo();
|
||||
const response = await statisticsApi.submitReview({
|
||||
statsYr: reviewOpinionContext.statsYr,
|
||||
sewerBzmnCd: reviewOpinionContext.sewerBzmnCd,
|
||||
statsCd: reviewOpinionContext.statsCd,
|
||||
mdfrId: userInfo.userUnqId,
|
||||
});
|
||||
|
||||
if (response.status !== "success") {
|
||||
alert(response.message || "제출에 실패했습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
alert(response.message || "제출되었습니다.");
|
||||
if (lastSearchValues != null) {
|
||||
await handleSearch(lastSearchValues);
|
||||
}
|
||||
} catch {
|
||||
alert("제출 중 오류가 발생했습니다.");
|
||||
}
|
||||
setSubmitDialogOpen(true);
|
||||
};
|
||||
|
||||
const reviewOpinionFunc = async () => {
|
||||
@@ -258,6 +255,16 @@ const SeweragePenetrationRateRvw = () => {
|
||||
initialProcessHistory={latestProcessHistory}
|
||||
onSave={saveReviewOpinion}
|
||||
/>
|
||||
<ReviewSubmitDialog
|
||||
open={submitDialogOpen}
|
||||
onOpenChange={setSubmitDialogOpen}
|
||||
context={submitDialogContext}
|
||||
onSubmitted={async () => {
|
||||
if (lastSearchValues != null) {
|
||||
await handleSearch(lastSearchValues);
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<ReturnReasonDialog
|
||||
open={returnDialogOpen}
|
||||
onOpenChange={setReturnDialogOpen}
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createColumnHelper, getCoreRowModel, useReactTable } from "@tanstack/re
|
||||
import DataGrid from "@/components/module/DataGrid";
|
||||
import SearchForm from "@/components/module/SearchForm";
|
||||
import ApproveButton from "@/components/button/ApproveButton";
|
||||
import { doList } from "@/components/util/column/input/DoList";
|
||||
import {
|
||||
Button,
|
||||
Dialog,
|
||||
@@ -39,6 +40,8 @@ const StatsInputStatusRvw = () => {
|
||||
const [historyRowData, setHistoryRowData] = useState<ReviewHistoryRow[]>([]);
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [searchedYear, setSearchedYear] = useState<string>("");
|
||||
const [lastSearchedValues, setLastSearchedValues] = useState<SearchFormValues | null>(null);
|
||||
const [hasCompletedSearch, setHasCompletedSearch] = useState(false);
|
||||
const [reviewHistoryOpen, setReviewHistoryOpen] = useState<boolean>(false);
|
||||
const [historySearchInfo, setHistorySearchInfo] = useState<{
|
||||
ctpvNm: string;
|
||||
@@ -85,6 +88,8 @@ const StatsInputStatusRvw = () => {
|
||||
const handleReset = () => {
|
||||
setRowData([]);
|
||||
setSearchedYear("");
|
||||
setLastSearchedValues(null);
|
||||
setHasCompletedSearch(false);
|
||||
};
|
||||
|
||||
const handleSearch = async (values: SearchFormValues) => {
|
||||
@@ -96,6 +101,8 @@ const StatsInputStatusRvw = () => {
|
||||
try {
|
||||
setIsLoading(true);
|
||||
setSearchedYear(values.year ?? "");
|
||||
setLastSearchedValues(values);
|
||||
setHasCompletedSearch(false);
|
||||
|
||||
const response = await statisticsManagementApi.getStatsInputStatusList({
|
||||
ctpvNm: values.sido,
|
||||
@@ -115,11 +122,15 @@ const StatsInputStatusRvw = () => {
|
||||
setRowData(toGridRows(convertedData));
|
||||
} else {
|
||||
setRowData([]);
|
||||
setHasCompletedSearch(false);
|
||||
alert(response.message || "조회된 데이터가 없습니다.");
|
||||
return;
|
||||
}
|
||||
setHasCompletedSearch(true);
|
||||
} catch {
|
||||
alert('데이터 조회 중 오류가 발생했습니다.');
|
||||
setRowData([]);
|
||||
setHasCompletedSearch(false);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
@@ -127,6 +138,12 @@ const StatsInputStatusRvw = () => {
|
||||
|
||||
const approveFunc = () => console.log('approveFunc');
|
||||
|
||||
const gugunOkOrNotDoList = doList.includes(lastSearchedValues?.bsnmCd || "")
|
||||
? Boolean(lastSearchedValues?.gugun && lastSearchedValues.gugun !== "ALL")
|
||||
: true;
|
||||
const showActionToolbarCard =
|
||||
hasCompletedSearch && rowData.length > 0 && gugunOkOrNotDoList;
|
||||
|
||||
const handleRowClick = async (row: Record<string, string | number>) => {
|
||||
setHistorySearchInfo({
|
||||
ctpvNm: String(row.ctpvNm ?? ""),
|
||||
@@ -157,11 +174,13 @@ const StatsInputStatusRvw = () => {
|
||||
<div className="relative">
|
||||
<SearchForm onSubmit={handleSearch} onReset={handleReset} />
|
||||
|
||||
<div className="card !py-0">
|
||||
<div className="flex justify-end items-center gap-[0.6rem] m-[0.6rem]">
|
||||
<ApproveButton approveFunc={approveFunc} />
|
||||
{showActionToolbarCard && (
|
||||
<div className="card !py-0">
|
||||
<div className="flex justify-end items-center gap-[0.6rem] m-[0.6rem]">
|
||||
<ApproveButton approveFunc={approveFunc} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{isLoading && (
|
||||
<div className="absolute inset-0 z-50 [data-theme='black']:bg-transparent rounded-lg p-10 flex justify-center items-center">
|
||||
@@ -180,6 +199,43 @@ const StatsInputStatusRvw = () => {
|
||||
rowData={rowData}
|
||||
setRowData={setRowData}
|
||||
onRowClick={handleRowClick}
|
||||
cellStyleCallback={({ row, fieldName }) => {
|
||||
if (fieldName === "submitStatusNm") {
|
||||
const statusCd = String(row.submitStatusCd ?? "");
|
||||
|
||||
if (statusCd === "0" || statusCd === "1") {
|
||||
return "rg-cell-stats-status-pending";
|
||||
}
|
||||
if (statusCd === "2") {
|
||||
return "rg-cell-stats-status-submitted";
|
||||
}
|
||||
if (statusCd === "3") {
|
||||
return "rg-cell-stats-status-approved";
|
||||
}
|
||||
if (statusCd === "4") {
|
||||
return "rg-cell-stats-status-rejected";
|
||||
}
|
||||
return undefined;
|
||||
} else if (fieldName === "prvnStatusNm") {
|
||||
const statusCd = String(row.prvnStatusCd ?? "");
|
||||
|
||||
if (statusCd === "0" || statusCd === "1") {
|
||||
return "rg-cell-stats-status-pending";
|
||||
}
|
||||
if (statusCd === "2") {
|
||||
return "rg-cell-stats-status-submitted";
|
||||
}
|
||||
if (statusCd === "3") {
|
||||
return "rg-cell-stats-status-approved";
|
||||
}
|
||||
if (statusCd === "4") {
|
||||
return "rg-cell-stats-status-rejected";
|
||||
}
|
||||
return undefined;
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<Dialog open={reviewHistoryOpen} onOpenChange={setReviewHistoryOpen}>
|
||||
<DialogContent
|
||||
|
||||
Reference in New Issue
Block a user