forked from Gitlink/forgeplus-react
git cherry-pick d41dce26b1
This commit is contained in:
parent
c9a9da6de9
commit
f94edf90a5
|
@ -13,21 +13,12 @@ import Calendar from '../Echart/Calendar';
|
|||
import ConcentrateProject from './ConcentrateProject';
|
||||
import Activity from './Activity';
|
||||
import moment from 'moment';
|
||||
import Axios from 'axios';
|
||||
import Nodata from '../../Nodata';
|
||||
|
||||
const { Option } = Select;
|
||||
const aLimit = 5;
|
||||
function Index(props) {
|
||||
const [ page , setPage ] = useState(1);
|
||||
const [ total , setTotal ] = useState(0);
|
||||
const [ projectTrends , setProjectTrends ] = useState(undefined);
|
||||
|
||||
const [ year , setYear ] = useState(moment().get('year'));
|
||||
const [ yearList , setYearList ] = useState(undefined);
|
||||
const [ activityDate , setActivityDate ] = useState(undefined);
|
||||
|
||||
const [ statisticData , setStatisticData ] = useState(undefined);
|
||||
const [ createYear , setCreateYear ] = useState(undefined);
|
||||
|
||||
const username = props.match.params.username;
|
||||
const current_user = props.current_user;
|
||||
|
@ -36,64 +27,21 @@ function Index(props) {
|
|||
useEffect(()=>{
|
||||
if(user){
|
||||
let c = user.created_time && user.created_time.split("-")[0];
|
||||
let y = moment().get('year');
|
||||
let array = []
|
||||
for(var i = y ; i >= parseInt(c,0);i--){
|
||||
array.push(i);
|
||||
}
|
||||
setYearList(array);
|
||||
setCreateYear(parseInt(c,0));
|
||||
}
|
||||
},[user])
|
||||
|
||||
// 在贡献度日历表中选择一个时间
|
||||
function chooseTime(data) {
|
||||
if(data){
|
||||
setPage(1);
|
||||
setActivityDate(data[0]);
|
||||
console.log(data);
|
||||
}
|
||||
}
|
||||
|
||||
// 年份下拉框option
|
||||
function renderYear(list){
|
||||
return list.map((i,k)=>{
|
||||
return(
|
||||
<Option key={i}>{i}</Option>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(()=>{
|
||||
getActivity();
|
||||
},[activityDate,page])
|
||||
|
||||
// 获取动态列表
|
||||
function getActivity() {
|
||||
const url = `/users/${username}/project_trends.json`;
|
||||
Axios.get(url,{
|
||||
params:{
|
||||
date:activityDate,
|
||||
limit:aLimit,page
|
||||
}
|
||||
}).then(result=>{
|
||||
if(result && result.data){
|
||||
setProjectTrends(result.data.project_trends);
|
||||
setTotal(result.data.total_count);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
}
|
||||
|
||||
// 获取近期活动统计
|
||||
useEffect(()=>{
|
||||
getStatistics();
|
||||
},[])
|
||||
|
||||
function getStatistics() {
|
||||
const url = `/users/${username}/statistics/activity.json`;
|
||||
Axios.get(url).then(result=>{
|
||||
if(result && result.data){
|
||||
setStatisticData(result.data);
|
||||
}
|
||||
}).catch(error=>{})
|
||||
function renderYear(){
|
||||
let y = moment().get('year');
|
||||
for(var i = y ; i > createYear;i--){
|
||||
}
|
||||
}
|
||||
|
||||
return(
|
||||
|
@ -106,24 +54,21 @@ function Index(props) {
|
|||
/>
|
||||
</div>
|
||||
<div className="recentStatic">
|
||||
<p className="font-18 mb15">近期活动统计</p>
|
||||
<div className="echartBox"><Line data={statisticData}/></div>
|
||||
<Line />
|
||||
</div>
|
||||
<div className="calendarStatic">
|
||||
<FlexAJ style={{marginBottom:"15px"}}>
|
||||
<FlexAJ>
|
||||
<span className="font-18">贡献度</span>
|
||||
<Select style={{width:"200px"}} placeholder="选择年份" value={year} onSelect={(e)=>{setYear(e);setActivityDate(undefined)}}>
|
||||
{ yearList && renderYear(yearList) }
|
||||
<Select style={{width:"200px"}} placeholder="选择年份">
|
||||
<Select.Option key="">选择年份</Select.Option>
|
||||
{ createYear && renderYear()}
|
||||
</Select>
|
||||
</FlexAJ>
|
||||
<div className="echartBox">
|
||||
<Calendar time={year} userLogin={username} chooseTime={chooseTime}/>
|
||||
</div>
|
||||
<Calendar time={''} userLogin={username} chooseTime={chooseTime}/>
|
||||
</div>
|
||||
<div className="activeStatic">
|
||||
<span className="font-18">动态</span>
|
||||
{ projectTrends && projectTrends.length > 0 && <Activity list = {projectTrends}/> }
|
||||
{ projectTrends && projectTrends.length === 0 && <Nodata _html="暂无动态" />}
|
||||
<Activity />
|
||||
{ total > aLimit && <div style={{textAlign:'center',paddingBottom:"30px"}}><Pagination pageSize={aLimit} current={page} total={total} onChange={(p)=>setPage(p)}/></div> }
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue