fix(analysis): 统一方案名与接口错误提示
This commit is contained in:
@@ -30,9 +30,17 @@ import { api } from "@/lib/api";
|
||||
import { config, NETWORK_NAME } from "@/config/config";
|
||||
import { useControllableObjectState } from "@components/olmap/core/useControllableState";
|
||||
import { useSessionRecoveryDraft } from "@/lib/sessionRecoveryDraft";
|
||||
import { getApiErrorMessage } from "@/lib/apiError";
|
||||
import { along, lineString, length, toMercator } from "@turf/turf";
|
||||
import { Point } from "ol/geom";
|
||||
import { toLonLat } from "ol/proj";
|
||||
import {
|
||||
createSchemeName,
|
||||
isSchemeNameValid,
|
||||
normalizeSchemeName,
|
||||
SCHEME_NAME_MAX_LENGTH,
|
||||
SCHEME_NAME_PREFIXES,
|
||||
} from "@utils/schemeName";
|
||||
|
||||
export interface PipePoint {
|
||||
id: string;
|
||||
@@ -52,7 +60,7 @@ export const createBurstAnalysisParametersState = (): BurstAnalysisParametersSta
|
||||
pipePoints: [],
|
||||
startTime: dayjs(new Date()),
|
||||
duration: 3600,
|
||||
schemeName: "FANGAN" + new Date().getTime(),
|
||||
schemeName: createSchemeName(SCHEME_NAME_PREFIXES.burstAnalysis),
|
||||
network: NETWORK_NAME,
|
||||
});
|
||||
|
||||
@@ -104,7 +112,7 @@ const AnalysisParameters: React.FC<AnalysisParametersProps> = ({
|
||||
pipePoints.length > 0 &&
|
||||
startTime !== null &&
|
||||
duration > 0 &&
|
||||
schemeName.trim() !== "";
|
||||
isSchemeNameValid(schemeName);
|
||||
|
||||
// 地图点击选择要素事件处理函数
|
||||
const handleMapClickSelectFeatures = useCallback(
|
||||
@@ -333,7 +341,7 @@ const AnalysisParameters: React.FC<AnalysisParametersProps> = ({
|
||||
burst_id: burst_ID,
|
||||
burst_size: burst_size,
|
||||
modify_total_duration: modify_total_duration,
|
||||
scheme_name: schemeName,
|
||||
scheme_name: normalizeSchemeName(schemeName),
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -358,8 +366,7 @@ const AnalysisParameters: React.FC<AnalysisParametersProps> = ({
|
||||
key: "burst-analysis",
|
||||
type: "error",
|
||||
message: "提交分析失败",
|
||||
description:
|
||||
error instanceof Error ? error.message : "请检查网络连接或稍后重试",
|
||||
description: getApiErrorMessage(error, "爆管模拟请求失败"),
|
||||
});
|
||||
} finally {
|
||||
setAnalyzing(false);
|
||||
@@ -525,6 +532,13 @@ const AnalysisParameters: React.FC<AnalysisParametersProps> = ({
|
||||
value={schemeName}
|
||||
onChange={(e) => setParameterField("schemeName", e.target.value)}
|
||||
placeholder="输入方案名称"
|
||||
error={schemeName.trim().length > SCHEME_NAME_MAX_LENGTH}
|
||||
helperText={
|
||||
schemeName.trim().length > SCHEME_NAME_MAX_LENGTH
|
||||
? `方案名称不能超过 ${SCHEME_NAME_MAX_LENGTH} 个字符`
|
||||
: undefined
|
||||
}
|
||||
inputProps={{ maxLength: SCHEME_NAME_MAX_LENGTH }}
|
||||
/>
|
||||
</Box>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user