From 6a377c17c5f45be441a2187a7cc0427ffade4526 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Tue, 7 Jan 2020 14:20:10 +0800 Subject: [PATCH] add knowledge --- .../developer/components/knowledge/index.js | 83 +++++++++++++++---- .../developer/components/knowledge/index.scss | 6 ++ public/react/src/services/ojService.js | 7 +- 3 files changed, 76 insertions(+), 20 deletions(-) diff --git a/public/react/src/modules/developer/components/knowledge/index.js b/public/react/src/modules/developer/components/knowledge/index.js index 3a588ba89..ccbf0719b 100644 --- a/public/react/src/modules/developer/components/knowledge/index.js +++ b/public/react/src/modules/developer/components/knowledge/index.js @@ -4,13 +4,12 @@ * @Github: * @Date: 2019-12-30 13:51:19 * @LastEditors : tangjiang - * @LastEditTime : 2020-01-07 11:08:58 + * @LastEditTime : 2020-01-07 14:19:39 */ import './index.scss'; import React, { useState, useEffect } from 'react'; -import { Select, notification } from 'antd'; -import { CNotificationHOC} from 'educoder'; -// import {} from 'antd'; +import { Select, notification, Modal, Form, Input, Button } from 'antd'; + const { Option } = Select; function KnowLedge (props) { @@ -18,7 +17,8 @@ function KnowLedge (props) { const { options = [], // 下拉选项 values = [], // 已选择的下拉项 - onChange // 获取选择的值 + onChange, // 获取选择的值 + form } = props; useEffect(() => { @@ -39,9 +39,12 @@ function KnowLedge (props) { const [selectOptions, setSelectOptions] = useState(options); // 已选择的下拉项 const [selectValue, setSelectValue] = useState([]); + const [visible, setVisible] = useState(false); // const [value] = useState([]); + const { getFieldDecorator } = form; + const FormItem = Form.Item; // 渲染下拉选项 const renderOptions = (options = []) => { return options.map((opt, i) => ( @@ -117,27 +120,71 @@ function KnowLedge (props) { // 添加知识点 const handleAddKnowledge = () => { - + setVisible(true); }; + const handleResetForm = () => { + form.resetFields(); + setVisible(false); + } + + const handleSubmitForm = (e) => { + e.preventDefault(); + form.validateFieldsAndScroll((err, values) => { + if (err) { + return; + } + setVisible(false); + console.log(values); + }) + } + const _styles = { display: selectOptions.length > 0 || selectValue.length > 0 ? 'inline-block' : 'none' }; return ( -
- { renderSelect(selectOptions) } - {/* 渲染下拉选择项 */} -
- - { renderResult(selectValue) } + +
+ { renderSelect(selectOptions) } + {/* 渲染下拉选择项 */} +
+ {/* */} + { renderResult(selectValue) } +
-
+ + +
+ + { + getFieldDecorator('name', { + rules: [{ + required: true, message: '知识点名称不能为空' + }] + })( + + ) + } + + + + + +
+
+ + ); } -export default CNotificationHOC()(KnowLedge); +export default Form.create()(KnowLedge); diff --git a/public/react/src/modules/developer/components/knowledge/index.scss b/public/react/src/modules/developer/components/knowledge/index.scss index acd17e91c..9a457acf9 100644 --- a/public/react/src/modules/developer/components/knowledge/index.scss +++ b/public/react/src/modules/developer/components/knowledge/index.scss @@ -48,3 +48,9 @@ } } } + +.knowledge-form{ + .ant-form-explain{ + padding: 0; + } +} diff --git a/public/react/src/services/ojService.js b/public/react/src/services/ojService.js index 59151e687..62ebf9dbb 100644 --- a/public/react/src/services/ojService.js +++ b/public/react/src/services/ojService.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 10:55:38 * @LastEditors : tangjiang - * @LastEditTime : 2019-12-30 09:44:56 + * @LastEditTime : 2020-01-07 14:19:24 */ import axios from 'axios'; @@ -148,4 +148,7 @@ export async function fetchAddNotes (identifier, params) { export async function fetchQuestion (params) { const url = `/disciplines.json`; return axios.get(url, { params }); -} \ No newline at end of file +} + +// 新增选题 +export async function fetchExaminationItems () {} \ No newline at end of file