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 ( -