diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index da9a4b317..bf8a0651e 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -232,6 +232,14 @@ class ApplicationController < ActionController::Base User.current = User.find 57703 end + if params[:debug] == 'teacher' #todo 为了测试,记得讲debug删除 + User.current = User.find 81403 + elsif params[:debug] == 'student' + User.current = User.find 8686 + elsif params[:debug] == 'admin' + User.current = User.find 1 + end + # User.current = User.find 81403 end diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb index 014262aea..a6c74818c 100644 --- a/app/controllers/attachments_controller.rb +++ b/app/controllers/attachments_controller.rb @@ -2,8 +2,9 @@ # # 文件上传 class AttachmentsController < ApplicationController - before_action :require_login, :check_auth + before_action :require_login, :check_auth, except: [:show] before_action :find_file, only: %i[show destroy] + before_action :attachment_candown, only: [:show] include ApplicationHelper @@ -157,4 +158,33 @@ class AttachmentsController < ApplicationController end edu_setting('public_cdn_host') + "/" + path end + + def attachment_candown + unless current_user.admin? || current_user.business? + candown = true + if @file.container && current_user.logged? + # 课堂资源、作业、毕设相关资源的权限判断 + if @file.container.is_a?(Course) + course = @file.container + candown = current_user.member_of_course?(course) || @file.is_public == 1 + elsif @file.container.is_a?(HomeworkCommon) || @file.container.is_a?(GraduationTask) || @file.container.is_a?(GraduationTopic) + course = @file.container&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(StudentWork) + course = @file.container&.homework_common&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(StudentWorksScore) + course = @file.container&.student_work&.homework_common&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(GraduationWork) + course = @file.container&.graduation_task&.course + candown = current_user.member_of_course?(course) + elsif @file.container.is_a?(GraduationWorkScore) + course = @file.container&.graduation_work&.graduation_task&.course + candown = current_user.member_of_course?(course) + end + tip_exception(403, "您没有权限进入") if course.present? && !candown + end + end + end end diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index bb0737128..f5830adff 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -29,10 +29,10 @@ class CoursesController < ApplicationController :transfer_to_course_group, :delete_from_course, :search_users, :add_students_by_search, :get_historical_courses, :add_teacher_popup, :add_teacher] before_action :admin_allowed, only: [:set_invite_code_halt, :set_public_or_private, :change_course_admin, - :set_course_group, :delete_course_teacher, :create_group_by_importing_file] + :set_course_group, :create_group_by_importing_file] before_action :teacher_or_admin_allowed, only: [:graduation_group_list, :create_graduation_group, :join_graduation_group, :change_course_teacher, :export_member_scores_excel, :course_group_list, - :teacher_application_review, :apply_teachers] + :teacher_application_review, :apply_teachers, :delete_course_teacher] before_action :validate_course_name, only: [:create, :update] before_action :find_board, only: :board_list before_action :validate_page_size, only: :mine diff --git a/app/models/user.rb b/app/models/user.rb index 03c97b9f3..34576db66 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -250,7 +250,7 @@ class User < ApplicationRecord # 课堂成员 def member_of_course?(course) - course.course_members.exists?(user_id: id) + course&.course_members.exists?(user_id: id) end # 实训路径管理员:创建者或admin diff --git a/app/views/users/get_user_info.json.jbuilder b/app/views/users/get_user_info.json.jbuilder index fbb9778e2..164c943d0 100644 --- a/app/views/users/get_user_info.json.jbuilder +++ b/app/views/users/get_user_info.json.jbuilder @@ -14,6 +14,7 @@ if @course if params[:group_info] json.group_info @course.teacher_group(@user.id) if @course_identity < Course::STUDENT end + json.first_category_url module_url(@course.none_hidden_course_modules.first, @course) end if params[:school] diff --git a/config/routes.rb b/config/routes.rb index bb5bc49cc..6024201a4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,8 @@ Rails.application.routes.draw do require 'admin_constraint' mount Sidekiq::Web => '/sidekiq', :constraints => AdminConstraint.new + get 'attachments/download/:id', to: 'attachments#show' + resources :edu_settings scope '/api' do get 'home/index' diff --git a/db/migrate/20190725024516_modify_attachment_url_for_challenge_answer.rb b/db/migrate/20190725024516_modify_attachment_url_for_challenge_answer.rb deleted file mode 100644 index 41840bac1..000000000 --- a/db/migrate/20190725024516_modify_attachment_url_for_challenge_answer.rb +++ /dev/null @@ -1,7 +0,0 @@ -class ModifyAttachmentUrlForChallengeAnswer < ActiveRecord::Migration[5.2] - def change - ChallengeChoose.find_each do |cc| - cc.update_column(:subject, cc.subject.gsub("(/attachments/download", "(/api/attachments")) if cc.subject.present? - end - end -end diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js index e382625b0..31f127af1 100644 --- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js +++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js @@ -218,6 +218,20 @@ class Testpapersettinghomepage extends Component{ // DownloadMessageval:undefined // }) // } + goback=()=>{ + // let {datalist}=this.state; + // let courseId=this.props.match.params.coursesId; + // let category_id=this.props.match.params.category_id; + // + // window.location.href="/courses/"+courseId+"/graduation_tasks/"+datalist.graduation_id; + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + + } render(){ let {tab,visible,Commonheadofthetestpaper}=this.state; const isAdmin =this.props.isAdmin(); @@ -251,9 +265,9 @@ class Testpapersettinghomepage extends Component{

- {this.props.coursedata.name} + {this.props.coursedata.name} > - 试卷 + 试卷 > 试卷详情

