/* * @Description: 右侧代码块控制台 * @Author: tangjiang * @Github: * @Date: 2019-11-27 16:02:36 * @LastEditors: tangjiang * @LastEditTime: 2019-12-20 14:37:39 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; import { Tabs, Button, Icon } from 'antd'; import { connect } from 'react-redux'; import InitTabCtx from '../initTabCtx'; import ExecResult from '../execResult'; import actions from '../../../../redux/actions'; const { TabPane } = Tabs; const ControlSetting = (props) => { const { inputValue, loading, submitLoading, identifier, excuteState, showOrHideControl, commitTestRecordDetail, changeLoadingState, changeSubmitLoadingStatus, changeShowOrHideControl, // debuggerCode, // startDebuggerCode, // 外部存入 onDebuggerCode, // updateCode, onSubmitForm } = props; const [defaultActiveKey, setDefaultActiveKey] = useState('1'); // 当前选中的tab const [showTextResult, setShowTextResult] = useState(false); // 是否点击控制台按钮 const formRef = useRef(null); const classNames = `control_tab ${showTextResult ? 'move_up move_up_final' : 'move_down_final'}`; // 切换tab const handleTabChange = (key) => { setDefaultActiveKey(key); } useEffect(() => { setShowTextResult(props.showOrHideControl); }, [props]); // 显示/隐藏tab const handleShowControl = () => { setShowTextResult(!showTextResult); changeShowOrHideControl(!showTextResult); } // 调试代码 const handleTestCode = (e) => { // console.log(formRef.current.handleTestCodeFormSubmit); // 调出控制台界面 setShowTextResult(true); changeShowOrHideControl(true); formRef.current.handleTestCodeFormSubmit(() => { setDefaultActiveKey('2'); }); } // 提交 const handleSubmit = (e) => { e.preventDefault(); changeSubmitLoadingStatus(true); onSubmitForm && onSubmitForm(); } // 处理调度代码 const handleDebuggerCode = (values) => { // 改变状态值 changeLoadingState(true); // 调用代码保存接口, 成功后再调用调试接口 // updateCode(identifier, values, 'debug'); // 调用调试接口 // debuggerCode(identifier, values); onDebuggerCode(values); } return (
formRef.current = form} onDebuggerCode={handleDebuggerCode} />

); } const mapStateToProps = (state) => { const {commonReducer, ojForUserReducer} = state; const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer; const { commitTestRecordDetail } = ojForUserReducer; return { loading, submitLoading, excuteState, showOrHideControl, // identifier: user_program_identifier, commitTestRecordDetail // 提交详情 }; }; // changeSubmitLoadingStatus const mapDispatchToProps = (dispatch) => ({ changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag)), changeLoadingState: (flag) => dispatch(actions.changeLoadingState(flag)), changeSubmitLoadingStatus: (flag) => dispatch(actions.changeSubmitLoadingStatus(flag)), debuggerCode: (identifier, values) => dispatch(actions.debuggerCode(identifier, values)), // inputValue 输入值 updateCode: (identifier, inputValue, type) => dispatch(actions.updateCode(identifier, inputValue, type)) }); export default connect( mapStateToProps, mapDispatchToProps )(ControlSetting);