fix(map): 修复接口返回数据空值处理,防止异常崩溃

- 所有异步接口获取的数据添加空值判断或默认空数组/空对象处理
- 修正部分状态赋值,避免因数据缺失导致报错
- 调整地图分公司信息逻辑,防止空值访问异常
- 统一视频播放地址获取时的空值赋默认值
- 优化部分组件初始化时对接口数据的安全调用代码
master
LiuJiaNan 2026-08-13 14:53:57 +08:00
parent 85885a7d8f
commit b9ad0d8d44
46 changed files with 118 additions and 94 deletions

View File

@ -17,8 +17,9 @@ function VideoPatrolPanel(props) {
const { data, success } = await props.getFixedCameraPlayUrl({ const { data, success } = await props.getFixedCameraPlayUrl({
indexCode: cameraNumber, indexCode: cameraNumber,
}); });
if (success && data) const videoUrl = data || "";
setPlayUrl(data || ""); if (success)
setPlayUrl(videoUrl);
}; };
const selectCorp = (item) => { const selectCorp = (item) => {
setActive(item.corpinfoName); setActive(item.corpinfoName);
@ -36,9 +37,10 @@ function VideoPatrolPanel(props) {
useEffect(() => { useEffect(() => {
const loadVideoList = async () => { const loadVideoList = async () => {
const { data } = await props.getFixedCameraVideoList(); const { data } = await props.getFixedCameraVideoList();
setList(data || []); const videoList = data || [];
if (data?.length) { setList(videoList);
selectCorp(data[0]); if (videoList.length) {
selectCorp(videoList[0]);
} }
}; };

View File

@ -18,10 +18,11 @@ function WeatherPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { result = {} } = await props.getWeather(); const { result } = await props.getWeather();
const weatherResult = result || {};
setWeather({ setWeather({
...result.now, ...weatherResult.now,
alertTitle: result.alerts?.[0]?.title || "当前暂无气象预警", alertTitle: weatherResult.alerts?.[0]?.title || "当前暂无气象预警",
}); });
const { data } = await props.getEventReportListUnfinished({ const { data } = await props.getEventReportListUnfinished({

View File

@ -33,18 +33,20 @@ function WorkPanel(props) {
props.getEightWorkInfoDangerWorkStatistics(), props.getEightWorkInfoDangerWorkStatistics(),
props.getKeyProjectLargeScreenStatistics(), props.getKeyProjectLargeScreenStatistics(),
]); ]);
const eightWorkStatistics = eightWorkData || {};
const keyProjectStatistics = keyProjectData || {};
setData((prevState) => { setData((prevState) => {
prevState[1].doingCount = eightWorkData?.doingCount; prevState[1].doingCount = eightWorkStatistics.doingCount;
prevState[1].appliedCount = eightWorkData?.appliedCount; prevState[1].appliedCount = eightWorkStatistics.appliedCount;
prevState[0].doingCount = keyProjectData?.morePeopleStartCount; prevState[0].doingCount = keyProjectStatistics.morePeopleStartCount;
prevState[0].appliedCount = keyProjectData?.morePeopleApplyCount; prevState[0].appliedCount = keyProjectStatistics.morePeopleApplyCount;
prevState[2].doingCount = keyProjectData?.fourNewHomeworkStartCount; prevState[2].doingCount = keyProjectStatistics.fourNewHomeworkStartCount;
prevState[2].appliedCount = keyProjectData?.fourNewHomeworkApplyCount; prevState[2].appliedCount = keyProjectStatistics.fourNewHomeworkApplyCount;
prevState[3].doingCount = keyProjectData?.nightWorkStartCount; prevState[3].doingCount = keyProjectStatistics.nightWorkStartCount;
prevState[3].appliedCount = keyProjectData?.nightWorkApplyCount; prevState[3].appliedCount = keyProjectStatistics.nightWorkApplyCount;
return [...prevState]; return [...prevState];
}); });

View File

@ -18,8 +18,9 @@ function VideoItem({ cameraNumber, videoName, getFixedCameraPlayUrl }) {
setLoading(true); setLoading(true);
setPlayUrl(""); setPlayUrl("");
const { data, success } = await getFixedCameraPlayUrl({ indexCode: cameraNumber }); const { data, success } = await getFixedCameraPlayUrl({ indexCode: cameraNumber });
const videoUrl = data || "";
if (!isUnmounted && success) if (!isUnmounted && success)
setPlayUrl(data || ""); setPlayUrl(videoUrl);
if (!isUnmounted) if (!isUnmounted)
setLoading(false); setLoading(false);

View File

@ -37,7 +37,7 @@ function Camera(props) {
pageSize: 99, pageSize: 99,
}), }),
]); ]);
setLevelList(dictionaryData); setLevelList(dictionaryData || []);
setVideoList(data || []); setVideoList(data || []);
}; };

