|
|
|
@ -8,8 +8,8 @@
|
|
|
|
|
|
|
|
|
|
import './index.scss';
|
|
|
|
|
|
|
|
|
|
import React, { Component } from 'react';
|
|
|
|
|
import { Table, Button, Dropdown, Icon, Menu, Card, Input, Select, Tag, Divider } from 'antd';
|
|
|
|
|
import React from 'react';
|
|
|
|
|
import { Table, Button, Dropdown, Icon, Menu, Card, Input, Select, Tag } from 'antd';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import actions from '../../redux/actions';
|
|
|
|
|
import MultipTags from './components/multiptags';
|
|
|
|
@ -28,63 +28,63 @@ const maps = {
|
|
|
|
|
{
|
|
|
|
|
'key': '0',
|
|
|
|
|
'name': '全部',
|
|
|
|
|
'vlaue': '0'
|
|
|
|
|
'value': '0'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': '1',
|
|
|
|
|
'name': '程序设计基础',
|
|
|
|
|
'vlaue': '1'
|
|
|
|
|
'value': '1'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': '2',
|
|
|
|
|
'name': '数据结构与计算',
|
|
|
|
|
'vlaue': '2'
|
|
|
|
|
'value': '2'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'hardMenu': [
|
|
|
|
|
'difficultMenu': [
|
|
|
|
|
{
|
|
|
|
|
'key': '1',
|
|
|
|
|
'name': '简单',
|
|
|
|
|
'vlaue': '1'
|
|
|
|
|
'value': '1'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': '2',
|
|
|
|
|
'name': '中等',
|
|
|
|
|
'vlaue': '2'
|
|
|
|
|
'value': '2'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': '3',
|
|
|
|
|
'name': '困难',
|
|
|
|
|
'vlaue': '3'
|
|
|
|
|
'value': '3'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'statusMenu': [
|
|
|
|
|
{
|
|
|
|
|
'key': '-1',
|
|
|
|
|
'name': '未做',
|
|
|
|
|
'vlaue': '-1'
|
|
|
|
|
'value': '-1'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': '0',
|
|
|
|
|
'name': '未通过',
|
|
|
|
|
'vlaue': '0'
|
|
|
|
|
'value': '0'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': '1',
|
|
|
|
|
'name': '已通过',
|
|
|
|
|
'vlaue': '1'
|
|
|
|
|
'value': '1'
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
'originMenu': [
|
|
|
|
|
'come_fromMenu': [
|
|
|
|
|
{
|
|
|
|
|
'key': 'all',
|
|
|
|
|
'name': '全部',
|
|
|
|
|
'vlaue': 'all'
|
|
|
|
|
'value': 'all'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
'key': 'mine',
|
|
|
|
|
'name': '我创建的',
|
|
|
|
|
'vlaue': 'mine'
|
|
|
|
|
'value': 'mine'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
};
|
|
|
|
@ -151,19 +151,13 @@ const columns = [
|
|
|
|
|
sorter: true,
|
|
|
|
|
align:'right',
|
|
|
|
|
width: '10%',
|
|
|
|
|
render: val => <span>{`${val}%`}</span>
|
|
|
|
|
render: val => <span>{`${val}%`}</span>
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
class DeveloperHome extends Component {
|
|
|
|
|
class DeveloperHome extends React.PureComponent {
|
|
|
|
|
state = {
|
|
|
|
|
data: [],
|
|
|
|
|
pagination: {
|
|
|
|
|
total: 1, // 总条数
|
|
|
|
|
pageSize: 10, // 每页显示条数
|
|
|
|
|
current: 1, // 当前页数
|
|
|
|
|
showQuickJumper: true
|
|
|
|
|
},
|
|
|
|
|
loading: false,
|
|
|
|
|
searchParams: {
|
|
|
|
|
search: '', // 查询关键字
|
|
|
|
@ -172,15 +166,18 @@ class DeveloperHome extends Component {
|
|
|
|
|
status: '', // 未做
|
|
|
|
|
category: '', // 分类
|
|
|
|
|
'sort_by': '', // 排序
|
|
|
|
|
'sort_direction': '' // 排序方向
|
|
|
|
|
'sort_direction': '', // 排序方向
|
|
|
|
|
page: 1, // 当前页数
|
|
|
|
|
limit: 10 // 每页显示条件
|
|
|
|
|
},
|
|
|
|
|
columns: columns
|
|
|
|
|
columns: columns,
|
|
|
|
|
searchInfo: []
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
// 是否是我的,如果是我的 显示编辑按钮
|
|
|
|
|
const { isMySource } = this.props;
|
|
|
|
|
if (isMySource) {
|
|
|
|
|
// this.handleFilterSearch()
|
|
|
|
|
this.handleFilterSearch({come_from: 'mine'});
|
|
|
|
|
let _columns = columns.concat([options]);
|
|
|
|
|
this.setState({
|
|
|
|
@ -199,9 +196,15 @@ class DeveloperHome extends Component {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleTableChange = (pagination, filters, sorter) => {
|
|
|
|
|
// console.log(pagination, filters, sorter);
|
|
|
|
|
const {field, order} = sorter;
|
|
|
|
|
this.handleFilterSearch({sort_by: field, sort_direction: order === 'descend' ? 'desc' : 'asc'});
|
|
|
|
|
const {current, pageSize} = pagination;
|
|
|
|
|
this.handleFilterSearch({
|
|
|
|
|
sort_by: field,
|
|
|
|
|
sort_direction: order === 'descend' ? 'desc' : 'asc',
|
|
|
|
|
page: current,
|
|
|
|
|
limit: pageSize
|
|
|
|
|
});
|
|
|
|
|
this.props.changePaginationInfo(pagination);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
fetchData = () => {
|
|
|
|
@ -228,6 +231,7 @@ class DeveloperHome extends Component {
|
|
|
|
|
</Menu>
|
|
|
|
|
)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getOptionsItem = (type) => {
|
|
|
|
|
return maps[type].map(item => {
|
|
|
|
|
return <Option key={item.key} value={item.value}>{item.name}</Option>
|
|
|
|
@ -242,6 +246,21 @@ class DeveloperHome extends Component {
|
|
|
|
|
this.fetchData();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加显示搜索条件
|
|
|
|
|
addShowFilterCtx = (obj) => {
|
|
|
|
|
const {searchInfo} = this.state
|
|
|
|
|
const index = searchInfo.findIndex(item => item.type === obj.type);
|
|
|
|
|
let tempArr = [...searchInfo];
|
|
|
|
|
if (index > -1) {
|
|
|
|
|
tempArr[index] = obj;
|
|
|
|
|
} else {
|
|
|
|
|
tempArr.push(obj);
|
|
|
|
|
}
|
|
|
|
|
this.setState({
|
|
|
|
|
searchInfo: tempArr
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 搜索输入框
|
|
|
|
|
* @param value 输入框值
|
|
|
|
@ -257,18 +276,36 @@ class DeveloperHome extends Component {
|
|
|
|
|
// }
|
|
|
|
|
// 下拉类别菜单
|
|
|
|
|
handleCategoryMenuClick = (item) => {
|
|
|
|
|
this.addShowFilterCtx({
|
|
|
|
|
type: 'category',
|
|
|
|
|
key: item.key
|
|
|
|
|
});
|
|
|
|
|
this.handleFilterSearch({category: +item.key === 0 ? '' : +item.key});
|
|
|
|
|
}
|
|
|
|
|
// 难度下拉
|
|
|
|
|
handleHardMenuClick = (item) => {
|
|
|
|
|
this.addShowFilterCtx({
|
|
|
|
|
type: 'difficult',
|
|
|
|
|
key: item.key
|
|
|
|
|
});
|
|
|
|
|
this.handleFilterSearch({difficult: +item.key});
|
|
|
|
|
}
|
|
|
|
|
// 状态下拉
|
|
|
|
|
handleSatusMenuClick = (item) => {
|
|
|
|
|
this.addShowFilterCtx({
|
|
|
|
|
type: 'status',
|
|
|
|
|
key: item.key
|
|
|
|
|
});
|
|
|
|
|
this.handleFilterSearch({status: +item.key});
|
|
|
|
|
}
|
|
|
|
|
// 来源下拉
|
|
|
|
|
handleOriginMenuClick = (item) => {
|
|
|
|
|
|
|
|
|
|
this.addShowFilterCtx({
|
|
|
|
|
type: 'come_from',
|
|
|
|
|
key: item.key
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.handleFilterSearch({come_from: item.key === 'all' ? '' : item.key});
|
|
|
|
|
|
|
|
|
|
if (item.key !== 'all') {
|
|
|
|
@ -283,11 +320,49 @@ class DeveloperHome extends Component {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleTagClose = (info) => {
|
|
|
|
|
|
|
|
|
|
this.handleFilterSearch({[info.type]: ''});
|
|
|
|
|
// 移除 searcInfo 中的数据
|
|
|
|
|
const { type } = info;
|
|
|
|
|
let tempArr = [...this.state.searchInfo];
|
|
|
|
|
const index = tempArr.findIndex(item => item.type === type);
|
|
|
|
|
if (index > -1) tempArr.splice(index, 1);
|
|
|
|
|
this.setState({
|
|
|
|
|
searchInfo: tempArr
|
|
|
|
|
});
|
|
|
|
|
if (info.type === 'come_from' && info.key === 'mine') {
|
|
|
|
|
this.setState({
|
|
|
|
|
columns: columns
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
render () {
|
|
|
|
|
// const { testReducer, handleClick } = this.props;
|
|
|
|
|
const { ojListReducer: {hacks_list, top_data, hacks_count} } = this.props;
|
|
|
|
|
const {
|
|
|
|
|
ojListReducer: {hacks_list, top_data, hacks_count},
|
|
|
|
|
pagination
|
|
|
|
|
} = this.props;
|
|
|
|
|
const {passed_count = 0, simple_count = 0, medium_count = 0, diff_count = 0} = top_data;
|
|
|
|
|
const { columns } = this.state;
|
|
|
|
|
|
|
|
|
|
// 渲染条件内容
|
|
|
|
|
const renderSearch = () => {
|
|
|
|
|
return this.state.searchInfo.map(info => {
|
|
|
|
|
let ctx = '';
|
|
|
|
|
const arrs = maps[`${info.type}Menu`];
|
|
|
|
|
arrs.forEach(item => {
|
|
|
|
|
if (item.key === info.key) ctx = item.name;
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<Tag
|
|
|
|
|
closable
|
|
|
|
|
key={info.type}
|
|
|
|
|
onClose={() => this.handleTagClose(info)}
|
|
|
|
|
>{ctx}</Tag>
|
|
|
|
|
)});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="developer-list">
|
|
|
|
|
<div className="ant-spin-container">
|
|
|
|
@ -307,34 +382,39 @@ class DeveloperHome extends Component {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div className={'card-table'}>
|
|
|
|
|
<Card bordered={false}>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('categoryMenu', this.handleCategoryMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>分类 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('hardMenu', this.handleHardMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>难度 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('statusMenu', this.handleSatusMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>状态 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('originMenu', this.handleOriginMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>来源 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<div bordered={false} className={'filter_ctx_area'}>
|
|
|
|
|
<div>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('categoryMenu', this.handleCategoryMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>分类 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('difficultMenu', this.handleHardMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>难度 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('statusMenu', this.handleSatusMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>状态 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
<Dropdown className={'dropdonw-style'} placement="bottomLeft" overlay={this.getMenuItems('come_fromMenu', this.handleOriginMenuClick)}>
|
|
|
|
|
<span className={'dropdown-span'}>来源 <Icon type="down"/></span>
|
|
|
|
|
</Dropdown>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className={'choice_ctx'}>
|
|
|
|
|
{renderSearch()}
|
|
|
|
|
</div>
|
|
|
|
|
<Search
|
|
|
|
|
placeholder="输入标题进行搜索"
|
|
|
|
|
onChange={this.handleSearchChange}
|
|
|
|
|
onSearch={value => this.handleInputSearch(value)}
|
|
|
|
|
style={{ width: 320, float: 'right' }}
|
|
|
|
|
/>
|
|
|
|
|
</Card>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Card bordered={false} style={{ marginTop: '2px'}}>
|
|
|
|
|
<Table
|
|
|
|
|
columns={columns}
|
|
|
|
|
rowKey={record => Math.random()}
|
|
|
|
|
dataSource={hacks_list}
|
|
|
|
|
pagination={this.state.pagination}
|
|
|
|
|
pagination={pagination}
|
|
|
|
|
onChange={this.handleTableChange}
|
|
|
|
|
/>
|
|
|
|
|
</Card>
|
|
|
|
@ -350,16 +430,28 @@ class DeveloperHome extends Component {
|
|
|
|
|
* @param {*} state store
|
|
|
|
|
* @param {*} ownProps DeveloperHome 中的 props
|
|
|
|
|
*/
|
|
|
|
|
const mapStateToProps = (state, ownProps) => ({
|
|
|
|
|
testReducer: state.testReducer,
|
|
|
|
|
ojListReducer: state.ojListReducer,
|
|
|
|
|
isMySource: state.commonReducer.isMySource
|
|
|
|
|
});
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
const {
|
|
|
|
|
testReducer,
|
|
|
|
|
ojListReducer,
|
|
|
|
|
commonReducer
|
|
|
|
|
} = state;
|
|
|
|
|
|
|
|
|
|
const { pagination } = ojListReducer;
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
testReducer,
|
|
|
|
|
ojListReducer,
|
|
|
|
|
isMySource: commonReducer.isMySource,
|
|
|
|
|
pagination
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
handleClick: () => dispatch(actions.toggleTodo()),
|
|
|
|
|
fetchOJList: (params) => dispatch(actions.getOJList(params)),
|
|
|
|
|
changePaginationInfo: (obj) => dispatch(actions.changePaginationInfo(obj)),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|