@@ -274,9 +288,7 @@ class Testpapersettinghomepage extends Component{ - 返回 + 返回

diff --git a/public/react/src/modules/courses/exercise/question/single.js b/public/react/src/modules/courses/exercise/question/single.js index aa23aa3d9..4ff4bf12b 100644 --- a/public/react/src/modules/courses/exercise/question/single.js +++ b/public/react/src/modules/courses/exercise/question/single.js @@ -35,12 +35,13 @@ class single extends Component{ }=this.props let isStudent =this.props.isStudent(); + let isJudge = questionType.question_type == 2 return(
{ questionType.question_choices && questionType.question_choices.map((item,key)=>{ - let prefix = `${tagArray[key]}.` + let prefix = isJudge ? undefined : `${tagArray[key]}.` return(

{prefix} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js index 044d0a3ae..fbaa5b7c3 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitedit.js @@ -78,12 +78,12 @@ class GraduationTasksSubmitedit extends Component{ } setedit=()=>{ - let coursesId=this.props.match.params.coursesId; - let workId=this.props.match.params.work_Id; - let {workslist}=this.state - let task_id=workslist&&workslist.task_id; + // let coursesId=this.props.match.params.coursesId; + // let workId=this.props.match.params.work_Id; + // let {workslist}=this.state + // let task_id=workslist&&workslist.task_id; // window.location.href="/courses/"+coursesId+"/graduation_tasks/"+task_id+"/"+workId+"/works/edit"; - window.location.href="/courses/"+coursesId+"/graduation_tasks/"+workId+"/appraise"; + this.goback() } @@ -96,11 +96,13 @@ class GraduationTasksSubmitedit extends Component{ } goback=()=>{ - let courseId=this.props.match.params.coursesId; - let work_Id=this.props.match.params.work_Id; - // window.location.href="/courses/"+courseId+"/graduation/graduation_tasks/"+category_id; - window.location.href="/courses/"+courseId+"/graduation_tasks/"+work_Id+"/appraise"; + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -568,7 +570,7 @@ class GraduationTasksSubmitedit extends Component{

{/* {workslist&&workslist.course_name}*/} {/*>*/} - 毕设任务 + 毕设任务 > 任务详情 > @@ -825,7 +827,7 @@ class GraduationTasksSubmitedit extends Component{

- 取消 + 取消
{/**/} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js index 50f2a4fde..dddb11e53 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksSubmitnew.js @@ -100,9 +100,12 @@ class GraduationTasksSubmitnew extends Component{ goback=()=>{ let courseId=this.props.match.params.coursesId; - let category_id=this.props.match.params.category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } - window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; } @@ -438,7 +441,7 @@ class GraduationTasksSubmitnew extends Component{ spinnings:false }) if(response!==undefined){ - this.setedit(response.data.work_id) + this.goback() } // if(response.status===200) { // GraduationTasksnewtype=false; @@ -567,7 +570,7 @@ render(){

{/* {workslist&&workslist.course_name}*/} {/*>*/} - 毕设任务 + 毕设任务 > 任务详情 > @@ -802,7 +805,7 @@ render(){

- 取消 + 取消
{/**/} diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js index 971152781..5eccb2332 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksappraise.js @@ -70,7 +70,13 @@ class GraduationTasksappraise extends Component{ // let category_id=this.props.match.params.category_id; // // window.location.href="/courses/"+courseId+"/graduation_tasks/"+datalist.graduation_id; - window.history.go(-1) + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } Cancelvisible=()=>{ @@ -164,7 +170,7 @@ class GraduationTasksappraise extends Component{

- {datalist&&datalist.course_name} + {datalist&&datalist.course_name} > {datalist&&datalist.graduation_name} > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js index 2e9efba0c..2b55e0737 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksedit.js @@ -81,10 +81,13 @@ class GraduationTasksedit extends Component{ goback=()=>{ - // let courseId=this.props.match.params.coursesId; - // window.location.href="/courses/"+courseId+"/graduation_tasks/"+this.state.data.graduation_id; - // goback = () => { - window.history.go(-1) + + let courseId = this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -233,8 +236,8 @@ class GraduationTasksedit extends Component{ // console.log(response) // GraduationTasksedittype=false; // window.location.href="/courses/"+course_id+"/graduation/"+graduationId+"/graduation_tasks/"+category_id+"/questions"; - // this.goback() - this.props.history.push("/courses/"+this.props.match.params.coursesId+"/graduation_tasks/"+graduation_id+"/"+this.props.match.params.category_id +"/setting"); + this.goback() + //this.props.history.push("/courses/"+this.props.match.params.coursesId+"/graduation_tasks/"+graduation_id+"/"+this.props.match.params.category_id +"/setting"); } }).catch((error) => { console.log(error) @@ -333,7 +336,7 @@ class GraduationTasksedit extends Component{

- {this.props.current_user&&this.props.current_user.course_name} + {this.props.current_user&&this.props.current_user.course_name} > 毕设任务 > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js index 90f67a984..e27d8382b 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTasksnew.js @@ -91,7 +91,7 @@ class GraduationTasksnew extends Component { // GraduationTasksnewtype = false; // this.goback(); if(response!==undefined){ - this.props.history.push("/courses/" + this.props.match.params.coursesId + "/graduation_tasks/" + this.props.match.params.category_id + "/" + response.data.task_id + "/setting"); + this.goback() } // } }).catch((error) => { @@ -108,9 +108,11 @@ class GraduationTasksnew extends Component { goback = () => { let courseId = this.props.match.params.coursesId; - let category_id = this.props.match.params.category_id; - - window.location.href = "/courses/" + courseId + "/graduation_tasks/" + category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -307,8 +309,7 @@ class GraduationTasksnew extends Component {

- {this.props.current_user && this.props.current_user.course_name} + {this.props.current_user && this.props.current_user.course_name} > 毕设任务 diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js index 983231167..5bbbe1a14 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssetting.js @@ -761,9 +761,11 @@ class GraduationTaskssettingapp extends Component{ goback=()=>{ let courseId=this.props.match.params.coursesId; - let category_id=this.props.match.params.category_id; - - window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } isgoback=()=>{ @@ -1046,7 +1048,7 @@ class GraduationTaskssettingapp extends Component{

- {coursename} + {coursename} > 毕设任务 > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js index 291095008..d773d8411 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettinglist.js @@ -57,11 +57,15 @@ class GraduationTaskssettinglist extends Component{ let{teacher_comment,task_status,course_group,cross_comment,order,b_order,search}=this.state; this.seacthdata(teacher_comment,task_status,course_group,cross_comment,order,b_order,search,this.state.page); } + goback=()=>{ // window.history.back(-1) let courseId=this.props.match.params.coursesId; - let category_id=this.props.match.params.category_id; - window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } @@ -1058,7 +1062,7 @@ class GraduationTaskssettinglist extends Component{

- {taskslistdata.course_name} + {taskslistdata.course_name} > {taskslistdata.graduation_name} > diff --git a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js index dee8f0c91..1bf6eb962 100644 --- a/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js +++ b/public/react/src/modules/courses/graduation/tasks/GraduationTaskssettingquestions.js @@ -55,7 +55,12 @@ class GraduationTasksquestions extends Component{ // let courseId=this.props.match.params.coursesId; // let category_id=this.props.match.params.category_id; // window.location.href="/courses/"+courseId+"/graduation_tasks/"+category_id; - window.history.go(-1) + let courseId = this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } } end=()=>{ @@ -300,7 +305,7 @@ class GraduationTasksquestions extends Component{

- {questionslist.course_name} + {questionslist.course_name} > {questionslist.graduation_name} > diff --git a/public/react/src/modules/courses/new/CoursesNew.js b/public/react/src/modules/courses/new/CoursesNew.js index 149f9bc27..c8b090b8b 100644 --- a/public/react/src/modules/courses/new/CoursesNew.js +++ b/public/react/src/modules/courses/new/CoursesNew.js @@ -28,6 +28,7 @@ function disabledDateTime() { }; } + class CoursesNew extends Component { constructor(props) { @@ -46,7 +47,8 @@ class CoursesNew extends Component { 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) => { @@ -85,8 +87,7 @@ class CoursesNew extends Component { }) } - this.getschool("") - this.Searchvalue("") + } componentDidUpdate(prevProps){ @@ -152,7 +153,7 @@ class CoursesNew extends Component { } if(values.school===""||values.school===undefined){ - this.scrollToAnchor("isschool") + // this.scrollToAnchor("isschool") return } @@ -191,17 +192,7 @@ class CoursesNew extends Component { ).then((response) => { // debugger if (response.data.status === 0) { - // this.setState({ - // Modalstype: true, - // Modalstopval: response.data.message, - // ModalSave: this.cancelmodel, - // Loadtype: true, - // checkBoxValues: [], - // checkAllValue: false, - // // Realnamecertification : authentication, - // // professional_certification: values.Professionalcertification - // }) - window.location.href = "/courses/" + coursesId+"/students"; + this.goback() } }).catch((error) => { console.log(error) @@ -220,7 +211,7 @@ class CoursesNew extends Component { return } if(values.school===""||values.school===undefined){ - this.scrollToAnchor("isschool") + // this.scrollToAnchor("isschool") return } @@ -244,9 +235,7 @@ class CoursesNew extends Component { } ).then((response) => { if (response.status === 200) { - if (response.data.course_id != undefined) { - window.location.href = "/courses/" + response.data.course_id+"/students"; - } + this.goback() } }).catch((error) => { console.log(error) @@ -262,7 +251,7 @@ class CoursesNew extends Component { if(this.props.match.params.coursesId===undefined){ this.props.history.push("/courses"); }else{ - this.props.history.push(`/courses/${this.props.match.params.coursesId}`); + this.props.history.push(this.props.current_user.first_category_url); } // window.history.go(-1) } @@ -292,7 +281,8 @@ class CoursesNew extends Component { search:value }).then((result)=>{ // console.log(result.data) - if (result.data.status===0) { + if (result.data.message===undefined) { + this.setState({ searchlist: result.data.course_lists, // course:value, @@ -357,7 +347,9 @@ class CoursesNew extends Component { }; getschool=(value)=>{ - + this.props.form.setFieldsValue({ + school: value + }) let url="/schools/school_list.json"; axios.get(url,{ params: { @@ -369,9 +361,7 @@ class CoursesNew extends Component { searchlistscholl: result.data.school_names, school: value }) - this.props.form.setFieldsValue({ - school: value - }) + } }).catch((error)=>{ console.log(error) @@ -389,7 +379,7 @@ class CoursesNew extends Component { const optionschool = this.state.searchlistscholl&&this.state.searchlistscholl.map(z => ); // console.log(this.props.current_user.user_school) // form合并了 - // console.log(optionschool) + return ( diff --git a/public/react/src/modules/courses/poll/PollDetailIndex.js b/public/react/src/modules/courses/poll/PollDetailIndex.js index 0099c8615..8e3f78d5c 100644 --- a/public/react/src/modules/courses/poll/PollDetailIndex.js +++ b/public/react/src/modules/courses/poll/PollDetailIndex.js @@ -22,169 +22,169 @@ import axios from 'axios' const map={1:"未发布",2:"提交中",3:"已截止",4:"已结束"} class PollDetailIndex extends Component{ - constructor(props){ - super(props); - this.state={ - tab:["0"], - pollDetail:undefined, - user_permission:undefined, - DownloadType:false, - DownloadMessageval:undefined, - } - } - - getPollInfo=()=>{ - console.log(this.props); - let pollId=this.props.match.params.pollId; - let url=`/polls/${pollId}/common_header.json` - axios.get(url).then((result)=>{ - if(result.status==200){ - this.setState({ - pollDetail:result.data, - user_permission:result.data.user_permission - }) - } - }).catch((error)=>{ - console.log(error); - }) - } - - componentDidMount(){ - const query =this.props.location.search; - if(query.indexOf("?")!=-1){ - const type = query.split('?'); - let name = type[1].split("tab="); - name = String(name).split(","); - name = decodeURI(name[1]); - if(name!=undefined && name!="" && name!="undefined"){ - this.setState({ - tab:[name] - }) - } - } - - this.getPollInfo(); - } - - //切换tab - changeTab=(e)=>{ - this.setState({ - tab:e.key - }) - } - - /// 确认是否下载 - confirmysl(url){ - axios.get(url).then((response) => { - if(response.data.status&&response.data.status===-1){ - - }else if(response.data.status&&response.data.status===-2){ - if(response.data.message === "100"){ - // 已超出文件导出的上限数量(100 ),建议: - - this.setState({ - DownloadType:true, - DownloadMessageval:100 - }) - }else { - //因附件资料超过500M - this.setState({ - DownloadType:true, - DownloadMessageval:500 - }) - } - }else { - this.props.showNotification(`正在下载中`); - window.open("/api"+url, '_blank'); - } - }).catch((error) => { - console.log(error) - }); - } - - Downloadcal=()=>{ - this.setState({ - DownloadType:false, - DownloadMessageval:undefined - }) - } - render(){ - let {tab,pollDetail,user_permission}=this.state; - - const isAdmin =this.props.isAdmin(); - const isStudent = this.props.isStudent(); - return( -

- -
-

- {this.props.coursedata.name} - > - 问卷 - > - 问卷详情 -

-

- {pollDetail && pollDetail.polls_name} - + constructor(props){ + super(props); + this.state={ + tab:["0"], + pollDetail:undefined, + user_permission:undefined, + DownloadType:false, + DownloadMessageval:undefined, + } + } + + getPollInfo=()=>{ + console.log(this.props); + let pollId=this.props.match.params.pollId; + let url=`/polls/${pollId}/common_header.json` + axios.get(url).then((result)=>{ + if(result.status==200){ + this.setState({ + pollDetail:result.data, + user_permission:result.data.user_permission + }) + } + }).catch((error)=>{ + console.log(error); + }) + } + + componentDidMount(){ + const query =this.props.location.search; + if(query.indexOf("?")!=-1){ + const type = query.split('?'); + let name = type[1].split("tab="); + name = String(name).split(","); + name = decodeURI(name[1]); + if(name!=undefined && name!="" && name!="undefined"){ + this.setState({ + tab:[name] + }) + } + } + + this.getPollInfo(); + } + + //切换tab + changeTab=(e)=>{ + this.setState({ + tab:e.key + }) + } + + /// 确认是否下载 + confirmysl(url){ + axios.get(url).then((response) => { + if(response.data.status&&response.data.status===-1){ + + }else if(response.data.status&&response.data.status===-2){ + if(response.data.message === "100"){ + // 已超出文件导出的上限数量(100 ),建议: + + this.setState({ + DownloadType:true, + DownloadMessageval:100 + }) + }else { + //因附件资料超过500M + this.setState({ + DownloadType:true, + DownloadMessageval:500 + }) + } + }else { + this.props.showNotification(`正在下载中`); + window.open("/api"+url, '_blank'); + } + }).catch((error) => { + console.log(error) + }); + } + + Downloadcal=()=>{ + this.setState({ + DownloadType:false, + DownloadMessageval:undefined + }) + } + render(){ + let {tab,pollDetail,user_permission}=this.state; + + const isAdmin =this.props.isAdmin(); + const isStudent = this.props.isStudent(); + return( +

+ +
+

+ {this.props.coursedata.name} + > + 问卷 + > + 问卷详情 +

+

+ {pollDetail && pollDetail.polls_name} + - this.props.history.goBack()}>返回 -

-
-
-
- - 答题列表 - { - (isAdmin || (isStudent && pollDetail && pollDetail.show_result == 1 && pollDetail.polls_status == 3 && user_permission && user_permission.current_status==1)) && 统计结果 - } - { isAdmin && 问卷预览 } - 设置 - -
- { - isAdmin && - + this.props.history.goBack()}>返回 +

+
+
+
+ + 答题列表 + { + (isAdmin || (isStudent && pollDetail && pollDetail.show_result == 1 && pollDetail.polls_status == 3 && user_permission && user_permission.current_status==1)) && 统计结果 + } + { isAdmin && 问卷预览 } + 设置 + +
+ { + isAdmin && + 编辑问卷 - {/* 立即发布 */} - { - user_permission && user_permission.poll_unpublish_count > 0 ? -
  • - -
  • - :"" - } - {/* 立即截止、撤销发布 */} - { - user_permission && user_permission.poll_publish_count > 0 ? -
  • - -
  • - :"" - } - {/* { + {/* 立即发布 */} + { + user_permission && user_permission.poll_unpublish_count > 0 ? +
  • + +
  • + :"" + } + {/* 立即截止、撤销发布 */} + { + user_permission && user_permission.poll_publish_count > 0 ? +
  • + +
  • + :"" + } + {/* { user_permission && user_permission.poll_publish_count>0 ?
  • :"" } */} - this.confirmysl("/polls/"+this.props.match.params.pollId+"/commit_result.xlsx")} href="javascript:void(0);">导出统计 + this.confirmysl("/polls/"+this.props.match.params.pollId+"/commit_result.xlsx")} href="javascript:void(0);">导出统计 - } - { - isStudent && - + } + { + isStudent && + { - user_permission && user_permission.current_status!=3 ? - - { user_permission && user_permission.current_status ==0 ? "继续答题" : user_permission.current_status == 1 ? "查看答题" : "开始答题" } - - :"" - } + user_permission && user_permission.current_status!=3 ? + + { user_permission && user_permission.current_status ==0 ? "继续答题" : user_permission.current_status == 1 ? "查看答题" : "开始答题" } + + :"" + } - } - -
  • - - { - // 答题列表 - parseInt(tab[0])==0 && - } - { - // 统计结果 - parseInt(tab[0])==1 && - } - - { - //问卷预览 - parseInt(tab[0])==2 && - } - { - //设置 - parseInt(tab[0])==3 && - } - -
    -
    -
    - ) - } + } + +
    + + { + // 答题列表 + parseInt(tab[0])==0 && + } + { + // 统计结果 + parseInt(tab[0])==1 && + } + + { + //问卷预览 + parseInt(tab[0])==2 && + } + { + //设置 + parseInt(tab[0])==3 && + } + +
    +
    +
    + ) + } } export default PollDetailIndex \ No newline at end of file diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index cf415aa28..0c4109ceb 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -2319,7 +2319,14 @@ class PollNew extends Component { } } - + gotohome=()=>{ + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } //试图 render() { let { @@ -2373,19 +2380,18 @@ class PollNew extends Component { /> : ""}

    - {this.props.coursedata.name} + this.gotohome()}>{this.props.coursedata.name} > - 问卷 + 问卷 > {this.props.match.params.news === undefined ? "新建" : this.props.match.params.news === "new" ? "新建" : "编辑"}

    {this.props.match.params.news === undefined ? "新建问卷" : this.props.match.params.news === "new" ? "新建问卷" : "编辑问卷"}

    - 返回 + this.gotohome()} + className=" fr font-16">返回
    {/*
    */} diff --git a/public/react/src/modules/courses/shixunHomework/CommitSummary.js b/public/react/src/modules/courses/shixunHomework/CommitSummary.js index af8bda0dc..b40cb3536 100644 --- a/public/react/src/modules/courses/shixunHomework/CommitSummary.js +++ b/public/react/src/modules/courses/shixunHomework/CommitSummary.js @@ -70,7 +70,14 @@ class CommitSummary extends Component{ const mdContnet = this.refs[`md${1}`].getValue().trim(); console.log(mdContnet) } - + gotohome=()=>{ + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } asdasdsad=()=>{ this.setState({ contents:"" @@ -123,20 +130,19 @@ class CommitSummary extends Component{ }} >

    - {data === undefined ? "" :data.course_name===undefined?"": data.course_name} + this.gotohome()}>{data === undefined ? "" :data.course_name===undefined?"": data.course_name} > - {data === undefined ? "" :data.category===undefined?"":data.category.category_name} + {data === undefined ? "" :data.category===undefined?"":data.category.category_name} > - 作业详情 + 作业详情

    {/*educontentbox*/}
    diff --git a/public/react/src/modules/courses/shixunHomework/ShixunHomeworkPage.js b/public/react/src/modules/courses/shixunHomework/ShixunHomeworkPage.js index d9e589bd4..e2285a7a6 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunHomeworkPage.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunHomeworkPage.js @@ -111,7 +111,14 @@ class ShixunHomeworkPage extends Component { bindRef = ref => { this.child = ref } ///////////////教师截止 - + gotohome=()=>{ + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } render() { let {tab, teacherdatapage, jobsettingsdatapage} = this.state; @@ -125,12 +132,11 @@ class ShixunHomeworkPage extends Component {

    - {jobsettingsdatapage === undefined ? "" : jobsettingsdatapage.data.course_name} + this.gotohome()}>{jobsettingsdatapage === undefined ? "" : jobsettingsdatapage.data.course_name} > - {jobsettingsdatapage === undefined ? "" : jobsettingsdatapage.data.category.category_name} + href={`/courses/${this.props.match.params.coursesId}/${this.state.shixuntypes}/${jobsettingsdatapage === undefined ? "" : jobsettingsdatapage.data.category.category_id === undefined ? "" : jobsettingsdatapage.data.category.category_id}`}>{jobsettingsdatapage === undefined ? "" : jobsettingsdatapage.data.category.category_name} > 作业详情

    @@ -142,8 +148,7 @@ class ShixunHomeworkPage extends Component { - 返回 + this.gotohome()}>返回 实训详情 diff --git a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js index 3c2367942..91f6f3001 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js @@ -101,6 +101,14 @@ class ShixunWorkReport extends Component { } } } + gotohome=()=>{ + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } render() { let{data} =this.state; let category_id=data===undefined?"":data.category===null?"":data.category.category_id; @@ -119,16 +127,15 @@ class ShixunWorkReport extends Component { modalsType={this.state.DownloadType} />

    - - + this.gotohome()}> {data&&data.course_name} - + > - + {data===undefined?"":data.category===null?"":data.category.category_name} - + > - 作业详情 + 作业详情 > {data&&data.username}

    diff --git a/public/react/src/modules/courses/shixunHomework/shixunHomework.js b/public/react/src/modules/courses/shixunHomework/shixunHomework.js index 504dd9c57..61133acd2 100644 --- a/public/react/src/modules/courses/shixunHomework/shixunHomework.js +++ b/public/react/src/modules/courses/shixunHomework/shixunHomework.js @@ -875,6 +875,14 @@ class ShixunHomework extends Component{ let data={id:parseInt(datas.category_id),name:name} trigger('editshixunname', data) } + gotohome=()=>{ + let courseId=this.props.match.params.coursesId; + if(courseId===undefined){ + this.props.history.push("/courses"); + }else{ + this.props.history.push(this.props.current_user.first_category_url); + } + } render(){ let { modalname, diff --git a/public/react/src/modules/home/shixunsHome.js b/public/react/src/modules/home/shixunsHome.js index 92f3c9f44..9c166f43f 100644 --- a/public/react/src/modules/home/shixunsHome.js +++ b/public/react/src/modules/home/shixunsHome.js @@ -93,7 +93,7 @@ class ShixunsHome extends Component { const CustomNextArrow = props => { return (
    - +
    ); }; @@ -101,7 +101,7 @@ class ShixunsHome extends Component { const CustomPrevArrow = props => { return (
    - +
    ); }; @@ -374,7 +374,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -388,7 +388,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -402,7 +402,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -418,7 +418,7 @@ class ShixunsHome extends Component { return (
  • - + {item.username}
  • @@ -450,7 +450,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -464,7 +464,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -478,7 +478,7 @@ class ShixunsHome extends Component {
  • - + {item.username}
  • @@ -494,7 +494,7 @@ class ShixunsHome extends Component { return (
  • - + {item.username}
  • diff --git a/public/react/src/modules/login/EducoderLogin.js b/public/react/src/modules/login/EducoderLogin.js index 14d80181a..713593100 100644 --- a/public/react/src/modules/login/EducoderLogin.js +++ b/public/react/src/modules/login/EducoderLogin.js @@ -120,6 +120,9 @@ class EducoderLogin extends Component { }) } + gohome=()=>{ + window.location.href="/" + } Setshowbool = (e,name,pass) => { if (e===1) { this.setState({ @@ -146,7 +149,7 @@ class EducoderLogin extends Component { "width": "100%" }}>
    - + this.gohome()} src={educodernet}/>
    diff --git a/public/react/src/modules/page/MainContent.js b/public/react/src/modules/page/MainContent.js index c03d49351..601c002a9 100644 --- a/public/react/src/modules/page/MainContent.js +++ b/public/react/src/modules/page/MainContent.js @@ -114,7 +114,7 @@ class MainContent extends Component { ? readRepoTimeout === true ?
    代码加载失败, this.props.fetchRepositoryCode(this.props, null, null, true)}>重试 + onClick={() => this.props.fetchRepositoryCode(this.props, null, null, true, true)}>重试
    :
    diff --git a/public/react/src/modules/page/MainContentContainer.js b/public/react/src/modules/page/MainContentContainer.js index d24a5cefb..829b84b16 100644 --- a/public/react/src/modules/page/MainContentContainer.js +++ b/public/react/src/modules/page/MainContentContainer.js @@ -235,7 +235,10 @@ class MainContentContainer extends Component { } // arg_path 点击文件目录树时,传入的点击节点对应的path - fetchRepositoryCode( props, arg_path, type, isRetry) { + fetchRepositoryCode( props, arg_path, type, isRetry, retryAndRefresh) { + if (retryAndRefresh) { + this.retryAndRefresh = retryAndRefresh + } const { challenge, showSnackbar, game, shixun, myshixun, hide_code } = props ? props : this.props; if (shixun.vnc == true) { // vnc模式下不需要加载代码 @@ -293,6 +296,11 @@ class MainContentContainer extends Component { // that._cancel = c; // }) }).then((fetchRepositoryCodeResponse) => { + // monaca 需要刷新,不然无法编辑 + if (this.retryAndRefresh && fetchRepositoryCodeResponse.data.content) { + window.location.reload() + return; + } // 空字符串还是正常切换 if (fetchRepositoryCodeResponse.data.status == 0) { readingRepoTimes = readingRepoTimes + 1; diff --git a/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js b/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js index 5534dd415..340505655 100644 --- a/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js +++ b/public/react/src/modules/paths/PathDetail/DetailCardsEditAndAdd.js @@ -402,7 +402,7 @@ class DetailCardsEditAndAdd extends Component{
    *
    - +
    名称不能为空
    必填项
    diff --git a/public/react/src/modules/paths/ShixunPathCard.js b/public/react/src/modules/paths/ShixunPathCard.js index 9260b9f46..1b0759d1f 100644 --- a/public/react/src/modules/paths/ShixunPathCard.js +++ b/public/react/src/modules/paths/ShixunPathCard.js @@ -38,7 +38,7 @@ class ShixunPathCard extends Component{
    {/*target="_blank"*/} - 13?1543211263 + 13?1543211263

    diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 20436f3c7..791110b0b 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -708,7 +708,7 @@ submittojoinclass=(value)=>{ onInput={()=>this.onKeywordSearchKeyDowns()} onSearch={(value) => this.onKeywordSearchKeyDown(value)} // onPressEnter={this.onKeywordSearchKeyDown} - style={{ width: 300 }} + style={{ width: 300,height:32}} autoFocus={true} />

    :""} diff --git a/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js b/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js index 2cca8cb65..7a6f1ec4b 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js +++ b/public/react/src/modules/tpm/challengesnew/TPMchallengesnew.js @@ -493,7 +493,7 @@ export default class TPMchallengesnew extends Component {

    过关任务

    + watch={true} className="courseMessageMD" initValue={this.state.exercisememoMDRefval} height={700}>

    diff --git a/public/react/src/modules/user/FindPasswordComponent.js b/public/react/src/modules/user/FindPasswordComponent.js index 7df2d82c5..19b5a7388 100644 --- a/public/react/src/modules/user/FindPasswordComponent.js +++ b/public/react/src/modules/user/FindPasswordComponent.js @@ -12,6 +12,7 @@ import ReadPassword from './ReadPassword'; import axios from 'axios'; import './common.css' +import './commontwo.css' const TabPane = Tabs.TabPane const loginInputsyl = { @@ -27,7 +28,7 @@ class LoginRegisterComponent extends Component { login: "", password: "", passwords: "", - seconds: 35, + seconds: 60, codes: "", getverificationcodes: true, Phonenumberisnotcobool: false, @@ -126,7 +127,7 @@ class LoginRegisterComponent extends Component { clearInterval(timer); this.setState({ getverificationcodes: false, - seconds: 35, + seconds: 60, }) } }); @@ -144,7 +145,7 @@ class LoginRegisterComponent extends Component { clearInterval(timer); this.setState({ getverificationcodes: false, - seconds: 35, + seconds: 60, }) } @@ -600,6 +601,7 @@ class LoginRegisterComponent extends Component { height={38} successGreenColor="#29bd8b" style={{height: "38px", width: "100%"}} dragOkCallback={()=>this.dragOkCallback()} + className="ysllw100" > : "" @@ -611,6 +613,7 @@ class LoginRegisterComponent extends Component { height={38} successGreenColor="#29bd8b" style={{height: "38px", width: "100%"}} dragOkCallback={()=>this.dragOkCallback()} + className="ysllw100" > : "" diff --git a/public/react/src/modules/user/Interestpage.js b/public/react/src/modules/user/Interestpage.js index dbca5a242..1054d620e 100644 --- a/public/react/src/modules/user/Interestpage.js +++ b/public/react/src/modules/user/Interestpage.js @@ -192,6 +192,8 @@ class InterestpageComponent extends Component { ints.push(this.state.gouxuans4[i].id); } } + console.log("195195"); + console.log(ints); if(ints.length<1){ this.openNotification("请至少选择一个您感兴趣的内容"); return diff --git a/public/react/src/modules/user/InterestpageMax.js b/public/react/src/modules/user/InterestpageMax.js index e0585ed33..6dc182154 100644 --- a/public/react/src/modules/user/InterestpageMax.js +++ b/public/react/src/modules/user/InterestpageMax.js @@ -182,10 +182,6 @@ class InterestpageMax extends Component { //兴趣页面点击 Interestcompletionpage(){ - - this.setState({ - setpagecomplet:true - }) if(this.state.gouxuans.length === 0){ this.openNotification("请选择职业"); return @@ -197,6 +193,8 @@ class InterestpageMax extends Component { ints.push(this.state.gouxuans4[i].id); } } + console.log("200200"); + console.log(ints); if(ints.length<1){ this.openNotification("请至少选择一个您感兴趣的内容"); return @@ -302,7 +300,7 @@ class InterestpageMax extends Component { ) })}
    - +
    diff --git a/public/react/src/modules/user/LoginRegisterComponent.js b/public/react/src/modules/user/LoginRegisterComponent.js index b761a910f..b27fe8cec 100644 --- a/public/react/src/modules/user/LoginRegisterComponent.js +++ b/public/react/src/modules/user/LoginRegisterComponent.js @@ -9,6 +9,7 @@ import passoff from '../../../src/images/login/passoff.png'; import axios from 'axios'; import DragValidatortwo from '../../../src/common/components/DragValidatortwo' import './common.css' +import './commontwo.css' const { TabPane } = Tabs; const loginInputsyl = { "width":"434px", @@ -36,7 +37,7 @@ class LoginRegisterComponent extends Component { classpass: "text", // 登录 passopens: passoff, - seconds: 35, + seconds: 60, discodeBtn: false, clearInterval: false, autoLogin: true, @@ -45,7 +46,7 @@ class LoginRegisterComponent extends Component { readAgreement: false, getverificationcodes: true, dragOk: false, - Agreetotheterms: false, + Agreetotheterms: true, login: "", password: "", logins: "", @@ -71,7 +72,7 @@ class LoginRegisterComponent extends Component { classpass: "text", // 登录 passopens: passoff, - seconds: 35, + seconds: 60, discodeBtn: false, clearInterval: false, autoLogin: true, @@ -80,7 +81,7 @@ class LoginRegisterComponent extends Component { readAgreement: false, getverificationcodes: true, dragOk: false, - Agreetotheterms: false, + Agreetotheterms: true, login: "", password: "", logins: "", @@ -528,7 +529,7 @@ class LoginRegisterComponent extends Component { clearInterval(timer); this.setState({ getverificationcodes: false, - seconds: 35, + seconds: 60, }) } }); @@ -546,7 +547,7 @@ class LoginRegisterComponent extends Component { clearInterval(timer); this.setState({ getverificationcodes: false, - seconds: 35, + seconds: 60, }) } @@ -718,7 +719,7 @@ class LoginRegisterComponent extends Component { console.log(classpass); return ( -
    +
    - + 登录 注册 @@ -839,8 +840,9 @@ class LoginRegisterComponent extends Component { Whethertoverify===false&&pciphone===true? : "" @@ -850,8 +852,9 @@ class LoginRegisterComponent extends Component { Whethertoverify===true&&pciphone===true? : "" @@ -941,7 +944,7 @@ class LoginRegisterComponent extends Component { } 我已阅读并同意 diff --git a/public/react/src/modules/user/account/AccountBasicEdit.js b/public/react/src/modules/user/account/AccountBasicEdit.js index 8af24022d..1458862a1 100644 --- a/public/react/src/modules/user/account/AccountBasicEdit.js +++ b/public/react/src/modules/user/account/AccountBasicEdit.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import { SnackbarHOC, getImageUrl, City, ConditionToolTip } from 'educoder'; -import { Form, Button, Input, Radio, Select, Tooltip, Icon } from 'antd' +import { Form, Button, Input, Radio, Select, Tooltip, Icon, AutoComplete } from 'antd' import ApplyForAddOrgModal from '../modal/ApplyForAddOrgModal' import ApplyForAddChildOrgModal from '../modal/ApplyForAddChildOrgModal' import axios from 'axios' @@ -70,28 +70,44 @@ class AccountBasic extends Component { job2:basicInfo && basicInfo.identity=="professional" ? basicInfo.technical_title:"企业管理者", }) }, 100) - //if(basicInfo.nickname){ this.setState({ forDisable: true, nameLength:basicInfo.nickname?basicInfo.nickname.length:0, showRealName:basicInfo.show_realname, realName: basicInfo.name, - identity:basicInfo.identity + identity:basicInfo.identity, + school_id:basicInfo.school_id, + department_id:basicInfo.department_id }) //} } } // 获取学校、单位 - getSchoolList=(basicInfo)=>{ + getSchoolList=(basicInfo, selectedName)=>{ let url=`/schools/for_option.json`; axios.get(url).then((result)=>{ if(result){ this.setState({ schoolList:result.data.schools }) - if(basicInfo && basicInfo.school_name){ + if (selectedName) { + let school_id + result.data.schools.reverse().some( item => { + if (item.name == selectedName) { + school_id = item.id + return true; + } + }) + this.props.form.setFieldsValue({ + org: selectedName + }) + this.setState({ + school_id, + school: selectedName + }) + } else if(basicInfo && basicInfo.school_name){ this.setState({ school:basicInfo.school_name, filterSchoolList:this.state.schoolList.filter(function(item){ @@ -119,6 +135,15 @@ class AccountBasic extends Component { console.log(values); let {basicInfo}=this.props; if(!err ){ + if (!this.state.school_id) { + this.props.showNotification('请先选择学校/单位') + return; + } + if (!this.state.department_id) { + this.props.showNotification('请先选择院系/部门') + return; + } + let url=`/users/accounts/${basicInfo.id}.json` axios.put((url),{ nickname:values.nickname, @@ -187,6 +212,10 @@ class AccountBasic extends Component { school:e, filterSchoolList:arr }) + } else { + this.setState({ + school: '', + }) } // else{ // let {school}=this.state; @@ -208,17 +237,30 @@ class AccountBasic extends Component { filterDepartments:arr, departmentsName:e }) + } else { + this.setState({ + filterDepartments: this.state.departments + }) } } // 选择部门、学院 changeDepartment=(e)=>{ - let arr= this.state.departments && this.state.departments.filter ? this.state.departments.filter(function(item){ + let arr = this.state.departments && this.state.departments.filter ? this.state.departments.filter(function(item){ return item.name == e; }) : []; + if (!arr[0]) { + this.setState({ + department_id: '', + departmentsName: e, + }) + this.this_department_id = '' + return; + } + this.this_department_id = arr[0].id this.setState({ departmentsName:e, - department_id:arr[0].id + department_id: arr[0].id }) } @@ -231,20 +273,58 @@ class AccountBasic extends Component { let arr=this.state.schoolList.filter(function(item){ return item.name == e; }); + if (!arr[0]) { + // 没找到学校,清空部门 + this.setState({ + departments: [], + filterDepartments: [], + departmentsName: '', + school_id: '', + department_id: '', + }) + this.this_school_id = '' + this.props.form.setFieldsValue({ + org2: '' + }) + return; + } + this.props.form.setFieldsValue({ + org: arr[0].name + }) + this.filterList(e) // 保存选择的学校id + this.this_school_id = arr[0].id this.setState({ - school_id:arr[0].id, + school_id: arr[0].id, school:e, }) - let url=`/schools/${arr[0].id}/departments/for_option.json`; + this._getDepartments(arr[0].id, flag) + } + _getDepartments = (schoolId, flag, selectedName) => { + let url=`/schools/${schoolId || this.state.school_id}/departments/for_option.json`; axios.get(url).then((result)=>{ if(result){ this.setState({ departments:result.data.departments, filterDepartments:result.data.departments }) - // 切换学校后,部门默认选择第一个 - if(result.data.departments && result.data.departments.length>0 && flag==true){ + if (selectedName) { + let department_id + result.data.departments.reverse().some( item => { + if (item.name == selectedName) { + department_id = item.id + return true; + } + }) + this.props.form.setFieldsValue({ + org2: selectedName + }) + this.setState({ + department_id, + // school: selectedName + }) + } else if(result.data.departments && result.data.departments.length>0 && flag==true){ + // 切换学校后,部门默认选择第一个 this.props.form.setFieldsValue({ org2:result.data.departments[0].name }) @@ -273,6 +353,23 @@ class AccountBasic extends Component { } } + addOrgSuccess = (name) => { + // const schoolList = this.state.schoolList.slice(0) + // schoolList.push({ id: schoolList.length + 2000, name: name}) + // this.setState({ schoolList }) + + this.getSchoolList(this.props.basicInfo, name); + + this.props.form.setFieldsValue({ + name: name + }) + } + + addChildOrgSuccess = (deptName) => { + + this._getDepartments(this.state.school_id, false, deptName); + + } showApplyForAddOrgModal = () => { this.applyForAddOrgForm.setVisible(true) @@ -309,19 +406,22 @@ class AccountBasic extends Component { return (
    this.applyForAddOrgForm = form} schoolName={school} - {...propsWithoutForm}> + {...propsWithoutForm} addOrgSuccess={this.addOrgSuccess} + > this.applyForAddChildOrgForm = form} > + {...propsWithoutForm} wrappedComponentRef={(form) => this.applyForAddChildOrgForm = form} + addChildOrgSuccess={this.addChildOrgSuccess} + > -
    +
    基本信息
    @@ -473,6 +575,7 @@ class AccountBasic extends Component { {getFieldDecorator('student_No', { @@ -544,28 +647,40 @@ class AccountBasic extends Component { // type: 'array', required: true, message: '请先选择学校/单位', + + // 做不了,输入时和submit时都会执行这里 + // validator: (rule, value, callback) => { + // if (this.this_school_id) { + // callback(); + // return; + // } + // callback('请先选择学校/单位'); + // } + }], })( - + )} -
    - {!filterSchoolList || (filterSchoolList && filterSchoolList.length==0 )&& - - 未找到包含“{school}”的高校, - 申请新增 - + + {!filterSchoolList || (filterSchoolList && filterSchoolList.length==0 )&& school && +
    + + 未找到包含“{school}”的高校, + 申请新增 + +
    } -
    {getFieldDecorator('org2', { rules: [{ @@ -573,9 +688,16 @@ class AccountBasic extends Component { // type: 'array', required: true, message: '请先选择院系/部门', + // validator: (rule, value, callback) => { + // if (this.this_department_id) { + // callback(); + // return; + // } + // callback('请先选择院系/部门'); + // } }], })( - + )} -
    + { - !filterDepartments || (filterDepartments && filterDepartments.length==0 )&& - - 未找到包含“{departmentsName}”的院系/部门, - 申请新增 - + !filterDepartments || (filterDepartments && filterDepartments.length==0 )&& departmentsName && +
    + + 未找到包含“{departmentsName}”的院系/部门, + 申请新增 + +
    } -
    + {/* htmlType="submit" */} {/* @@ -607,7 +731,7 @@ class AccountBasic extends Component { */}
    -
    * 我们确保你所提供的信息均处于严格保密状态,不会泄露
    +
    * 我们确保你所提供的信息均处于严格保密状态,不会泄露
    ); } diff --git a/public/react/src/modules/user/account/AccountCertification.js b/public/react/src/modules/user/account/AccountCertification.js index 455967398..15a78b564 100644 --- a/public/react/src/modules/user/account/AccountCertification.js +++ b/public/react/src/modules/user/account/AccountCertification.js @@ -15,7 +15,7 @@ class AccountCertification extends Component { } checkBasicInfo = (index) => { - if (this.props.basicInfo.base_info_completed == true) { + if ( this.props.basicInfo.base_info_completed == true) { this.showRealNameCertificationModal(index) } else { this.props.confirm({ @@ -26,25 +26,31 @@ class AccountCertification extends Component { } }) } + } showRealNameCertificationModal = (index) => { this.setState({ certification:index, + }, () => { + if (index == 1) { + this.realNameCertificationModal1.setVisible(true) + } else if (index == 2) { + this.realNameCertificationModal2.setVisible(true) + } }) - this.realNameCertificationModal.setVisible(true) } render() { let {certification}=this.state let {basicInfo} = this.props; return (
    - {this.state.certification===1? this.realNameCertificationModal = form} certification={certification} + {this.state.certification===1? this.realNameCertificationModal1 = form} certification={certification} >:""} - {this.state.certification===2? this.realNameCertificationModal = form} certification={certification} + {this.state.certification===2? this.realNameCertificationModal2 = form} certification={certification} >:""}
    -
    + { - if(this.props.schoolName && prevState.schoolName != this.props.schoolName){ - this.props.form.setFieldsValue({ - schoolName:this.props.schoolName - }) - } - } - componentDidMount=()=>{ - if(this.props.schoolName){ - this.props.form.setFieldsValue({ - schoolName:this.props.schoolName - }) - } - } - - setVisible = (visible) => { - this.refs.modalWrapper.setVisible(visible) - } - - onSendOk = () => { - this.props.form.validateFieldsAndScroll((err, values) => { - console.log(values); - if(!err){ - let url=`/add_school_applies.json`; - axios.post(url,{ - name:values.schoolName, - province:values.city && values.city[0], - city:values.city && values.city[1], - address:values.address, - remarks:values.remarks - }).then((result)=>{ - if(result){ - this.props.showNotification("新增学校/单位成功!"); - this.setVisible(false); - } - }).catch((error)=>{ - console.log(error); - }) - } - }) - } - - onOk = () => { - this.onSendOk() - } - - render(){ - const { course_lists, checkBoxValues, searchValue, loading, hasMore } = this.state - const { moduleName } = this.props - const { getFieldDecorator } = this.props.form; - return( - - - - - {getFieldDecorator('schoolName', { - rules: [{ - // initialValue: this.state.cityDefaultValue, - required: true, - message: '请输入学校或工作单位', - }], - })( - - )} -
    -
  • 示例:
  • -
      -
    • - - 国防科学技术大学 -
    • -
    • - - 国防科学技术大学开福校区 -
    • -
    -
    -
    - - - {getFieldDecorator('city', { - rules: [], - })( - - )} - - - - {getFieldDecorator('address', { - rules: [], - })( - - )} - - - - {getFieldDecorator('remarks', { - })( - - )} - - - - - -
    - ) - } -} -const WrappedApplyForAddOrgModal = Form.create({ name: 'ApplyForAddOrgModal' })(ApplyForAddOrgModal); - -export default WrappedApplyForAddOrgModal; - - +import React, { Component } from "react"; +import { Modal, Button, Input, Form, } from "antd"; +import axios from 'axios' +import ModalWrapper from "../../courses/common/ModalWrapper" +import { City } from 'educoder' +import '../account/common.css' + +const { TextArea } = Input; +const Search = Input.Search +class ApplyForAddOrgModal extends Component{ + constructor(props){ + super(props); + this.state={ + + } + } + + componentDidUpdate=(prevState)=>{ + if(this.props.schoolName && prevState.schoolName != this.props.schoolName){ + this.props.form.setFieldsValue({ + schoolName:this.props.schoolName + }) + } + } + componentDidMount=()=>{ + if(this.props.schoolName){ + this.props.form.setFieldsValue({ + schoolName:this.props.schoolName + }) + } + } + + setVisible = (visible) => { + this.refs.modalWrapper.setVisible(visible) + } + + onSendOk = () => { + this.props.form.validateFieldsAndScroll((err, values) => { + console.log(values); + if(!err){ + let url=`/add_school_applies.json`; + axios.post(url,{ + name:values.schoolName, + province:values.city && values.city[0], + city:values.city && values.city[1], + address:values.address, + remarks:values.remarks + }).then((result)=>{ + if(result){ + this.props.showNotification("新增学校/单位成功!"); + this.setVisible(false); + this.props.addOrgSuccess(values.schoolName) + + } + }).catch((error)=>{ + console.log(error); + }) + } + }) + } + + onOk = () => { + this.onSendOk() + } + + render(){ + const { course_lists, checkBoxValues, searchValue, loading, hasMore } = this.state + const { moduleName } = this.props + const { getFieldDecorator } = this.props.form; + return( + + +
    + + {getFieldDecorator('schoolName', { + rules: [{ + // initialValue: this.state.cityDefaultValue, + required: true, + message: '请输入学校或工作单位', + }], + })( + + )} +
    +
  • 示例:
  • +
      +
    • + + 国防科学技术大学 +
    • +
    • + + 国防科学技术大学开福校区 +
    • +
    +
    +
    + + + {getFieldDecorator('city', { + rules: [], + })( + + )} + + + + {getFieldDecorator('address', { + rules: [], + })( + + )} + + + + {getFieldDecorator('remarks', { + })( + + )} + + +
    + + +
    + ) + } +} +const WrappedApplyForAddOrgModal = Form.create({ name: 'ApplyForAddOrgModal' })(ApplyForAddOrgModal); + +export default WrappedApplyForAddOrgModal; + + diff --git a/public/react/src/modules/user/modal/RealNameCertificationModal.js b/public/react/src/modules/user/modal/RealNameCertificationModal.js index 617d24a22..bdd2270ae 100644 --- a/public/react/src/modules/user/modal/RealNameCertificationModal.js +++ b/public/react/src/modules/user/modal/RealNameCertificationModal.js @@ -147,7 +147,7 @@ class RealNameCertificationModal extends Component{ {...this.props } onOk={this.onOk} okText="保存" - className="applyForModal certificationModal" + className="applyForModal certificationModal courseNormalForm" bottomRender={ certification && certification == 1?
    @@ -186,7 +186,7 @@ class RealNameCertificationModal extends Component{ >