From cca7aabf8419dbf10a5c4e6cde29b95886a69663 Mon Sep 17 00:00:00 2001 From: daiao <35855898@qq.com> Date: Thu, 7 Mar 2019 17:33:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E8=AF=BE=E7=A8=8B=E5=85=B3?= =?UTF-8?q?=E8=81=94=E8=AF=BE=E7=A8=8B=E4=BD=93=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 8 ++++++++ app/models/subject_level_system.rb | 2 ++ app/views/managements/_subject_list.html.erb | 19 +++++++++++++++++-- config/routes.rb | 1 + 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9502ee76..e1d89df0 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -16,6 +16,13 @@ class ManagementsController < ApplicationController CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z) + # 更新实训课程的等级 + def update_level_for_subject + subject = Subject.find params[:subject_id] + subject.update_attribute(:subject_level_system_id, params[:level_id]) + render :json => {status: 1} + end + # 实训课程等级体系 def subject_level_system @levels = SubjectLevelSystem.all @@ -1964,6 +1971,7 @@ end @audit_class_sx_num=Subject.where(:status => 1).count @publish_class_sx_num=Subject.where(:status => 2).count @repertories = Repertoire.where(nil).order("CONVERT( name USING gbk ) COLLATE gbk_chinese_ci ASC") + @levels = SubjectLevelSystem.all search = params[:search] # 搜索字 keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索 status = params[:status].to_i diff --git a/app/models/subject_level_system.rb b/app/models/subject_level_system.rb index 6ba73437..dae815b2 100644 --- a/app/models/subject_level_system.rb +++ b/app/models/subject_level_system.rb @@ -1,4 +1,6 @@ class SubjectLevelSystem < ActiveRecord::Base + default_scope :order => 'level' + # attr_accessible :title, :body has_many :subjects diff --git a/app/views/managements/_subject_list.html.erb b/app/views/managements/_subject_list.html.erb index abc18548..40a3b0c4 100644 --- a/app/views/managements/_subject_list.html.erb +++ b/app/views/managements/_subject_list.html.erb @@ -28,8 +28,11 @@ - + + <% @levels.each do |l| %> + + <% end %> @@ -140,4 +143,16 @@ }); } + + function select_subject_level(subject_id, level_id){ + $.ajax({ + url: "<%=update_level_for_subject_managements_path %>", + data: {subject_id: subject_id, level_id: level_id}, + type: "POST", + success: function(data){ + notice_box("关联成功!"); + } + + }); + } diff --git a/config/routes.rb b/config/routes.rb index 81d4e832..dda5d272 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -677,6 +677,7 @@ RedmineApp::Application.routes.draw do post 'create_subject_level' post 'rename_subject_level' post 'delete_subject_level' + post 'update_level_for_subject' end end # Enable Grack support