From 980aee35fd2e969de8b8b9ab9c3bb93fd3a05b1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 14 Aug 2019 17:00:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/modules/courses/Index.js | 12 +- .../src/modules/courses/ListPageIndex.js | 13 +- .../courses/coursesDetail/CoursesLeftNav.js | 11 +- .../modules/courses/gradinforms/Eduinforms.js | 174 ++++ .../src/modules/courses/new/Goldsubject.js | 814 ++++++++++++++++++ 5 files changed, 1021 insertions(+), 3 deletions(-) create mode 100644 public/react/src/modules/courses/gradinforms/Eduinforms.js create mode 100644 public/react/src/modules/courses/new/Goldsubject.js diff --git a/public/react/src/modules/courses/Index.js b/public/react/src/modules/courses/Index.js index 83f6679f7..78e839e5a 100644 --- a/public/react/src/modules/courses/Index.js +++ b/public/react/src/modules/courses/Index.js @@ -72,7 +72,11 @@ const WrappedCoursesNewApp= Loadable({ loader: () => import('./new/CoursesNew'), loading: Loading, }) - +//新建金品课堂 +const WrappedCoursesNewAppGoldclass= Loadable({ + loader: () => import('./new/Goldsubject'), + loading: Loading, +}) const ShixunHomeworkPage =Loadable({ loader: () => import('./shixunHomework/ShixunHomeworkPage'), loading: Loading, @@ -821,6 +825,12 @@ class CoursesIndex extends Component{ (props) => () } > + {/*新建金品课堂*/} + () + } + > {/*修改课堂*/} import('./members/studentsList'), loading: Loading, -}) +}); +const Eduinforms= Loadable({ + loader: () => import('./gradinforms/Eduinforms.js'), + loading: Loading, +}); // const Exercise= Loadable({ loader: () => import('./exercise/Exercise'), @@ -239,6 +243,13 @@ class ListPageIndex extends Component{ } > + {/*公告栏列表*/} + + () + } + > {/* 实训作业页面*/} { return (
+ {/*公告栏*/} {/*作业*/} {item.type==="shixun_homework"?
this.Navmodalnames(e,1,"shixun_homework",item.id)}>添加目录
:""} {/*资源*/} @@ -774,8 +775,12 @@ class Coursesleftnav extends Component{ // // console.log(item.category_url) // console.log(this.props.location.pathname) + console.log("778"); + console.log("CoursesLeftNav"); + console.log(this.props); + console.log(course_modules); - return( + return(
+ + {this.props.isAdmin()===true?
+ +
+ 已选 {checkBoxValues&&checkBoxValues.length} 个 +
+
  • 删除
  • +
  • 立即发布
  • + {/*onClick={this.homeworkstart}*/} +
  • 立即截止
  • +
  • + 设为公开 +
  • +
  • + {/*onClick={()=>this.selectBlank(4)}*/} + 移动到... +
      + { course_modules&&course_modules.homework_category.length > 10 &&

      + {this.setState({dirSearchValue: e.target.value})}}/> +

      } + + {course_modules&&course_modules.main_category.map((item,key)=>{ + return( + datas&&datas.category_id===null?"":
    • this.moveTos(item.main_category_id)}>{item.main_category_name}
    • + ) + })} + + + { course_modules&&course_modules.homework_category.filter((item,key)=> { + return (!this.state.dirSearchValue || item.category_name.indexOf(this.state.dirSearchValue) != -1) + }).map( (item,key) => { + if(datas&&datas.category_id!=null&&datas&&datas.category_id===item.category_id===false){ + return
    • this.moveTos(item.category_id )}>{item.category_name}
    • + } + if(datas&&datas.category_id===null){ + return
    • this.moveTos(item.category_id )}>{item.category_name}
    • + } + })} + + + + {course_modules&&course_modules.homework_category.length===0&&datas&&datas.category_id===null? +
      暂无数据
      :""} + + {/*{course_modules&&course_modules.homework_category.map((item,key)=>{*/} + {/*return(*/} + {/*
    • this.moveTos(item.category_id )}>{item.category_name}
    • */} + {/*)*/} + {/*})}*/} + + {this.props.isAdmin()?datas&&datas.category_name===undefined||datas&&datas.category_name===null? +

      + this.addDir()}>添加目录... +

      + :"":""} + +
    +
  • +
    +
    + +
    :""} + + + +
    + + + + ) + } +} +export default Eduinforms; diff --git a/public/react/src/modules/courses/new/Goldsubject.js b/public/react/src/modules/courses/new/Goldsubject.js new file mode 100644 index 000000000..5a02d54e8 --- /dev/null +++ b/public/react/src/modules/courses/new/Goldsubject.js @@ -0,0 +1,814 @@ +import React, {Component} from "React"; +import {Form, Select, Input, Button, Checkbox, DatePicker,Spin,Icon,AutoComplete,InputNumber} from "antd"; +import ApplyForAddOrgModal from '../../user/modal/ApplyForAddOrgModal'; +import axios from 'axios'; +import "../css/Courses.css"; +import locale from 'antd/lib/date-picker/locale/zh_CN'; +import moment from 'moment'; +import Modals from '../../modals/Modals'; + + + +const { Option } = Select; + + +const dateFormat = 'YYYY-MM-DD'; + +function range(start, end) { + const result = []; + for (let i = start; i < end; i++) { + result.push(i); + } + return result; +} + +function disabledDateTime() { + return { + disabledMinutes: () => range(1, 30).concat(range(31, 60)), + }; +} + +function disabledDate(current) { + return current && current < moment().endOf('day').subtract(1, 'days'); +} + +class Goldsubject extends Component { + + constructor(props) { + super(props) + this.state = { + coursedata: undefined, + searchlist: [], + searchlistscholl:[], + listvalue: undefined, + fetching:false, + subject_id:"", + start_date:"", + } + } + + componentDidMount() { + + + let coursesId = this.props.match.params.coursesId; + let user_school=this.props.current_user&&this.props.current_user.user_school; + // this.getschool("") + // this.Searchvalue("") + if (coursesId != undefined) { + let url = "/courses/" + coursesId + "/settings.json" + axios.get(url).then((result) => { + + let data = result.data; + this.props.form.setFieldsValue({ + course: data.course_list_name, + classroom: data.name, + period: data.class_period, + credit: data.credit, + checkboxgroup: data.course_module_types, + Realnamecertification: data.authentication, + Professionalcertification:data.professional_certification, + endtime: data.end_date === undefined ? "" : moment(data.end_date, dateFormat), + school:data.school + + }); + + this.setState({ + datatime: data.end_date, + datatimetwo: data.end_date, + is_public: 1, + Realnamecertification: data.authentication, + Professionalcertification:data.professional_certification, + }) + this.handleSearchschool(data.school); + }).catch((error) => { + console.log(error); + }) + }else{ + let url = "/courses/new.json" + axios.get(url).then((result) => { + console.log(result) + }).catch((error) => { + console.log(error); + }) + // console.log(user_school); + this.props.form.setFieldsValue({ + school:user_school, + }); + this.setState({ + school:user_school, + }); + + this.handleSearchschool(user_school); + + + } + + + } + componentDidUpdate(prevProps) { + if(prevProps.current_user !== this.props.current_user){ + let user_school=this.props.current_user&&this.props.current_user.user_school; + this.props.form.setFieldsValue({ + school:user_school, + }); + this.setState({ + school:user_school, + }); + + this.handleSearchschool(user_school); + } + } + onChangeTimepublishs = (date, dateString) => { + if(dateString===""){ + this.setState({ + datatime: undefined, + }) + }else{ + this.setState({ + datatime: dateString, + }) + } + }; + onChangeTimepublishstwo = (date, dateString) => { + if(dateString===""){ + this.setState({ + datatimetwo: undefined, + }) + }else{ + this.setState({ + datatimetwo: dateString, + }) + } + }; + cancelmodel = () => { + + this.setState({ + Modalstype: false, + Loadtype: false, + Modalstopval: "", + ModalCancel: "", + ModalSave: "", + }) + + } + + scrollToAnchor = (anchorName) => { + if (anchorName) { + // 找到锚点 + let anchorElement = document.getElementById(anchorName); + // 如果对应id的锚点存在,就跳转到锚点 + window.scrollTo(0, anchorElement.offsetTop - window.innerHeight / 2); + } + } + + //提交数据的地方 + handleSubmit = (e) => { + + e.preventDefault(); + let first_category_url=this.props.current_user.first_category_url; + let coursesId = this.props.match.params.coursesId; + let {is_public,datatime,datatimetwo} = this.state + // console.log(is_public) + if (coursesId != undefined) { + // 编辑 + + this.props.form.validateFields((err, values) => { + + // if(values.course===""||values.course===undefined){ + // this.scrollToAnchor("iscourse") + // return + // + // } + if(values.classroom===""||values.classroom===undefined){ + this.scrollToAnchor("isclassroom") + return + } + + if(values.school===""||values.school===undefined){ + // this.scrollToAnchor("isschool") + return + + } + + if(values.checkboxgroup.length===0){ + this.setState({ + Modalstype:true, + Modalstopval:"请您至少添加一个课堂模块,", + ModalsBottomval:"否则您将无法新建课堂。", + Loadtype:true, + ModalSave:()=>this.cancelmodel(), + }) + return + } + + + if (!err) { + + + + // console.log('Received values of form: ', values); + + let url = "/courses/" + coursesId + ".json"; + axios.put(url, { + // subject_id:128, //这是带过来的值 编辑就不要传值了 + name: values.classroom, + class_period: values.period, + credit: parseFloat(values.credit), + start_date:datatimetwo===undefined?"":datatimetwo, + end_date: datatime===undefined?"":datatime, + is_public: 1, //这是也是带过来的值 + course_module_types: values.checkboxgroup, + school:values.school + } + ).then((response) => { + // debugger + if (response.data.status === 0) { + // this.goback() + + window.location.href=first_category_url; + var yslGuideone = window.localStorage.getItem('yslGuideone'); + try { + if(yslGuideone=== null){ + window.localStorage.setItem('yslGuideone', "true"); + return + } + if(yslGuideone=== undefined){ + window.localStorage.setItem('yslGuideone', "true"); + return + } + }catch (e) { + + } + + } + }).catch((error) => { + console.log(error) + }) + } + }); + } else { + this.props.form.validateFields((err, values) => { + + // if(values.course===""||values.course===undefined){ + // this.scrollToAnchor("iscourse") + // return + // } + if(values.classroom===""||values.classroom===undefined){ + this.scrollToAnchor("isclassroom") + return + } + if(values.school===""||values.school===undefined){ + // this.scrollToAnchor("isschool") + return + + } + if (!err) { + // debugger + //新建 + // console.log('Received values of form: ', values); + + let url = "/courses.json"; + axios.post(url, { + subject_id:128, //这是带过来的值 + name: values.classroom, + class_period: values.period, + credit: parseFloat(values.credit), + start_date:datatimetwo===undefined?"":datatimetwo, + end_date: datatime===undefined?"":datatime, + is_public: 1, //这是也是带过来的值 + course_module_types: values.checkboxgroup, + school:values.school + } + ).then((response) => { + if (response.status === 200) { + // this.goback + window.location.href=response.data.first_category_url; + var yslGuideone = window.localStorage.getItem('yslGuideone'); + try { + if(yslGuideone=== null){ + window.localStorage.setItem('yslGuideone', "true"); + return + } + if(yslGuideone=== undefined){ + window.localStorage.setItem('yslGuideone', "true"); + return + } + }catch (e) { + + } + } + }).catch((error) => { + console.log(error) + }) + } + }); + } + + } + + goback = () => { + + // if(this.props.match.params.coursesId===undefined){ + // this.props.history.push("/courses"); + // }else{ + // this.props.history.push(this.props.current_user.first_category_url); + // } + // window.history.go(-1) + this.props.history.goBack() + } + + onCheckAllChange = (e) => { + // console.log(e.target.checked) + this.setState({ + is_public: e.target.checked == true ? 1 : 0, + }); + } + onchanges =(e)=>{ + this.setState({ + Realnamecertification:e.target.checked, + }) + // console.log(e.target.checked); + } + onchangess=(e)=>{ + this.setState({ + Professionalcertification:e.target.checked, + }) + // console.log(e.target.checked); + } + Searchvalue=(value)=>{ + + let url="/courses/search_course_list.json"; + axios.post(url,{ + search:value + }).then((result)=>{ + // console.log(result.data) + if (result.data.message===undefined) { + + this.setState({ + searchlist: result.data.course_lists, + // course:value, + + }) + } + // this.props.form.setFieldsValue({ + // course:value + // }) + }).catch((error)=>{ + console.log(error) + }) + } + handleSearch=(value)=>{ + + + if(value!=""){ + this.props.form.setFieldsValue({ + classroom:value, + // course:value + }); + this.Searchvalue(value) + } + + }; + + handleChange=(value)=>{ + + this.props.form.setFieldsValue({ + // course:value, + classroom:value + }) + }; + + handleSearchschool=(value)=>{ + + if(value!="") { + // this.props.form.setFieldsValue({ + // // school: value, + // fetching: true, + // }); + this.setState({ + fetching: true, + school: value + }) + this.getschool(value) + } + }; + + handleChangeschools=(value)=>{ + + // this.props.form.setFieldsValue({ + // // school: value, + // fetching: true, + // }); + // this.setState({ + // fetching: true + // }) + } + + handleChangeschool=(value)=>{ + + this.setState({ + school:value + }); + this.props.form.setFieldsValue({ + school:value, + }) + }; + + getschool=(value)=>{ + // this.props.form.setFieldsValue({ + // school: value + // }) + let url="/schools/school_list.json"; + axios.get(url,{ + params: { + search: value + } + }).then((result)=>{ + if (result.data.status===0) { + this.setState({ + searchlistscholl: result.data.school_names, + + }) + if(result.data.school_names.length!=0){ + this.setState({ + fetching: false + }) + } + } + }).catch((error)=>{ + console.log(error) + }) + } + showApplyForAddOrgModal = () => { + this.applyForAddOrgForm.setVisible(true) + } + render() { + let {datatime,datatimetwo,school,searchlistscholl} = this.state; + const {getFieldDecorator} = this.props.form; + const propsWithoutForm = Object.assign({}, this.props) + delete propsWithoutForm.form + const options = this.state.searchlist && this.state.searchlist.map(d => ); + const optionschool = this.state.searchlistscholl===undefined?"":this.state.searchlistscholl===null?"":this.state.searchlistscholl==="[]"?"":this.state.searchlistscholl.map(z => ); + // console.log(this.props.current_user.user_school) + // form合并了 + console.log("获取到的数据"); + console.log(this.state); + console.log(this.props); + console.log(this.props.current_user); + return ( + + +
    + + this.applyForAddOrgForm = form} schoolName={school} + {...propsWithoutForm}> + {/*提示*/} + +
    +
    +
    +

    {this.props.match.params.coursesId === undefined ? "新建课堂" : "编辑课堂"}

    + 返回 +
    + + +
    + {/*内容*/} + + + {/*
    */} + {/*
    */} + {/* */} + {/* {getFieldDecorator('course', {*/} + {/* rules: [{required: true, message: "不能为空"}],*/} + {/* })(*/} + + {/* */} + {/* {options}*/} + {/* */} + {/* )}*/} + {/* */} + {/* /!*(错误示例:数据结构2017本部;数据结构2017秋季;数据结构2017电子商务1班)*!/*/} + {/*

    */} + {/* */} + {/* 正确示例:数据结构*/} + {/*

    */} + {/*

    */} + {/* */} + {/* 错误示例:数据结构2019春*/} + {/*

    */} + {/*
    */} + {/*
    */} + {/*
    */} + {/*
    */} + + {/*
    */} + + +
    + + + {getFieldDecorator('classroom', { + rules: [{required: true, message: "不能为空"}], + })( + + + {options} + + )} + + {/*(如果本学期包含多个班级,只需创建一个课堂然后在课堂内部建立不同的分班)*/} +

    + + 正确示例:数据结构2019春季班级 +

    +

    + + 错误示例:2019春季班级数据结构 +

    +
    +
    +
    + + +
    + +
    + + + {getFieldDecorator("period", + { + rules:[{ + required:false, + pattern: new RegExp(/^[0-9]\d*$/, "g"), + message: '' + }], + getValueFromEvent: (event) => { + return event.target.value.replace(/\D/g,'') + }} + )( + + )} + + + + {getFieldDecorator("credit", + { + rules:[{ + required:false, + pattern: new RegExp(/^[0-9]\d*$/, "g"), + message: '' + }], + getValueFromEvent: (event) => { + return event.target.value.replace(/\D/g,'') + }} + )( + + )} + + + {getFieldDecorator("starttime")( + + + + )} + + + {getFieldDecorator("endtime")( + + + + )} + +
    + +
    + + + {getFieldDecorator("checkboxgroup", { + initialValue: [ + "announcement","online_learning","shixun_homework", "exercise", + ], + })( + + 公告栏 + 在线学习 + 实训作业 + 普通作业 + 试卷 + 问卷 + 资源 + 讨论 + 分班 + + )} + +
    + {/*
    */} + {/* */} + {/* */} + {/* {getFieldDecorator("Realnamecertification")(*/} + {/* 已实名认证*/} + {/* // */} + {/* // 已实名认证*/} + {/* // 已职业认证 (勾选,则通过邀请码加入课堂的用户,需要完成相关认证才能加入课堂)*/} + {/* // */} + {/* )}*/} + {/* */} + {/* */} + {/* */} + {/* */} + {/* {getFieldDecorator("Professionalcertification")(*/} + {/* 已职业认证 (勾选,则通过邀请码加入课堂的用户,需要完成相关认证才能加入课堂)*/} + {/* )}*/} + {/* */} + {/* */} + {/*
    */} + {/*
    */} + {/* */} + {/* {getFieldDecorator("publicclass")(*/} + {/* 公开课堂*/} + {/* )}*/} + {/* (选中后本课堂对所有用户可见,否则仅本课堂成员可见)*/} + {/* */} + {/*
    */} + +
    + + {getFieldDecorator('school', { + rules: [{required: true, message: "不能为空"}], + })( + + {optionschool} + + )} + + {/*(输入内容出现匹配的下拉菜单←同账号管理的单位信息填写)*/} + +
    +
    + + {searchlistscholl.length===0&&this.state.fetching===true?
    + + 未找到包含“{school}”的高校, + 申请新增 + +
    :""} + +
    + + + +
    + +
    + + {/*提交*/} + 取消 +
    +
    +
    +
    +
    +
    +
    + +
    + + ) + } +} + +const WrappedCoursesNewAppGoldclass = Form.create({name: 'goldsubject'})(Goldsubject); +export default WrappedCoursesNewAppGoldclass; \ No newline at end of file