四好公路
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

65 lines
2.4 KiB

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 (
<div style={{ width: '100%', height: '100%', }}>
<Left roadData={roadData} loading={loading} data={data} shuju={shuju} />
<Right highwaysData={highwaysData} roadMaintenances={roadMaintenances} />
</div>
)
}
function mapStateToProps(state) {
// const { auth } = state;
return {
}
}
export default connect(mapStateToProps)(Conserve)