From e33ad04bcb817df379cf0267458a7e24079ae96f Mon Sep 17 00:00:00 2001
From: p31729568 <winse.wang@foxmail.com>
Date: Thu, 19 Sep 2019 16:13:48 +0800
Subject: [PATCH 1/4] ecs: add graduation_subitems list api

---
 app/controllers/ecs/graduation_subitems_controller.rb | 5 +++++
 app/views/ecs/graduation_subitems/index.json.jbuilder | 8 ++++++++
 config/routes.rb                                      | 1 +
 3 files changed, 14 insertions(+)
 create mode 100644 app/controllers/ecs/graduation_subitems_controller.rb
 create mode 100644 app/views/ecs/graduation_subitems/index.json.jbuilder

diff --git a/app/controllers/ecs/graduation_subitems_controller.rb b/app/controllers/ecs/graduation_subitems_controller.rb
new file mode 100644
index 000000000..b2570891d
--- /dev/null
+++ b/app/controllers/ecs/graduation_subitems_controller.rb
@@ -0,0 +1,5 @@
+class Ecs::GraduationSubitemsController < Ecs::BaseController
+  def index
+    @graduation_subitems = current_year.ec_graduation_subitems#.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC')
+  end
+end
\ No newline at end of file
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

From b10c91c55d29af390e06c8c4b7467f65d3cccbb8 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, 19 Sep 2019 16:14:51 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E8=AE=A4=E8=AF=81?=
 =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=93=E7=B3=BBVS=E6=AF=95=E4=B8=9A?=
 =?UTF-8?q?=E8=A6=81=E6=B1=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 public/react/src/AppConfig.js                 |  15 +-
 .../CourseSupports/ecCourseSupports.css       |   6 +
 .../ecs/EcSetting/CourseSupports/index.js     | 187 ++++++++++++------
 3 files changed, 136 insertions(+), 72 deletions(-)

diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js
index 5f30a26a8..025db7f5c 100644
--- a/public/react/src/AppConfig.js
+++ b/public/react/src/AppConfig.js
@@ -38,14 +38,13 @@ export function initAxiosInterceptors(props) {
     //      https://github.com/axios/axios/issues/1497
 
     // TODO 读取到package.json中的配置?
-    var proxy = "http://localhost:3000"
-    
-        // proxy="https://pre-newweb.educoder.net"
-        // proxy="https://test-newweb.educoder.net"
-	       proxy="http://192.168.2.63:3001";
-
-    // 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<neweditcourse.length;j++){
-                        if(neweditcourse[j].weigths===undefined){
-                            newnum=0
-                        }else{
-                            newnum=newnum+neweditcourse[j].weigths;
-                        }
-                    }
-                    newnum= Math.round(newnum*100)/100;
-
-                    this.setState({
-                        editnum:newnum
-                    })
-                }
 
-            })
-            .catch(function (error) {
-                console.log(error);
-            });
+        // const url = `/ec_course_supports/edit_require_vs_course?subitem_id=`+id
+        // axios.get(url)
+        //     .then((response) => {
+				//
+        //         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<neweditcourse.length;j++){
+        //                 if(neweditcourse[j].weigths===undefined){
+        //                     newnum=0
+        //                 }else{
+        //                     newnum=newnum+neweditcourse[j].weigths;
+        //                 }
+        //             }
+        //             newnum= Math.round(newnum*100)/100;
+				//
+        //             this.setState({
+        //                 editnum:newnum
+        //             })
+        //         }
+				//
+        //     })
+        //     .catch(function (error) {
+        //         console.log(error);
+        //     });
+      let  {data}=this.state;
+
+
+			data.graduation_subitems.map((item,key)=>{
+				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<editcourse.length;p++){
-            if(editcourse[p].weigths===""){
-                editcourse[p].weigths=0;
-            }
-            if(editcourse[p].ec_course_id===""){
-                this.setState({
-                    // Supportstype:true,
-                    Supportslist:'保存失败,课程不能为空',
-                    Supportsclass:true
-                })
-                return
-            }
-        }    
+
+        // for(var p=0; p<editcourse.length;p++){
+        //     if(editcourse[p].weigths===""){
+        //         editcourse[p].weigths=0;
+        //     }
+        //     if(editcourse[p].ec_course_id===""){
+        //         this.setState({
+        //             // Supportstype:true,
+        //             Supportslist:'保存失败,课程不能为空',
+        //             Supportsclass:true
+        //         })
+        //         return
+        //     }
+        // }
+
+				editcourse.map((item,key)=>{
+					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 {
                                                 </p>
 
                                                 <div className="clearfix editorModify">
-
+																									{Supportsclass===true?<style>
+																										{
+																											`
+																											.showredfont .ant-select-selection{
+																											    border: 1px solid #db0505 !important;
+																											}
+																											`
+																										}
+																									</style>:""}
                                                     {
                                                         editcourse.map((it,key)=>{
 
                                                             return(
                                                                 <div className="mb15" key={key}>
 
-                                                                    <Select className={Supportsclass===true?"bor-red heightimportant":"heightimportant"} showSearch value={it.ec_course_name} onChange={this.handleChange}>
+                                                                    <Select className={Supportsclasskey===key?"showredfont heightimportant":"heightimportant"} showSearch value={it.ec_course_name} onChange={this.handleChange}>
                                                                         {
                                                                             ec_courses_list.map((qva,qk)=>{
                                                                                 return(
-                                                                                    <Option value={[qva.id,key,qva.name]} key={qk}>{qva.name}</Option>
+                                                                                    <Option value={[qva.id,key,qva.name]} key={[qva.id,key,qva.name]}>{qva.name}</Option>
                                                                                 )
                                                                             })
 
@@ -557,7 +616,7 @@ class CourseSupports extends Component {
                                                     }
 
                                                 </div>
-                                                <span className="c_red none ml35" id="error_tip" style={{display:Supportssum===true||Supportsclass===true?'inline':'none'}}>{Supportslist}</span>
+                                                <span className="c_red none ml35 color-red" id="error_tip" style={{display:Supportssum===true||Supportsclass===true?'inline':'none'}}>{Supportslist}</span>
                                                 <div className="clearfix editorModify">
                                                     <span className="column-1"
                                                     style={{
@@ -569,7 +628,7 @@ class CourseSupports extends Component {
                                                     <span className="ml30">合计: <span>{editnum}</span></span>
                                                 </div>
 
-                                                <div className="right editglybuttonboxs">
+                                                <div className="right editlybuttonbox">
                                                     <div className="defalutSubmitbtn fr" onClick={this.SubmitClassData}>保存</div>
                                                     <div className="defalutCancelbtn fr mr20" onClick={this.CancelSupports}>取消</div>
                                                 </div>

From cbeeb84a74c4d180fb5aeb3e88a5abc8787c8d20 Mon Sep 17 00:00:00 2001
From: p31729568 <winse.wang@foxmail.com>
Date: Thu, 19 Sep 2019 16:17:37 +0800
Subject: [PATCH 3/4] ecs: fix graduation subitem api order

---
 app/controllers/ecs/graduation_subitems_controller.rb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/app/controllers/ecs/graduation_subitems_controller.rb b/app/controllers/ecs/graduation_subitems_controller.rb
index b2570891d..03cf379bb 100644
--- a/app/controllers/ecs/graduation_subitems_controller.rb
+++ b/app/controllers/ecs/graduation_subitems_controller.rb
@@ -1,5 +1,6 @@
 class Ecs::GraduationSubitemsController < Ecs::BaseController
   def index
-    @graduation_subitems = current_year.ec_graduation_subitems#.reorder('ec_graduation_requirements.position ASC, ec_graduation_subitems.position ASC')
+    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

From 8b80e360c6bbf89337d7a62796a87b225fbe3c9a Mon Sep 17 00:00:00 2001
From: p31729568 <winse.wang@foxmail.com>
Date: Thu, 19 Sep 2019 16:23:52 +0800
Subject: [PATCH 4/4] fix

---
 .../shared/_ec_graduation_subitem.json.jbuilder                 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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)