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;
if (check) {
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, {
markType: item1.type,
markIcon: item1.markIcon,
subLabel: item1.label,
titleKey: item1.titleKey,
isShowModal: item1.isShowModal,
});
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -93,6 +93,11 @@
.table {
margin-top: 5px;
.scroll{
height: 400px;
overflow-y: hidden;
}
.tr {
display: flex;
@ -133,14 +138,6 @@
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(() => {
const loadDeviceList = async () => {
setIsVisible(false);
const { data } = await props.getFirePointDeviceList({
const { data = [] } = await props.getFirePointDeviceList({
portArea,
...queryParams,
pageIndex: 1,

View File

@ -130,7 +130,7 @@ export default function useMapMethods(viewerRef, request) {
// 添加分公司点
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);
let branchOfficePoint = [];
if (!pointInfo) {
@ -348,6 +348,7 @@ export default function useMapMethods(viewerRef, request) {
* @param options.markType {String} 扎点类型
* @param options.subLabel {String} 二级标题用于弹窗标题
* @param options.titleKey {String} 标题键用于从item中获取标题
* @param options.isShowModal {Boolean} 是否显示弹窗
*/
const addMarkPoint = async (pointList, options) => {
if (!options.markType)
@ -367,7 +368,7 @@ export default function useMapMethods(viewerRef, request) {
position: getPosition(item.longitude || item.lng, item.latitude || item.lat),
billboard: await getBillboard({ image: options.markIcon, name }),
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) => {
mitt.emit(clickMarkPointMittKey, data);
if (data.isShowModal)
mitt.emit(clickMarkPointMittKey, data);
};
// 点位点击