fix(api): 统一处理接口返回数据的默认值为null或undefined时的兼容问题
- 调整多个接口调用中解构data时去掉默认空数组或空对象,改用逻辑或操作符进行兼容处理 - 防止data为null或undefined导致程序异常,保证数据显示和渲染安全 - 相关组件和业务逻辑中增加了对data字段的非空判断和安全访问 - 更新图表和列表渲染初始化逻辑,避免因数据缺失导致的异常 - 优化请求数据接收后赋值流程,提升代码的鲁棒性与稳定性master
parent
fdeeb1e9a2
commit
1f8f47f946
|
|
@ -130,8 +130,8 @@ function BottomUtils(props) {
|
||||||
if (gateTypes.includes(item1.type)) {
|
if (gateTypes.includes(item1.type)) {
|
||||||
requestParams.gateType = item1.type;
|
requestParams.gateType = item1.type;
|
||||||
}
|
}
|
||||||
const { data = [] } = await props[item1.request](requestParams);
|
const { data } = await props[item1.request](requestParams);
|
||||||
pointData = [...data];
|
pointData = [...(data || [])];
|
||||||
if (dangerWorkTypes.includes(item1.type)) {
|
if (dangerWorkTypes.includes(item1.type)) {
|
||||||
for (let i = 0; i < pointData.length; i++) {
|
for (let i = 0; i < pointData.length; i++) {
|
||||||
pointData[i].latitude = pointData[i].info.latitude;
|
pointData[i].latitude = pointData[i].info.latitude;
|
||||||
|
|
|
||||||
|
|
@ -12,8 +12,8 @@ function RecordStatsPanel(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getXgfStatisticsListRecordProjectStatistics();
|
const { data } = await props.getXgfStatisticsListRecordProjectStatistics();
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ 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)
|
||||||
setPlayUrl(data.url);
|
setPlayUrl(data?.url || "");
|
||||||
};
|
};
|
||||||
const selectCorp = (item) => {
|
const selectCorp = (item) => {
|
||||||
setActive(item.corpinfoName);
|
setActive(item.corpinfoName);
|
||||||
|
|
@ -35,9 +35,9 @@ 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]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ function RectificationPanel(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getHiddenStatisticsByPortArea({
|
const { data } = await props.getHiddenStatisticsByPortArea({
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,11 @@ function WeatherPanel(props) {
|
||||||
alertTitle: result.alerts?.[0]?.title || "当前暂无气象预警",
|
alertTitle: result.alerts?.[0]?.title || "当前暂无气象预警",
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data = [] } = await props.getEventReportListUnfinished({
|
const { data } = await props.getEventReportListUnfinished({
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setEmergencyList(data);
|
setEmergencyList(data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -137,8 +137,8 @@ function WorkStatusPanel(props) {
|
||||||
};
|
};
|
||||||
useMount(() => {
|
useMount(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getProjectTaskScoreCount();
|
const { data } = await props.getProjectTaskScoreCount();
|
||||||
initEcharts(chartRef, chartInstance, data);
|
initEcharts(chartRef, chartInstance, data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ function AlarmPanel(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
|
const { data } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ function PartnerPanel(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getXgfStatisticsListCorpStatistics({
|
const { data } = await props.getXgfStatisticsListCorpStatistics({
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -29,22 +29,22 @@ function WorkPanel(props) {
|
||||||
]);
|
]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const [{ data: eightWorkData = [] }, { data: keyProjectData = [] }] = await Promise.all([
|
const [{ data: eightWorkData }, { data: keyProjectData }] = await Promise.all([
|
||||||
props.getEightWorkInfoDangerWorkStatistics(),
|
props.getEightWorkInfoDangerWorkStatistics(),
|
||||||
props.getKeyProjectLargeScreenStatistics(),
|
props.getKeyProjectLargeScreenStatistics(),
|
||||||
]);
|
]);
|
||||||
setData((prevState) => {
|
setData((prevState) => {
|
||||||
prevState[1].doingCount = eightWorkData.doingCount;
|
prevState[1].doingCount = eightWorkData?.doingCount;
|
||||||
prevState[1].appliedCount = eightWorkData.appliedCount;
|
prevState[1].appliedCount = eightWorkData?.appliedCount;
|
||||||
|
|
||||||
prevState[0].doingCount = keyProjectData.morePeopleStartCount;
|
prevState[0].doingCount = keyProjectData?.morePeopleStartCount;
|
||||||
prevState[0].appliedCount = keyProjectData.morePeopleApplyCount;
|
prevState[0].appliedCount = keyProjectData?.morePeopleApplyCount;
|
||||||
|
|
||||||
prevState[2].doingCount = keyProjectData.fourNewHomeworkStartCount;
|
prevState[2].doingCount = keyProjectData?.fourNewHomeworkStartCount;
|
||||||
prevState[2].appliedCount = keyProjectData.fourNewHomeworkApplyCount;
|
prevState[2].appliedCount = keyProjectData?.fourNewHomeworkApplyCount;
|
||||||
|
|
||||||
prevState[3].doingCount = keyProjectData.nightWorkStartCount;
|
prevState[3].doingCount = keyProjectData?.nightWorkStartCount;
|
||||||
prevState[3].appliedCount = keyProjectData.nightWorkApplyCount;
|
prevState[3].appliedCount = keyProjectData?.nightWorkApplyCount;
|
||||||
|
|
||||||
return [...prevState];
|
return [...prevState];
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ function VideoItem({ cameraNumber, videoName, getFixedCameraPlayUrl }) {
|
||||||
const loadPlayUrl = async () => {
|
const loadPlayUrl = async () => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setPlayUrl("");
|
setPlayUrl("");
|
||||||
const { data = {}, success } = await getFixedCameraPlayUrl({ indexCode: cameraNumber });
|
const { data, success } = await getFixedCameraPlayUrl({ indexCode: cameraNumber });
|
||||||
if (!isUnmounted && success)
|
if (!isUnmounted && success)
|
||||||
setPlayUrl(data?.url || "");
|
setPlayUrl(data?.url || "");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ function Camera(props) {
|
||||||
const [videoList, setVideoList] = useState([]);
|
const [videoList, setVideoList] = useState([]);
|
||||||
|
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const [dictionaryData, { data = [] }] = await Promise.all([
|
const [dictionaryData, { data }] = await Promise.all([
|
||||||
getDictionary({ dictValue: "videoLevel" }),
|
getDictionary({ dictValue: "videoLevel" }),
|
||||||
props.getFixedCameraVideoInfoPage({
|
props.getFixedCameraVideoInfoPage({
|
||||||
portArea,
|
portArea,
|
||||||
|
|
@ -36,7 +36,7 @@ function Camera(props) {
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
setLevelList(dictionaryData);
|
setLevelList(dictionaryData);
|
||||||
setVideoList(data);
|
setVideoList(data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ function AreaAlarmPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
|
const { data } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ function KeyWorkStatsPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const [{ data: eightWorkData = [] }, { data: keyProjectData = [] }]
|
const [{ data: eightWorkData }, { data: keyProjectData }]
|
||||||
= await Promise.all([
|
= await Promise.all([
|
||||||
props.getEightWorkInfoScreenDepartmentStatistics({
|
props.getEightWorkInfoScreenDepartmentStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
|
|
@ -26,7 +26,7 @@ function KeyWorkStatsPanel(props) {
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
const departmentMap = new Map(
|
const departmentMap = new Map(
|
||||||
keyProjectData.map(item => [
|
(keyProjectData || []).map(item => [
|
||||||
item.departmentId,
|
item.departmentId,
|
||||||
{
|
{
|
||||||
departmentName: item.departmentName,
|
departmentName: item.departmentName,
|
||||||
|
|
@ -36,7 +36,7 @@ function KeyWorkStatsPanel(props) {
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
eightWorkData.forEach((item) => {
|
(eightWorkData || []).forEach((item) => {
|
||||||
const department = departmentMap.get(item.departmentId) || {
|
const department = departmentMap.get(item.departmentId) || {
|
||||||
departmentName: item.departmentName,
|
departmentName: item.departmentName,
|
||||||
fourNewHomeworkCount: 0,
|
fourNewHomeworkCount: 0,
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,11 @@ function ClosedAreaStatsPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = {} } = await props.getPrimeportClosedAreaCorpStat({ portArea, corpinfoId: currentBranchOffice });
|
const { data } = await props.getPrimeportClosedAreaCorpStat({ portArea, corpinfoId: currentBranchOffice });
|
||||||
|
|
||||||
setData(statistics.map(item => ({
|
setData(statistics.map(item => ({
|
||||||
...item,
|
...item,
|
||||||
count: item.field ? data[item.field] || 0 : item.count,
|
count: item.field ? (data || {})[item.field] || 0 : item.count,
|
||||||
})));
|
})));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,13 +19,13 @@ function GateApplicationPanel(props) {
|
||||||
|
|
||||||
const loadData = async (activeIndex) => {
|
const loadData = async (activeIndex) => {
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
const { data = [] } = await props[activeIndex === 1 ? "getPrimeportClosedAreaCarApplyScreenList" : "getPrimeportClosedAreaPersonApplyScreenList"]({
|
const { data } = await props[activeIndex === 1 ? "getPrimeportClosedAreaCarApplyScreenList" : "getPrimeportClosedAreaPersonApplyScreenList"]({
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ function DangerWorkDataPanel(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] }
|
const { data }
|
||||||
= await props.getEightWorkInfoScreenDangerWorkDataStatistics({
|
= await props.getEightWorkInfoScreenDangerWorkDataStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ function DepartmentWorkPanel(props) {
|
||||||
const [data, setData] = useState([]);
|
const [data, setData] = useState([]);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const [{ data: eightWorkData = [] }, { data: keyProjectData = [] }]
|
const [{ data: eightWorkData }, { data: keyProjectData }]
|
||||||
= await Promise.all([
|
= await Promise.all([
|
||||||
props.getEightWorkInfoScreenDepartmentStatistics({
|
props.getEightWorkInfoScreenDepartmentStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
|
|
@ -25,7 +25,7 @@ function DepartmentWorkPanel(props) {
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
const departmentMap = new Map(
|
const departmentMap = new Map(
|
||||||
keyProjectData.map(item => [
|
(keyProjectData || []).map(item => [
|
||||||
item.departmentId,
|
item.departmentId,
|
||||||
{
|
{
|
||||||
departmentName: item.departmentName,
|
departmentName: item.departmentName,
|
||||||
|
|
@ -35,7 +35,7 @@ function DepartmentWorkPanel(props) {
|
||||||
},
|
},
|
||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
eightWorkData.forEach((item) => {
|
(eightWorkData || []).forEach((item) => {
|
||||||
const department = departmentMap.get(item.departmentId) || {
|
const department = departmentMap.get(item.departmentId) || {
|
||||||
departmentName: item.departmentName,
|
departmentName: item.departmentName,
|
||||||
fourNewHomeworkCount: 0,
|
fourNewHomeworkCount: 0,
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ function KeyWorkPanel(props) {
|
||||||
const [data, setData] = useState(defaultStatistics);
|
const [data, setData] = useState(defaultStatistics);
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const [{ data: eightWorkData = {} }, { data: keyProjectData = {} }]
|
const [{ data: eightWorkData }, { data: keyProjectData }]
|
||||||
= await Promise.all([
|
= await Promise.all([
|
||||||
props.getEightWorkInfoDangerWorkStatistics({
|
props.getEightWorkInfoDangerWorkStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
|
|
@ -68,21 +68,21 @@ function KeyWorkPanel(props) {
|
||||||
setData([
|
setData([
|
||||||
{
|
{
|
||||||
...defaultStatistics[0],
|
...defaultStatistics[0],
|
||||||
currentCount: keyProjectData.fourNewHomeworkStartCount,
|
currentCount: keyProjectData?.fourNewHomeworkStartCount,
|
||||||
doingCount: keyProjectData.fourNewHomeworkDoingCount,
|
doingCount: keyProjectData?.fourNewHomeworkDoingCount,
|
||||||
archivedCount: keyProjectData.fourNewHomeworkArchiveCount,
|
archivedCount: keyProjectData?.fourNewHomeworkArchiveCount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...defaultStatistics[1],
|
...defaultStatistics[1],
|
||||||
currentCount: eightWorkData.doingCount,
|
currentCount: eightWorkData?.doingCount,
|
||||||
doingCount: eightWorkData.workingCount,
|
doingCount: eightWorkData?.workingCount,
|
||||||
archivedCount: eightWorkData.archivedCount,
|
archivedCount: eightWorkData?.archivedCount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...defaultStatistics[2],
|
...defaultStatistics[2],
|
||||||
currentCount: keyProjectData.morePeopleStartCount,
|
currentCount: keyProjectData?.morePeopleStartCount,
|
||||||
doingCount: keyProjectData.morePeopleDoingCount,
|
doingCount: keyProjectData?.morePeopleDoingCount,
|
||||||
archivedCount: keyProjectData.morePeopleArchiveCount,
|
archivedCount: keyProjectData?.morePeopleArchiveCount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ function KeyWorkStatsPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const [{ data: eightWorkData = {} }, { data: keyProjectData = {} }]
|
const [{ data: eightWorkData }, { data: keyProjectData }]
|
||||||
= await Promise.all([
|
= await Promise.all([
|
||||||
props.getEightWorkInfoDangerWorkStatistics({
|
props.getEightWorkInfoDangerWorkStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
|
|
@ -42,18 +42,18 @@ function KeyWorkStatsPanel(props) {
|
||||||
setData([
|
setData([
|
||||||
{
|
{
|
||||||
...defaultStatistics[0],
|
...defaultStatistics[0],
|
||||||
currentCount: keyProjectData.fourNewHomeworkStartCount,
|
currentCount: keyProjectData?.fourNewHomeworkStartCount,
|
||||||
applyCount: keyProjectData.fourNewHomeworkApplyCount,
|
applyCount: keyProjectData?.fourNewHomeworkApplyCount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...defaultStatistics[1],
|
...defaultStatistics[1],
|
||||||
currentCount: eightWorkData.workingCount,
|
currentCount: eightWorkData?.workingCount,
|
||||||
applyCount: eightWorkData.appliedCount,
|
applyCount: eightWorkData?.appliedCount,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...defaultStatistics[2],
|
...defaultStatistics[2],
|
||||||
currentCount: keyProjectData.morePeopleStartCount,
|
currentCount: keyProjectData?.morePeopleStartCount,
|
||||||
applyCount: keyProjectData.morePeopleApplyCount,
|
applyCount: keyProjectData?.morePeopleApplyCount,
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,13 @@ function FireAlarmRecordPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
|
const { data } = await props.getAlarmRecordScreenIotDeviceAlarmPage({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@ function FireDeviceStatusPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = {} } = await props.getSensorDeviceFireSituation({
|
const { data } = await props.getSensorDeviceFireSituation({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
});
|
});
|
||||||
setData({
|
setData({
|
||||||
totalCount: data.totalCount || 0,
|
totalCount: data?.totalCount || 0,
|
||||||
statusList: data.statusList || [],
|
statusList: data?.statusList || [],
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,13 @@ function VolunteerFireTeamPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getFireBrigadeMemberScreenList({
|
const { data } = await props.getFireBrigadeMemberScreenList({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -159,13 +159,13 @@ function ContractProjectPanel(props) {
|
||||||
|
|
||||||
useMount(() => {
|
useMount(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getProjectContractProjectStatistics({
|
const { data } = await props.getProjectContractProjectStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
initEcharts(chartRef, chartInstance, data);
|
initEcharts(chartRef, chartInstance, data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,21 +15,21 @@ function MobileMonitoringPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
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) {
|
||||||
setPlayUrl(data.url);
|
setPlayUrl(data?.url || "");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const loadCamera = async () => {
|
const loadCamera = async () => {
|
||||||
const { data = [] } = await props.getFixedCameraVideoInfoPage({
|
const { data } = await props.getFixedCameraVideoInfoPage({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
if (data.length) {
|
if (data?.length) {
|
||||||
loadPlayUrl(data[Math.floor(randoms(0, data.length - 1))].cameraNumber);
|
loadPlayUrl(data[Math.floor(randoms(0, data.length - 1))].cameraNumber);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ function ProjectProgressPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getKeyProjectLargeScreenProjectProgress({
|
const { data } = await props.getKeyProjectLargeScreenProjectProgress({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,14 @@ function ProjectStatsPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = {} } = await props.getProjectVisualProjectStatistics({
|
const { data } = await props.getProjectVisualProjectStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
corpinfoId: currentBranchOffice,
|
corpinfoId: currentBranchOffice,
|
||||||
});
|
});
|
||||||
setData([
|
setData([
|
||||||
{ ...defaultStatistics[0], value: data.totalProjectCount },
|
{ ...defaultStatistics[0], value: data?.totalProjectCount },
|
||||||
{ ...defaultStatistics[1], value: data.pendingProjectCount },
|
{ ...defaultStatistics[1], value: data?.pendingProjectCount },
|
||||||
{ ...defaultStatistics[2], value: data.executingProjectCount },
|
{ ...defaultStatistics[2], value: data?.executingProjectCount },
|
||||||
]);
|
]);
|
||||||
};
|
};
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,8 @@ const KeyProject = (props) => {
|
||||||
const [info, setInfo] = useState({});
|
const [info, setInfo] = useState({});
|
||||||
|
|
||||||
const getData = async () => {
|
const getData = async () => {
|
||||||
const { data = {} } = await props.keyProjectInfo({ id: props.id });
|
const { data } = await props.keyProjectInfo({ id: props.id });
|
||||||
console.log(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: data.keyProjectId,
|
||||||
|
|
|
||||||
|
|
@ -24,11 +24,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 counts = [
|
const counts = [
|
||||||
data.branchCorpCount,
|
data?.branchCorpCount,
|
||||||
data.relatedCorpCount,
|
data?.relatedCorpCount,
|
||||||
data.userCount,
|
data?.userCount,
|
||||||
];
|
];
|
||||||
|
|
||||||
setData(
|
setData(
|
||||||
|
|
|
||||||
|
|
@ -20,13 +20,13 @@ function PersonnelStatsPanel(props) {
|
||||||
|
|
||||||
const loadData = async (enterpriseType) => {
|
const loadData = async (enterpriseType) => {
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
const { data = [] } = await props.getCorpInfoCorpUserStatisticPage({
|
const { data } = await props.getCorpInfoCorpUserStatisticPage({
|
||||||
portArea,
|
portArea,
|
||||||
enterpriseType,
|
enterpriseType,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,9 @@ function RiskStatsPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = 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]),
|
||||||
);
|
);
|
||||||
|
|
||||||
setData(
|
setData(
|
||||||
|
|
|
||||||
|
|
@ -21,11 +21,11 @@ function GateStatsPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getPrimeportMkmjStatistics({ portArea });
|
const { data } = await props.getPrimeportMkmjStatistics({ portArea });
|
||||||
|
|
||||||
// 根据固定区域模板重新生成状态,避免直接修改 React 保存的上一轮统计数据。
|
// 根据固定区域模板重新生成状态,避免直接修改 React 保存的上一轮统计数据。
|
||||||
setData(statistics.map((item) => {
|
setData(statistics.map((item) => {
|
||||||
const currentStatistics = data.find(statisticsItem => statisticsItem.areaType === item.areaType) || {};
|
const currentStatistics = (data || []).find(statisticsItem => statisticsItem.areaType === item.areaType) || {};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,12 @@ function WorkRecordPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getEightWorkInfoScreenWorkRecord({
|
const { data } = await props.getEightWorkInfoScreenWorkRecord({
|
||||||
portArea,
|
portArea,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,13 @@ function WorkStatusPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = {} } = await props.getEightWorkInfoScreenStatusStatistics({
|
const { data } = await props.getEightWorkInfoScreenStatusStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
});
|
});
|
||||||
const counts = [
|
const counts = [
|
||||||
data.appliedCount,
|
data?.appliedCount,
|
||||||
data.approvingCount,
|
data?.approvingCount,
|
||||||
data.archivedCount,
|
data?.archivedCount,
|
||||||
];
|
];
|
||||||
setData(
|
setData(
|
||||||
defaultStatistics.map((item, index) => ({
|
defaultStatistics.map((item, index) => ({
|
||||||
|
|
|
||||||
|
|
@ -115,10 +115,10 @@ function WorkTrendPanel(props) {
|
||||||
|
|
||||||
useMount(() => {
|
useMount(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = [] } = await props.getEightWorkInfoScreenWorkTrend({
|
const { data } = await props.getEightWorkInfoScreenWorkTrend({
|
||||||
portArea,
|
portArea,
|
||||||
});
|
});
|
||||||
initEcharts(chartRef, chartInstance, formatWorkTrendData(data));
|
initEcharts(chartRef, chartInstance, formatWorkTrendData(data || []));
|
||||||
};
|
};
|
||||||
|
|
||||||
loadData();
|
loadData();
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@ function FireDeviceListPanel(props) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
setIsVisible(false);
|
setIsVisible(false);
|
||||||
const { data = [] } = await props.getFirePointDeviceList({
|
const { data } = await props.getFirePointDeviceList({
|
||||||
portArea,
|
portArea,
|
||||||
...queryParams,
|
...queryParams,
|
||||||
pageIndex: 1,
|
pageIndex: 1,
|
||||||
pageSize: 9999,
|
pageSize: 9999,
|
||||||
});
|
});
|
||||||
setData(data);
|
setData(data || []);
|
||||||
setIsVisible(true);
|
setIsVisible(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,10 +23,10 @@ function KeyProjectPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = {} } = await props.getKeyProjectLargeScreenProjectStatistics({
|
const { data } = await props.getKeyProjectLargeScreenProjectStatistics({
|
||||||
portArea,
|
portArea,
|
||||||
});
|
});
|
||||||
const counts = [data.totalProjectCount, data.startCount];
|
const counts = [data?.totalProjectCount, data?.startCount];
|
||||||
setData(
|
setData(
|
||||||
defaultStatistics.map((item, index) => ({
|
defaultStatistics.map((item, index) => ({
|
||||||
...item,
|
...item,
|
||||||
|
|
|
||||||
|
|
@ -21,10 +21,10 @@ function VideoLocationPanel(props) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const loadData = async () => {
|
const loadData = async () => {
|
||||||
const { data = {} } = await props.getFixedCameraVideoLocationStat({
|
const { data } = await props.getFixedCameraVideoLocationStat({
|
||||||
portArea,
|
portArea,
|
||||||
});
|
});
|
||||||
const counts = [data.totalCount, data.onlineCount, data.offlineCount];
|
const counts = [data?.totalCount, data?.onlineCount, data?.offlineCount];
|
||||||
setData(
|
setData(
|
||||||
defaultStatistics.map((item, index) => ({
|
defaultStatistics.map((item, index) => ({
|
||||||
...item,
|
...item,
|
||||||
|
|
|
||||||
|
|
@ -132,8 +132,8 @@ export default function useMapMethods(viewerRef, request) {
|
||||||
const addBranchOfficePoint = async (portArea = "", pointInfo = null) => {
|
const addBranchOfficePoint = async (portArea = "", pointInfo = null) => {
|
||||||
let requestData = [];
|
let requestData = [];
|
||||||
if (!pointInfo) {
|
if (!pointInfo) {
|
||||||
const { data = [] } = await request.getCorpInfoListAll({ eqPortArea: portArea, inType: [0, 1, 2, 6] });
|
const { data } = await request.getCorpInfoListAll({ eqPortArea: portArea, inType: [0, 1, 2, 6] });
|
||||||
requestData = data;
|
requestData = data || [];
|
||||||
}
|
}
|
||||||
mitt.emit(changeCoverMaskVisibleMittKey, true);
|
mitt.emit(changeCoverMaskVisibleMittKey, true);
|
||||||
let branchOfficePoint = [];
|
let branchOfficePoint = [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue