diff --git a/app/controllers/ecs/graduation_subitems_controller.rb b/app/controllers/ecs/graduation_subitems_controller.rb new file mode 100644 index 000000000..03cf379bb --- /dev/null +++ b/app/controllers/ecs/graduation_subitems_controller.rb @@ -0,0 +1,6 @@ +class Ecs::GraduationSubitemsController < Ecs::BaseController + def index + subitems = current_year.ec_graduation_subitems.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC') + @graduation_subitems = subitems.includes(:ec_graduation_requirement) + end +end \ No newline at end of file diff --git a/app/views/ecs/graduation_course_supports/shared/_ec_graduation_subitem.json.jbuilder b/app/views/ecs/graduation_course_supports/shared/_ec_graduation_subitem.json.jbuilder index aee77c5b7..ced8a5c72 100644 --- a/app/views/ecs/graduation_course_supports/shared/_ec_graduation_subitem.json.jbuilder +++ b/app/views/ecs/graduation_course_supports/shared/_ec_graduation_subitem.json.jbuilder @@ -2,5 +2,5 @@ json.extract! ec_graduation_subitem, :id, :position, :content, :ec_graduation_re json.graduation_requirement_position ec_graduation_subitem.ec_graduation_requirement.position -json.course_supports ec_graduation_subitem.ec_course_supports, partial: 'ec_course_support', as: :ec_course_support +json.course_supports ec_graduation_subitem.ec_course_supports, partial: 'ecs/graduation_course_supports/shared/ec_course_support', as: :ec_course_support json.weights_total ec_graduation_subitem.ec_course_supports.to_a.sum(&:weights) diff --git a/app/views/ecs/graduation_subitems/index.json.jbuilder b/app/views/ecs/graduation_subitems/index.json.jbuilder new file mode 100644 index 000000000..0a1235b1d --- /dev/null +++ b/app/views/ecs/graduation_subitems/index.json.jbuilder @@ -0,0 +1,8 @@ +json.graduation_subitems do + json.array! @graduation_subitems do |graduation_subitem| + json.extract! graduation_subitem, :id, :position, :content + json.graduation_requirement_position graduation_subitem.ec_graduation_requirement.position + end +end + +json.count @graduation_subitems.size \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d759ab9bd..1647101ea 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -737,6 +737,7 @@ Rails.application.routes.draw do resource :graduation_course_supports, only: [:show, :create] resource :reach_evaluation, only: [:show, :create] resource :reach_criteria, only: [:create] + resources :graduation_subitems, only: [:index] end resources :ec_courses, only: [] do diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 207f1c916..025db7f5c 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -38,17 +38,13 @@ export function initAxiosInterceptors(props) { // https://github.com/axios/axios/issues/1497 // TODO 读取到package.json中的配置? - var proxy = "http://localhost:3000"; - // proxy = "http://testbdweb.trustie.net" - // proxy = "http://testbdweb.educoder.net" - // proxy = "https://testeduplus2.educoder.net" - proxy="http://47.96.87.25:48080"; - // wy - proxy="https://pre-newweb.educoder.net"; - proxy="https://test-newweb.educoder.net" - - // wy - // proxy="http://192.168.2.63:3001" + var proxy = "http://localhost:3000" + // proxy = "http://testbdweb.trustie.net" + // proxy = "http://testbdweb.educoder.net" + // proxy = "https://testeduplus2.educoder.net" + //proxy="http://47.96.87.25:48080" + proxy="https://pre-newweb.educoder.net" + proxy="https://test-newweb.educoder.net" // 在这里使用requestMap控制,避免用户通过双击等操作发出重复的请求; // 如果需要支持重复的请求,考虑config里面自定义一个allowRepeat参考来控制 diff --git a/public/react/src/modules/ecs/EcSetting/CourseSupports/ecCourseSupports.css b/public/react/src/modules/ecs/EcSetting/CourseSupports/ecCourseSupports.css index 3f1dc000a..7f497b28e 100644 --- a/public/react/src/modules/ecs/EcSetting/CourseSupports/ecCourseSupports.css +++ b/public/react/src/modules/ecs/EcSetting/CourseSupports/ecCourseSupports.css @@ -349,4 +349,10 @@ input{ .mt60{ margin-top:60px; +} + + +.editlybuttonbox{ + margin-bottom: 30px; + margin-right: 3%; } \ No newline at end of file diff --git a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js index e5d413601..0d6771e79 100644 --- a/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js +++ b/public/react/src/modules/ecs/EcSetting/CourseSupports/index.js @@ -33,7 +33,8 @@ class CourseSupports extends Component { Supportstype:false, Supportslist:'', Supportssum:false, - Supportsclass:false + Supportsclass:false, + Supportsclasskey:undefined } } @@ -72,6 +73,24 @@ class CourseSupports extends Component { console.log(error); }); + const zrl = `/ec_years/${ec_year_id}/ec_courses/search.json`; + axios.get(zrl,{params:{ + per_page:10000, + } + }) + .then((response) => { + + if(response.status===200){ + this.setState({ + ec_courses_list:response.data.ec_courses + }) + } + + }) + .catch(function (error) { + console.log(error); + }); + } componentDidMount(){ this.setState({ @@ -81,58 +100,71 @@ class CourseSupports extends Component { this.UpdateClassData(); } - EditSupportCourse=(key,e)=>{ + EditSupportCourse=(keys,e)=>{ $('#school_major_list').scrollLeft(0); let id=e.target.id; id=parseInt(id); let subindex =e.target.getAttribute("subindex"); - const url = `/ec_course_supports/edit_require_vs_course?subitem_id=`+id - axios.get(url) - .then((response) => { - - if(response.status===200){ - var support_data; - if(response.data.edit_support_data.length>0){ - support_data=response.data.edit_support_data; - }else if(response.data.edit_support_data.length===0){ - support_data=[{weights: 0,top_relation: false,ec_course_name:'',ec_course_id:''}]; - } - - this.setState({ - ec_courses_list:response.data.ec_courses_list, - editcourse:support_data, - index:subindex, - ec_graduation_subitem_id:id, - Supportssum:false, - Supportsclass:false, - }) - - let {editcourse} =this.state; - let neweditcourse=editcourse; - let newnum=0; - for(var j=0;j { + // + // if(response.status===200){ + + // + // this.setState({ + // ec_courses_list:response.data.ec_courses_list, + // editcourse:support_data, + // index:subindex, + // ec_graduation_subitem_id:id, + // Supportssum:false, + // Supportsclass:false, + // }) + // + // let {editcourse} =this.state; + // let neweditcourse=editcourse; + // let newnum=0; + // for(var j=0;j{ + if(keys===key){ + + if(item.course_supports.length>0){ + this.setState({ + editcourse:item.course_supports, + Editkey:key + }) + }else if(item.course_supports.length===0){ + this.setState({ + editcourse:[{weights: 0,top_relation: false,ec_course_name:'',ec_course_id:''}], + Editkey:key + }) + } + + } + }) - this.setState({ - Editkey:key - }) // $("#school_ListTableLine").show(); // let offsettop=$("#school_ListTableLine").position().top||$("#school_ListTableLine").scrollTop || $("#school_ListTableLine").pageYOffset; // window.scrollTo(0, offsettop) @@ -314,19 +346,36 @@ class CourseSupports extends Component { }) return } - for(var p=0; p{ + if(item.weigths===""){ + item.weigths=0; + } + if(item.ec_course_id===""){ + this.setState({ + // Supportstype:true, + Supportslist:'保存失败,课程不能为空', + Supportsclass:true, + Supportsclasskey:key + }) + return + } + }) + var Url = '/ec_course_supports'; axios.post(Url, { ec_year_id: ec_year_id, @@ -345,6 +394,7 @@ class CourseSupports extends Component { Supportstype:true, Supportssum:false, Supportsclass:false, + Supportsclasskey:undefined, }) this.UpdateClassData(); }else if(response.data.status===-1){ @@ -353,6 +403,7 @@ class CourseSupports extends Component { Supportstype:true, Supportssum:false, Supportsclass:false, + Supportsclasskey:undefined, }) } }).catch((error) => { @@ -505,18 +556,26 @@ class CourseSupports extends Component {

- + {Supportsclass===true?:""} { editcourse.map((it,key)=>{ return(
- { ec_courses_list.map((qva,qk)=>{ return( - + ) }) @@ -557,7 +616,7 @@ class CourseSupports extends Component { }
- {Supportslist} + {Supportslist}
合计: {editnum}
-
+
保存
取消