dev_SaaS
cxt 6 years ago
commit d6384b7313

@ -16,6 +16,50 @@ 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) 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
end
# 创建课程等级体系
def create_subject_level
raise("名称不能为空") if params[:name].blank?
repeat_name = SubjectLevelSystem.where(name: params[:name]).count
raise("名称不能重复") if repeat_name > 0
level = SubjectLevelSystem.pluck(:level).max.to_i + 1
SubjectLevelSystem.create(name: params[:name], level: level)
redirect_to subject_level_system_managements_path(:format => "js")
end
# 重命名课程等级
def rename_subject_level
raise("名称不能为空!") if params[:name].blank?
repeat_name = SubjectLevelSystem.where("name = ? and id != ?", params[:name], params[:id]).count
raise("名称不能重复") if repeat_name > 0
level = SubjectLevelSystem.find params[:id]
level.update_attribute(:name, params[:name])
redirect_to subject_level_system_managements_path(:format => "js")
end
# 删除课程等级
def delete_subject_level
level = SubjectLevelSystem.find params[:id]
Subject.where(:subject_level_system_id => level).update_all(:subject_level_system_id => nil)
levels = SubjectLevelSystem.where("level > ?", level.level)
levels.each do |l|
l.update_attribute(:level, l.level-1)
end
level.delete
redirect_to subject_level_system_managements_path(:format => "js")
end
# 工程认证视频导入模板 # 工程认证视频导入模板
def ec_template def ec_template
@template = EcTemplate.where(nil) @template = EcTemplate.where(nil)
@ -1927,6 +1971,7 @@ end
@audit_class_sx_num=Subject.where(:status => 1).count @audit_class_sx_num=Subject.where(:status => 1).count
@publish_class_sx_num=Subject.where(:status => 2).count @publish_class_sx_num=Subject.where(:status => 2).count
@repertories = Repertoire.where(nil).order("CONVERT( name USING gbk ) COLLATE gbk_chinese_ci ASC") @repertories = Repertoire.where(nil).order("CONVERT( name USING gbk ) COLLATE gbk_chinese_ci ASC")
@levels = SubjectLevelSystem.all
search = params[:search] # 搜索字 search = params[:search] # 搜索字
keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索 keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
status = params[:status].to_i status = params[:status].to_i

@ -18,6 +18,7 @@ class Subject < ActiveRecord::Base
has_many :tidings, :as => :container, :dependent => :destroy has_many :tidings, :as => :container, :dependent => :destroy
belongs_to :repertoire belongs_to :repertoire
belongs_to :user belongs_to :user
has_one :subject_level_system
scope :visible, lambda{where(status: 2)} scope :visible, lambda{where(status: 2)}

@ -0,0 +1,7 @@
class SubjectLevelSystem < ActiveRecord::Base
default_scope :order => 'level'
# attr_accessible :title, :body
has_many :subjects
end

@ -55,7 +55,7 @@
</li> </li>
<li class="fl edu-admin-nav-li edu-position <%= 'active' if @menu_type == 4 %>" style="width: 100px"><a href="javascript:void(0);" class="edu-admin-nav-a" >实训课程+</a> <li class="fl edu-admin-nav-li edu-position <%= 'active' if @menu_type == 4 %>" style="width: 100px"><a href="javascript:void(0);" class="edu-admin-nav-a" >实训课程+</a>
<ul class="edu-admin-nav-inner edu-absolute"> <ul class="edu-admin-nav-inner edu-absolute">
<li style="width: 120px"><%= link_to "实训课程等级体系", class_shixuns_managements_path %></li> <li style="width: 120px"><%= link_to "实训课程等级体系", subject_level_system_managements_path %></li>
<li style="width: 120px"><%= link_to "实训课程列表", class_shixuns_managements_path %></li> <li style="width: 120px"><%= link_to "实训课程列表", class_shixuns_managements_path %></li>
<li style="width: 120px"><%= link_to "实训课程配置", subject_setting_list_managements_path %></li> <li style="width: 120px"><%= link_to "实训课程配置", subject_setting_list_managements_path %></li>
<li style="width: 120px"><%= link_to "已发布实训课程", class_publish_shixuns_managements_path %></li> <li style="width: 120px"><%= link_to "已发布实训课程", class_publish_shixuns_managements_path %></li>

