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 ConcentrateProject from './ConcentrateProject';
|
||||||
import Activity from './Activity';
|
import Activity from './Activity';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import Axios from 'axios';
|
|
||||||
import Nodata from '../../Nodata';
|
|
||||||
|
|
||||||
const { Option } = Select;
|
|
||||||
const aLimit = 5;
|
const aLimit = 5;
|
||||||
function Index(props) {
|
function Index(props) {
|
||||||
const [ page , setPage ] = useState(1);
|
const [ page , setPage ] = useState(1);
|
||||||
const [ total , setTotal ] = useState(0);
|
const [ total , setTotal ] = useState(0);
|
||||||
const [ projectTrends , setProjectTrends ] = useState(undefined);
|
const [ createYear , setCreateYear ] = 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 username = props.match.params.username;
|
const username = props.match.params.username;
|
||||||
const current_user = props.current_user;
|
const current_user = props.current_user;
|
||||||
|
@ -36,64 +27,21 @@ function Index(props) {
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(user){
|
if(user){
|
||||||
let c = user.created_time && user.created_time.split("-")[0];
|
let c = user.created_time && user.created_time.split("-")[0];
|
||||||
let y = moment().get('year');
|
setCreateYear(parseInt(c,0));
|
||||||
let array = []
|
|
||||||
for(var i = y ; i >= parseInt(c,0);i--){
|
|
||||||
array.push(i);
|
|
||||||
}
|
|
||||||
setYearList(array);
|
|
||||||
}
|
}
|
||||||
},[user])
|
},[user])
|
||||||
|
|
||||||
// 在贡献度日历表中选择一个时间
|
// 在贡献度日历表中选择一个时间
|
||||||
function chooseTime(data) {
|
function chooseTime(data) {
|
||||||
if(data){
|
if(data){
|
||||||
setPage(1);
|
console.log(data);
|
||||||
setActivityDate(data[0]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 年份下拉框option
|
function renderYear(){
|
||||||
function renderYear(list){
|
let y = moment().get('year');
|
||||||
return list.map((i,k)=>{
|
for(var i = y ; i > createYear;i--){
|
||||||
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=>{})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(
|
return(
|
||||||
|
@ -106,24 +54,21 @@ function Index(props) {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="recentStatic">
|
<div className="recentStatic">
|
||||||
<p className="font-18 mb15">近期活动统计</p>
|
<Line />
|
||||||
<div className="echartBox"><Line data={statisticData}/></div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="calendarStatic">
|
<div className="calendarStatic">
|
||||||
<FlexAJ style={{marginBottom:"15px"}}>
|
<FlexAJ>
|
||||||
<span className="font-18">贡献度</span>
|
<span className="font-18">贡献度</span>
|
||||||
<Select style={{width:"200px"}} placeholder="选择年份" value={year} onSelect={(e)=>{setYear(e);setActivityDate(undefined)}}>
|
<Select style={{width:"200px"}} placeholder="选择年份">
|
||||||
{ yearList && renderYear(yearList) }
|
<Select.Option key="">选择年份</Select.Option>
|
||||||
|
{ createYear && renderYear()}
|
||||||
</Select>
|
</Select>
|
||||||
</FlexAJ>
|
</FlexAJ>
|
||||||
<div className="echartBox">
|
<Calendar time={''} userLogin={username} chooseTime={chooseTime}/>
|
||||||
<Calendar time={year} userLogin={username} chooseTime={chooseTime}/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="activeStatic">
|
<div className="activeStatic">
|
||||||
<span className="font-18">动态</span>
|
<span className="font-18">动态</span>
|
||||||
{ projectTrends && projectTrends.length > 0 && <Activity list = {projectTrends}/> }
|
<Activity />
|
||||||
{ projectTrends && projectTrends.length === 0 && <Nodata _html="暂无动态" />}
|
|
||||||
{ total > aLimit && <div style={{textAlign:'center',paddingBottom:"30px"}}><Pagination pageSize={aLimit} current={page} total={total} onChange={(p)=>setPage(p)}/></div> }
|
{ total > aLimit && <div style={{textAlign:'center',paddingBottom:"30px"}}><Pagination pageSize={aLimit} current={page} total={total} onChange={(p)=>setPage(p)}/></div> }
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue