fix(api): 优化接口调用默认值及地图点位弹窗显示

- 各接口调用解构时添加 data 默认空数组或空对象,避免空值异常
- 地图标记点新增 isShowModal 参数,控制弹窗是否显示
- 点位点击事件中根据 isShowModal 判断是否触发弹窗显示事件
- 修正样式中 .scroll 容器高度及溢出处理
- 统一接口返回数据默认值处理,提升稳定性和健壮性
master
LiuJiaNan 2026-07-22 08:52:47 +08:00
parent 411eeaae1d
commit c68862b954
16 changed files with 28 additions and 29 deletions

View File

@ -107,12 +107,13 @@ function BottomUtils(props) {
const check = !list[index].list[index1].check; const check = !list[index].list[index1].check;
if (check) { if (check) {
if (item1.request) { if (item1.request) {
const { data } = await props[item1.request]({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999 }); const { data = [] } = await props[item1.request]({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999 });
mapMethods.current.addMarkPoint(data, { mapMethods.current.addMarkPoint(data, {
markType: item1.type, markType: item1.type,
markIcon: item1.markIcon, markIcon: item1.markIcon,
subLabel: item1.label, subLabel: item1.label,
titleKey: item1.titleKey, titleKey: item1.titleKey,
isShowModal: item1.isShowModal,
}); });
} }
} }

View File

@ -12,7 +12,7 @@ function RecordStatsPanel(props) {
const [list, setList] = useState([]); const [list, setList] = useState([]);
useEffect(() => { useEffect(() => {
const loadList = async () => { const loadList = async () => {
const { data } = await props.getXgfStatisticsListRecordProjectStatistics(); const { data = [] } = await props.getXgfStatisticsListRecordProjectStatistics();
setList(data); setList(data);
}; };

View File

@ -14,7 +14,7 @@ function VideoPatrolPanel(props) {
const [active, setActive] = useState(""); const [active, setActive] = useState("");
const [playUrl, setPlayUrl] = useState(""); const [playUrl, setPlayUrl] = useState("");
const loadPlayUrl = async (cameraNumber) => { const loadPlayUrl = async (cameraNumber) => {
const { data, success } = await props.getFixedCameraPlayUrl({ const { data = {}, success } = await props.getFixedCameraPlayUrl({
indexCode: cameraNumber, indexCode: cameraNumber,
}); });
if (success && data) if (success && data)
@ -35,7 +35,7 @@ function VideoPatrolPanel(props) {
}; };
useEffect(() => { useEffect(() => {
const loadVideoList = async () => { const loadVideoList = async () => {
const { data } = await props.getFixedCameraVideoList(); const { data = [] } = await props.getFixedCameraVideoList();
setList(data); setList(data);
if (data.length) { if (data.length) {
selectCorp(data[0]); selectCorp(data[0]);

View File

@ -13,7 +13,7 @@ function RectificationPanel(props) {
const [list, setList] = useState([]); const [list, setList] = useState([]);
useEffect(() => { useEffect(() => {
const loadList = async () => { const loadList = async () => {
const { data } = await props.getHiddenStatisticsByCorp({ const { data = [] } = await props.getHiddenStatisticsByCorp({
pageIndex: 1, pageIndex: 1,
pageSize: 999, pageSize: 999,
}); });

View File

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

View File

@ -137,7 +137,7 @@ function WorkStatusPanel(props) {
}; };
useMount(() => { useMount(() => {
const loadChartData = async () => { const loadChartData = async () => {
const { data } = await props.getProjectTaskScoreCount(); const { data = [] } = await props.getProjectTaskScoreCount();
initEcharts(chartRef, chartInstance, data); initEcharts(chartRef, chartInstance, data);
}; };

View File

@ -13,7 +13,7 @@ function AlarmPanel(props) {
const [list, setList] = useState([]); const [list, setList] = useState([]);
useEffect(() => { useEffect(() => {
const loadList = async () => { const loadList = async () => {
const { data } = await props.getAlarmRecordScreenIotDeviceAlarmPage(); const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage();
setList(data); setList(data);
}; };

View File

@ -13,7 +13,7 @@ function PartnerPanel(props) {
const [list, setList] = useState([]); const [list, setList] = useState([]);
useEffect(() => { useEffect(() => {
const loadList = async () => { const loadList = async () => {
const { data } = await props.getXgfStatisticsListCorpStatistics(); const { data = [] } = await props.getXgfStatisticsListCorpStatistics();
setList(data); setList(data);
}; };

View File

@ -29,8 +29,8 @@ function WorkPanel(props) {
]); ]);
useEffect(() => { useEffect(() => {
const loadStatistics = async () => { const loadStatistics = async () => {
const { data: eightWorkData } = await props.getEightWorkInfoDangerWorkStatistics(); const { data: eightWorkData = {} } = await props.getEightWorkInfoDangerWorkStatistics();
const { data: keyProjectData } = await props.getKeyProjectLargeScreenStatistics(); const { data: keyProjectData = {} } = await props.getKeyProjectLargeScreenStatistics();
setList((prevState) => { setList((prevState) => {
prevState[1].doingCount = eightWorkData.doingCount; prevState[1].doingCount = eightWorkData.doingCount;
prevState[1].appliedCount = eightWorkData.appliedCount; prevState[1].appliedCount = eightWorkData.appliedCount;

View File

@ -24,7 +24,7 @@ function BasicInfoPanel(props) {
useEffect(() => { useEffect(() => {
const loadStatistics = async () => { const loadStatistics = async () => {
const { data } = await props.getCorpInfoCorpUserSummary({ portArea }); const { data = {} } = await props.getCorpInfoCorpUserSummary({ portArea });
const counts = [ const counts = [
data.branchCorpCount, data.branchCorpCount,
data.relatedCorpCount, data.relatedCorpCount,

View File

@ -20,7 +20,7 @@ function PersonnelStatsPanel(props) {
const loadStatistics = async (enterpriseType) => { const loadStatistics = async (enterpriseType) => {
setIsVisible(false); setIsVisible(false);
const { data } = await props.getCorpInfoCorpUserStatisticPage({ const { data = [] } = await props.getCorpInfoCorpUserStatisticPage({
portArea, portArea,
enterpriseType, enterpriseType,
}); });

View File

@ -51,7 +51,7 @@ function RiskStatsPanel(props) {
useEffect(() => { useEffect(() => {
const loadStatistics = async () => { const loadStatistics = async () => {
const { data } = await props.getRiskPointCorpRiskLevel({ portArea }); const { data = [] } = await props.getRiskPointCorpRiskLevel({ portArea });
const countByLevel = Object.fromEntries( const countByLevel = Object.fromEntries(
data.map(item => [item.level, item.count]), data.map(item => [item.level, item.count]),
); );

View File

@ -93,6 +93,11 @@
.table { .table {
margin-top: 5px; margin-top: 5px;
.scroll{
height: 400px;
overflow-y: hidden;
}
.tr { .tr {
display: flex; display: flex;
@ -133,14 +138,6 @@
padding-left: 0; padding-left: 0;
} }
} }
.empty {
flex: 1;
text-align: center;
font-size: 12px;
color: #fff;
padding: 5px;
}
} }
} }
} }

View File

@ -17,7 +17,7 @@ function FireDeviceListPanel(props) {
useEffect(() => { useEffect(() => {
const loadDeviceList = async () => { const loadDeviceList = async () => {
setIsVisible(false); setIsVisible(false);
const { data } = await props.getFirePointDeviceList({ const { data = [] } = await props.getFirePointDeviceList({
portArea, portArea,
...queryParams, ...queryParams,
pageIndex: 1, pageIndex: 1,

View File

@ -130,7 +130,7 @@ export default function useMapMethods(viewerRef, request) {
// 添加分公司点 // 添加分公司点
const addBranchOfficePoint = async (portArea = 1, pointInfo = null) => { const addBranchOfficePoint = async (portArea = 1, pointInfo = null) => {
const { data } = await request.getCorpInfoListAll({ eqPortArea: portArea, inType: [0, 1, 2, 6] }); const { data = [] } = await request.getCorpInfoListAll({ eqPortArea: portArea, inType: [0, 1, 2, 6] });
mitt.emit(changeCoverMaskVisibleMittKey, true); mitt.emit(changeCoverMaskVisibleMittKey, true);
let branchOfficePoint = []; let branchOfficePoint = [];
if (!pointInfo) { if (!pointInfo) {
@ -348,6 +348,7 @@ export default function useMapMethods(viewerRef, request) {
* @param options.markType {String} 扎点类型 * @param options.markType {String} 扎点类型
* @param options.subLabel {String} 二级标题用于弹窗标题 * @param options.subLabel {String} 二级标题用于弹窗标题
* @param options.titleKey {String} 标题键用于从item中获取标题 * @param options.titleKey {String} 标题键用于从item中获取标题
* @param options.isShowModal {Boolean} 是否显示弹窗
*/ */
const addMarkPoint = async (pointList, options) => { const addMarkPoint = async (pointList, options) => {
if (!options.markType) if (!options.markType)
@ -367,7 +368,7 @@ export default function useMapMethods(viewerRef, request) {
position: getPosition(item.longitude || item.lng, item.latitude || item.lat), position: getPosition(item.longitude || item.lng, item.latitude || item.lat),
billboard: await getBillboard({ image: options.markIcon, name }), billboard: await getBillboard({ image: options.markIcon, name }),
monitorItems: { monitorItems: {
data: { ...item, markType: `标记点_${options.markType}`, title: options.subLabel }, data: { ...item, markType: `标记点_${options.markType}`, title: options.subLabel, isShowModal: options.isShowModal ?? true },
}, },
}), }),
); );

View File

@ -103,7 +103,8 @@ export default function usePointClickEvent(viewerRef, mapMethods) {
}; };
const clickMarkPoint = (data) => { const clickMarkPoint = (data) => {
mitt.emit(clickMarkPointMittKey, data); if (data.isShowModal)
mitt.emit(clickMarkPointMittKey, data);
}; };
// 点位点击 // 点位点击