From b6de31849466cdb43672769d60b9b5df02bab145 Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Fri, 28 Jun 2019 15:36:31 +0800 Subject: [PATCH] CreateGroupByImportModal --- .../members/modal/CreateGroupByImportModal.js | 158 ++++++++++++++++++ .../modules/courses/members/studentsList.js | 9 +- 2 files changed, 166 insertions(+), 1 deletion(-) create mode 100644 public/react/src/modules/courses/members/modal/CreateGroupByImportModal.js diff --git a/public/react/src/modules/courses/members/modal/CreateGroupByImportModal.js b/public/react/src/modules/courses/members/modal/CreateGroupByImportModal.js new file mode 100644 index 000000000..fe2a88dce --- /dev/null +++ b/public/react/src/modules/courses/members/modal/CreateGroupByImportModal.js @@ -0,0 +1,158 @@ +import React, { Component } from "react"; +import { Modal, Checkbox, Input, Spin, Upload, Divider, Icon } from "antd"; +import axios from 'axios' +import ModalWrapper from "../../common/ModalWrapper" + +import { ConditionToolTip, getUploadActionUrl } from 'educoder' + +const { Dragger } = Upload; + + + +class CreateGroupByImportModal extends Component{ + constructor(props){ + super(props); + this.state={ + } + } + fetchMemberList = (arg_page) => { + } + componentDidMount() { + + + } + onSendOk = () => { + const courseId = this.props.match.params.coursesId + + let url = `/courses/${courseId}/create_group_by_importing_file.json` + let { fileList } =this.state; + + if (!fileList || fileList.length == 0) { + // this.props.showNotification('请先上传附件') + this.setState({ + errorTip :'请先上传附件', + }) + return; + } + let newfileList=[]; + for(var list of fileList){ + newfileList.push(list.response.id) + } + + axios.post(url, { + attachment_ids: newfileList + }) + .then((response) => { + if (response.data.status == 0) { + this.props.showNotification(response.data.message) + this.setVisible(false) + } else { + + } + }) + .catch(function (error) { + console.log(error); + }); + } + setVisible = (visible) => { + if (visible) { + this.setState({ fileList: [] }); + } + this.refs.modalWrapper.setVisible(visible) + + } + handleChange = (info) => { + let fileList = info.fileList; + console.log(fileList) + this.setState({ fileList }); + } + + onOk = () => { + this.onSendOk() + } + + onAttachmentRemove = (file) => { + this.props.confirm({ + content: '是否确认删除?', + + onOk: () => { + this.deleteAttachment(file) + }, + onCancel() { + console.log('Cancel'); + }, + }); + + return false; + } + deleteAttachment = (file) => { + const url = `/attachments/${file.response ? file.response.id : file.uid}.json` + axios.delete(url, { + }) + .then((response) => { + if (response.data) { + // const { status } = response.data; + if (response.data.status === 0) { + + this.setState((state) => { + const index = state.fileList.indexOf(file); + const newFileList = state.fileList.slice(); + newFileList.splice(index, 1); + return { + fileList: newFileList, + }; + }); + } + } + }) + .catch(function (error) { + console.log(error); + }); + } + + render(){ + const { candidates, checkBoxValues, loading, hasMore, name, school_name, school_names + , graduationGroup, graduation_groups, courseGroup, course_groups } = this.state + const { moduleName } = this.props + + const props = { + name: 'file', + multiple: true, + action: getUploadActionUrl(), + onRemove: this.onAttachmentRemove, + onChange: this.handleChange + }; + return( + + + +
+ + + +
+ +

+ +

+

点击或拖拽文件到这里上传

+

+ 单个文件最大150MB +

+
+
+ ) + } +} +export default CreateGroupByImportModal; diff --git a/public/react/src/modules/courses/members/studentsList.js b/public/react/src/modules/courses/members/studentsList.js index 9c6254cbd..ba41f1f9e 100644 --- a/public/react/src/modules/courses/members/studentsList.js +++ b/public/react/src/modules/courses/members/studentsList.js @@ -14,6 +14,8 @@ import axios from 'axios' import _ from 'lodash' import NoneData from "../coursesPublic/NoneData" +import CreateGroupByImportModal from './modal/CreateGroupByImportModal' + const Search =Input.Search; const dataSource = [{ check:, @@ -488,7 +490,10 @@ class studentsList extends Component{ searchPlaceholder={ '请输入姓名、学号进行搜索' } firstRowRight={ - {/* { isSuperAdmin && this.addTeacher()}>导入创建分班 } */} + { isSuperAdmin && + {/* */} + this.refs['createGroupByImportModal'].setVisible(true)}>导入创建分班 + } { isAdmin && isParent && this.addDir()}>新建分班 } { isAdmin && !isParent && course_group_id != 0 && this.deleteDir()}>删除分班 } { isAdmin && !isParent && course_group_id != 0 && this.renameDir()}>分班重命名 } @@ -582,11 +587,13 @@ class studentsList extends Component{ ) }) } { isAdmin && +

this.addDir()} >添加分班...

+ } }