Browse Source

养护大屏部分数据接入

release_0.0.1
‘lijianhao’ 3 years ago
parent
commit
5cffe7c57f
  1. 7
      web/client/src/sections/organization/components/depModal.js
  2. 0
      web/client/src/sections/quanju/containers/footer/conserve/action/index.js
  3. 31
      web/client/src/sections/quanju/containers/footer/conserve/index.js
  4. 11
      web/client/src/sections/quanju/containers/footer/conserve/left.js
  5. 50
      web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js
  6. 40
      web/client/src/sections/quanju/containers/footer/conserve/left/left-top.js
  7. 9
      web/client/src/sections/quanju/containers/footer/conserve/right.js

7
web/client/src/sections/organization/components/depModal.js

@ -75,7 +75,12 @@ function mapStateToProps(state) {
title: d.name, title: d.name,
value: d.id, value: d.id,
// key: d.id, // key: d.id,
children: pakData(d.subordinate) children: d.subordinate.map(s => {
return {
title: s.name,
value: s.id,
}
})
} }
}) })
} }

0
web/client/src/sections/quanju/containers/footer/conserve/action/index.js

31
web/client/src/sections/quanju/containers/footer/conserve/index.js

@ -1,14 +1,35 @@
import React from 'react' import React, { useEffect, useState } from 'react'
import Left from './left' import Left from './left'
import Right from './right' import Right from './right'
import { connect } from 'react-redux'
import { getdaolutongji } from '../../../actions/example'
const Conserve = () => {
const Conserve = (props) => {
const [roadData, setRoadData] = useState()
const [loading, setLoading] = useState(true)
const { dispatch } = props
useEffect(() => {
dispatch(getdaolutongji()).then(res => {
setLoading(false)
setRoadData(res.payload.data || {})
})
}, [])
return ( return (
<div style={{ display: 'flex', width: '100%', height: '100%', justifyContent: 'space-between' }}> <div style={{ display: 'flex', width: '100%', height: '100%', justifyContent: 'space-between' }}>
<Left /> <Left roadData={roadData} loading={loading} />
<Right /> <Right roadData={roadData} loading={loading} />
</div> </div>
) )
} }
export default Conserve function mapStateToProps(state) {
// const { auth } = state;
return {
}
}
export default connect(mapStateToProps)(Conserve)

11
web/client/src/sections/quanju/containers/footer/conserve/left.js

@ -3,12 +3,13 @@ import LeftBottom from './left/left-bottom'
import LeftCenter from './left/left-center' import LeftCenter from './left/left-center'
import LeftTop from './left/left-top' import LeftTop from './left/left-top'
const Left = () => { const Left = (props) => {
const { roadData,loading } = props
return ( return (
<div style={{ display: 'flex',flexDirection: 'column', width: "23%", height: "100%", marginLeft: "1%" }}> <div style={{ display: 'flex', flexDirection: 'column', width: "23%", height: "100%", marginLeft: "1%" }}>
<LeftTop /> <LeftTop roadData={roadData} loading ={loading}/>
<LeftCenter /> <LeftCenter roadData={roadData} loading ={loading}/>
<LeftBottom /> <LeftBottom roadData={roadData} loading ={loading}/>
</div> </div>
) )
} }

50
web/client/src/sections/quanju/containers/footer/conserve/left/left-center.js

