import React, {Component} from 'react'; import {TPMIndexHOC} from '../TPMIndexHOC'; import {SnackbarHOC} from 'educoder'; import {Select, Radio, Input, Modal, Button, Form, Tooltip, Upload,Icon} from 'antd'; import locale from 'antd/lib/date-picker/locale/zh_CN'; import axios from 'axios'; import {getUrl,getUploadActionUrl} from 'educoder'; import moment from 'moment'; import './css/Newshixuns.css'; import TPMMDEditor from "../challengesnew/TPMMDEditor"; let path = getUrl("/editormd/lib/"); const $ = window.$; let timeout; let currentValue; const Option = Select.Option; const RadioGroup = Radio.Group; const confirm = Modal.confirm; class Newshixuns extends Component { constructor(props) { super(props) this.contentMdRef = React.createRef(); this.state = { shixunName: undefined, NAME_COUNT: 60, Radiovalue: "1", newshixunlist: undefined, languagewrite:undefined, systemenvironment:undefined, testcoderunmode:undefined, postapplyvisible:undefined } } componentDidMount() { this.props.form.setFieldsValue({ radiogroup: `1`, }); let newshixunUrl = `/shixuns/new.json`; axios.get(newshixunUrl).then((response) => { if (response.status === 200) { if (response.data.message === undefined) { this.setState({ newshixunlist: response.data }); this.contentMdRef.current.setValue(!response.data.sample[0][1] ? "" : response.data.sample[0][1]); } } }).catch((error) => { console.log(error) }); let departmentsUrl = `/shixuns/departments.json`; axios.get(departmentsUrl).then((response) => { if (response.status === 200) { if (response.data.message === undefined) { this.setState({ departmentslist: response.data.shools_name }); } } }).catch((error) => { console.log(error) }); // const mdContnet = this.contentMdRef.current.getValue().trim(); } shixunNameInput = (e) => { this.setState({ shixunName: e.target.value }) this.props.form.setFieldsValue({ name: e.target.value, }); } RadiovalueonChange = (e) => { this.setState({ Radiovalue: e.target.value, }); }; handleSubmit = e => { e.preventDefault(); this.props.form.validateFieldsAndScroll((err, values) => { if (!err) { console.log('Received values of form: ', values); } }); }; Selectthestudent = (value) => { this.props.form.setFieldsValue({ select: value, }); } selectleft = (value) => { this.props.form.setFieldsValue({ selectleft: value, }); } selectright=(value)=>{ this.props.form.setFieldsValue({ selectright: value, }); } post_apply = () => { this.setState({ postapplyvisible: true }) } sendhideModaly = () => { this.setState({ postapplyvisible: false, }) if(this.state.file !== undefined){ console.log("580"); // this.deleteAttachment(this.state.file); this.setState({ file:undefined, deleteisnot:true, languagewrite:"", systemenvironment:"", testcoderunmode:"", fileList:[] }) }else { this.setState({ file:undefined, deleteisnot:true, languagewrite:"", systemenvironment:"", testcoderunmode:"", fileList:[] }) } } sendsure_apply = () => { let {languagewrite,systemenvironment,testcoderunmode} = this.state; // console.log("点击确定") // console.log("languagewrite"+languagewrite); // console.log("systemenvironment"+systemenvironment); // console.log("testcoderunmode"+testcoderunmode); // let attachment_ids = undefined // if (this.state.fileList) { // attachment_ids = this.state.fileList.map(item => { // return item.response ? item.response.id : item.id // }) // } if(languagewrite === undefined || languagewrite === "" ){ // this.props.showNotification(`请填写该镜像是基于什么语言`); this.setState({ languagewritetype:true }) return } if(systemenvironment === undefined || systemenvironment === ""){ // this.props.showNotification(`请填写该镜像是基于什么语言系统环境`); this.setState({ systemenvironmenttype:true }) return; } if(testcoderunmode === undefined || testcoderunmode === "") { // this.props.showNotification(`请填写该镜像中测试代码运行方式`); this.setState({ testcoderunmodetype:true }) return; } var attachment_ids=undefined; if (this.state.fileList) { attachment_ids = this.state.fileList.map(item => { return item.response ? item.response.id : item.id }) } if( attachment_ids === undefined || attachment_ids.length===0){ // notification.open( // { // message: '提示', // description: // '请上传附件!', // // } // ) this.setState({ attachmentidstype:true }) return; } // console.log("attachment_ids"+attachment_ids); // alert(languagewrite +" "+systemenvironment +" "+testcoderunmode + " "+attachment_ids); var data={ language:languagewrite, runtime:systemenvironment, run_method:testcoderunmode, attachment_id:attachment_ids[0], } var url =`/shixuns/apply_shixun_mirror.json`; axios.post(url,data ).then((response) => { try { if (response.data) { // const { id } = response.data; // if (id) { if(this.state.file !== undefined){ console.log("549"); // this.deleteAttachment(this.state.file); this.setState({ file:undefined, deleteisnot:true, languagewrite:"", systemenvironment:"", testcoderunmode:"", fileList:[] }) }else { this.setState({ file:undefined, deleteisnot:true, languagewrite:"", systemenvironment:"", testcoderunmode:"", fileList:[] }) } // this.props.showNotification('提交成功!'); notification.open( { message: '提示', description: '提交成功!', } ) this.sendhideModaly() // this.props.history.push(`/courses/${cid}/graduation_topics`); // } } }catch (e) { } }) } render() { const {getFieldDecorator} = this.props.form; const {newshixunlist,languagewrite,systemenvironment,testcoderunmode,fileList,postapplytitle,postapplyvisible} = this.state; const uploadProps = { width: 600, fileList, multiple: true, // https://github.com/ant-design/ant-design/issues/15505 // showUploadList={false},然后外部拿到 fileList 数组自行渲染列表。 // showUploadList: false, action: `${getUploadActionUrl()}`, onChange: this.handleChange, onRemove: this.onAttachmentRemove, beforeUpload: (file, fileList) => { if (this.state.fileList.length >= 1) { return false } // console.log('beforeUpload', file.name); const isLt150M = file.size / 1024 / 1024 < 50; if (!isLt150M) { // this.props.showNotification(`文件大小必须小于50MB`); notification.open( { message: '提示', description: '文件大小必须小于50MB', } ) } if(this.state.file !== undefined){ console.log("763") this.setState({ file:file }) }else { this.setState({ file:file }) } console.log("handleChange2"); return isLt150M; }, } return (
新建申请已提交,请等待管理员的审核