diff --git a/public/react/src/modules/developer/components/initTabCtx/index.js b/public/react/src/modules/developer/components/initTabCtx/index.js
index 315fd7242..da0e97fe9 100644
--- a/public/react/src/modules/developer/components/initTabCtx/index.js
+++ b/public/react/src/modules/developer/components/initTabCtx/index.js
@@ -76,8 +76,8 @@ function InitTabCtx(props, ref) {
}, [inputValue]);
const _handleTestCodeFormSubmit = (cb) => {
- const { form } = props;
- form.validateFields((err, values) => {
+ const {form} = props;
+ form.validateFieldsAndScroll((err, values) => {
if (!err) { // 表单验证通过时,调用测试接口
cb && cb(); // 调用回调函数,切换 tab
onDebuggerCode && onDebuggerCode(values);
diff --git a/public/react/src/modules/developer/components/initTabCtx/index1.js b/public/react/src/modules/developer/components/initTabCtx/index1.js
index edf741c36..9c2cf099e 100644
--- a/public/react/src/modules/developer/components/initTabCtx/index1.js
+++ b/public/react/src/modules/developer/components/initTabCtx/index1.js
@@ -1,7 +1,7 @@
/*
- * @Description: 显示tab中的内容
- * @Author: tangjiang
- * @Date: 2019-11-18 10:43:03
+ * @Description: 显示tab中的内容
+ * @Author: tangjiang
+ * @Date: 2019-11-18 10:43:03
* @Last Modified by: tangjiang
* @Last Modified time: 2019-11-18 11:35:12
*/
@@ -31,7 +31,7 @@ const renderUserCase = (ctx, position, props) => {
})()
}
- {/*
{
@@ -76,7 +76,7 @@ class InitTabCtx extends PureComponent {
handleTestCodeFormSubmit = (cb) => {
const { form, debuggerCode } = this.props;
console.log(debuggerCode);
- form.validateFields((err, values) => {
+ form.validateFieldsAndScroll((err, values) => {
if (!err) { // 表单验证通过时,调用测试接口
cb && cb(); // 调用回调函数,切换 tab
console.log('表单值:', values);
diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index2.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index2.js
new file mode 100644
index 000000000..851262949
--- /dev/null
+++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index2.js
@@ -0,0 +1,334 @@
+/*
+ * @Description:
+ * @Author: tangjiang
+ * @Github:
+ * @Date: 2019-12-01 09:17:07
+ * @LastEditors: tangjiang
+ * @LastEditTime: 2019-12-02 16:33:35
+ */
+import 'quill/dist/quill.core.css';
+import 'quill/dist/quill.bubble.css';
+import 'quill/dist/quill.snow.css';
+import './index.scss';
+import React, { useState, useImperativeHandle, useRef, useEffect } from 'react';
+import { Form, Input, InputNumber, Button, Select } from 'antd';
+import { connect } from 'react-redux';
+import AddTestDemo from './AddTestDemo';
+import QuillEditor from '../../../quillEditor';
+import actions from '../../../../../redux/actions';
+import CONST from '../../../../../constants';
+
+const {jcLabel} = CONST;
+const { Option } = Select;
+const FormItem = Form.Item;
+
+const maps = {
+ language: [
+ { title: 'C', key: 'C' },
+ { title: 'C++', key: 'C++' },
+ { title: 'Python', key: 'Python' },
+ { title: 'Java', key: 'Java' }
+ ],
+ difficult: [
+ { title: '简单', key: '1' },
+ { title: '中等', key: '2'},
+ { title: '困难', key: '3' }
+ ],
+ category: [
+ { title: '程序设计', key: '1' },
+ { title: '算法', key: '2'}
+ ],
+ openOrNot: [
+ { title: '公开', key: '1' },
+ { title: '私有', key: '0' }
+ ]
+}
+
+function EditTab (props, ref) {
+
+ const {
+ form,
+ ojForm,
+ position,
+ testCases,
+ addTestCase,
+ deleteTestCase,
+ testCasesValidate,
+ getFormData
+ } = props;
+
+ const { getFieldDecorator } = form;
+
+ const formRef = useRef(null);
+ const [description, setDescription] = useState('');
+
+ // 获取表单label
+ const myLabel = (name, subTitle) => {
+ if (subTitle) {
+ return (
+
+ {name}
+
+ ({subTitle})
+
+
+ )
+ } else {
+ return (
+ {name}
+ )
+ }
+ };
+ // 获取下拉列表项
+ const getOptions = (key) => {
+ return maps[key].map((opt, i) => {
+ return (
+
+ );
+ });
+ };
+ // 向外暴露的方法
+ useImperativeHandle(ref, () => ({
+ validateForm () {
+ props.form.validateFieldsAndScroll((err, values) => {
+ if (!err) {
+ getFormData(() => {
+ return values;
+ });
+ } else {
+ return;
+ }
+ })
+ }
+ }));
+ // 添加测试用例
+ const handleAddTest = () => {
+ const obj = { // 测试用例参数
+ input: '',
+ output: '',
+ position: position,
+ isAdd: true // 新增的测试用例
+ }
+ const validateObj = { // 测试用例验证参数
+ input: {
+ validateStatus: '',
+ errMsg: ''
+ },
+ output: {
+ validateStatus: '',
+ errMsg: ''
+ }
+ }
+ addTestCase({testCase: obj, tcValidate: validateObj});
+ // TODO 点击新增时,需要滚到到最底部
+ // this.editorRef.current.scrollTop
+ // const oDiv = this.editorRef.current;
+ // oDiv.scrollTo(oDiv.scrollLeft, 99999);
+ // console.log(oDiv.scrollTop);
+ // oDiv.scrollTop = 99999;
+ }
+ // 渲染测试用例
+ const renderTestCase = () => {
+ return testCases.map((item, i) => {
+ return (
+
+ )
+ });
+ };
+ // 提交测试用例
+ const handleSubmitTest = (obj) => {
+ console.log('提交的测试用例: ', obj);
+ };
+ // 删除测试用例
+ const handleDeleteTest = (obj) => {
+ console.log('删除的测试用例: ', obj);
+ deleteTestCase(obj);
+ };
+ // 描述信息改变时
+ const handleChangeDescription = (value) => {
+ console.log('描述信息改变: ', value);
+ if (value) {
+ setDescription(value);
+ }
+ }
+
+ useEffect(() => {
+ if (description) {
+ props.form.setFieldsValue({
+ description: description
+ }, function () {
+ console.log('设置成功。。。');
+ });
+ }
+ }, [description]);
+
+ return (
+
+
+ {/* 添加测试用例 */}
+
+
测试用例
+
+
+
+ { renderTestCase() }
+
+
+ );
+}
+
+const mapStateToProps = (state) => {
+ const ojFormReducer = state.ojFormReducer;
+ const {ojForm, position, testCases, testCasesValidate} = ojFormReducer;
+ return {
+ ojForm,
+ testCases,
+ testCasesValidate,
+ position
+ };
+}
+
+const mapDispatchToProps = (dispatch) => ({
+ // 新增测试用例
+ addTestCase: (value) => dispatch(actions.addTestCase(value)),
+ // 删除测试用例
+ deleteTestCase: (value) => dispatch(actions.deleteTestCase(value)),
+})
+
+// EditTab = React.formRef(EditTab);
+// EditTab = React.forwardRef(EditTab);
+
+export default connect(
+ mapStateToProps,
+ mapDispatchToProps
+)(Form.create()(
+ React.forwardRef(EditTab)
+));
diff --git a/public/react/src/modules/developer/newOrEditTask/rightpane/initTabCtx/index.js b/public/react/src/modules/developer/newOrEditTask/rightpane/initTabCtx/index.js
index a1d9d7c57..73d983ba2 100644
--- a/public/react/src/modules/developer/newOrEditTask/rightpane/initTabCtx/index.js
+++ b/public/react/src/modules/developer/newOrEditTask/rightpane/initTabCtx/index.js
@@ -1,7 +1,7 @@
/*
- * @Description: 显示tab中的内容
- * @Author: tangjiang
- * @Date: 2019-11-18 10:43:03
+ * @Description: 显示tab中的内容
+ * @Author: tangjiang
+ * @Date: 2019-11-18 10:43:03
* @Last Modified by: tangjiang
* @Last Modified time: 2019-11-18 11:35:12
*/
@@ -31,7 +31,7 @@ const renderUserCase = (ctx, position, props) => {
})()
}
- {/*
{
@@ -76,7 +76,7 @@ class InitTabCtx extends PureComponent {
handleTestCodeFormSubmit = (cb) => {
const { form, debuggerCode } = this.props;
// console.log(debuggerCode);
- form.validateFields((err, values) => {
+ form.validateFieldsAndScroll((err, values) => {
if (!err) { // 表单验证通过时,调用测试接口
cb && cb(); // 调用回调函数,切换 tab
// console.log('表单值:', values);
diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js
index 38f41fcd1..0282d5b7b 100644
--- a/public/react/src/modules/developer/studentStudy/rightpane/index.js
+++ b/public/react/src/modules/developer/studentStudy/rightpane/index.js
@@ -1,7 +1,7 @@
/*
- * @Description:
+ * @Description:
* @Author: tangjiang
- * @Github:
+ * @Github:
* @Date: 2019-11-27 14:59:51
* @LastEditors : tangjiang
* @LastEditTime : 2020-01-02 14:23:43
@@ -37,6 +37,17 @@ const RightPane = (props) => {
const [noteClazz, setNoteClazz] = useState('editor_nodte_area');
const [noteCount] = useState(5000);
+ // const [code, setCode] = useState(editor_code || hack.code);
+ // let initFlag = true;
+
+ // useEffect(() => {
+ // if (editor_code) {
+ // setEditorCode(editor_code);
+ // } else {
+ // setEditorCode(hack.code);
+ // }
+ // }, [hack, editor_code]);
+
const handleSubmitForm = () => {
submitUserCode(identifier, submitInput, 'submit');
@@ -83,7 +94,7 @@ const RightPane = (props) => {
}
const handleSubmitNote = () => {
- props.form.validateFields((err, values) => {
+ props.form.validateFieldsAndScroll((err, values) => {
if (!err) {
changeLoadingState(true);
addNotes(identifier, values, function () {