@ -1,88 +0,0 @@
<div class="mt20" id="levelSystem">
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<th width="10%">等级</th>
<th width="15%" class="edu-txt-left">名称</th>
<th width="45" class="edu-txt-left">实训课程数</th>
<th width="15%">创建时间</th>
<th width="15%">操作</th>
</thead>
<tbody>
<tr>
<td class="levelNo">1</td>
<td class="edu-txt-left levelName">初级课程</td>
<td class="edu-txt-left">500</td>
<td>2019-03-02 10:38</td>
<td>
<a href="javascript:void(0)" class="mr15">删除</a>
<a href="javascript:void(0)" class="mr15 renameLine">重命名</a>
</td>
</tr>
<tr>
<td class="levelNo">2</td>
<td class="edu-txt-left levelName">初级课程</td>
<td class="edu-txt-left">--</td>
<td>2019-03-02 10:38</td>
<td>
<a href="javascript:void(0)" class="mr15">删除</a>
<a href="javascript:void(0)" class="mr15 renameLine">重命名</a>
</td>
</tr>
<tr>
<td colspan="5">
<a href="javascript:void(0)" class="color-blue" onclick="createLevel();">+ 新建</a>
</td>
</tr>
</tbody>
</table>
</div>
<script type="text/html" id="template_newForm">
<div class="bor-grey-e mt20 clearfix padding10-20 edu-back-white" id="newForm">
<span class="fl mt3">名称</span>
<input type="text" class="winput-240-35 fl ml20"/>
<li class="fr mt3">
<a href="javascript:void(0)" class="mr15" onclick="cancelNew();">取消</a>
<a href="javascript:void(0)" class="mr15">保存</a>
</li>
</div>
</script>
<script>
//新建
function createLevel(){
if($("#newForm").length==0){
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var html = bt('template_newForm', null);
$("#levelSystem").append(html);
}
}
//新建--取消
function cancelNew(){
$("#newForm").remove();
}
//重命名
var lastHtml="";
$("table").on("click",".renameLine",function(){
var tr=$(this).parents("tr");
lastHtml=$(tr).html();
var value=$(tr).find(".levelName").html();
var No=$(tr).find(".levelNo").html();
var html='<td>'+No+'</td>'+
'<td colspan="4" class="edu-txt-left">'+
'<input type="winput-240-35" name="rename" value="'+value+'"/>'+
'<a href="javascript:void(0)" class="mr15 ml20" onclick="cancelEdit(this);">取消</a>'+
'<a href="javascript:void(0)">保存</a>'+
'</td>';
$(tr).html(html);
})
//重命名--取消
function cancelEdit(item){
$(item).parents("tr").html(lastHtml);
}
</script>

@ -0,0 +1,107 @@
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<th width="10%">等级</th>
<th width="15%" class="edu-txt-left">名称</th>
<th width="45" class="edu-txt-left">实训课程数</th>
<th width="15%">创建时间</th>
<th width="15%">操作</th>
</thead>
<tbody>
<% @levels.each do |l| %>
<tr>
<td class="levelNo"><%= l.level %></td>
<td class="edu-txt-left levelName" data-value="<%= l.id %>"><%= l.name %></td>
<td class="edu-txt-left"><%= l.subjects.size %></td>
<td><%= format_time l.created_at %></td>
<td>
<a href="javascript:void(0)" class="mr15" onclick="delete_confirm_box_4('/managements/delete_subject_level?id=<%= l.id %>', '是否确定删除!');">删除</a>
<a href="javascript:void(0)" class="mr15 renameLine">重命名</a>
</td>
</tr>
<% end %>
<tr>
<td colspan="5">
<a href="javascript:void(0)" class="color-blue" onclick="createLevel();">+ 新建</a>
</td>
</tr>
</tbody>
</table>
<script type="text/html" id="template_newForm">
<div class="bor-grey-e mt20 clearfix padding10-20 edu-back-white" id="newForm">
<span class="fl mt3">名称</span>
<input type="text" class="winput-240-35 fl ml20" id="level_name"/>
<li class="fr mt3">
<a href="javascript:void(0)" class="mr15" onclick="cancelNew();">取消</a>
<a href="javascript:void(0)" class="mr15" onclick="createSubjectLevel()">保存</a>
</li>
</div>
</script>
<script>
//新建
function createLevel(){
if($("#newForm").length==0){
var bt = baidu.template;
bt.LEFT_DELIMITER = '<!';
bt.RIGHT_DELIMITER = '!>';
var html = bt('template_newForm', null);
$("#levelSystem").append(html);
}
}
//新建--取消
function cancelNew(){
$("#newForm").remove();
}
//重命名
var lastHtml="";
$("table").on("click",".renameLine",function(){
var tr=$(this).parents("tr");
lastHtml=$(tr).html();
var value=$(tr).find(".levelName").html();
var id = $(tr).find(".levelName").attr("data-value");
var No=$(tr).find(".levelNo").html();
var html='<td>'+No+'</td>'+
'<td colspan="4" class="edu-txt-left">'+
'<input type="winput-240-35" id="rename" name="name" value="'+value+'"/>'+
'<input type="hidden" id="level_id" value="'+id+'"/>'+
'<a href="javascript:void(0)" class="mr15 ml20" onclick="cancelEdit(this);">取消</a>'+
'<a href="javascript:void(0)" onclick="update_level(this);">保存</a>'+
'</td>';
$(tr).html(html);
})
//重命名--取消
function cancelEdit(item){
$(item).parents("tr").html(lastHtml);
}
// 重命名
function update_level(item){
var name = $(item).siblings("#rename").val();
var id = $(item).siblings("#level_id").val();
$.ajax({
url: "<%= rename_subject_level_managements_path %>",
type: "POST",
data:{id: id, name: name}
})
}
function createSubjectLevel(){
var name = $("#level_name").val()
$.ajax({
url: "<%= create_subject_level_managements_path %>",
type: "POST",
data: {name: name}
})
}
function deleteLevel(id){
$.ajax({
url: "<%= delete_subject_level_managements_path %>",
type: "POST",
data: {id: id}
})
}
</script>

