|
|
|
@ -15,6 +15,7 @@ import actions from '../../redux/actions';
|
|
|
|
|
import MultipTags from './components/multiptags';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import CONST from '../../constants';
|
|
|
|
|
import { withRouter } from 'react-router';
|
|
|
|
|
|
|
|
|
|
const {tagBackground, diffText} = CONST;
|
|
|
|
|
const { Search } = Input;
|
|
|
|
@ -96,66 +97,67 @@ const testMaps = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 表格列
|
|
|
|
|
*/
|
|
|
|
|
const options = {
|
|
|
|
|
title: '操作',
|
|
|
|
|
key: 'action',
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
width: 100,
|
|
|
|
|
render: (text, record) => (
|
|
|
|
|
<span>
|
|
|
|
|
<Button type="primary">
|
|
|
|
|
<Link to={`/problems/${record.identifier}/edit`}>编辑</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
</span>
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
const columns = [
|
|
|
|
|
{
|
|
|
|
|
title: '标题',
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
render: (name, record) => <Link style={{ color: '#459be5' }} to={`/myproblems/${record.identifier}`}>{name}</Link>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '分类',
|
|
|
|
|
dataIndex: 'category',
|
|
|
|
|
width: '20%',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (category) => <span>{category ? testMaps['category'][+category] : '-'}</span>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '难度',
|
|
|
|
|
dataIndex: 'difficult',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: '15%',
|
|
|
|
|
render: (difficult) => {
|
|
|
|
|
if (difficult) {
|
|
|
|
|
return <Tag color={tagBackground[+difficult]}>{diffText[+difficult]}</Tag>
|
|
|
|
|
} else {
|
|
|
|
|
return '-';
|
|
|
|
|
class DeveloperHome extends React.PureComponent {
|
|
|
|
|
/**
|
|
|
|
|
* 表格列
|
|
|
|
|
*/
|
|
|
|
|
options = {
|
|
|
|
|
title: '操作',
|
|
|
|
|
key: 'action',
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
width: 100,
|
|
|
|
|
render: (text, record) => (
|
|
|
|
|
<span>
|
|
|
|
|
<Button type="primary">
|
|
|
|
|
<Link to={`/problems/${record.identifier}/edit`}>编辑</Link>
|
|
|
|
|
</Button>
|
|
|
|
|
</span>
|
|
|
|
|
),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
columns = [
|
|
|
|
|
{
|
|
|
|
|
title: '标题',
|
|
|
|
|
dataIndex: 'name',
|
|
|
|
|
render: (name, record) => <Button type="link" onClick={() => this.handleNameClick(record)} className={'oj_item_name'}>{name}</Button>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '分类',
|
|
|
|
|
dataIndex: 'category',
|
|
|
|
|
width: '20%',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: (category) => <span>{category ? testMaps['category'][+category] : '-'}</span>
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '难度',
|
|
|
|
|
dataIndex: 'difficult',
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: '15%',
|
|
|
|
|
render: (difficult) => {
|
|
|
|
|
if (difficult) {
|
|
|
|
|
return <Tag color={tagBackground[+difficult]}>{diffText[+difficult]}</Tag>
|
|
|
|
|
} else {
|
|
|
|
|
return '-';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '热度',
|
|
|
|
|
dataIndex: 'hack_user_lastest_codes_count',
|
|
|
|
|
sorter: true,
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: '10%'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '通过率',
|
|
|
|
|
dataIndex: 'passed_rate',
|
|
|
|
|
sorter: true,
|
|
|
|
|
align:'right',
|
|
|
|
|
width: '10%',
|
|
|
|
|
render: val => <span>{`${val}%`}</span>
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '热度',
|
|
|
|
|
dataIndex: 'hack_user_lastest_codes_count',
|
|
|
|
|
sorter: true,
|
|
|
|
|
align: 'center',
|
|
|
|
|
width: '10%'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '通过率',
|
|
|
|
|
dataIndex: 'passed_rate',
|
|
|
|
|
sorter: true,
|
|
|
|
|
align:'right',
|
|
|
|
|
width: '10%',
|
|
|
|
|
render: val => <span>{`${val}%`}</span>
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
class DeveloperHome extends React.PureComponent {
|
|
|
|
|
state = {
|
|
|
|
|
data: [],
|
|
|
|
|
loading: false,
|
|
|
|
@ -170,7 +172,7 @@ class DeveloperHome extends React.PureComponent {
|
|
|
|
|
page: 1, // 当前页数
|
|
|
|
|
limit: 10 // 每页显示条件
|
|
|
|
|
},
|
|
|
|
|
columns: columns,
|
|
|
|
|
columns: this.columns,
|
|
|
|
|
searchInfo: []
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -179,7 +181,7 @@ class DeveloperHome extends React.PureComponent {
|
|
|
|
|
const { isMySource } = this.props;
|
|
|
|
|
if (isMySource) {
|
|
|
|
|
this.handleFilterSearch({come_from: 'mine'});
|
|
|
|
|
let _columns = columns.concat([options]);
|
|
|
|
|
let _columns = this.columns.concat([this.options]);
|
|
|
|
|
this.setState({
|
|
|
|
|
columns: _columns
|
|
|
|
|
});
|
|
|
|
@ -309,13 +311,13 @@ class DeveloperHome extends React.PureComponent {
|
|
|
|
|
this.handleFilterSearch({come_from: item.key === 'all' ? '' : item.key});
|
|
|
|
|
|
|
|
|
|
if (item.key !== 'all') {
|
|
|
|
|
let _columns = columns.concat([options]);
|
|
|
|
|
let _columns = this.columns.concat([this.options]);
|
|
|
|
|
this.setState({
|
|
|
|
|
columns: _columns
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
this.setState({
|
|
|
|
|
columns: columns
|
|
|
|
|
columns: this.columns
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -333,10 +335,19 @@ class DeveloperHome extends React.PureComponent {
|
|
|
|
|
});
|
|
|
|
|
if (info.type === 'come_from' && info.key === 'mine') {
|
|
|
|
|
this.setState({
|
|
|
|
|
columns: columns
|
|
|
|
|
columns: this.columns
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 点击name
|
|
|
|
|
|
|
|
|
|
handleNameClick = (record) => {
|
|
|
|
|
console.log('name has click', record);
|
|
|
|
|
// 先调用start接口获取返回的 identifier, 再跳转到开启编辑
|
|
|
|
|
this.props.startProgramQuestion(record.identifier, this.props);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render () {
|
|
|
|
|
// const { testReducer, handleClick } = this.props;
|
|
|
|
|
const {
|
|
|
|
@ -453,10 +464,11 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
handleClick: () => dispatch(actions.toggleTodo()),
|
|
|
|
|
fetchOJList: (params) => dispatch(actions.getOJList(params)),
|
|
|
|
|
changePaginationInfo: (obj) => dispatch(actions.changePaginationInfo(obj)),
|
|
|
|
|
startProgramQuestion: (id, props) => dispatch(actions.startProgramQuestion(id, props))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|
export default withRouter(connect(
|
|
|
|
|
mapStateToProps,
|
|
|
|
|
mapDispatchToProps
|
|
|
|
|
)(DeveloperHome);
|
|
|
|
|
)(DeveloperHome));
|
|
|
|
|
// export default DeveloperHome;
|
|
|
|
|