添加目录

dev_forum
hjm 6 years ago
parent 66ea00a7de
commit 9eb28db680

@ -0,0 +1,78 @@
import React,{ Component } from "react";
import {Tooltip, Modal, Input } from 'antd'
import moment from 'moment'
import { getUrl, WordsBtn } from 'educoder'
import axios from 'axios'
class AddDirModal extends Component{
constructor(props){
super(props);
this.state = {
}
}
onInput = (e) => {
this.setState({
inputValue: e.target.value
})
}
open = () => {
this.setState({ visible: true, inputValue: '' })
}
onSave = () => {
let coursesId = this.props.match.params.coursesId;
const url = `/courses/${coursesId}/boards.json`
let { inputValue } = this.state;
axios.post(url,{
name: inputValue
}).then((response)=>{
if (response.data.status == 0) {
this.onCancel()
this.props.showNotification('添加成功')
this.props.addSuccess && this.props.addSuccess()
}
}).catch((error)=>{
console.log(error)
})
}
onCancel = () => {
this.setState({ visible: false, inputValue: '' })
}
render(){
let { inputValue, visible } = this.state;
const { title } = this.props;
return(
<Modal
keyboard={false}
title={title}
visible={visible}
className={"Navmodal"}
closable={false}
footer={null}
destroyOnClose={true}
centered={true}
>
<div className="df">
<div className={"fl mt5"}>{this.props.label}</div>
<Input placeholder={this.props.inputPlaceholder || '示例讨论小组A'}
className={"input-flex-35 greyInput fl"}
maxLength="60"
value={inputValue}
onInput={this.onInput}
/>
</div>
{/* {this.state.NavmodalValuetype===true?<span className={"color-red"}>
{this.state.NavmodalValues}
</span>:""} */}
{/* this.state.NavmodalValuetype===true?"clearfix mt20 edu-txt-center": */}
<div className={"clearfix mt50 edu-txt-center"}>
<a className="task-btn mr30" onClick={this.onCancel}>取消</a>
<a className="task-btn task-btn-orange" onClick={this.onSave}>确定</a>
</div>
</Modal>
)
}
}
export default AddDirModal;

