修改逻辑流程

dev_forge
tangjiang 5 years ago
parent e802b89aa4
commit 7f2795a5a8

@ -15,6 +15,7 @@ import actions from '../../redux/actions';
import MultipTags from './components/multiptags'; import MultipTags from './components/multiptags';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import CONST from '../../constants'; import CONST from '../../constants';
import { withRouter } from 'react-router';
const {tagBackground, diffText} = CONST; const {tagBackground, diffText} = CONST;
const { Search } = Input; const { Search } = Input;
@ -96,10 +97,11 @@ const testMaps = {
} }
} }
class DeveloperHome extends React.PureComponent {
/** /**
* 表格列 * 表格列
*/ */
const options = { options = {
title: '操作', title: '操作',
key: 'action', key: 'action',
fixed: 'right', fixed: 'right',
@ -112,11 +114,12 @@ const options = {
</span> </span>
), ),
} }
const columns = [
columns = [
{ {
title: '标题', title: '标题',
dataIndex: 'name', dataIndex: 'name',
render: (name, record) => <Link style={{ color: '#459be5' }} to={`/myproblems/${record.identifier}`}>{name}</Link> render: (name, record) => <Button type="link" onClick={() => this.handleNameClick(record)} className={'oj_item_name'}>{name}</Button>
}, },
{ {
title: '分类', title: '分类',
@ -155,7 +158,6 @@ const columns = [
}, },
]; ];
class DeveloperHome extends React.PureComponent {
state = { state = {
data: [], data: [],
loading: false, loading: false,
@ -170,7 +172,7 @@ class DeveloperHome extends React.PureComponent {
page: 1, // 当前页数 page: 1, // 当前页数
limit: 10 // 每页显示条件 limit: 10 // 每页显示条件
}, },
columns: columns, columns: this.columns,
searchInfo: [] searchInfo: []
}; };
@ -179,7 +181,7 @@ class DeveloperHome extends React.PureComponent {
const { isMySource } = this.props; const { isMySource } = this.props;
if (isMySource) { if (isMySource) {
this.handleFilterSearch({come_from: 'mine'}); this.handleFilterSearch({come_from: 'mine'});
let _columns = columns.concat([options]); let _columns = this.columns.concat([this.options]);
this.setState({ this.setState({
columns: _columns columns: _columns
}); });
@ -309,13 +311,13 @@ class DeveloperHome extends React.PureComponent {
this.handleFilterSearch({come_from: item.key === 'all' ? '' : item.key}); this.handleFilterSearch({come_from: item.key === 'all' ? '' : item.key});
if (item.key !== 'all') { if (item.key !== 'all') {
let _columns = columns.concat([options]); let _columns = this.columns.concat([this.options]);
this.setState({ this.setState({
columns: _columns columns: _columns
}); });
} else { } else {
this.setState({ this.setState({
columns: columns columns: this.columns
}) })
} }
} }
@ -333,10 +335,19 @@ class DeveloperHome extends React.PureComponent {
}); });
if (info.type === 'come_from' && info.key === 'mine') { if (info.type === 'come_from' && info.key === 'mine') {
this.setState({ 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 () { render () {
// const { testReducer, handleClick } = this.props; // const { testReducer, handleClick } = this.props;
const { const {
@ -453,10 +464,11 @@ const mapDispatchToProps = (dispatch) => ({
handleClick: () => dispatch(actions.toggleTodo()), handleClick: () => dispatch(actions.toggleTodo()),
fetchOJList: (params) => dispatch(actions.getOJList(params)), fetchOJList: (params) => dispatch(actions.getOJList(params)),
changePaginationInfo: (obj) => dispatch(actions.changePaginationInfo(obj)), changePaginationInfo: (obj) => dispatch(actions.changePaginationInfo(obj)),
startProgramQuestion: (id, props) => dispatch(actions.startProgramQuestion(id, props))
}); });
export default connect( export default withRouter(connect(
mapStateToProps, mapStateToProps,
mapDispatchToProps mapDispatchToProps
)(DeveloperHome); )(DeveloperHome));
// export default DeveloperHome; // export default DeveloperHome;

@ -72,4 +72,8 @@
color: #fff; color: #fff;
} }
} }
.oj_item_name{
color: #459be5;
cursor: pointer;
}
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-23 10:53:19 * @Date: 2019-11-23 10:53:19
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-29 08:56:18 * @LastEditTime: 2019-11-29 19:15:25
*/ */
import './index.scss'; import './index.scss';
import React, { useEffect } from 'react'; import React, { useEffect } from 'react';
@ -20,9 +20,10 @@ import actions from '../../../redux/actions';
const StudentStudy = (props) => { const StudentStudy = (props) => {
useEffect(() => { useEffect(() => {
const { match: { params }, startProgramQuestion } = props; const { match: { params }, getUserProgramDetail } = props;
let { id } = params; let { id } = params;
startProgramQuestion(id); // startProgramQuestion(id);
getUserProgramDetail(id);
}, []); }, []);
return ( return (
<div className={'student_study_warp'}> <div className={'student_study_warp'}>
@ -61,7 +62,9 @@ const mapStateToProps = (state) => ({});
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({
// 调用开启编辑 // 调用开启编辑
startProgramQuestion: (id) => dispatch(actions.startProgramQuestion(id)) // startProgramQuestion: (id) => dispatch(actions.startProgramQuestion(id))
// 调用编程题详情
getUserProgramDetail: (id) => dispatch(actions.getUserProgramDetail(id))
}); });
export default connect( export default connect(

@ -36,6 +36,7 @@ import {
saveUserInputCode, saveUserInputCode,
changeUserCodeTab, changeUserCodeTab,
submitUserCode, submitUserCode,
getUserProgramDetail
// isUpdateCodeCtx // isUpdateCodeCtx
} from './ojForUser'; } from './ojForUser';
@ -79,6 +80,7 @@ export default {
changeSubmitLoadingStatus, changeSubmitLoadingStatus,
submitUserCode, submitUserCode,
changePublishLoadingStatus, changePublishLoadingStatus,
isMyPublish isMyPublish,
getUserProgramDetail
// isUpdateCodeCtx // isUpdateCodeCtx
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:42:11 * @Date: 2019-11-27 13:42:11
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-29 12:03:51 * @LastEditTime: 2019-11-29 19:37:24
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -19,7 +19,7 @@ import {
} from "../../services/ojService"; } from "../../services/ojService";
// 进入编程页面时,首先调用开启编程题接口 // 进入编程页面时,首先调用开启编程题接口
export const startProgramQuestion = (id) => { export const startProgramQuestion = (id, props) => {
return (dispatch) => { return (dispatch) => {
fetchStartProgram(id).then(res => { fetchStartProgram(id).then(res => {
const { status, data } = res; const { status, data } = res;
@ -29,8 +29,19 @@ export const startProgramQuestion = (id) => {
type: types.SAVE_USER_PROGRAM_ID, type: types.SAVE_USER_PROGRAM_ID,
payload: identifier payload: identifier
}); });
// 跳转至开启编程
props.history.push(`/myproblems/${identifier}.json`);
// Redirect.to
}
})
}
}
// 获取用户编程题详情
export const getUserProgramDetail = (identifier) => {
// 调用用户编程详情接口 // 调用用户编程详情接口
fetchUserProgramDetail(identifier).then(res => { fetchUserProgramDetail(identifier).then(res => {
return (dispatch) => {
const { status, data = {} } = res; const { status, data = {} } = res;
if (status === 200) { if (status === 200) {
dispatch({ dispatch({
@ -38,10 +49,8 @@ export const startProgramQuestion = (id) => {
payload: data payload: data
}); });
} }
})
}
})
} }
});
} }
/** /**

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-20 16:35:46 * @Date: 2019-11-20 16:35:46
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-28 21:21:56 * @LastEditTime: 2019-11-29 18:55:43
*/ */
import types from './actionTypes'; import types from './actionTypes';
import CONST from '../../constants'; import CONST from '../../constants';
@ -204,7 +204,7 @@ export const validateOjForm = (props, type) => {
payload: true payload: true
}); });
setTimeout(() => { setTimeout(() => {
props.history.push('/developer'); props.history.push('/problems');
}, 1000); }, 1000);
} }

Loading…
Cancel
Save