Merge branch 'iipbs/st/dev' of https://www.onasys.co.kr:3000/ONAANDALL/frontend into iipbs/st/dev
This commit is contained in:
@@ -1,9 +1,96 @@
|
||||
const Dashboard = () => {
|
||||
return (
|
||||
<div>
|
||||
Dashboard
|
||||
</div>
|
||||
);
|
||||
};
|
||||
"use client";
|
||||
|
||||
export default Dashboard;
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
import { closestCenter, DndContext } from "@dnd-kit/core";
|
||||
import { rectSortingStrategy, SortableContext } from "@dnd-kit/sortable";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
import { useUserStore } from "@/shared/lib";
|
||||
import { Skeleton } from "@common/components";
|
||||
|
||||
import { useDndSensors } from "@/pages/statistics/lib/hooks/use-dnd-sensors";
|
||||
import { usePanelOrder } from "@/pages/statistics/lib/hooks/use-panel-order";
|
||||
import { getInitialPanels } from "@/pages/statistics/model/panel-config";
|
||||
import { SortablePanel } from "@/pages/statistics/ui/sortable-panel";
|
||||
|
||||
interface PanelItem {
|
||||
id: string;
|
||||
component: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
function Dashboard() {
|
||||
const userInfo = useUserStore((state) => state.userInfo);
|
||||
const [initialPanels, setInitialPanels] = useState<PanelItem[]>([]);
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
const sensors = useDndSensors();
|
||||
|
||||
const { panels, handleDragEnd } = usePanelOrder({
|
||||
initialPanels,
|
||||
storageKey: "statistics-dashboard-panels-order",
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
setIsMounted(true);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!userInfo) return;
|
||||
const initialPanels = getInitialPanels({
|
||||
dashboardParams: {
|
||||
statsYr: String(dayjs().year() - 1),
|
||||
dtlInstCd: userInfo.dtlInstCd,
|
||||
enoCd: userInfo.enoCd,
|
||||
laeSeCd: userInfo.laeSeCd,
|
||||
},
|
||||
scheduleInfoParams: {
|
||||
statsYr: String(dayjs().year() - 1),
|
||||
},
|
||||
});
|
||||
setInitialPanels(initialPanels);
|
||||
}, [userInfo]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{isMounted && initialPanels.length > 0 ? (
|
||||
<DndContext
|
||||
sensors={sensors}
|
||||
collisionDetection={closestCenter}
|
||||
onDragEnd={handleDragEnd}
|
||||
>
|
||||
<SortableContext
|
||||
items={panels.map((p) => p.id)}
|
||||
strategy={rectSortingStrategy}
|
||||
>
|
||||
{/* TBD: 그리드 레이아웃 비율 정의 필요
|
||||
현재: 3열 그리드, 반응형 브레이크포인트 적용
|
||||
SPEC 레이아웃에 따라 조정 필요 */}
|
||||
<div className="grid grid-cols-1 gap-4 p-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
{panels.map((panel) => (
|
||||
<SortablePanel
|
||||
key={panel.id}
|
||||
id={panel.id}
|
||||
className={panel.className}
|
||||
>
|
||||
{panel.component}
|
||||
</SortablePanel>
|
||||
))}
|
||||
</div>
|
||||
</SortableContext>
|
||||
</DndContext>
|
||||
) : (
|
||||
<div className="grid grid-cols-1 gap-4 p-2 md:grid-cols-2 lg:grid-cols-3">
|
||||
<Skeleton className="h-[20rem] rounded-xl" />
|
||||
<Skeleton className="h-[20rem] rounded-xl" />
|
||||
<Skeleton className="h-[20rem] rounded-xl" />
|
||||
<Skeleton className="h-[20rem] rounded-xl" />
|
||||
<Skeleton className="h-[20rem] rounded-xl" />
|
||||
<Skeleton className="h-[20rem] rounded-xl" />
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Dashboard;
|
||||
|
||||
@@ -129,6 +129,7 @@ const DEFAULT_FILTERS: StatisticsVerificationFilterState = {
|
||||
statsYr: String(dayjs().year() - 1),
|
||||
sewerBzmnCd: null,
|
||||
statsCd: null,
|
||||
laeSbmsnSttsCd: "2",
|
||||
};
|
||||
|
||||
const DEFAULT_SUB_FILTERS: StatisticsVerificationSubFilterState = {
|
||||
@@ -156,15 +157,6 @@ function StatisticsVerificationReport() {
|
||||
useState<StatisticsVerificationFilterState>(DEFAULT_FILTERS);
|
||||
const [subFilters, setSubFilters] =
|
||||
useState<StatisticsVerificationSubFilterState>(DEFAULT_SUB_FILTERS);
|
||||
const [submittedFilters, setSubmittedFilters] =
|
||||
useState<StatisticsVerificationFilterState>(DEFAULT_FILTERS);
|
||||
const [submittedParams, setSubmittedParams] = useState<{
|
||||
main: StatisticsVerificationFilterState;
|
||||
sub: StatisticsVerificationSubFilterState;
|
||||
}>({
|
||||
main: DEFAULT_FILTERS,
|
||||
sub: DEFAULT_SUB_FILTERS,
|
||||
});
|
||||
const [selectedReportRows, setSelectedReportRows] = useState<
|
||||
StatsInputStatusList[]
|
||||
>([]);
|
||||
@@ -182,11 +174,30 @@ function StatisticsVerificationReport() {
|
||||
const { data: sigunguData } = useStAnlsSigunguCombo(
|
||||
filters.sewerBzmnCd ?? "",
|
||||
);
|
||||
const detailParams = useMemo(
|
||||
() => ({
|
||||
statsYr: filters.statsYr,
|
||||
ctpvNm:
|
||||
subFilters.ctpvNm !== "" ? subFilters.ctpvNm : filters.ctpvNm,
|
||||
sggNm: subFilters.sggNm !== "" ? subFilters.sggNm : filters.sggNm,
|
||||
sewerBzmnCd:
|
||||
subFilters.sewerBzmnCd !== ""
|
||||
? subFilters.sewerBzmnCd
|
||||
: filters.sewerBzmnCd,
|
||||
statsCd:
|
||||
subFilters.statsCd !== ""
|
||||
? subFilters.statsCd
|
||||
: filters.statsCd,
|
||||
prcsYnList: subFilters.prcsYnList,
|
||||
pbcpAprvYn: subFilters.pbcpAprvYn,
|
||||
laeSbmsnSttsCd: subFilters.laeSbmsnSttsCd,
|
||||
}),
|
||||
[filters, subFilters],
|
||||
);
|
||||
|
||||
const statisticsVerificationReportQuery =
|
||||
useStatsVrfcRptData(submittedFilters);
|
||||
const statisticsVerificationReportQuery = useStatsVrfcRptData(filters);
|
||||
const statisticsVerificationResultQuery =
|
||||
useStatsVrfcRsltData(submittedParams);
|
||||
useStatsVrfcRsltData(detailParams);
|
||||
|
||||
const statisticsVerificationReportData =
|
||||
statisticsVerificationReportQuery.data ?? [];
|
||||
@@ -253,11 +264,17 @@ function StatisticsVerificationReport() {
|
||||
const nextRows = statisticsVerificationResultGridRows;
|
||||
const prevLength = prevLengthRef.current;
|
||||
|
||||
if (!dataProvider || nextRows.length === 0) {
|
||||
if (!dataProvider) {
|
||||
prevLengthRef.current = nextRows.length;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nextRows.length === 0) {
|
||||
dataProvider.setRows?.([]);
|
||||
prevLengthRef.current = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (nextRows.length > prevLength && prevLength > 0) {
|
||||
// 무한스크롤 시 데이터 처리
|
||||
const newRows = nextRows.slice(prevLength);
|
||||
@@ -327,17 +344,16 @@ function StatisticsVerificationReport() {
|
||||
statisticsVerificationReportQuery.isError,
|
||||
]);
|
||||
|
||||
function handleSearch(
|
||||
nextFilters: StatisticsVerificationFilterState,
|
||||
nextSubFilters: StatisticsVerificationSubFilterState,
|
||||
) {
|
||||
setSelectedReportRows([]);
|
||||
function resetResultState() {
|
||||
setSelectedResultRows([]);
|
||||
setSubmittedFilters({ ...nextFilters });
|
||||
setSubmittedParams({
|
||||
main: { ...nextFilters },
|
||||
sub: { ...nextSubFilters },
|
||||
});
|
||||
editedResultRowMapRef.current = new Map();
|
||||
prevLengthRef.current = 0;
|
||||
resultGridRef.current?.dataProvider?.setRows?.([]);
|
||||
}
|
||||
|
||||
function resetReportState() {
|
||||
setSelectedReportRows([]);
|
||||
resetResultState();
|
||||
}
|
||||
|
||||
async function handleLoadMoreDetail() {
|
||||
@@ -350,14 +366,6 @@ function StatisticsVerificationReport() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleResultSearch() {
|
||||
setSelectedResultRows([]);
|
||||
setSubmittedParams({
|
||||
main: { ...filters },
|
||||
sub: { ...subFilters },
|
||||
});
|
||||
}
|
||||
|
||||
function handleFilterChange<
|
||||
K extends keyof StatisticsVerificationFilterState,
|
||||
>(key: K) {
|
||||
@@ -365,6 +373,7 @@ function StatisticsVerificationReport() {
|
||||
value?: StatisticsVerificationFilterState[K],
|
||||
optionData?: { label: string; value: string },
|
||||
) => {
|
||||
resetReportState();
|
||||
if (key === "sewerBzmnCd") {
|
||||
setFilters((prev) => ({
|
||||
...prev,
|
||||
@@ -372,8 +381,17 @@ function StatisticsVerificationReport() {
|
||||
sewerBzmnCd: optionData?.value,
|
||||
sggNm: "",
|
||||
}));
|
||||
setSubFilters((prev) => ({
|
||||
...prev,
|
||||
ctpvNm: "",
|
||||
sggNm: "",
|
||||
sewerBzmnCd: "",
|
||||
}));
|
||||
return;
|
||||
}
|
||||
if (key === "statsCd") {
|
||||
setSubFilters((prev) => ({ ...prev, statsCd: "" }));
|
||||
}
|
||||
setFilters((prev) => ({ ...prev, [key]: value }));
|
||||
};
|
||||
}
|
||||
@@ -382,10 +400,16 @@ function StatisticsVerificationReport() {
|
||||
K extends keyof StatisticsVerificationSubFilterState,
|
||||
>(key: K) {
|
||||
return (value?: StatisticsVerificationSubFilterState[K]) => {
|
||||
resetResultState();
|
||||
setSubFilters((prev) => ({ ...prev, [key]: value }));
|
||||
};
|
||||
}
|
||||
|
||||
function handleSubFilterReset() {
|
||||
setSubFilters(DEFAULT_SUB_FILTERS);
|
||||
resetResultState();
|
||||
}
|
||||
|
||||
function handleCellEdited(params: CellEditedCallbackParams) {
|
||||
const { itemIndex, fieldName, newValue } = params;
|
||||
const dataProvider = resultGridRef.current?.dataProvider as
|
||||
@@ -403,11 +427,7 @@ function StatisticsVerificationReport() {
|
||||
function handleReset() {
|
||||
setFilters(DEFAULT_FILTERS);
|
||||
setSubFilters(DEFAULT_SUB_FILTERS);
|
||||
setSelectedReportRows([]);
|
||||
setSelectedResultRows([]);
|
||||
editedResultRowMapRef.current = new Map();
|
||||
prevLengthRef.current = 0;
|
||||
handleSearch(DEFAULT_FILTERS, DEFAULT_SUB_FILTERS);
|
||||
resetReportState();
|
||||
}
|
||||
|
||||
function handleApprove() {
|
||||
@@ -532,9 +552,6 @@ function StatisticsVerificationReport() {
|
||||
<Button color="white" onClick={handleReset}>
|
||||
초기화
|
||||
</Button>
|
||||
<Button onClick={() => handleSearch(filters, subFilters)}>
|
||||
조회
|
||||
</Button>
|
||||
<Button
|
||||
color="green"
|
||||
onClick={handleApprove}
|
||||
@@ -557,6 +574,15 @@ function StatisticsVerificationReport() {
|
||||
setRowData={() => {}}
|
||||
showHeaderCheckbox={true}
|
||||
gridHeight={30}
|
||||
onRowClick={(row: StatsInputStatusList) => {
|
||||
setSubFilters((prev) => ({
|
||||
...prev,
|
||||
ctpvNm: row?.ctpvNm ?? "",
|
||||
sggNm: row?.sggNm ?? "",
|
||||
sewerBzmnCd: row?.sewerBzmnCd ?? "",
|
||||
statsCd: row?.statsCd ?? "",
|
||||
}));
|
||||
}}
|
||||
/>
|
||||
|
||||
<h3 className="mt-10 px-2 text-[1.8rem] font-bold text-title">
|
||||
@@ -578,14 +604,15 @@ function StatisticsVerificationReport() {
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-end justify-end gap-2">
|
||||
<Button onClick={handleResultSearch}>조회</Button>
|
||||
<Button color="white" onClick={handleSubFilterReset}>
|
||||
초기화
|
||||
</Button>
|
||||
<Button
|
||||
color="red"
|
||||
onClick={handleReject}
|
||||
disabled={
|
||||
selectedResultRows.length === 0
|
||||
// ||
|
||||
// selectedResultRows.some((row) => row.prcsYn !== "2")
|
||||
selectedResultRows.length === 0 ||
|
||||
selectedResultRows.some((row) => row.prcsYn !== "2")
|
||||
}
|
||||
>
|
||||
반려
|
||||
|
||||
@@ -65,21 +65,15 @@ const Indicators: React.FC<IndicatorsProps> = ({ anlsSn, vrfcTrgtSn }) => {
|
||||
|
||||
return (
|
||||
<div className="card card-border !m-0 grid min-h-[10rem] grid-cols-4 gap-2">
|
||||
<IndicatorItem label="r 중위수" value={dtl?.rtCnterVl} />
|
||||
<IndicatorItem label="R 중위수" value={dtl?.rtCnterVl} />
|
||||
<IndicatorItem label="E 중위수" value={dtl?.lastTrsfScrCnterVl} />
|
||||
<IndicatorItem label="하위 기준값" value={dtl?.lastTrsfScrLlmtVl} />
|
||||
<IndicatorItem
|
||||
label="(E_m)E 중위수"
|
||||
value={dtl?.lastTrsfScrCnterVl}
|
||||
/>
|
||||
<IndicatorItem
|
||||
label="(E_l)E 하한값"
|
||||
value={dtl?.lastTrsfScrLlmtVl}
|
||||
/>
|
||||
<IndicatorItem
|
||||
label="(E_u)E 상한값"
|
||||
label="상위 기준값"
|
||||
value={dtl?.lastTrsfScrUplmtVl}
|
||||
/>
|
||||
<IndicatorItem label="E_D_L" value={dtl?.llmtVl} />
|
||||
<IndicatorItem label="E_D_U" value={dtl?.uplmtVl} />
|
||||
<IndicatorItem label="이상치 하한값" value={dtl?.llmtVl} />
|
||||
<IndicatorItem label="이상치 상한값" value={dtl?.uplmtVl} />
|
||||
<IndicatorItem label="이상치 하한선" value={dtl?.otlrLlmtLine} />
|
||||
<IndicatorItem label="이상치 상한선" value={dtl?.otlrUplmtLine} />
|
||||
</div>
|
||||
|
||||
@@ -46,11 +46,6 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
selectedRowId,
|
||||
appliedFilter,
|
||||
}) => {
|
||||
const [selectedSido, setSelectedSido] = useState<string>("");
|
||||
const [selectedGugun, setSelectedGugun] = useState<string>("");
|
||||
const [selectedStatus, setSelectedStatus] = useState<string>("");
|
||||
const [showAllOnEmptyFilter, setShowAllOnEmptyFilter] =
|
||||
useState<boolean>(true);
|
||||
const [isDownloading, setIsDownloading] = useState<boolean>(false);
|
||||
|
||||
const [gridRowData, setGridRowData] = useState<
|
||||
@@ -58,7 +53,7 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
>([]);
|
||||
|
||||
const { data: sidoData } = useStAnlsSidoCombo();
|
||||
const { data: gugunData } = useStAnlsSigunguCombo(selectedSido);
|
||||
const { data: gugunData } = useStAnlsSigunguCombo(appliedFilter.sido ?? "");
|
||||
const sidoOptions = sidoData ?? EMPTY_ADST_LIST;
|
||||
const gugunOptions = gugunData ?? EMPTY_ADST_LIST;
|
||||
|
||||
@@ -69,14 +64,7 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
|
||||
const rowData = useMemo(() => {
|
||||
let data = (resultData?.content ?? []) as StAnlsRsltResponse[];
|
||||
|
||||
if (
|
||||
!appliedFilter.sido &&
|
||||
!appliedFilter.gugun &&
|
||||
!appliedFilter.status
|
||||
) {
|
||||
data = showAllOnEmptyFilter ? data : [];
|
||||
} else {
|
||||
{
|
||||
const sidoCd = appliedFilter.sido;
|
||||
if (sidoCd) {
|
||||
data = data.filter((item) =>
|
||||
@@ -116,32 +104,18 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
}));
|
||||
|
||||
return mappedData;
|
||||
}, [resultData, appliedFilter, showAllOnEmptyFilter]);
|
||||
}, [resultData, appliedFilter]);
|
||||
|
||||
const handleSidoChange = (val: string) => {
|
||||
setSelectedSido(val);
|
||||
setSelectedGugun("");
|
||||
};
|
||||
|
||||
const handleSearch = () => {
|
||||
onFilterChange({
|
||||
sido: selectedSido,
|
||||
gugun: selectedGugun,
|
||||
status: selectedStatus,
|
||||
});
|
||||
setShowAllOnEmptyFilter(false);
|
||||
onFilterChange({ ...appliedFilter, sido: val, gugun: "" });
|
||||
};
|
||||
|
||||
const handleReset = () => {
|
||||
setSelectedSido("");
|
||||
setSelectedGugun("");
|
||||
setSelectedStatus("");
|
||||
onFilterChange({
|
||||
sido: "",
|
||||
gugun: "",
|
||||
status: "",
|
||||
});
|
||||
setShowAllOnEmptyFilter(true);
|
||||
};
|
||||
|
||||
const handleDownload = async () => {
|
||||
@@ -182,7 +156,7 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
<div className="flex justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Select
|
||||
value={selectedSido || ""}
|
||||
value={appliedFilter.sido || ""}
|
||||
onValueChange={handleSidoChange}
|
||||
>
|
||||
<SelectTrigger className="w-[12rem] bg-white">
|
||||
@@ -197,9 +171,11 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select
|
||||
value={selectedGugun}
|
||||
onValueChange={setSelectedGugun}
|
||||
disabled={!selectedSido}
|
||||
value={appliedFilter.gugun || ""}
|
||||
onValueChange={(val) =>
|
||||
onFilterChange({ ...appliedFilter, gugun: val })
|
||||
}
|
||||
disabled={!appliedFilter.sido}
|
||||
>
|
||||
<SelectTrigger className="w-[12rem] bg-white">
|
||||
<SelectValue placeholder="시군구 선택" />
|
||||
@@ -213,8 +189,10 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select
|
||||
value={selectedStatus}
|
||||
onValueChange={setSelectedStatus}
|
||||
value={appliedFilter.status || ""}
|
||||
onValueChange={(val) =>
|
||||
onFilterChange({ ...appliedFilter, status: val })
|
||||
}
|
||||
>
|
||||
<SelectTrigger className="w-[10rem] bg-white">
|
||||
<SelectValue placeholder="상태 선택" />
|
||||
@@ -231,7 +209,7 @@ const RegionalGrid: React.FC<RegionalGridProps> = ({
|
||||
<Button color="white" onClick={handleReset}>
|
||||
초기화
|
||||
</Button>
|
||||
<Button onClick={handleSearch}>조회</Button>
|
||||
{/* <Button onClick={handleSearch}>조회</Button> */}
|
||||
<Button
|
||||
color="green"
|
||||
onClick={handleDownload}
|
||||
|
||||
@@ -104,10 +104,12 @@ const ScatterChart: React.FC<ScatterChartProps> = ({
|
||||
anlsSn,
|
||||
vrfcTrgtSn,
|
||||
);
|
||||
console.log("resultData: ", resultData);
|
||||
const { data: chartData, isLoading: isLoadingChart } = useStAnlsChartData(
|
||||
anlsSn,
|
||||
vrfcTrgtSn,
|
||||
);
|
||||
console.log("chartData: ", chartData);
|
||||
|
||||
const isLoading = isLoadingGrid || isLoadingChart;
|
||||
|
||||
@@ -158,10 +160,12 @@ const ScatterChart: React.FC<ScatterChartProps> = ({
|
||||
item,
|
||||
};
|
||||
|
||||
if (item.otlrYnCd === "0") {
|
||||
normalPoints.push(pt);
|
||||
} else {
|
||||
if (item.otlrYnCd === "2") {
|
||||
return;
|
||||
} else if (item.otlrYnCd === "1") {
|
||||
outlierPoints.push(pt);
|
||||
} else {
|
||||
normalPoints.push(pt);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user