View File

@ -144,7 +144,7 @@ function DepartmentResponsibilityPanel(props) {
useMount(() => { useMount(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getDepartmentDuty({ portArea, corpinfoId: currentBranchOffice }); const { data } = await props.getDepartmentDuty({ portArea, corpinfoId: currentBranchOffice });
initEcharts(data); initEcharts(data || []);
}; };
loadData(); loadData();

View File

@ -22,7 +22,7 @@ function RiskHazardPanel(props) {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getRiskPointHidden({ portArea, corpinfoId: currentBranchOffice }); const { data } = await props.getRiskPointHidden({ portArea, corpinfoId: currentBranchOffice });
setData(data); setData(data || []);
}; };
loadData(); loadData();

View File

@ -31,8 +31,9 @@ function WeatherPreventionPanel(props) {
await props.getWeather(), await props.getWeather(),
await props.getPersonStatistics({ portArea, corpinfoId: currentBranchOffice }), await props.getPersonStatistics({ portArea, corpinfoId: currentBranchOffice }),
]); ]);
setWeather(result.now || {}); const weatherResult = result || {};
setAlerts(Array.isArray(result.alerts) ? result.alerts : []); setWeather(weatherResult.now || {});
setAlerts(Array.isArray(weatherResult.alerts) ? weatherResult.alerts : []);
setData(statistics.map(item => ({ ...item, value: (data || {})[item.key] || 0 }))); setData(statistics.map(item => ({ ...item, value: (data || {})[item.key] || 0 })));
}; };
loadData(); loadData();

View File

@ -26,8 +26,9 @@ function VideoPatrolPanel(props) {
const { data, success } = await props.getFixedCameraPlayUrl({ const { data, success } = await props.getFixedCameraPlayUrl({
indexCode: video.cameraNumber, indexCode: video.cameraNumber,
}); });
const videoUrl = data || "";
if (success) if (success)
setPlayUrl(data || ""); setPlayUrl(videoUrl);
}; };
useEffect(() => { useEffect(() => {

View File

@ -168,7 +168,7 @@ function EntryExitTrendPanel(props) {
mkmjLevel: "2", mkmjLevel: "2",
mkmjType, mkmjType,
}); });
initEcharts(data); initEcharts(data || []);
}; };
useMount(() => { useMount(() => {

View File

@ -30,9 +30,10 @@ function WeatherPreventionPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { result = {} } = await props.getWeather(); const { result } = await props.getWeather();
setWeather(result.now || {}); const weatherResult = result || {};
setAlerts(Array.isArray(result.alerts) ? result.alerts : []); setWeather(weatherResult.now || {});
setAlerts(Array.isArray(weatherResult.alerts) ? weatherResult.alerts : []);
}; };
loadData(); loadData();
}, []); }, []);

View File

@ -20,7 +20,7 @@ function DepartmentWorkPanel(props) {
pageIndex: 1, pageIndex: 1,
pageSize: 99, pageSize: 99,
}); });
setData(data); setData(data || []);
}; };
loadData(); loadData();
}, []); }, []);

View File

@ -28,9 +28,10 @@ function FireDeviceStatusPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
}); });
const deviceStatus = data || {};
setData({ setData({
totalCount: data?.totalCount || 0, totalCount: deviceStatus.totalCount || 0,
statusList: data?.statusList || [], statusList: deviceStatus.statusList || [],
}); });
}; };
loadData(); loadData();

View File

@ -22,7 +22,7 @@ function FireInspectionRecordPanel(props) {
pageIndex: 1, pageIndex: 1,
pageSize: 99, pageSize: 99,
}); });
setData(data); setData(data || []);
}; };
loadData(); loadData();
}, []); }, []);

View File