@ -4,9 +4,16 @@ import { useEffect, useRef } from 'react'
import Module from '../../../public/module' import Module from '../../../public/module'
import * as echarts from 'echarts'; import * as echarts from 'echarts';
const LeftCenter = () => { const LeftCenter = (props) => {
const style = { height: "31%", marginTop: "3%" } const style = { height: "31%", marginTop: "3%" }
const chartRef = useRef(null); const chartRef = useRef(null);
const { roadData } = props
const data = roadData?.greenMileage || {}
const grad = Object.keys(data).map(g => g + '级可绿化里程') || []
const value = Object.values(data)?.map(s => s.canBeGreen.toFixed(3))
let totalData = value?.reduce((pre, cur) => Number(pre) + Number(cur), 0) || 0
let max = Math.max.apply(Math, value) + 10 || 0
useEffect(() => { useEffect(() => {
let chartInstance = echarts.init(chartRef.current); let chartInstance = echarts.init(chartRef.current);
let colorArray = [ let colorArray = [
@ -34,9 +41,9 @@ const LeftCenter = () => {
grid: { grid: {
left: "5%", left: "5%",
top: "12%", top: "12%",
right: "5%", right: "1%",
bottom: "8%", bottom: "8%",
width:'92%', width: '100%',
containLabel: true, containLabel: true,
}, },
@ -46,6 +53,7 @@ const LeftCenter = () => {
position: "bottom", position: "bottom",
axisTick: { axisTick: {
show: true, show: true,
interval: 2,
lineStyle: { lineStyle: {
color: "rgba(176,215,255,0.25)", color: "rgba(176,215,255,0.25)",
// type: "dashed", // type: "dashed",
@ -57,6 +65,10 @@ const LeftCenter = () => {
color: "rgba(216,240,255,0.8000)", color: "rgba(216,240,255,0.8000)",
}, },
}, },
axisLabel: {
interval: 2
},
splitLine: { splitLine: {
show: true, show: true,
lineStyle: { lineStyle: {
@ -85,7 +97,7 @@ const LeftCenter = () => {
}, },
}, },
zlevel: 100, zlevel: 100,
data: ["县级可绿化里程", "乡级可绿化里程", "村级可绿化里程"], data: grad,
}, },
{ {
type: "category", type: "category",
@ -106,12 +118,12 @@ const LeftCenter = () => {
width: 70, width: 70,
height: 22, height: 22,
color: '#D8F0FF', color: '#D8F0FF',
margin:50, margin: 40,
verticalAlign: 'middle', verticalAlign: 'middle',
align: 'center', align: 'center',
textShadowColor:'#1AD0FF', textShadowColor: '#1AD0FF',
textShadowBlur:6, textShadowBlur: 6,
fontSize:14 fontSize: 14
// formatter:(f) =>{console.log('f:',f);} // formatter:(f) =>{console.log('f:',f);}
}, },
inverse: true, //排序 inverse: true, //排序
@ -122,7 +134,7 @@ const LeftCenter = () => {
}, },
}, },
data: [60, 132, 89], data: value,
}, },
], ],
series: [ series: [
@ -133,7 +145,7 @@ const LeftCenter = () => {
barGap: "100%", barGap: "100%",
barCategoryGap: "50%", barCategoryGap: "50%",
color: "#15356E", color: "#15356E",
data: [150, 150, 150, 150], data: [max, max, max],
tooltip: { tooltip: {
show: false, show: false,
}, },
@ -145,7 +157,7 @@ const LeftCenter = () => {
barWidth: 3, barWidth: 3,
barGap: "-100%", barGap: "-100%",
barCategoryGap: "50%", barCategoryGap: "50%",
data: [60, 132, 89], data: value,
label: { label: {
show: true, show: true,
position: 'right', // 位置 position: 'right', // 位置
@ -201,12 +213,12 @@ const LeftCenter = () => {
], ],
}; };
chartInstance.setOption(option); chartInstance.setOption(option);
window.addEventListener('resize',() =>{ window.addEventListener('resize', () => {
if(chartInstance) { if (chartInstance) {
chartInstance.resize() chartInstance.resize()
} }
}) })
}, []); }, [roadData]);
return ( return (
<> <>
@ -214,12 +226,12 @@ const LeftCenter = () => {
<Row align='middle' style={{ padding: '10px 3% 0px 15px' }}> <Row align='middle' style={{ padding: '10px 3% 0px 15px' }}>
<Col span={15}> <Col span={15}>
<img src='assets/images/quanju/kelvhua_icon.png' alt='icon' /> <img src='assets/images/quanju/kelvhua_icon.png' alt='icon' style={{ width: '26%' }} />
<span style={{ color: '#C2EEFF', marginLeft: 5 }}>可绿化里程总数</span> <span style={{ color: '#C2EEFF', marginLeft: 5 }}>可绿化里程总数</span>
</Col> </Col>
<Col span={9} style={{ fontSize: 24, fontFamily: 'YouSheBiaoTiHei', color: '#fff' }}>1234</Col> <Col span={9} style={{ fontSize: 24, fontFamily: 'YouSheBiaoTiHei', color: '#fff' }}>{totalData}</Col>
</Row> </Row>
<div ref={chartRef} style={{ height: "14.5vh", width: "96%" }}></div> <div ref={chartRef} style={{ height: "14.5vh", width: "100%" }}></div>
</Module> </Module>
</> </>

40
web/client/src/sections/quanju/containers/footer/conserve/left/left-top.js

@ -1,19 +1,20 @@
import React, { useEffect, useRef } from 'react'; import React, { useEffect, useRef } from 'react';
import Module from '../../../public/module' import Module from '../../../public/module'
import * as echarts from 'echarts'; import * as echarts from 'echarts';
import { Badge } from 'antd'; import { Badge, Spin } from 'antd';
const LeftTop = () => { const LeftTop = (props) => {
const seasonChartRef = useRef(null); const seasonChartRef = useRef(null);
const frequentlyChartRef = useRef(null); const frequentlyChartRef = useRef(null);
const { roadData,loading } = props
let total = roadData?.curingPeriod?.frequent + roadData?.curingPeriod?.season
useEffect(() => { useEffect(() => {
let chartInstance = echarts.init(seasonChartRef.current); let chartInstance = echarts.init(seasonChartRef.current);
const seasonOption = { const seasonOption = {
tooltip:{ tooltip: {
show:true show: true
}, },
title: [ title: [
{ {
@ -26,7 +27,7 @@ const LeftTop = () => {
}, },
}, },
{ {
text: "2333", text: roadData?.curingPeriod?.season || 0,
x: "center", x: "center",
y: "35%", y: "35%",
textStyle: { textStyle: {
@ -48,7 +49,7 @@ const LeftTop = () => {
containLabel: true, containLabel: true,
}, },
angleAxis: { angleAxis: {
max: 100, max: total || 0,
show: false, show: false,
}, },
radiusAxis: { radiusAxis: {
@ -71,7 +72,7 @@ const LeftTop = () => {
roundCap: true, roundCap: true,
barWidth: 30, barWidth: 30,
showBackground: true, showBackground: true,
data: [{value:40,name:'季节性'}], data: [{ value: roadData?.curingPeriod?.season || 0, name: '季节性' }],
coordinateSystem: "polar", coordinateSystem: "polar",
itemStyle: { itemStyle: {
normal: { normal: {
@ -91,19 +92,19 @@ const LeftTop = () => {
], ],
}; };
chartInstance.setOption(seasonOption); chartInstance.setOption(seasonOption);
window.addEventListener('resize',() =>{ window.addEventListener('resize', () => {
if(chartInstance) { if (chartInstance) {
chartInstance.resize() chartInstance.resize()
} }
}) })
}, []) }, [roadData])
useEffect(() => { useEffect(() => {
let chartInstance = echarts.init(frequentlyChartRef.current); let chartInstance = echarts.init(frequentlyChartRef.current);
const frequentlyOption = { const frequentlyOption = {
tooltip:{ tooltip: {
show:true, show: true,
trigger: "item", trigger: "item",
}, },
title: [ title: [
@ -117,7 +118,7 @@ const LeftTop = () => {
}, },
}, },
{ {
text: "2333", text: roadData?.curingPeriod?.frequent || 0,
x: "center", x: "center",
y: "35%", y: "35%",
textStyle: { textStyle: {
@ -140,7 +141,7 @@ const LeftTop = () => {
containLabel: true, containLabel: true,
}, },
angleAxis: { angleAxis: {
max: 100, max: total || 0,
show: false, show: false,
}, },
radiusAxis: { radiusAxis: {
@ -163,7 +164,7 @@ const LeftTop = () => {
roundCap: true, roundCap: true,
barWidth: 30, barWidth: 30,
showBackground: true, showBackground: true,
data:[{value:40,name:'经常性'}], data: [{ value: roadData?.curingPeriod?.frequent || 0, name: '经常性' }],
coordinateSystem: "polar", coordinateSystem: "polar",
itemStyle: { itemStyle: {
normal: { normal: {
@ -190,10 +191,10 @@ const LeftTop = () => {
chartInstance.resize() chartInstance.resize()
} }
}) })
}, []) }, [roadData])
const style = { height: "31%", marginTop: "3%" } const style = { height: "31%", marginTop: "3%" }
return ( return (
<>
<Module style={style} title={"路段养护周期统计"}> <Module style={style} title={"路段养护周期统计"}>
<div style={{ position: 'relative', width: '100%', height: '100%' }}> <div style={{ position: 'relative', width: '100%', height: '100%' }}>
<div style={{ width: '100%', height: '100%', display: 'flex', padding: '3%' }}> <div style={{ width: '100%', height: '100%', display: 'flex', padding: '3%' }}>
@ -217,7 +218,6 @@ const LeftTop = () => {
}} /> }} />
</div> </div>
</Module> </Module>
</>
) )
} }
export default LeftTop export default LeftTop

9
web/client/src/sections/quanju/containers/footer/conserve/right.js

@ -3,12 +3,13 @@ import RightBottom from './right/right-bottom'
import RightCenter from './right/right-center' import RightCenter from './right/right-center'
import RightTop from './right/right-top' import RightTop from './right/right-top'
const Right = () => { const Right = (props) => {
const { roadData } = props
return ( return (
<div style={{ display: 'flex', flexDirection: 'column', width: "23%", height: "100%", marginRight: "1%", }}> <div style={{ display: 'flex', flexDirection: 'column', width: "23%", height: "100%", marginRight: "1%", }}>
<RightTop /> <RightTop roadData={roadData} />
<RightCenter /> <RightCenter roadData={roadData} />
<RightBottom /> <RightBottom roadData={roadData} />
</div> </div>
) )
} }

Loading…
Cancel
Save