From 17a37512e872a89403089beff895d74f6967ddf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 12 Dec 2019 19:52:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 4 +- public/react/src/modules/tpm/TPMIndex.js | 6 +- .../modules/tpm/TPMsettings/Configuration.js | 380 +++++++++++++----- .../tpm/TPMsettings/Shixuninformation.js | 144 +++---- .../modules/tpm/TPMsettings/TPMsettings.js | 38 +- .../tpm/TPMsettings/css/TPMsettings.css | 9 + .../react/src/modules/tpm/component/TPMNav.js | 6 +- 7 files changed, 392 insertions(+), 195 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index fb4b33fae..bb6e28b90 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -51,8 +51,8 @@ export function initAxiosInterceptors(props) { // proxy = "https://testeduplus2.educoder.net" //proxy="http://47.96.87.25:48080" proxy="https://pre-newweb.educoder.net" - proxy="https://test-newweb.educoder.net" - proxy="https://test-jupyterweb.educoder.net" + proxy="https://test-newweb.educoder.net" + proxy="https://test-jupyterweb.educoder.net" //proxy="http://192.168.2.63:3001" // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; diff --git a/public/react/src/modules/tpm/TPMIndex.js b/public/react/src/modules/tpm/TPMIndex.js index ba7fb25e3..4dc27ef8c 100644 --- a/public/react/src/modules/tpm/TPMIndex.js +++ b/public/react/src/modules/tpm/TPMIndex.js @@ -20,9 +20,9 @@ import TPMRepositoryComponent from './TPMRepositoryComponent'; import TPMRepositoryCommits from './shixunchild/Repository/TPMRepositoryCommits'; -//import TPMsettings from './TPMsettings/TPMsettings'; +import TPMsettings from './TPMsettings/TPMsettings'; -import TPMsettings from './TPMsettings/oldTPMsettings'; +//import TPMsettings from './TPMsettings/oldTPMsettings'; import TPMChallengeComponent from './TPMChallengeContainer'; import TPMPropaedeuticsComponent from './TPMPropaedeuticsComponent'; @@ -153,7 +153,7 @@ class TPMIndex extends Component { componentDidMount = () => { let id = this.props.match.params.shixunId; - console.log('props', this.props); + // console.log('props', this.props); // let collaborators = `/shixuns/` + id + `/propaedeutics.json`; // // axios.get(collaborators).then((response) => { diff --git a/public/react/src/modules/tpm/TPMsettings/Configuration.js b/public/react/src/modules/tpm/TPMsettings/Configuration.js index 2089d1939..c7156abe8 100644 --- a/public/react/src/modules/tpm/TPMsettings/Configuration.js +++ b/public/react/src/modules/tpm/TPMsettings/Configuration.js @@ -1,9 +1,15 @@ -import React, { Component } from 'react'; - -import MonacoEditor from 'react-monaco-editor'; +import React, {Component} from 'react'; //MonacoDiffEditor 对比模式 -import {Input, Select, Radio, Checkbox, Popconfirm, message, Modal,Icon,DatePicker,Breadcrumb,Upload,Button,notification, Tooltip} from 'antd'; +import { + Badge, + Select, + Radio, + Checkbox, + Modal, + DatePicker, + Button, +} from 'antd'; // import "antd/dist/antd.css"; @@ -15,12 +21,9 @@ import axios from 'axios'; import './css/TPMsettings.css'; -import { getImageUrl, toPath, getUrl ,appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; +import {getImageUrl, toPath, getUrl, appendFileSizeToUploadFileAll, getUploadActionUrl} from 'educoder'; import {handleDateStrings} from "./oldTPMsettings"; - -let origin = getUrl(); - -let path = getUrl("/editormd/lib/") +import Bottomsubmit from "../../modals/Bottomsubmit"; const $ = window.$; @@ -40,6 +43,7 @@ function range(start, end) { } return result; } + function disabledDateTime() { return { // disabledHours: () => range(0, 24).splice(4, 20), @@ -57,119 +61,311 @@ export default class Shixuninformation extends Component { constructor(props) { super(props) this.state = { + can_copy:false, + use_scope:0, + opening_time:null, + opentime:false, + oldscope_partment:[], + scope_partment:[] + } + } + + componentDidMount() { + if (this.props.data) { + + this.setState({ + can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy, + use_scope:this.props.data && this.props.data.shixun.use_scope, + opening_time: this.props.data && this.props.data.shixun.opening_time, + opentime:!this.props.data && this.props.data.shixun.opening_time?false:true, + oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment, + }) + + } + 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) + }); + } + + + componentDidUpdate(prevProps, prevState) { + if (prevProps.data != this.props.data) { + if (this.props.data) { + + this.setState({ + can_copy: this.props.data && this.props.data.shixun.can_copy === undefined ? false :this.props.data.shixun.can_copy, + use_scope:this.props.data && this.props.data.shixun.use_scope, + opening_time: this.props.data && this.props.data.shixun.opening_time, + opentime:!this.props.data && this.props.data.shixun.opening_time?false:true, + oldscope_partment:this.props.data&&this.props.data.shixun.scope_partment, + }) + } } } - onChangeTimePicker =(value, dateString)=> { + onChangeTimePicker = (value, dateString) => { this.setState({ - opening_time: dateString=== ""?"":moment(handleDateStrings(dateString)) + opening_time: dateString === "" ? "" :handleDateStrings(dateString) + }) + } + + onSubmits = () => { + let {can_copy,use_scope,scope_partment,opening_time }=this.state; + + let id = this.props.match.params.shixunId; + let url=`/shixuns/${id}/update_permission_setting.json`; + axios.post(url, + { + scope_partment:scope_partment, + shixun:{ + can_copy: can_copy, + use_scope:use_scope, + opening_time:opening_time + } + } + ).then((response) => { + if(response.data.status===-1){ + + }else{ + this.props.getdatas() + this.props.showNotification("保存成功") + } + }).catch((error) => { + console.log(error) + + }) + } + CheckboxonChange=(e)=>{ + this.setState({ + can_copy:e.target.checked + }) + } + SelectOpenpublic=(e)=>{ + this.setState({ + use_scope: e.target.value + }); + } + + shixunScopeInput = (e) => { + let {scope_partment,oldscope_partment} = this.state; + let datalist = scope_partment; + if (datalist===undefined) { + datalist=[] + } + + datalist.push(e) + + let scopetype=false; + + scope_partment.map((item,key)=>{ + if(item===e){ + scopetype=true + } }) + + oldscope_partment.map((item,key)=>{ + if(item===e){ + scopetype=true + } + }) + + if(scopetype===false){ + this.setState({ + scope_partment: datalist + }); + }else{ + this.props.showNotification("请勿指定相同的单位") + } + } + shixunsfetch = (value, callback) => { + if (timeout) { + clearTimeout(timeout); + timeout = null; + } + currentValue = value; + + function fake() { + let departmentsUrl = `/shixuns/departments.json?q=` + currentValue; + axios.get(departmentsUrl).then((response) => { + callback(response.data.shools_name); + }).catch((error) => { + console.log(error) + }); + } + timeout = setTimeout(fake, 300); + } + + shixunHandleSearch = (value) => { + this.shixunsfetch(value, departmentslist => this.setState({departmentslist})); + } + + deleteScopeInput = (key) => { + let {scope_partment} = this.state; + let datalist = scope_partment; + datalist.splice(key, 1); + this.setState({ + scope_partment: datalist + }); + } + + setopentime=(e)=>{ + this.setState({ + opentime:e.target.checked + }) + } render() { - let {can_copy}=this.state; - let options; - if (this.props.departmentslist != undefined) { - options = this.props.departmentslist.map((d, k) => { + let options; + if (this.state.departmentslist != undefined) { + options = this.state.departmentslist.map((d, k) => { return ( ) }) } + + const dateFormat = 'YYYY-MM-DD HH:mm'; + return ( -
公开程度
-服务配置
diff --git a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js index 6188fcafb..02ff6a660 100644 --- a/public/react/src/modules/tpm/TPMsettings/TPMsettings.js +++ b/public/react/src/modules/tpm/TPMsettings/TPMsettings.js @@ -29,11 +29,13 @@ export default class TPMsettings extends Component { componentDidMount() { + this.getdatas() + } - let id = this.props.match.params.shixunId; + getdatas=()=>{ + let id = this.props.match.params.shixunId; let Url = `/shixuns/` + id + `/settings.json`; - axios.get(Url).then((response) => { // alert(response.data.shixun.choice_standard_scripts) if (response.status === 200) { @@ -58,21 +60,6 @@ export default class TPMsettings extends Component { }); - - 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) - }); - - } operateshixuns = (value) => { @@ -126,6 +113,7 @@ export default class TPMsettings extends Component { render() { + let showtabs= this.props.shixunsDetails === undefined ?"":this.props.shixunsDetails.is_jupyter===true?"":"学习页面设置" return (