feat(ui): 统一面板空状态引导
This commit is contained in:
@@ -23,6 +23,7 @@ import { bbox, featureCollection } from "@turf/turf";
|
||||
import { useMap } from "@components/olmap/core/MapComponent";
|
||||
import { queryFeaturesByIds } from "@/utils/mapQueryService";
|
||||
import { BurstDetectionResult, BurstDetectionRow } from "./types";
|
||||
import PanelEmptyState from "@components/olmap/common/PanelEmptyState";
|
||||
|
||||
export interface BurstDetectionResultsState {
|
||||
selectedDay: number | null;
|
||||
@@ -73,17 +74,11 @@ const formatDateTime = (value?: string) =>
|
||||
value ? dayjs(value).format("YYYY-MM-DD HH:mm") : "-";
|
||||
|
||||
const EmptyState = () => (
|
||||
<Box className="flex h-full flex-col items-center justify-center bg-gray-50/50 p-6 text-center">
|
||||
<Box className="mb-4 rounded-full bg-white p-6 shadow-sm">
|
||||
<ShowChartIcon sx={{ fontSize: 48, color: "#cbd5e1" }} />
|
||||
</Box>
|
||||
<Typography variant="h6" className="mb-1 font-bold text-gray-700">
|
||||
等待侦测结果
|
||||
</Typography>
|
||||
<Typography variant="body2" className="max-w-xs text-gray-500">
|
||||
提交侦测后,这里会展示目标时刻状态、前 14 天参考分数和异常测点。
|
||||
</Typography>
|
||||
</Box>
|
||||
<PanelEmptyState
|
||||
icon={<ShowChartIcon />}
|
||||
title="尚未生成侦测结果"
|
||||
description="请在“侦测参数”中运行分析,或在“方案查询”中打开历史结果。"
|
||||
/>
|
||||
);
|
||||
|
||||
const DetectionResults: React.FC<Props> = ({ result, state, onStateChange }) => {
|
||||
|
||||
@@ -24,6 +24,7 @@ import { useNotification } from "@refinedev/core";
|
||||
import { api } from "@/lib/api";
|
||||
import { NETWORK_NAME } from "@config/config";
|
||||
import { useControllableObjectState } from "@components/olmap/core/useControllableState";
|
||||
import { SchemeQueryEmptyState } from "@components/olmap/common/PanelEmptyState";
|
||||
import {
|
||||
BurstDetectionResult,
|
||||
BurstDetectionSchemeDetail,
|
||||
@@ -42,6 +43,7 @@ export interface BurstDetectionSchemeQueryState {
|
||||
queryAll: boolean;
|
||||
queryDate: Dayjs | null;
|
||||
expandedId: number | null;
|
||||
hasQueried: boolean;
|
||||
}
|
||||
|
||||
export const createBurstDetectionSchemeQueryState =
|
||||
@@ -49,6 +51,7 @@ export const createBurstDetectionSchemeQueryState =
|
||||
queryAll: true,
|
||||
queryDate: dayjs(),
|
||||
expandedId: null,
|
||||
hasQueried: false,
|
||||
});
|
||||
|
||||
const SchemeQuery: React.FC<Props> = ({
|
||||
@@ -64,7 +67,7 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
onStateChange,
|
||||
createBurstDetectionSchemeQueryState(),
|
||||
);
|
||||
const { queryAll, queryDate, expandedId } = queryState;
|
||||
const { queryAll, queryDate, expandedId, hasQueried } = queryState;
|
||||
const [internalSchemes, setInternalSchemes] = useState<BurstDetectionSchemeRecord[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const schemes = externalSchemes !== undefined ? externalSchemes : internalSchemes;
|
||||
@@ -138,6 +141,7 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
const response = await api.get("/api/v1/schemes", { params });
|
||||
const nextSchemes = response.data as BurstDetectionSchemeRecord[];
|
||||
setSchemes(nextSchemes);
|
||||
setQueryField("hasQueried", true);
|
||||
open?.({
|
||||
type: "success",
|
||||
message: "查询成功",
|
||||
@@ -203,7 +207,10 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
<Checkbox
|
||||
size="small"
|
||||
checked={queryAll}
|
||||
onChange={(event) => setQueryField("queryAll", event.target.checked)}
|
||||
onChange={(event) => {
|
||||
setQueryField("queryAll", event.target.checked);
|
||||
setQueryField("hasQueried", false);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
label={<Typography variant="body2">查询全部</Typography>}
|
||||
@@ -212,7 +219,10 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
<LocalizationProvider dateAdapter={AdapterDayjs} adapterLocale="zh-cn">
|
||||
<DatePicker
|
||||
value={queryDate}
|
||||
onChange={(value) => setQueryField("queryDate", value)}
|
||||
onChange={(value) => {
|
||||
setQueryField("queryDate", value);
|
||||
setQueryField("hasQueried", false);
|
||||
}}
|
||||
disabled={queryAll}
|
||||
format="YYYY-MM-DD"
|
||||
slotProps={{ textField: { size: "small", sx: { width: 180 } } }}
|
||||
@@ -234,12 +244,7 @@ const SchemeQuery: React.FC<Props> = ({
|
||||
|
||||
<Box className="flex-1 overflow-auto">
|
||||
{sortedSchemes.length === 0 ? (
|
||||
<Box className="flex h-full flex-col items-center justify-center text-center text-gray-400">
|
||||
<Typography variant="body2">暂无侦测方案</Typography>
|
||||
<Typography variant="caption" className="mt-1">
|
||||
运行一次展示版侦测后,可在这里回看历史结果。
|
||||
</Typography>
|
||||
</Box>
|
||||
<SchemeQueryEmptyState hasQueried={hasQueried} />
|
||||
) : (
|
||||
<Box className="space-y-2 p-2">
|
||||
<Typography variant="caption" className="px-2 text-gray-500">
|
||||
|
||||
Reference in New Issue
Block a user