@ -21,7 +21,6 @@ function VolunteerFireTeamPanel(props) {
pageSize: 99, pageSize: 99,
teamType: "volunteer_rescue", teamType: "volunteer_rescue",
}); });
console.log(data);
setData(data || []); setData(data || []);
}; };
loadData(); loadData();

View File

@ -25,10 +25,11 @@ function ProjectStatsPanel(props) {
portArea, portArea,
corpinfoId: currentBranchOffice, corpinfoId: currentBranchOffice,
}); });
const projectStatistics = data || {};
setData([ setData([
{ ...defaultStatistics[0], value: data?.totalProjectCount }, { ...defaultStatistics[0], value: projectStatistics.totalProjectCount },
{ ...defaultStatistics[1], value: data?.waitStartCount }, { ...defaultStatistics[1], value: projectStatistics.waitStartCount },
{ ...defaultStatistics[2], value: data?.startCount }, { ...defaultStatistics[2], value: projectStatistics.startCount },
]); ]);
}; };
loadData(); loadData();

View File

@ -22,7 +22,7 @@ const AlarmEquipment = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.sensorDeviceInfo({ id: props.id }); const { data } = await props.sensorDeviceInfo({ id: props.id });
setInfo(data); setInfo(data || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -13,7 +13,7 @@ function BlindBoardWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -14,7 +14,7 @@ function BreakGroundWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -13,16 +13,16 @@ function ConfinedSpaceWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
const { data: supplementaryInfo } = await props.eightWorkSupplementaryInfo({ const { data: supplementaryInfo } = await props.eightWorkSupplementaryInfo({
eqWorkId: props.workId, eqWorkId: props.workId,
pageSize: 999, pageSize: 999,
pageIndex: 1, pageIndex: 1,
}); });
setGasMonitoringRecord(supplementaryInfo.filter(item => item.type === "gas")); setGasMonitoringRecord((supplementaryInfo || []).filter(item => item.type === "gas"));
const { data: measuresLogs } = await props.eightworkMeasuresLogs({ workId: props.workId }); const { data: measuresLogs } = await props.eightworkMeasuresLogs({ workId: props.workId });
setSafetyMeasures(measuresLogs.filter(item => item.type === 1)); setSafetyMeasures((measuresLogs || []).filter(item => item.type === 1));
setOtherSafetyMeasures(measuresLogs.filter(item => item.type === 2)); setOtherSafetyMeasures((measuresLogs || []).filter(item => item.type === 2));
}; };
useEffect(() => { useEffect(() => {

View File

@ -14,7 +14,7 @@ function CutRoadWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -12,14 +12,16 @@ const DoorCamera = (props) => {
const { data, success } = await props.getFixedCameraPlayUrl({ const { data, success } = await props.getFixedCameraPlayUrl({
indexCode: cameraNumber, indexCode: cameraNumber,
}); });
if (success && data) const videoUrl = data || "";
setPlayUrl(data || ""); if (success)
setPlayUrl(videoUrl);
}; };
const getData = async () => { const getData = async () => {
const { data } = await props.firstLevelDoorInfoCameraInfo({ id: props.id }); const { data } = await props.firstLevelDoorInfoCameraInfo({ id: props.id });
setInfo(data); const cameraInfo = data || {};
loadPlayUrl(data.videoResourceCode); setInfo(cameraInfo);
loadPlayUrl(cameraInfo.videoResourceCode);
}; };
useEffect(() => { useEffect(() => {

View File

@ -13,7 +13,7 @@ const Doorway = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.firstLevelDoorInfoInfo({ id: props.id }); const { data } = await props.firstLevelDoorInfoInfo({ id: props.id });
setInfo(data); setInfo(data || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -15,13 +15,13 @@ function ElectricityWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
const { data: supplementaryInfo } = await props.eightWorkSupplementaryInfo({ const { data: supplementaryInfo } = await props.eightWorkSupplementaryInfo({
eqWorkId: props.workId, eqWorkId: props.workId,
pageSize: 999, pageSize: 999,
pageIndex: 1, pageIndex: 1,
}); });
setGasMonitoringRecord(supplementaryInfo.filter(item => item.type === "gas")); setGasMonitoringRecord((supplementaryInfo || []).filter(item => item.type === "gas"));
}; };
useEffect(() => { useEffect(() => {

View File

@ -17,17 +17,18 @@ const FireControlRoom = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.fireControlRoomInfo({ id: props.id }); const { data } = await props.fireControlRoomInfo({ id: props.id });
const roomInfo = data || {};
const dictionaryData = await getDictionary({ dictValue: "fire_resource_contro_root_type" }); const dictionaryData = await getDictionary({ dictValue: "fire_resource_contro_root_type" });
const files = await getFile({ const files = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM[302], eqType: UPLOAD_FILE_TYPE_ENUM[302],
eqForeignKey: data.roomId, eqForeignKey: roomInfo.roomId,
}); });
setInfo({ setInfo({
...data, ...roomInfo,
roomImages: files, roomImages: files,
roomStatusName: getLabelName({ roomStatusName: getLabelName({
list: dictionaryData, list: dictionaryData,
status: data.roomStatus, status: roomInfo.roomStatus,
idKey: "dictValue", idKey: "dictValue",
nameKey: "dictLabel", nameKey: "dictLabel",
}), }),

View File

@ -11,7 +11,7 @@ const FirePointLocation = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.firePointInfo({ id: props.id }); const { data } = await props.firePointInfo({ id: props.id });
setInfo(data); setInfo(data || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -17,17 +17,18 @@ const FirePumpRoom = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.firePumpRoomInfo({ id: props.id }); const { data } = await props.firePumpRoomInfo({ id: props.id });
const pumpRoomInfo = data || {};
const dictionaryData = await getDictionary({ dictValue: "fire_resource_contro_root_type" }); const dictionaryData = await getDictionary({ dictValue: "fire_resource_contro_root_type" });
const files = await getFile({ const files = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM[302], eqType: UPLOAD_FILE_TYPE_ENUM[302],
eqForeignKey: data.pumpRoomId, eqForeignKey: pumpRoomInfo.pumpRoomId,
}); });
setInfo({ setInfo({
...data, ...pumpRoomInfo,
roomImages: files, roomImages: files,
pumpStatusName: getLabelName({ pumpStatusName: getLabelName({
list: dictionaryData, list: dictionaryData,
status: data.pumpRoomStatus, status: pumpRoomInfo.pumpRoomStatus,
idKey: "dictValue", idKey: "dictValue",
nameKey: "dictLabel", nameKey: "dictLabel",
}), }),

View File

@ -9,7 +9,7 @@ const FireRescueTeam = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.fireRescueTeamInfo({ id: props.id }); const { data } = await props.fireRescueTeamInfo({ id: props.id });
setInfo(data); setInfo(data || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -12,13 +12,14 @@ const FireWaterSource = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.fireWaterSourceInfo({ id: props.id }); const { data } = await props.fireWaterSourceInfo({ id: props.id });
const waterSourceInfo = data || {};
const dictionaryData = await getDictionary({ dictValue: "fire_resource_water_type" }); const dictionaryData = await getDictionary({ dictValue: "fire_resource_water_type" });
setInfo({ setInfo({
...data, ...waterSourceInfo,
waterSourceStatusName: getLabelName({ waterSourceStatusName: getLabelName({
list: dictionaryData, list: dictionaryData,
status: data.waterSourceStatus, status: waterSourceInfo.waterSourceStatus,
idKey: "dictValue", idKey: "dictValue",
nameKey: "dictLabel", nameKey: "dictLabel",
}), }),

View File

@ -13,7 +13,7 @@ const Gate = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.firstLevelDoorInfoFareGateInfo({ id: props.id }); const { data } = await props.firstLevelDoorInfoFareGateInfo({ id: props.id });
setInfo(data); setInfo(data || {});
}; };
useEffect(() => { useEffect(() => {
getData(); getData();

View File

@ -14,7 +14,7 @@ function HighWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -14,7 +14,7 @@ function HoistingWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
}; };
useEffect(() => { useEffect(() => {

View File

@ -14,14 +14,14 @@ function HotWork(props) {
const getData = async () => { const getData = async () => {
const { data: basicInfo } = await props.eightWorkInfo({ id: props.id }); const { data: basicInfo } = await props.eightWorkInfo({ id: props.id });
setInfo(basicInfo); setInfo(basicInfo || {});
const { data: supplementaryInfo } = await props.eightWorkSupplementaryInfo({ const { data: supplementaryInfo } = await props.eightWorkSupplementaryInfo({
eqWorkId: props.workId, eqWorkId: props.workId,
pageSize: 999, pageSize: 999,
pageIndex: 1, pageIndex: 1,
}); });
setDelayedMonitoringRecord(supplementaryInfo.filter(item => item.type === "delay")); setDelayedMonitoringRecord((supplementaryInfo || []).filter(item => item.type === "delay"));
setGasMonitoringRecord(supplementaryInfo.filter(item => item.type === "gas")); setGasMonitoringRecord((supplementaryInfo || []).filter(item => item.type === "gas"));
}; };
useEffect(() => { useEffect(() => {

View File

@ -55,14 +55,15 @@ const KeyProject = (props) => {
const getData = async () => { const getData = async () => {
const { data } = await props.keyProjectInfo({ id: props.id }); const { data } = await props.keyProjectInfo({ id: props.id });
const projectInfo = data || {};
const files = await getFile({ const files = await getFile({
eqType: UPLOAD_FILE_TYPE_ENUM["168"], eqType: UPLOAD_FILE_TYPE_ENUM["168"],
eqForeignKey: data.keyProjectId, eqForeignKey: projectInfo.keyProjectId,
}); });
setInfo({ setInfo({
files, files,
...data, ...projectInfo,
}); });
}; };

View File

@ -8,8 +8,9 @@ const VideoPlay = (props) => {
const getData = async () => { const getData = async () => {
const { data, success } = await props.getFixedCameraPlayUrl({ indexCode: props.cameraNumber }); const { data, success } = await props.getFixedCameraPlayUrl({ indexCode: props.cameraNumber });
if (success && data) const videoUrl = data || "";
setPlayUrl(data); if (success)
setPlayUrl(videoUrl);
}; };
useEffect(() => { useEffect(() => {

View File

@ -11,8 +11,9 @@ function SafetyMeasures(props) {
const getData = async () => { const getData = async () => {
const { data } = await props.eightWorkMeasuresLogs({ workId: props.workId }); const { data } = await props.eightWorkMeasuresLogs({ workId: props.workId });
setSafetyMeasures(data.filter(item => item.type === 1)); const measuresLogs = data || [];
setOtherSafetyMeasures(data.filter(item => item.type === 2)); setSafetyMeasures(measuresLogs.filter(item => item.type === 1));
setOtherSafetyMeasures(measuresLogs.filter(item => item.type === 2));
}; };
useEffect(() => { useEffect(() => {

View File

@ -25,10 +25,11 @@ function BasicInfoPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getCorpInfoCorpUserSummary({ portArea }); const { data } = await props.getCorpInfoCorpUserSummary({ portArea });
const summary = data || {};
const counts = [ const counts = [
data?.branchCorpCount, summary.branchCorpCount,
data?.relatedCorpCount, summary.relatedCorpCount,
data?.userCount, summary.userCount,
]; ];
setData( setData(

View File

@ -123,7 +123,7 @@ function EntryExitTrendPanel(props) {
useMount(() => { useMount(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getScreenMkmjRecord({ portArea, mkmjLevel: "1" }); const { data } = await props.getScreenMkmjRecord({ portArea, mkmjLevel: "1" });
initEcharts(data); initEcharts(data || []);
}; };
loadData(); loadData();

View File

@ -19,11 +19,11 @@ function GateRecordPanel(props) {
const loadRecords = async (tabIndex) => { const loadRecords = async (tabIndex) => {
setRecords([]); setRecords([]);
const { data = [] } = await props.getScreenAccessRecord({ const { data } = await props.getScreenAccessRecord({
portArea, portArea,
recordType: tabIndex + 1, recordType: tabIndex + 1,
}); });
setRecords(data); setRecords(data || []);
}; };
useEffect(() => { useEffect(() => {

View File

@ -16,7 +16,7 @@ function OnlineLocationInfoPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getScreenPersonLocationList({ portArea }); const { data } = await props.getScreenPersonLocationList({ portArea });
setData(data); setData(data || []);
}; };
loadData(); loadData();
}, []); }, []);

View File

@ -28,10 +28,11 @@ function WorkStatusPanel(props) {
const { data } = await props.getEightWorkInfoScreenStatusStatistics({ const { data } = await props.getEightWorkInfoScreenStatusStatistics({
portArea, portArea,
}); });
const workStatus = data || {};
const counts = [ const counts = [
data?.appliedCount, workStatus.appliedCount,
data?.approvingCount, workStatus.approvingCount,
data?.archivedCount, workStatus.archivedCount,
]; ];
setData( setData(
defaultStatistics.map((item, index) => ({ defaultStatistics.map((item, index) => ({

View File

@ -26,7 +26,8 @@ function KeyProjectPanel(props) {
const { data } = await props.getKeyProjectLargeScreenProjectStatistics({ const { data } = await props.getKeyProjectLargeScreenProjectStatistics({
portArea, portArea,
}); });
const counts = [data?.totalProjectCount, data?.startCount]; const projectStatistics = data || {};
const counts = [projectStatistics.totalProjectCount, projectStatistics.startCount];
setData( setData(
defaultStatistics.map((item, index) => ({ defaultStatistics.map((item, index) => ({
...item, ...item,

View File

@ -26,7 +26,7 @@ function KeyWorkInfoPanel(props) {
useEffect(() => { useEffect(() => {
const loadData = async () => { const loadData = async () => {
const { data } = await props.getScreenLargeScreenInfo({ portArea }); const { data } = await props.getScreenLargeScreenInfo({ portArea });
setData(data); setData(data || []);
}; };
loadData(); loadData();
}, []); }, []);

View File

@ -24,7 +24,8 @@ function VideoLocationPanel(props) {
const { data } = await props.getFixedCameraVideoLocationStat({ const { data } = await props.getFixedCameraVideoLocationStat({
portArea, portArea,
}); });
const counts = [data?.totalCount, data?.onlineCount, data?.offlineCount]; const videoStatistics = data || {};
const counts = [videoStatistics.totalCount, videoStatistics.onlineCount, videoStatistics.offlineCount];
setData( setData(
defaultStatistics.map((item, index) => ({ defaultStatistics.map((item, index) => ({
...item, ...item,

View File

@ -43,7 +43,8 @@ function PeopleTrajectorySelect(props) {
setQueryLoading(true); setQueryLoading(true);
try { try {
const { data } = await props.getPeopleTrajectory(params); const { data } = await props.getPeopleTrajectory(params);
const points = data?.points || []; const trajectoryData = data || {};
const points = trajectoryData.points || [];
if (points.length < 2) { if (points.length < 2) {
mapMethods.current.removePeopleTrajectory(); mapMethods.current.removePeopleTrajectory();
message.warning("该时间范围内没有可绘制的轨迹"); message.warning("该时间范围内没有可绘制的轨迹");

View File

@ -84,23 +84,24 @@ function Map(props) {
setTimeout(() => { setTimeout(() => {
if (window.sessionStorage.getItem("token")) { if (window.sessionStorage.getItem("token")) {
props.getCorpInfo().then(({ data }) => { props.getCorpInfo().then(({ data }) => {
if ([3, 4, 5].includes(data?.type)) { const corpInfo = data || {};
if ([3, 4, 5].includes(corpInfo.type)) {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
alert("您当前登录的账号没有权限访问此页面"); alert("您当前登录的账号没有权限访问此页面");
closeWindow(); closeWindow();
} }
else if ([0, 1, 6].includes(data?.type)) { else if ([0, 1, 6].includes(corpInfo.type)) {
const id = data.id; const id = corpInfo.id;
const name = data.corpName; const name = corpInfo.corpName;
const longitude = data.longitude; const longitude = corpInfo.longitude;
const latitude = data.latitude; const latitude = corpInfo.latitude;
if (!id || !name || !longitude || !latitude) if (!id || !name || !longitude || !latitude)
return message.warning("参数不完整,无法定位到对应分公司"); return message.warning("参数不完整,无法定位到对应分公司");
handlePortClick({ id: "00003" }); handlePortClick({ id: "00003" });
handleBranchOfficeClick(data); handleBranchOfficeClick(corpInfo);
mapMethods.current.addBranchOfficePoint(undefined, data); mapMethods.current.addBranchOfficePoint(undefined, corpInfo);
mapMethods.current.flyTo({ longitude, latitude, height: 2000 }); mapMethods.current.flyTo({ longitude, latitude, height: 2000 });
sessionStorage.setItem("mapCurrentBranchOfficeId", id); sessionStorage.setItem("mapCurrentBranchOfficeId", id);
setIsBranchCompanyUser(true); setIsBranchCompanyUser(true);