From c875bb9bd16c400b7a616ff64d75bd1ebda469d5 Mon Sep 17 00:00:00 2001
From: tangjiang <465264938@qq.com>
Date: Fri, 29 Nov 2019 11:11:39 +0800
Subject: [PATCH] =?UTF-8?q?=E5=88=97=E8=A1=A8=E9=A1=B5=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E9=80=89=E6=8B=A9=E6=9D=A1=E4=BB=B6=E6=8F=90=E7=A4=BA=E4=BF=A1?=
=?UTF-8?q?=E6=81=AF?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/modules/developer/DeveloperHome.js | 190 +++++++++++++-----
public/react/src/modules/developer/index.scss | 14 +-
.../newOrEditTask/rightpane/index.js | 2 -
.../developer/studentStudy/leftpane/index.js | 3 +-
public/react/src/redux/actions/actionTypes.js | 3 +-
public/react/src/redux/actions/index.js | 3 +-
public/react/src/redux/actions/ojForUser.js | 4 +-
public/react/src/redux/actions/ojList.js | 18 +-
.../react/src/redux/reducers/ojListReducer.js | 15 +-
9 files changed, 189 insertions(+), 63 deletions(-)
diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js
index 469f1f91c..a5d279950 100644
--- a/public/react/src/modules/developer/DeveloperHome.js
+++ b/public/react/src/modules/developer/DeveloperHome.js
@@ -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 => {`${val}%`}
+ render: val => {`${val}%`}
},
];
-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 {
)
};
+
getOptionsItem = (type) => {
return maps[type].map(item => {
return
@@ -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 (
+