import React, { useEffect, useState, useRef } from 'react' import { connect } from 'react-redux'; // import LeftTop from './Lefttop' // import LeftCenter from './Leftcenter' import LeftBottom from './Leftbottom' // import RightTop from './Righttop' import Rightcenter from './Rightcenter' // import Rightbottom from './Rightbottom' import NoData from '../../public/noData'; import Module from '../../public/module' import RightBottom from './Rightbottom' import AutoRollComponent from './AutoRollComponent' import './style.less' import { getdaolutongji, getxuanchuan } from '../../../actions/example' import { Carousel } from 'antd'; // import { number } from 'echarts'; const Build = (props) => { const { dispatch } = props let data1 = [ { name: "县", value: 207 }, { name: "乡", value: 729 }, { name: "村", value: 1938 } ] // const safetyData = [ // {name: '一级公路', value: 42}, // {name: '二级公路', value: 17}, // {name: '三级公路', value: 17}, // {name: '四级公路', value: 30}, // ] const [buildingnumber, setbuildingnumber] = useState(0) const [data, setdata] = useState([]) 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 res = await dispatch(getdaolutongji()); let alltype = Object.keys(res.payload.data?.roadType || {}).map((item) => ({ name: item, value: Number(keepThreeNum(res.payload.data.roadType[item])) })) // console.log(alltype,'打他啊') setdata(alltype.filter(item => item.name === '县' || item.name === "乡" || item.name === '村')) setbuildingnumber(res.payload.data) console.log(res.payload.data, '哈哈哈') } //获取宣传栏数据 const requestxuanchuanlan = async () => { const res = await dispatch(getxuanchuan()); // setdata(alltype.filter(item=>item.name!=='null')) setxuandata(res.payload.data || []) console.log(res.payload.data, '宣传栏数据') } let t1 = Object.values(buildingnumber?.townRoad || {}) 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 = buildingnumber?.buildedRoad || 0 // let sungongli = alltype.reduce((x,y)=>x+y.value,0) const keepThreeNum = (value) => { let resValue = 0 //小数点的位置 let index = value && value.toString().indexOf('.') + 1 //小数的位数 let num = value && Math.abs(Number(value)).toString().length - index if (index && num > 3) { resValue = value && Number(value).toFixed(3) } else { resValue = value } 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 list = datas.sort((a, b) => { return b.number - a.number }) list = list.filter(item => item.name !== "其他") // console.log(list,'红红火') //道路等级数据 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] })) onlineproject = onlineproject.sort((a, b) => { return b.total - a.total }) //console.log('onlineproject', onlineproject) let sunonlineproject = onlineproject?.reduce((x, y) => x + y.total, 0) let buildingCount = buildingnumber?.buildingCount //console.log('projectAll', projectAll) //let projectAll= 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 sunsafetyData = safetyData?.reduce((x, y) => x + y.value, 0) useEffect(() => { requestbuildingnumber(); requestxuanchuanlan() }, []) useEffect(() => { lunbo.current.goTo(lunboindex) }, [lunboindex]) const rendercontent = () => { return (
{list.map(({ name, number, gongli }, index) =>
{name} {number} {gongli}
)}
) } // const xuandata1 = [ // { // "id": 26, // "name": "111", // "video":null, // "enable": true // } // ] // console.log(localStorage.getItem("qndmn"), '七牛') // 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 ( <>
{/* */} {buildingnumber && buildingnumber.buildedRoad !== 0 && totalgongli !== 0 ?
{/*
在建公路数量
{buildingnumber?.buildingRoad || 0}
*/}
{buildingCount || 0}
{/* */} {/* */} 在建数量
: }
{totalcount && totalcount !== 0 ?
公路公里数/公里 {keepThreeNum(totalgongli)}
公路总数/条 {totalcount || 0}
乡镇名称 公路数量/条 公里
: }
{data && sundata !== 0 ? : }
{/* */} {/* { videos.map((v, i) => { console.log('first') return i == lunboMsg.current.index ? :

123

}) } */} { xuandata && xuandata !== null && xuandata.length !== 0 ? xuandata.filter(i => i.enable).map((item, index1) => { if (item.video && item.video !== null && item.video.length !== 0) { return item.video.map((i, index) => { // console.log(i,'视频') console.log(index1, 'index1') if (index1 === lunboindex) { // lunbo.current.goTo(lunboindex) console.log("自动播放", index1) return } else { // console.log("不自动播放",index1) return } }) } // return }) : } {/* */}

全面建设好农村公路,切实发挥先行官作用

{sunonlineproject !== 0 ? : } {safetyData && sunsafetyData !== 0 ? : }
) } function mapStateToProps(state) { const { auth, depMessage } = state; const pakData = (dep) => { return dep.map((d) => { return { title: d.name, value: d.id, // children: d.type >= 2 ? [] : pakData(d.subordinate) children: pakData(d.subordinate) } }) } let depData = pakData(depMessage.data || []) return { user: auth.user, depMessage: depMessage.data || [], depLoading: depMessage.isRequesting, depData, }; } export default connect(mapStateToProps)(Build);