@ -28,8 +28,11 @@
</select> </select>
</td> </td>
<td> <td>
<select> <select onchange="select_subject_level(<%= c_shixun.id %>, this.options[this.options.selectedIndex].value)">
<option>请选择等级</option> <option <%= c_shixun.subject_level_system_id.present? ? "" : "selected='selected'".html_safe %> value="-1" >请选择课程体系</option>
<% @levels.each do |l| %>
<option value="<%= l.id %>" <%= l.id == c_shixun.subject_level_system_id ? "selected='selected'".html_safe : "" %> ><%= l.name %></option>
<% end %>
</select> </select>
</td> </td>
<td> <td>
@ -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("关联成功!");
}
});
}
</script> </script>

@ -0,0 +1,3 @@
<div class="mt20" id="levelSystem">
<%= render :partial => "managements/subject_level_list" %>
</div>

@ -0,0 +1 @@
$("#levelSystem").html("<%= j (render :partial => "subject_level_list") %>")

@ -673,6 +673,11 @@ RedmineApp::Application.routes.draw do
post 'add_course_info_for_school' post 'add_course_info_for_school'
get 'ec_template' get 'ec_template'
post 'add_template' post 'add_template'
get 'subject_level_system'
post 'create_subject_level'
post 'rename_subject_level'
post 'delete_subject_level'
post 'update_level_for_subject'
end end
end end
# Enable Grack support # Enable Grack support

@ -0,0 +1,9 @@
class CreateSubjectLevelSystems < ActiveRecord::Migration
def change
create_table :subject_level_systems do |t|
t.integer :level
t.string :name
t.timestamps
end
end
end

@ -0,0 +1,9 @@
class AddSubjectLevelSystemIdForSubjects < ActiveRecord::Migration
def up
add_column :subjects, :subject_level_system_id, :integer
add_index :subjects, :subject_level_system_id
end
def down
end
end

@ -2075,6 +2075,14 @@ function delete_confirm_box_3(url, str){
pop_box_new(htmlvalue, 300, 140); pop_box_new(htmlvalue, 300, 140);
} }
//点击删除时的确认弹框: 走post方法
function delete_confirm_box_4(url, str){
var htmlvalue = '<div class="task-popup" style="width:480px;"><div class="task-popup-title clearfix"><h3 class="fl color-grey3">提示</h3><a href="javascript:void(0);" class="pop_close"><i class="fa fa-times-circle font-18 link-color-grey fr mt5"></i></a></div>'+
'<div class="task-popup-content"><p class="task-popup-text-center font-16">' + str + '</p></div><div class="task-popup-submit clearfix"><a href="javascript:void(0);" onclick="hideModal();" class="task-btn fl">取消</a>'+
'<a href="'+ url +'" class="task-btn task-btn-orange fr pop_close" data-method="POST" data-remote="true">确定</a></div></div>';
pop_box_new(htmlvalue, 480, 160);
}
//提示框:只有一个按钮,点击关闭弹框 //提示框:只有一个按钮,点击关闭弹框
function notice_sure_box(str){ function notice_sure_box(str){
var htmlvalue = '<div id="muban_popup_box" style="width:350px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+ var htmlvalue = '<div id="muban_popup_box" style="width:350px;"><div class="muban_popup_top"><h3 class="fl">提示</h3><a href="javascript:void(0);" class="muban_icons_close fr"></a></div>'+

@ -56,7 +56,7 @@ If you continue to experience problems please contact your Trustie administrator
温馨提示:为了给大家提供更优质的服务 温馨提示:为了给大家提供更优质的服务
</p> </p>
<p class="font-18"> <p class="font-18">
平台拟于<span style="color: red">2019年3月7日00:00--8:00</span>进行全面升级,带来不便,敬请谅解! 平台拟于<span style="color: red">2019年3月8日00:00--8:00</span>进行全面升级,带来不便,敬请谅解!
</p> </p>
</div> </div>
</div> </div>

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :subject_level_system do
end
end

@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe SubjectLevelSystem, :type => :model do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save