import React, { useEffect, useState } from 'react' import Left from './left' import Right from './right' import { connect } from 'react-redux' import moment from 'moment'; import { getdaolutongji } from '../../../actions/example' import { getHighways, getRoadMaintenances, getxiuyang,getMaintenance } from './action' const Conserve = (props) => { const [roadData, setRoadData] = useState() const [highwaysData, setHighwaysData] = useState() const [roadMaintenances, setRoadMaintenances] = useState() const [data, setData] = useState() const [shuju, setShuju] = useState() const [loading, setLoading] = useState(true) const { dispatch } = props useEffect(() => { dispatch(getdaolutongji()).then(res => { setLoading(false) setRoadData(res.payload.data || {}) }) dispatch(getHighways()).then(res => { setHighwaysData(res.payload.data || []) }) dispatch(getRoadMaintenances()).then(res => { setRoadMaintenances(res.payload.data || []) }) dispatch(getxiuyang()).then(res => { // let obj = {}; setData(res.payload.data.filter(item => { if (moment(item.maintenanceDate).format("MM") == (new Date().getMonth() < 10 ? "0" + new Date().getMonth() : new Date().getMonth())) { return item } })) console.log('是发错地方v',res.payload.data.filter((i)=>i.countyName=='向塘镇人民政府')) // setShuju(res.payload.data.filter(item => { // if ((new Date().getMonth() < 10 ? "0" + new Date().getMonth() : new Date().getMonth()) - 6 < moment(item.maintenanceDate).format("MM") && moment(item.maintenanceDate).format("MM") <= (new Date().getMonth() < 10 ? "0" + new Date().getMonth() : new Date().getMonth())) { // return item // } // })) }) dispatch(getMaintenance()).then(res => { setShuju(res.payload.data) }) }, []) return (
) } function mapStateToProps(state) { // const { auth } = state; return { } } export default connect(mapStateToProps)(Conserve)