From 451fa80126be236eb059e2e2a0c49a5c46ef8783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98lijianhao=E2=80=99?= Date: Mon, 25 Jul 2022 21:39:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../footer/conserve/action/index.js | 12 +++++- .../footer/conserve/chart/pie-chart.js | 4 +- .../containers/footer/conserve/index.js | 8 +++- .../footer/conserve/left/left-bottom.js | 5 --- .../containers/footer/conserve/right.js | 4 +- .../footer/conserve/right/right-bottom.js | 43 +++++++++++++++---- 6 files changed, 55 insertions(+), 21 deletions(-) diff --git a/web/client/src/sections/quanju/containers/footer/conserve/action/index.js b/web/client/src/sections/quanju/containers/footer/conserve/action/index.js index 09142754..aca6e2bc 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/action/index.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/action/index.js @@ -9,9 +9,19 @@ export function getHighways() { type: 'get', dispatch: dispatch, actionType: 'GET_HIGHWAYS', - url: `${ApiTable.getHighways}`, + url: ApiTable.getHighways, msg: { error: '获取路政列表失败' }, reducer: { name: 'highways' } }); } //获取道路养护统计及列表 +export function getRoadMaintenances() { + return dispatch => basicAction({ + type: 'get', + dispatch: dispatch, + actionType: 'GET_ROAD_MAINTENANCES', + url: ApiTable.getRoadMaintenance, + msg: { error: '获取道路养护列表失败' }, + reducer: { name: 'RoadMaintenances' } + }); +} diff --git a/web/client/src/sections/quanju/containers/footer/conserve/chart/pie-chart.js b/web/client/src/sections/quanju/containers/footer/conserve/chart/pie-chart.js index 2f3348a7..75ec1b77 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/chart/pie-chart.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/chart/pie-chart.js @@ -43,13 +43,13 @@ const PieChart = (props) => { a: { color: '#E9F7FF', fontSize: 14, - padding:[0,10] + padding:[0,2] }, b: { fontSize: 16, fontFamily: 'YouSheBiaoTiHei', color: '#fff', - padding:[0,0,0,15] + padding:[0,0,0,10] }, } } diff --git a/web/client/src/sections/quanju/containers/footer/conserve/index.js b/web/client/src/sections/quanju/containers/footer/conserve/index.js index 93338e64..750f3285 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/index.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/index.js @@ -3,13 +3,14 @@ import Left from './left' import Right from './right' import { connect } from 'react-redux' import { getdaolutongji } from '../../../actions/example' -import { getHighways } from './action' +import { getHighways, getRoadMaintenances } from './action' const Conserve = (props) => { const [roadData, setRoadData] = useState() const [highwaysData, setHighwaysData] = useState() + const [roadMaintenances, setRoadMaintenances] = useState() const [loading, setLoading] = useState(true) const { dispatch } = props @@ -21,12 +22,15 @@ const Conserve = (props) => { dispatch(getHighways()).then(res =>{ setHighwaysData(res.payload.data || []) }) + dispatch(getRoadMaintenances()).then(res =>{ + setRoadMaintenances(res.payload.data || []) + }) }, []) return (
- +
) } diff --git a/web/client/src/sections/quanju/containers/footer/conserve/left/left-bottom.js b/web/client/src/sections/quanju/containers/footer/conserve/left/left-bottom.js index 5036f587..37394a3a 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/left/left-bottom.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/left/left-bottom.js @@ -2,11 +2,6 @@ import React from 'react' import Module from '../../../public/module' import PieChart from '../chart/pie-chart'; -let data = [ - { value: 435, name: "县道" }, - { value: 679, name: "乡道" }, - { value: 848, name: "村道" }, -] let colorList = [ "rgba(7,185,254,1)", "rgba(28,96,254,1)", diff --git a/web/client/src/sections/quanju/containers/footer/conserve/right.js b/web/client/src/sections/quanju/containers/footer/conserve/right.js index 2d5cfeaf..b96513e2 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/right.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/right.js @@ -4,12 +4,12 @@ import RightCenter from './right/right-center' import RightTop from './right/right-top' const Right = (props) => { - const { highwaysData } = props + const { highwaysData,roadMaintenances } = props return (
- +
) } diff --git a/web/client/src/sections/quanju/containers/footer/conserve/right/right-bottom.js b/web/client/src/sections/quanju/containers/footer/conserve/right/right-bottom.js index 744165df..919bcdc0 100644 --- a/web/client/src/sections/quanju/containers/footer/conserve/right/right-bottom.js +++ b/web/client/src/sections/quanju/containers/footer/conserve/right/right-bottom.js @@ -2,12 +2,6 @@ import React from 'react' import Module from '../../../public/module' import PieChart from '../chart/pie-chart'; -let data = [ - { value: 435, name: "道路" }, - { value: 679, name: "桥梁" }, - { value: 848, name: "涵洞" }, - { value: 666, name: "其他" }, -] let colorList = [ "rgba(7,185,254,1)", "rgba(28,96,254,1)", @@ -20,18 +14,49 @@ let underColorList = [ "rgba(4,251,240,0.5)", "rgba(255,194,20,0.5)" ] -const RightBottom = () => { + +const type = ['road', 'culvert', 'bridge'] + +const RightBottom = (props) => { + const { roadMaintenances } = props + let totalData = null + let typesNum = null + const list = roadMaintenances?.reportCount?.map((r, index) => { + totalData += Number(r.count) + if (r.projectType === type[index]) { + typesNum += Number(r.count) + } + switch (r.projectType) { + case 'road': + return { + name: '道路', + value: r.count + }; + case 'culvert': + return { + name: '涵洞', + value: r.count + }; + case 'bridge': + return { + name: '桥梁', + value: r.count + } + } + }).filter(f => f !== undefined) + const otherNum = totalData - typesNum + otherNum !== null && list?.push({ name: '其他', value: otherNum }) const style = { height: "31%", marginTop: "3%" } return ( <> {/*
*/}