From 97792143b0e6689a1a67c0c4d88f5f9c85dc03f3 Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Thu, 23 Jul 2026 15:34:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(data):=20=E7=BB=9F=E4=B8=80=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E5=91=BD=E5=90=8D=E5=B9=B6=E4=BC=98=E5=8C=96=E5=BC=82?= =?UTF-8?q?=E6=AD=A5=E5=8A=A0=E8=BD=BD=E5=87=BD=E6=95=B0=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将多个组件中的状态变量统一命名为data,替代原有的records、statistics、list等命名 - 将异步加载函数名统一修改为loadData,提高代码一致性和可读性 - 修改相关组件渲染部分变量引用,确保渲染数据源正确 - 优化useEffect及useMount中异步函数调用名称,增强代码规范性 - 涉及组件包括branchOffice、IndexInfo、port等多个子模块,全面提升代码风格统一性 --- .../IndexInfo/Bottom/RecordStatsPanel/index.js | 12 ++++++------ .../LeftPanel/RectificationPanel/index.js | 12 ++++++------ .../IndexInfo/LeftPanel/WorkStatusPanel/index.js | 4 ++-- .../IndexInfo/RightPanel/AlarmPanel/index.js | 12 ++++++------ .../IndexInfo/RightPanel/PartnerPanel/index.js | 12 ++++++------ .../IndexInfo/RightPanel/WorkPanel/index.js | 10 +++++----- .../IndexLeft/WeatherPreventionPanel/index.js | 4 ++-- .../IndexRight/AreaAlarmPanel/index.js | 12 ++++++------ .../IndexRight/KeyWorkStatsPanel/index.js | 12 ++++++------ .../QiXiang/WeatherPreventionPanel/index.js | 4 ++-- .../WeiXian/DangerWorkDataPanel/index.js | 12 ++++++------ .../WeiXian/DepartmentWorkPanel/index.js | 12 ++++++------ .../branchOffice/WeiXian/KeyWorkPanel/index.js | 10 +++++----- .../WeiXian/KeyWorkStatsPanel/index.js | 10 +++++----- .../XiaoFang/FireAlarmRecordPanel/index.js | 12 ++++++------ .../XiaoFang/FireDeviceStatusPanel/index.js | 12 ++++++------ .../XiaoFang/VolunteerFireTeamPanel/index.js | 12 ++++++------ .../ZhongDian/ContractProjectPanel/index.js | 4 ++-- .../ZhongDian/ProjectProgressPanel/index.js | 12 ++++++------ .../ZhongDian/ProjectStatsPanel/index.js | 10 +++++----- .../Content/port/Index/BasicInfoPanel/index.js | 10 +++++----- .../port/Index/PersonnelStatsPanel/index.js | 14 +++++++------- .../Content/port/Index/RiskStatsPanel/index.js | 10 +++++----- .../Content/port/WeiXian/WorkRecordPanel/index.js | 12 ++++++------ .../Content/port/WeiXian/WorkStatusPanel/index.js | 10 +++++----- .../Content/port/WeiXian/WorkTrendPanel/index.js | 4 ++-- .../port/XiaoFang/FireDeviceListPanel/index.js | 12 ++++++------ .../port/ZhongDian/KeyProjectPanel/index.js | 10 +++++----- .../port/ZhongDian/VideoLocationPanel/index.js | 10 +++++----- 29 files changed, 146 insertions(+), 146 deletions(-) diff --git a/src/pages/Container/Map/components/Content/IndexInfo/Bottom/RecordStatsPanel/index.js b/src/pages/Container/Map/components/Content/IndexInfo/Bottom/RecordStatsPanel/index.js index a6f02ba..554fe1e 100644 --- a/src/pages/Container/Map/components/Content/IndexInfo/Bottom/RecordStatsPanel/index.js +++ b/src/pages/Container/Map/components/Content/IndexInfo/Bottom/RecordStatsPanel/index.js @@ -9,14 +9,14 @@ import "./index.less"; /** 负责查询并展示相关方单位备案和项目执行统计。 */ function RecordStatsPanel(props) { - const [list, setList] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadList = async () => { + const loadData = async () => { const { data = [] } = await props.getXgfStatisticsListRecordProjectStatistics(); - setList(data); + setData(data); }; - loadList(); + loadData(); }, []); return ( 人员培训情况统计
- - {list.map((item, index) => ( + + {data.map((item, index) => (
{item.qualificationsTypeName}
{item.managerDeptName}
diff --git a/src/pages/Container/Map/components/Content/IndexInfo/LeftPanel/RectificationPanel/index.js b/src/pages/Container/Map/components/Content/IndexInfo/LeftPanel/RectificationPanel/index.js index 294f47e..890b22d 100644 --- a/src/pages/Container/Map/components/Content/IndexInfo/LeftPanel/RectificationPanel/index.js +++ b/src/pages/Container/Map/components/Content/IndexInfo/LeftPanel/RectificationPanel/index.js @@ -10,17 +10,17 @@ import "./index.less"; /** 负责查询并展示各公司隐患整改统计。 */ function RectificationPanel(props) { - const [list, setList] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadList = async () => { + const loadData = async () => { const { data = [] } = await props.getHiddenStatisticsByCorp({ pageIndex: 1, pageSize: 9999, }); - setList(data); + setData(data); }; - loadList(); + loadData(); }, []); return ( 待验收
- - {list.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadChartData = async () => { + const loadData = async () => { const { data = [] } = await props.getProjectTaskScoreCount(); initEcharts(chartRef, chartInstance, data); }; - loadChartData(); + loadData(); return () => chartInstance.current?.dispose(); }); diff --git a/src/pages/Container/Map/components/Content/IndexInfo/RightPanel/AlarmPanel/index.js b/src/pages/Container/Map/components/Content/IndexInfo/RightPanel/AlarmPanel/index.js index df58f1a..02d3ed2 100644 --- a/src/pages/Container/Map/components/Content/IndexInfo/RightPanel/AlarmPanel/index.js +++ b/src/pages/Container/Map/components/Content/IndexInfo/RightPanel/AlarmPanel/index.js @@ -10,17 +10,17 @@ import "./index.less"; /** 负责查询并展示物联网设备报警记录。 */ function AlarmPanel(props) { - const [list, setList] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadList = async () => { + const loadData = async () => { const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage({ pageIndex: 1, pageSize: 9999, }); - setList(data); + setData(data); }; - loadList(); + loadData(); }, []); return ( @@ -36,8 +36,8 @@ function AlarmPanel(props) {
处置状态
- - {list.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadList = async () => { + const loadData = async () => { const { data = [] } = await props.getXgfStatisticsListCorpStatistics({ pageIndex: 1, pageSize: 9999, }); - setList(data); + setData(data); }; - loadList(); + loadData(); }, []); return ( 执行人员情况
- - {list.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadStatistics = async () => { + const loadData = async () => { const [{ data: eightWorkData = [] }, { data: keyProjectData = [] }] = await Promise.all([ props.getEightWorkInfoDangerWorkStatistics(), props.getKeyProjectLargeScreenStatistics(), ]); - setList((prevState) => { + setData((prevState) => { prevState[1].doingCount = eightWorkData.doingCount; prevState[1].appliedCount = eightWorkData.appliedCount; @@ -50,13 +50,13 @@ function WorkPanel(props) { }); }; - loadStatistics(); + loadData(); }, []); return (
- {list.map(item => ( + {data.map(item => (
diff --git a/src/pages/Container/Map/components/Content/branchOffice/IndexLeft/WeatherPreventionPanel/index.js b/src/pages/Container/Map/components/Content/branchOffice/IndexLeft/WeatherPreventionPanel/index.js index 77f174c..9776510 100644 --- a/src/pages/Container/Map/components/Content/branchOffice/IndexLeft/WeatherPreventionPanel/index.js +++ b/src/pages/Container/Map/components/Content/branchOffice/IndexLeft/WeatherPreventionPanel/index.js @@ -28,12 +28,12 @@ function WeatherPreventionPanel(props) { const [alerts, setAlerts] = useState([]); useEffect(() => { - const loadWeather = async () => { + const loadData = async () => { const { result = {} } = await props.getWeather(); setWeather(result.now || {}); setAlerts(Array.isArray(result.alerts) ? result.alerts : []); }; - loadWeather(); + loadData(); }, []); return ( diff --git a/src/pages/Container/Map/components/Content/branchOffice/IndexRight/AreaAlarmPanel/index.js b/src/pages/Container/Map/components/Content/branchOffice/IndexRight/AreaAlarmPanel/index.js index cc422c1..11eee07 100644 --- a/src/pages/Container/Map/components/Content/branchOffice/IndexRight/AreaAlarmPanel/index.js +++ b/src/pages/Container/Map/components/Content/branchOffice/IndexRight/AreaAlarmPanel/index.js @@ -12,19 +12,19 @@ const disposalStatus = { 10: "报警中", 20: "未处置", 30: "已消警" }; /** 负责查询并滚动展示封闭区域告警。 */ function AreaAlarmPanel(props) { const { portArea, currentBranchOffice } = useContext(Context); - const [records, setRecords] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadRecords = async () => { + const loadData = async () => { const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999, }); - setRecords(data); + setData(data); }; - loadRecords(); + loadData(); }, []); return ( @@ -43,8 +43,8 @@ function AreaAlarmPanel(props) { props.biStatistics.getAlarmRecordScreenIotDeviceAlarmPageLoading } > - - {records.map((item, index) => ( + + {data.map((item, index) => (
{item.fireRegionName}
{item.alarmTypeName}
diff --git a/src/pages/Container/Map/components/Content/branchOffice/IndexRight/KeyWorkStatsPanel/index.js b/src/pages/Container/Map/components/Content/branchOffice/IndexRight/KeyWorkStatsPanel/index.js index a071142..73f0d47 100644 --- a/src/pages/Container/Map/components/Content/branchOffice/IndexRight/KeyWorkStatsPanel/index.js +++ b/src/pages/Container/Map/components/Content/branchOffice/IndexRight/KeyWorkStatsPanel/index.js @@ -10,10 +10,10 @@ import "./index.less"; /** 负责合并两类作业统计并展示部门维度数据。 */ function KeyWorkStatsPanel(props) { const { portArea, currentBranchOffice } = useContext(Context); - const [records, setRecords] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadRecords = async () => { + const loadData = async () => { const [{ data: eightWorkData = [] }, { data: keyProjectData = [] }] = await Promise.all([ props.getEightWorkInfoScreenDepartmentStatistics({ @@ -46,9 +46,9 @@ function KeyWorkStatsPanel(props) { department.eightWorkCount = item.workCount || 0; departmentMap.set(item.departmentId, department); }); - setRecords([...departmentMap.values()]); + setData([...departmentMap.values()]); }; - loadRecords(); + loadData(); }, []); return ( @@ -73,8 +73,8 @@ function KeyWorkStatsPanel(props) { .getEightWorkInfoScreenDepartmentStatisticsLoading } > - - {records.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadWeather = async () => { + const loadData = async () => { const { result = {} } = await props.getWeather(); setWeather(result.now || {}); setAlerts(Array.isArray(result.alerts) ? result.alerts : []); }; - loadWeather(); + loadData(); }, []); return ( diff --git a/src/pages/Container/Map/components/Content/branchOffice/WeiXian/DangerWorkDataPanel/index.js b/src/pages/Container/Map/components/Content/branchOffice/WeiXian/DangerWorkDataPanel/index.js index 33332a4..df33b7f 100644 --- a/src/pages/Container/Map/components/Content/branchOffice/WeiXian/DangerWorkDataPanel/index.js +++ b/src/pages/Container/Map/components/Content/branchOffice/WeiXian/DangerWorkDataPanel/index.js @@ -10,17 +10,17 @@ import "./index.less"; /** 负责查询并展示危险作业类别、状态及参与人数统计。 */ function DangerWorkDataPanel(props) { const { portArea, currentBranchOffice } = useContext(Context); - const [records, setRecords] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadRecords = async () => { + const loadData = async () => { const { data = [] } = await props.getEightWorkInfoScreenDangerWorkDataStatistics({ portArea, corpinfoId: currentBranchOffice, }); - setRecords(data); + setData(data); }; - loadRecords(); + loadData(); }, []); return ( @@ -39,8 +39,8 @@ function DangerWorkDataPanel(props) { .getEightWorkInfoScreenDangerWorkDataStatisticsLoading } > - - {records.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadRecords = async () => { + const loadData = async () => { const [{ data: eightWorkData = [] }, { data: keyProjectData = [] }] = await Promise.all([ props.getEightWorkInfoScreenDepartmentStatistics({ @@ -45,9 +45,9 @@ function DepartmentWorkPanel(props) { department.eightWorkCount = item.workCount || 0; departmentMap.set(item.departmentId, department); }); - setRecords([...departmentMap.values()]); + setData([...departmentMap.values()]); }; - loadRecords(); + loadData(); }, []); return ( - - {records.map((item, index) => ( + + {data.map((item, index) => (
{item.departmentName}
{item.fourNewHomeworkCount}
diff --git a/src/pages/Container/Map/components/Content/branchOffice/WeiXian/KeyWorkPanel/index.js b/src/pages/Container/Map/components/Content/branchOffice/WeiXian/KeyWorkPanel/index.js index 525ba5b..4e2fdfb 100644 --- a/src/pages/Container/Map/components/Content/branchOffice/WeiXian/KeyWorkPanel/index.js +++ b/src/pages/Container/Map/components/Content/branchOffice/WeiXian/KeyWorkPanel/index.js @@ -51,9 +51,9 @@ const defaultStatistics = [ /** 负责查询并展示各重点作业的执行状态。 */ function KeyWorkPanel(props) { const { portArea, currentBranchOffice } = useContext(Context); - const [statistics, setStatistics] = useState(defaultStatistics); + const [data, setData] = useState(defaultStatistics); useEffect(() => { - const loadStatistics = async () => { + const loadData = async () => { const [{ data: eightWorkData = {} }, { data: keyProjectData = {} }] = await Promise.all([ props.getEightWorkInfoDangerWorkStatistics({ @@ -65,7 +65,7 @@ function KeyWorkPanel(props) { corpinfoId: currentBranchOffice, }), ]); - setStatistics([ + setData([ { ...defaultStatistics[0], currentCount: keyProjectData.fourNewHomeworkStartCount, @@ -86,7 +86,7 @@ function KeyWorkPanel(props) { }, ]); }; - loadStatistics(); + loadData(); }, []); return ( @@ -97,7 +97,7 @@ function KeyWorkPanel(props) { } >
- {statistics.map((item, index) => ( + {data.map((item, index) => (
{ - const loadStatistics = async () => { + const loadData = async () => { const [{ data: eightWorkData = {} }, { data: keyProjectData = {} }] = await Promise.all([ props.getEightWorkInfoDangerWorkStatistics({ @@ -39,7 +39,7 @@ function KeyWorkStatsPanel(props) { corpinfoId: currentBranchOffice, }), ]); - setStatistics([ + setData([ { ...defaultStatistics[0], currentCount: keyProjectData.fourNewHomeworkStartCount, @@ -57,7 +57,7 @@ function KeyWorkStatsPanel(props) { }, ]); }; - loadStatistics(); + loadData(); }, []); return ( @@ -69,7 +69,7 @@ function KeyWorkStatsPanel(props) { } >
- {statistics.map(item => ( + {data.map(item => (
{ - const loadRecords = async () => { + const loadData = async () => { const { data = [] } = await props.getAlarmRecordScreenIotDeviceAlarmPage({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999, }); - setRecords(data); + setData(data); }; - loadRecords(); + loadData(); }, []); return ( @@ -44,8 +44,8 @@ function FireAlarmRecordPanel(props) { props.biStatistics.getAlarmRecordScreenIotDeviceAlarmPageLoading } > - - {records.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadStatistics = async () => { + const loadData = async () => { const { data = {} } = await props.getSensorDeviceFireSituation({ portArea, corpinfoId: currentBranchOffice, }); - setStatistics({ + setData({ totalCount: data.totalCount || 0, statusList: data.statusList || [], }); }; - loadStatistics(); + loadData(); }, []); return ( @@ -42,12 +42,12 @@ function FireDeviceStatusPanel(props) {
设备总数 - {statistics.totalCount} + {data.totalCount}
- {statistics.statusList.map(item => ( + {data.statusList.map(item => (
{ - const loadRecords = async () => { + const loadData = async () => { const { data = [] } = await props.getFireBrigadeMemberScreenList({ portArea, corpinfoId: currentBranchOffice, pageIndex: 1, pageSize: 9999, }); - setRecords(data); + setData(data); }; - loadRecords(); + loadData(); }, []); return ( @@ -40,8 +40,8 @@ function VolunteerFireTeamPanel(props) {
- - {records.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadContractProjects = async () => { + const loadData = async () => { const { data = [] } = await props.getProjectContractProjectStatistics({ portArea, corpinfoId: currentBranchOffice, @@ -167,7 +167,7 @@ function ContractProjectPanel(props) { }); initEcharts(chartRef, chartInstance, data); }; - loadContractProjects(); + loadData(); return () => { if (chartInstance.current) { diff --git a/src/pages/Container/Map/components/Content/branchOffice/ZhongDian/ProjectProgressPanel/index.js b/src/pages/Container/Map/components/Content/branchOffice/ZhongDian/ProjectProgressPanel/index.js index e851f18..08ac1bc 100644 --- a/src/pages/Container/Map/components/Content/branchOffice/ZhongDian/ProjectProgressPanel/index.js +++ b/src/pages/Container/Map/components/Content/branchOffice/ZhongDian/ProjectProgressPanel/index.js @@ -10,17 +10,17 @@ import "./index.less"; /** 负责查询并滚动展示项目检查、隐患和处罚数据。 */ function ProjectProgressPanel(props) { const { portArea, currentBranchOffice } = useContext(Context); - const [records, setRecords] = useState([]); + const [data, setData] = useState([]); useEffect(() => { - const loadRecords = async () => { + const loadData = async () => { const { data = [] } = await props.getKeyProjectLargeScreenProjectProgress({ portArea, corpinfoId: currentBranchOffice, }); - setRecords(data); + setData(data); }; - loadRecords(); + loadData(); }, []); return ( @@ -38,8 +38,8 @@ function ProjectProgressPanel(props) { - - {records.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadStatistics = async () => { + const loadData = async () => { const { data = {} } = await props.getProjectVisualProjectStatistics({ portArea, corpinfoId: currentBranchOffice, }); - setStatistics([ + setData([ { ...defaultStatistics[0], value: data.totalProjectCount }, { ...defaultStatistics[1], value: data.pendingProjectCount }, { ...defaultStatistics[2], value: data.executingProjectCount }, ]); }; - loadStatistics(); + loadData(); }, []); return ( @@ -39,7 +39,7 @@ function ProjectStatsPanel(props) {
- {statistics.map(item => ( + {data.map(item => (
{ - const loadStatistics = async () => { + const loadData = async () => { const { data = {} } = await props.getCorpInfoCorpUserSummary({ portArea }); const counts = [ data.branchCorpCount, @@ -31,7 +31,7 @@ function BasicInfoPanel(props) { data.userCount, ]; - setStatistics( + setData( defaultStatistics.map((item, index) => ({ ...item, count: counts[index], @@ -39,14 +39,14 @@ function BasicInfoPanel(props) { ); }; - loadStatistics(); + loadData(); }, []); return (
- {statistics.map(item => ( + {data.map(item => (
{ + const loadData = async (enterpriseType) => { setIsVisible(false); const { data = [] } = await props.getCorpInfoCorpUserStatisticPage({ portArea, @@ -26,7 +26,7 @@ function PersonnelStatsPanel(props) { pageIndex: 1, pageSize: 9999, }); - setStatistics(data); + setData(data); setIsVisible(true); }; @@ -35,11 +35,11 @@ function PersonnelStatsPanel(props) { return; setActiveTab(index); - loadStatistics(index === 0 ? 2 : 3); + loadData(index === 0 ? 2 : 3); }; useEffect(() => { - loadStatistics(2); + loadData(2); }, []); return ( @@ -68,8 +68,8 @@ function PersonnelStatsPanel(props) {
{isVisible && ( - - {statistics.map((item, index) => ( + + {data.map((item, index) => (
{item.corpName} diff --git a/src/pages/Container/Map/components/Content/port/Index/RiskStatsPanel/index.js b/src/pages/Container/Map/components/Content/port/Index/RiskStatsPanel/index.js index df67be3..14be10a 100644 --- a/src/pages/Container/Map/components/Content/port/Index/RiskStatsPanel/index.js +++ b/src/pages/Container/Map/components/Content/port/Index/RiskStatsPanel/index.js @@ -47,16 +47,16 @@ const defaultStatistics = [ /** 负责查询并展示不同风险等级的风险点数量。 */ function RiskStatsPanel(props) { const { portArea } = useContext(Context); - const [statistics, setStatistics] = useState(defaultStatistics); + const [data, setData] = useState(defaultStatistics); useEffect(() => { - const loadStatistics = async () => { + const loadData = async () => { const { data = [] } = await props.getRiskPointCorpRiskLevel({ portArea }); const countByLevel = Object.fromEntries( data.map(item => [item.level, item.count]), ); - setStatistics( + setData( defaultStatistics.map(item => ({ ...item, count: countByLevel[item.level] || 0, @@ -64,14 +64,14 @@ function RiskStatsPanel(props) { ); }; - loadStatistics(); + loadData(); }, []); return (
- {statistics.map(item => ( + {data.map(item => (
{ - const loadRecords = async () => { + const loadData = async () => { const { data = [] } = await props.getEightWorkInfoScreenWorkRecord({ portArea, pageIndex: 1, pageSize: 9999, }); - setRecords(data); + setData(data); }; - loadRecords(); + loadData(); }, []); return ( @@ -39,8 +39,8 @@ function WorkRecordPanel(props) {
- - {records.map((item, index) => ( + + {data.map((item, index) => (
{ - const loadStatistics = async () => { + const loadData = async () => { const { data = {} } = await props.getEightWorkInfoScreenStatusStatistics({ portArea, }); @@ -33,7 +33,7 @@ function WorkStatusPanel(props) { data.approvingCount, data.archivedCount, ]; - setStatistics( + setData( defaultStatistics.map((item, index) => ({ ...item, count: counts[index], @@ -41,14 +41,14 @@ function WorkStatusPanel(props) { ); }; - loadStatistics(); + loadData(); }, []); return (
- {statistics.map(item => ( + {data.map(item => (
{ - const loadTrendData = async () => { + const loadData = async () => { const { data = [] } = await props.getEightWorkInfoScreenWorkTrend({ portArea, }); initEcharts(chartRef, chartInstance, formatWorkTrendData(data)); }; - loadTrendData(); + loadData(); return () => chartInstance.current?.dispose(); }); diff --git a/src/pages/Container/Map/components/Content/port/XiaoFang/FireDeviceListPanel/index.js b/src/pages/Container/Map/components/Content/port/XiaoFang/FireDeviceListPanel/index.js index 51f6a7a..30f75fd 100644 --- a/src/pages/Container/Map/components/Content/port/XiaoFang/FireDeviceListPanel/index.js +++ b/src/pages/Container/Map/components/Content/port/XiaoFang/FireDeviceListPanel/index.js @@ -11,11 +11,11 @@ import "./index.less"; function FireDeviceListPanel(props) { const { portArea } = useContext(Context); const { queryParams } = props; - const [deviceList, setDeviceList] = useState([]); + const [data, setData] = useState([]); const [isVisible, setIsVisible] = useState(true); useEffect(() => { - const loadDeviceList = async () => { + const loadData = async () => { setIsVisible(false); const { data = [] } = await props.getFirePointDeviceList({ portArea, @@ -23,11 +23,11 @@ function FireDeviceListPanel(props) { pageIndex: 1, pageSize: 9999, }); - setDeviceList(data); + setData(data); setIsVisible(true); }; - loadDeviceList(); + loadData(); }, [queryParams]); return ( @@ -42,8 +42,8 @@ function FireDeviceListPanel(props) {
{isVisible && ( - - {deviceList.map((item, index) => ( + + {data.map((item, index) => (
{item.firePointName} diff --git a/src/pages/Container/Map/components/Content/port/ZhongDian/KeyProjectPanel/index.js b/src/pages/Container/Map/components/Content/port/ZhongDian/KeyProjectPanel/index.js index 07481a4..cbbaafc 100644 --- a/src/pages/Container/Map/components/Content/port/ZhongDian/KeyProjectPanel/index.js +++ b/src/pages/Container/Map/components/Content/port/ZhongDian/KeyProjectPanel/index.js @@ -19,15 +19,15 @@ const defaultStatistics = [ /** 负责查询并展示重点工程总量与开工数量。 */ function KeyProjectPanel(props) { const { portArea } = useContext(Context); - const [statistics, setStatistics] = useState(defaultStatistics); + const [data, setData] = useState(defaultStatistics); useEffect(() => { - const loadStatistics = async () => { + const loadData = async () => { const { data = {} } = await props.getKeyProjectLargeScreenProjectStatistics({ portArea, }); const counts = [data.totalProjectCount, data.startCount]; - setStatistics( + setData( defaultStatistics.map((item, index) => ({ ...item, count: counts[index], @@ -35,14 +35,14 @@ function KeyProjectPanel(props) { ); }; - loadStatistics(); + loadData(); }, []); return (
- {statistics.map(item => ( + {data.map(item => (
{ - const loadStatistics = async () => { + const loadData = async () => { const { data = {} } = await props.getFixedCameraVideoLocationStat({ portArea, }); const counts = [data.totalCount, data.onlineCount, data.offlineCount]; - setStatistics( + setData( defaultStatistics.map((item, index) => ({ ...item, count: counts[index], @@ -33,7 +33,7 @@ function VideoLocationPanel(props) { ); }; - loadStatistics(); + loadData(); }, []); return ( @@ -46,7 +46,7 @@ function VideoLocationPanel(props) { style={{ backgroundImage: `url(${videoBackground})` }} />
- {statistics.map(item => ( + {data.map(item => (