LUCAS 2 years ago
parent
commit
0ff14c9a0a
  1. 2
      web/client/src/sections/fillion/components/patrolTable.js
  2. 219
      web/client/src/sections/quanju/containers/footer/build/index.js

2
web/client/src/sections/fillion/components/patrolTable.js

@ -123,7 +123,7 @@ const DetailList = (props) => {
switch (text) { switch (text) {
case 'road': return '道路'; case 'road': return '道路';
case 'bridge': return '桥梁'; case 'bridge': return '桥梁';
case 'culvert ': return '涵洞'; case 'culvert': return '涵洞';
case 'other': return '其他'; case 'other': return '其他';
default: return text; default: return text;
} }

219
web/client/src/sections/quanju/containers/footer/build/index.js

@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react' import React, { useEffect, useState, useRef } from 'react'
import { connect } from 'react-redux'; import { connect } from 'react-redux';
// import LeftTop from './Lefttop' // import LeftTop from './Lefttop'
// import LeftCenter from './Leftcenter' // import LeftCenter from './Leftcenter'
@ -11,94 +11,103 @@ import Module from '../../public/module'
import RightBottom from './Rightbottom' import RightBottom from './Rightbottom'
import AutoRollComponent from './AutoRollComponent' import AutoRollComponent from './AutoRollComponent'
import './style.less' import './style.less'
import {getdaolutongji,getxuanchuan} from '../../../actions/example' import { getdaolutongji, getxuanchuan } from '../../../actions/example'
import { Carousel } from 'antd'; import { Carousel } from 'antd';
// import { number } from 'echarts'; // import { number } from 'echarts';
const Build = (props) => { const Build = (props) => {
const { dispatch } = props const { dispatch } = props
let data1 = [ let data1 = [
{name: "县", value: 207}, { name: "县", value: 207 },
{name: "乡", value: 729}, { name: "乡", value: 729 },
{name: "村", value: 1938} { name: "村", value: 1938 }
] ]
// const safetyData = [ // const safetyData = [
// {name: '一级公路', value: 42}, // {name: '一级公路', value: 42},
// {name: '二级公路', value: 17}, // {name: '二级公路', value: 17},
// {name: '三级公路', value: 17}, // {name: '三级公路', value: 17},
// {name: '四级公路', value: 30}, // {name: '四级公路', value: 30},
// ] // ]
const [buildingnumber,setbuildingnumber] = useState(0) const [buildingnumber, setbuildingnumber] = useState(0)
const [data,setdata] = useState([]) const [data, setdata] = useState([])
const [xuandata,setxuandata] = useState(null) const [xuandata, setxuandata] = useState(null)
const lunbo = useRef(null)
const lunbovideo = useRef(null)
const [lunboindex, setlunboindex] = useState(0)
//
const lunboMsg = useRef({ index: 0 })
//获取道路管理数据 //获取道路管理数据
const requestbuildingnumber = async ()=>{ const requestbuildingnumber = async () => {
const res = await dispatch(getdaolutongji()); const res = await dispatch(getdaolutongji());
let alltype = Object.keys(res.payload.data?.roadType || {}).map((item)=>({name:item,value:Number(keepThreeNum(res.payload.data.roadType[item]))})) let alltype = Object.keys(res.payload.data?.roadType || {}).map((item) => ({ name: item, value: Number(keepThreeNum(res.payload.data.roadType[item])) }))
// console.log(alltype,'打他啊') // console.log(alltype,'打他啊')
setdata(alltype.filter(item=>item.name==='县'||item.name==="乡"||item.name==='村')) setdata(alltype.filter(item => item.name === '县' || item.name === "乡" || item.name === '村'))
setbuildingnumber(res.payload.data) setbuildingnumber(res.payload.data)
// console.log(res.payload.data,'哈哈哈') // console.log(res.payload.data,'哈哈哈')
} }
//获取宣传栏数据 //获取宣传栏数据
const requestxuanchuanlan = async ()=>{ const requestxuanchuanlan = async () => {
const res = await dispatch(getxuanchuan()); const res = await dispatch(getxuanchuan());
// setdata(alltype.filter(item=>item.name!=='null')) // setdata(alltype.filter(item=>item.name!=='null'))
setxuandata(res.payload.data || []) setxuandata(res.payload.data || [])
console.log(res.payload.data,'宣传栏数据') console.log(res.payload.data, '宣传栏数据')
} }
let t1 = Object.values(buildingnumber?.townRoad || {}) let t1 = Object.values(buildingnumber?.townRoad || {})
let totalgongli = t1.length!==0 ? t1.reduce((x,y)=>x+y.mileage,0):0 //乡镇道路占比总公里数 let totalgongli = t1.length !== 0 ? t1.reduce((x, y) => x + y.mileage, 0) : 0 //乡镇道路占比总公里数
// let totalcount = t1.length !==0 ? t1.reduce((x,y)=>x+y.roadCount,0):0 //乡镇道路占比公路总条数 // let totalcount = t1.length !==0 ? t1.reduce((x,y)=>x+y.roadCount,0):0 //乡镇道路占比公路总条数
let totalcount = buildingnumber?.buildedRoad || 0 let totalcount = buildingnumber?.buildedRoad || 0
// let sungongli = alltype.reduce((x,y)=>x+y.value,0) // let sungongli = alltype.reduce((x,y)=>x+y.value,0)
const keepThreeNum=(value)=> { const keepThreeNum = (value) => {
let resValue = 0 let resValue = 0
//小数点的位置 //小数点的位置
let index = value&&value.toString().indexOf('.') + 1 let index = value && value.toString().indexOf('.') + 1
//小数的位数 //小数的位数
let num = value&&Math.abs(Number(value)).toString().length - index let num = value && Math.abs(Number(value)).toString().length - index
if(index && num > 3){ if (index && num > 3) {
resValue = value&&Number(value).toFixed(3) resValue = value && Number(value).toFixed(3)
} else { } else {
resValue = value resValue = value
} }
return resValue return resValue
} }
let datas = Object.keys(buildingnumber?.townRoad || {}).map((item)=>({name:item,number:buildingnumber.townRoad[item].roadCount,gongli:Number(keepThreeNum(buildingnumber.townRoad[item].mileage))})) let datas = Object.keys(buildingnumber?.townRoad || {}).map((item) => ({ name: item, number: buildingnumber.townRoad[item].roadCount, gongli: Number(keepThreeNum(buildingnumber.townRoad[item].mileage)) }))
let list = datas.sort((a,b)=>{ let list = datas.sort((a, b) => {
return b.number - a.number return b.number - a.number
}) })
// console.log(list,'红红火') // console.log(list,'红红火')
//道路等级数据 //道路等级数据
let alldengji = Object.keys(buildingnumber?.roadLevel || {}).map((item)=>({name:item,value:Number(keepThreeNum(buildingnumber.roadLevel[item]))})) let alldengji = Object.keys(buildingnumber?.roadLevel || {}).map((item) => ({ name: item, value: Number(keepThreeNum(buildingnumber.roadLevel[item])) }))
let onlineproject = Object.keys(buildingnumber?.townProject||{}).map((item)=>({name:item,total:buildingnumber.townProject[item]})) let onlineproject = Object.keys(buildingnumber?.townProject || {}).map((item) => ({ name: item, total: buildingnumber.townProject[item] }))
onlineproject = onlineproject.sort((a,b)=>{ onlineproject = onlineproject.sort((a, b) => {
return b.total - a.total return b.total - a.total
}) })
let sunonlineproject = onlineproject?.reduce((x,y)=>x+y.total,0) let sunonlineproject = onlineproject?.reduce((x, y) => x + y.total, 0)
let safetyData = alldengji?.filter(item=>item.name==='一级公路'||item.name==='二级公路'||item.name==='三级公路'||item.name==='四级公路'||item.name==='等外公路') let safetyData = alldengji?.filter(item => item.name === '一级公路' || item.name === '二级公路' || item.name === '三级公路' || item.name === '四级公路' || item.name === '等外公路')
let sundata = data?.reduce((x,y)=>x+y.value,0) let sundata = data?.reduce((x, y) => x + y.value, 0)
let sunsafetyData = safetyData?.reduce((x,y)=>x+y.value,0) let sunsafetyData = safetyData?.reduce((x, y) => x + y.value, 0)
useEffect(()=>{ useEffect(() => {
requestbuildingnumber(); requestbuildingnumber();
requestxuanchuanlan() requestxuanchuanlan()
},[]) }, [])
const rendercontent = ()=>{ useEffect(()=>{
lunbo.current.goTo(lunboindex)
},[lunboindex])
const rendercontent = () => {
return (<div className='build-left-center-content'> return (<div className='build-left-center-content'>
{list.map(({name,number,gongli},index)=><div className='build-left-center-item' key={index}> {list.map(({ name, number, gongli }, index) => <div className='build-left-center-item' key={index}>
<span>{name}</span> <span>{name}</span>
<span>{number}</span> <span>{number}</span>
<span>{gongli}</span> <span>{gongli}</span>
@ -113,41 +122,57 @@ const Build = (props) => {
// "enable": true // "enable": true
// } // }
// ] // ]
console.log(localStorage.getItem("qndmn"),'七牛') // console.log(localStorage.getItem("qndmn"), '七牛')
console.log(xuandata,"宣传") // console.log(xuandata, "宣传")
let videos = []
if (xuandata && xuandata.length) {
for (let x of xuandata) {
if (x.enable) {
if (x.video && x.video.length) {
for (let v of x.video) {
videos.push(v)
}
}
}
}
}
console.log(lunboindex)
return ( return (
<> <>
<div className='bgbuild-left'> <div className='bgbuild-left'>
<Module title={"各状态公路数量统计"} style={{ width: "100%", <Module title={"各状态公路数量统计"} style={{
height:" 33%" width: "100%",
}} customize = {true}> height: " 33%"
<div style={{height:"100%",position:"relative"}} > }} customize={true}>
<span style={{position:"absolute",width:"10%",color:"#FFF",backgroundColor:'rgba(216, 240, 255, 0.1)',right:"5%",textAlign:"center"}}></span> <div style={{ height: "100%", position: "relative" }} >
{buildingnumber&&buildingnumber.buildedRoad!==0&&totalgongli!==0?<div className='build-left-top'> <span style={{ position: "absolute", width: "10%", color: "#FFF", backgroundColor: 'rgba(216, 240, 255, 0.1)', right: "5%", textAlign: "center" }}></span>
{buildingnumber && buildingnumber.buildedRoad !== 0 && totalgongli !== 0 ? <div className='build-left-top'>
<div className='build-left-top-item'> <div className='build-left-top-item'>
<div> <div>
{/* <i>&#9658;</i> */} {/* <i>&#9658;</i> */}
<span/> <span />
<span>在建公路数量</span> <span>在建公路数量</span>
</div> </div>
<div>{buildingnumber?.buildingRoad || 0}</div> <div>{buildingnumber?.buildingRoad || 0}</div>
</div> </div>
<img src='/assets/images/quanju/zhuangtaigonglui.png' className='build-left-top-center'/> <img src='/assets/images/quanju/zhuangtaigonglui.png' className='build-left-top-center' />
<div className='build-left-top-item'> <div className='build-left-top-item'>
<div> <div>
{/* <i>&#9658;</i> */} {/* <i>&#9658;</i> */}
<span/> <span />
<span>已建公路数量</span> <span>已建公路数量</span>
</div> </div>
<div>{buildingnumber?.buildedRoad || 0}</div> <div>{buildingnumber?.buildedRoad || 0}</div>
</div> </div>
</div>:<NoData/>} </div> : <NoData />}
</div> </div>
</Module> </Module>
<Module title={"各乡镇已建道路统计"} style={{ width: "100%", <Module title={"各乡镇已建道路统计"} style={{
height:" 33%",marginTop:'3%' width: "100%",
}} customize = {true}> height: " 33%", marginTop: '3%'
{ totalcount && totalcount!==0?<div className='build-left-center'> }} customize={true}>
{totalcount && totalcount !== 0 ? <div className='build-left-center'>
<div className='build-left-center-top'> <div className='build-left-center-top'>
<div> <div>
<img src='/assets/images/quanju/gonglugongli.png'></img> <img src='/assets/images/quanju/gonglugongli.png'></img>
@ -160,7 +185,7 @@ const Build = (props) => {
<img src='/assets/images/quanju/gongluzong.png'></img> <img src='/assets/images/quanju/gongluzong.png'></img>
<div> <div>
<span>公路总数/</span> <span>公路总数/</span>
<span>{totalcount||0}</span> <span>{totalcount || 0}</span>
</div> </div>
</div> </div>
</div> </div>
@ -169,14 +194,15 @@ const Build = (props) => {
<span>公路数量/</span> <span>公路数量/</span>
<span>公里</span> <span>公里</span>
</div> </div>
<AutoRollComponent content = {rendercontent()} containerStyle={{ position: "relative", height: "50%", }} <AutoRollComponent content={rendercontent()} containerStyle={{ position: "relative", height: "50%", }}
divHeight={"100%"} divId={"chart"} /> divHeight={"100%"} divId={"chart"} />
</div>:<NoData/>} </div> : <NoData />}
</Module> </Module>
<Module title={"道路统计"} style={{ width: "100%", <Module title={"道路统计"} style={{
height:" 30%",marginTop:'3%' width: "100%",
}} customize = {true}> height: " 30%", marginTop: '3%'
{ data&&sundata!==0?<LeftBottom }} customize={true}>
{data && sundata !== 0 ? <LeftBottom
data={data} data={data}
width='100%' width='100%'
height='100%' height='100%'
@ -184,46 +210,85 @@ const Build = (props) => {
total={keepThreeNum(sundata)} total={keepThreeNum(sundata)}
// colorList={colorList} // colorList={colorList}
// underColorList={underColorList} // underColorList={underColorList}
/>:<NoData/>} /> : <NoData />}
</Module> </Module>
</div> </div>
<div className='bgbuild-right'> <div className='bgbuild-right'>
<Module title={"宣传栏"} style={{ width: "100%", <Module title={"宣传栏"} style={{
height:" 33%" width: "100%",
height: " 33%"
}} customize={true}> }} customize={true}>
<div className='build-right-top'> <div className='build-right-top'>
{lunboindex}//{lunboMsg.current.index}
{/* <img src='/assets/images/quanju/xuanchuanlan.jpg'></img> */} {/* <img src='/assets/images/quanju/xuanchuanlan.jpg'></img> */}
<Carousel autoplay={true} dots={false} autoplaySpeed={180000}> <Carousel dots={true} ref={lunbo} key={lunboindex} afterChange={(current)=>{
{xuandata&&xuandata!==null&&xuandata.length!==0?xuandata.map((item,index)=>{
setlunboindex(current)}}>
{/* {
videos.map((v, i) => {
console.log('first')
return i == lunboMsg.current.index ?
<video src={`${localStorage.getItem("qndmn")}/${v}`} key={Math.random()} autoPlay={i == lunboMsg.current.index} onEnded={() => {
console.log('end', i + 1, videos.length)
if (i == videos.length - 1) {
setlunboindex(0)
lunboMsg.current.index = 0
lunbo.current.goTo(1)
} else {
console.log('first222', i + 1)
setlunboindex(i + 1)
lunboMsg.current.index = i + 1
lunbo.current.next()
}
}}></video>
: <p>123</p>
})
} */}
{
xuandata&&xuandata!==null&&xuandata.length!==0?xuandata.map((item,index1)=>{
if(item.enable){ if(item.enable){
if(item.video&&item.video!==null&&item.video.length!==0){ if(item.video&&item.video!==null&&item.video.length!==0){
return item.video.map((i,index)=>{ return item.video.map((i,index)=>{
// console.log(i,'视频') // console.log(i,'视频')
return <video src={`${localStorage.getItem("qndmn")}/${i}`} autoPlay="autoplay" loop></video> console.log(index1,'index1')
if(index1-1===lunboindex){
// lunbo.current.goTo(lunboindex)
console.log("自动播放",index1)
return <video src={`${localStorage.getItem("qndmn")}/${i}`} autoPlay={true} ref={lunbovideo} loop></video>
}else{
// console.log("不自动播放",index1)
return <video src={`${localStorage.getItem("qndmn")}/${i}`} autoPlay={false}></video>
}
}) })
} }
// return <video src={`${localStorage.getItem("qndmn")}/${item.video!==null&&item.video.length!==0?item.video[0]:""}`} autoPlay="autoplay" loop></video> // return <video src={`${localStorage.getItem("qndmn")}/${item.video!==null&&item.video.length!==0?item.video[0]:""}`} autoPlay="autoplay" loop></video>
} }
}):<video src='#'></video>} })
:<video src='#'></video>
}
{/* <video src={xuandata&&xuandata!==null&&xuandata.length!==0?`${localStorage.getItem("qndmn")}/${xuandata[0].video!==null&&xuandata[0].video?xuandata[0].video[0]:""}`:"#"} autoPlay="autoplay" loop></video> */} {/* <video src={xuandata&&xuandata!==null&&xuandata.length!==0?`${localStorage.getItem("qndmn")}/${xuandata[0].video!==null&&xuandata[0].video?xuandata[0].video[0]:""}`:"#"} autoPlay="autoplay" loop></video> */}
</Carousel> </Carousel>
<h2>全面建设好农村公路切实发挥先行官作用</h2> <h2>全面建设好农村公路切实发挥先行官作用</h2>
</div> </div>
</Module> </Module>
<Module title={"各乡镇在建工程统计"} style={{ width: "100%", <Module title={"各乡镇在建工程统计"} style={{
height:" 33%",marginTop:'3%' width: "100%",
}} customize = {true}> height: " 33%", marginTop: '3%'
{sunonlineproject!==0?<Rightcenter data={onlineproject} sundata={sunonlineproject}/>:<NoData/>} }} customize={true}>
{sunonlineproject !== 0 ? <Rightcenter data={onlineproject} sundata={sunonlineproject} /> : <NoData />}
</Module> </Module>
<Module title={"各路段技术等级统计"} style={{ width: "100%", <Module title={"各路段技术等级统计"} style={{
height:" 30%",marginTop:'3%' width: "100%",
}} customize = {true}> height: " 30%", marginTop: '3%'
{safetyData&&sunsafetyData!==0?<RightBottom width='100%' }} customize={true}>
{safetyData && sunsafetyData !== 0 ? <RightBottom width='100%'
height='100%' height='100%'
text='道路总公里' text='道路总公里'
total={keepThreeNum(sundata)} total={keepThreeNum(sundata)}
data={keepThreeNum(safetyData)}/>:<NoData/>} data={keepThreeNum(safetyData)} /> : <NoData />}
</Module> </Module>
</div> </div>
</> </>

Loading…
Cancel
Save