@ -3,13 +3,13 @@ import React,{ Component } from "react";
import { import {
Form, Input, InputNumber, Switch, Radio, Form, Input, InputNumber, Switch, Radio,
Slider, Button, Upload, Icon, Rate, Checkbox, message, Slider, Button, Upload, Icon, Rate, Checkbox, message,
Row, Col, Select, Modal Row, Col, Select, Modal, Divider
} from 'antd'; } from 'antd';
import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor'; import TPMMDEditor from '../../tpm/challengesnew/TPMMDEditor';
import axios from 'axios' import axios from 'axios'
import './board.css' import './board.css'
import "../common/formCommon.css" import "../common/formCommon.css"
import AddDirModal from './AddDirModal'
import { RouteHOC } from './common.js' import { RouteHOC } from './common.js'
import CBreadcrumb from '../common/CBreadcrumb' import CBreadcrumb from '../common/CBreadcrumb'
import {getUploadActionUrl, bytesToSize, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll} from 'educoder'; import {getUploadActionUrl, bytesToSize, uploadNameSizeSeperator, appendFileSizeToUploadFile, appendFileSizeToUploadFileAll} from 'educoder';
@ -29,14 +29,14 @@ class BoardsNew extends Component{
boards: [] boards: []
} }
} }
componentDidMount = () => { addSuccess = () => {
this.fetchBoards()
const topicId = this.props.match.params.topicId }
fetchBoards = () => {
const isEdit = this.isEdit
const boardId = this.props.match.params.boardId const boardId = this.props.match.params.boardId
const boardsUrl = `/courses/board_list.json?board_id=${boardId}`
const isEdit = !!topicId
const boardsUrl = `/courses/board_list.json?board_id=${boardId}`
axios.get(boardsUrl, { }) axios.get(boardsUrl, { })
.then((response) => { .then((response) => {
if (response.data.status == 0) { if (response.data.status == 0) {
@ -57,8 +57,17 @@ class BoardsNew extends Component{
.catch(function (error) { .catch(function (error) {
console.log(error); console.log(error);
}); });
}
componentDidMount = () => {
const topicId = this.props.match.params.topicId
const isEdit = !!topicId
this.isEdit = isEdit this.isEdit = isEdit
const boardId = this.props.match.params.boardId
this.fetchBoards()
if (isEdit) { if (isEdit) {
const url = `/messages/${topicId}.json` const url = `/messages/${topicId}.json`
axios.get(url, { axios.get(url, {
@ -260,6 +269,12 @@ class BoardsNew extends Component{
return( return(
<div className="newMain "> <div className="newMain ">
<AddDirModal {...this.props}
title="添加目录"
label="目录名称"
ref="addDirModal"
addSuccess={this.addSuccess}
></AddDirModal>
<style>{` <style>{`
.courseForm .ant-form { .courseForm .ant-form {
} }
@ -312,7 +327,17 @@ class BoardsNew extends Component{
{getFieldDecorator('select_board_id', { {getFieldDecorator('select_board_id', {
// initialValue: '3779', // initialValue: '3779',
})( })(
<Select style={{ width: 230 }}> <Select style={{ width: 230 }}
dropdownRender={menu => (
<div>
{menu}
<Divider style={{ margin: '4px 0' }} />
<div style={{ padding: '8px', cursor: 'pointer' }} onMouseDown={() => this.refs['addDirModal'].open()}>
<Icon type="plus" /> 添加目录
</div>
</div>
)}
>
{this.state.boards.map(item => { {this.state.boards.map(item => {
return ( return (
<Option value={item.id}>{item.name}</Option> <Option value={item.id}>{item.name}</Option>

@ -33,6 +33,7 @@ function buildColumns(that) {
const { course_groups } = that.state const { course_groups } = that.state
const columns = [{ const columns = [{
title: '序号', title: '序号',
width: 28,
// dataIndex: 'name', // dataIndex: 'name',
key: 'index', key: 'index',
render: (content, item, index) => { render: (content, item, index) => {
@ -40,12 +41,13 @@ function buildColumns(that) {
} }
},{ },{
title: '用户ID', title: '用户ID',
width: 82,
dataIndex: 'login', dataIndex: 'login',
key: 'login' key: 'login'
}, { }, {
title: '姓名', title: '姓名',
dataIndex: 'name', dataIndex: 'name',
width: 160, width: 140,
key: 'name', key: 'name',
render: (name, record) => { render: (name, record) => {
return <a href={`/login/${record.login}`} target="_blank">{name}</a> return <a href={`/login/${record.login}`} target="_blank">{name}</a>
@ -57,7 +59,7 @@ function buildColumns(that) {
}] }]
that.state.course_groups && that.state.course_groups.length && columns.push({ that.state.course_groups && that.state.course_groups.length && columns.push({
title: <Tooltip title="仅能批阅指定分班的作品">管理权限</Tooltip>, title: <Tooltip title="仅能批阅指定分班的作品">管理权限</Tooltip>,
width: 230, // width: 230,
key: 'course_groups', key: 'course_groups',
dataIndex: 'course_groups', dataIndex: 'course_groups',
// onClick={() => that.joinCourseGroup(item.id)} // onClick={() => that.joinCourseGroup(item.id)}
@ -113,6 +115,7 @@ function buildColumns(that) {
if (hasGraduationModule) { if (hasGraduationModule) {
columns.push({ columns.push({
title: '答辩组', title: '答辩组',
width: 74,
key: 'graduation_group', key: 'graduation_group',
dataIndex: 'graduation_group', dataIndex: 'graduation_group',
render: text => ( render: text => (
@ -126,6 +129,7 @@ function buildColumns(that) {
columns.push({ columns.push({
title: '操作', title: '操作',
key: 'action', key: 'action',
width: 150,
align:'center', align:'center',
render: (text, record) => { render: (text, record) => {
if (record.application_id) { if (record.application_id) {

Loading…
Cancel
Save