diff --git a/app/assets/javascripts/admins/auth_schools/index.js b/app/assets/javascripts/admins/auth_schools/index.js new file mode 100644 index 000000000..924a1a73e --- /dev/null +++ b/app/assets/javascripts/admins/auth_schools/index.js @@ -0,0 +1,6 @@ + +function show_add_manager(id) { + $(".auth-schools-user-add").modal("show"); + + $(".auth-schools-user-add").find("#school_id_input").val(id) +} \ No newline at end of file diff --git a/app/assets/javascripts/admins/major_informations/index.js b/app/assets/javascripts/admins/major_informations/index.js new file mode 100644 index 000000000..f0ab9c5f5 --- /dev/null +++ b/app/assets/javascripts/admins/major_informations/index.js @@ -0,0 +1,13 @@ +$(document).on('turbolinks:load', function() { + if ($('body.admins-major-informations-index-page').length > 0) { + var box_contain = $(".major-informations-list-container"); + box_contain.on("click",".collapse-item",function () { + var a_fa = $(this).find("i"); + if(a_fa.hasClass("fa-caret-right")){ + a_fa.removeClass("fa-caret-right").addClass("fa-caret-down"); + }else{ + a_fa.removeClass("fa-caret-down").addClass("fa-caret-right"); + } + }); + } +}); \ No newline at end of file diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index efa12b32e..c70f7a572 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -51,3 +51,5 @@ input.form-control { position: absolute; } .position-r{position:relative;} +.color-grey-c{color:#ccc} +.inline-block{display:inline-block;} diff --git a/app/assets/stylesheets/admins/auth_schools.scss b/app/assets/stylesheets/admins/auth_schools.scss new file mode 100644 index 000000000..7106f6d42 --- /dev/null +++ b/app/assets/stylesheets/admins/auth_schools.scss @@ -0,0 +1,66 @@ +.admins-auth-schools-index-page{ + .list-item-title{ + padding-bottom:5px; + padding-left: 33px; + color: #555; + } + .list-item-title-1{ + width: 100px; + display: inline-block; + } + .list-item-title-2{ + width: 200px; + display: inline-block; + } + .collegeManage{ + float: left; + padding: 0px 8px; + border-radius: 6px; + background-color: #f5f5f5; + margin: 3px 0px 3px 10px; + height: 34px; + line-height: 34px; + a{ + color: #05101a; + } + a:hover{ + color: #007bff; + } + } + i:hover{ + color: #333; + } + .add-manager-i{ + float: left; + i{ + padding: 10px 5px; + } + } + .auth-schools-new-add, .auth-schools-user-add{ + .flex-column{ + input{ + height: 38px; + } + } + .search-school{ + margin-left: 15px; + } + + } + .school-search-list{ + background: #F4FAFF; + height: 280px; + overflow-y: scroll; + padding: 10px 0; + } + .school-list-item{ + padding: 2px 10px; + input{ + font-size: 20px; + margin-right: 5px; + } + + } + + +} \ No newline at end of file diff --git a/app/assets/stylesheets/admins/major_informations.scss b/app/assets/stylesheets/admins/major_informations.scss new file mode 100644 index 000000000..b5d4096e7 --- /dev/null +++ b/app/assets/stylesheets/admins/major_informations.scss @@ -0,0 +1,37 @@ +.admins-major-informations-index-page{ + .fr{ + float:right; + } + .panel-default{ + margin-bottom: 10px; + background-color: rgb(245, 245, 245); + .panel-heading{ + i{ + margin-right:15px; + font-size:16px; + color:rgb(204, 204, 204); + } + a{ + padding: 8px 10px; + display: inline-block; + width:100%; + color:rgb(102, 102, 102); + } + } + .panel-collapse{ + padding-top: 10px; + background: #fff; + table{ + text-align:center; + th,td{ + padding: 8px; + } + td{ + color:#888; + } + } + } + + } + +} \ No newline at end of file diff --git a/app/assets/stylesheets/common.scss b/app/assets/stylesheets/common.scss index 3310ec828..06b5c6643 100644 --- a/app/assets/stylesheets/common.scss +++ b/app/assets/stylesheets/common.scss @@ -33,4 +33,8 @@ input.form-control { .font-12 { font-size: 12px !important; } .font-14 { font-size: 14px !important; } .font-16 { font-size: 16px !important; } -.font-18 { font-size: 18px !important; } \ No newline at end of file +.font-18 { font-size: 18px !important; } +.padding10-5 { padding: 10px 5px;} +.width100 { width: 100%;} +.mb10 { margin-bottom: 10px ;} +.mt10 { margin-top: 10px ;} diff --git a/app/controllers/admins/auth_schools_controller.rb b/app/controllers/admins/auth_schools_controller.rb new file mode 100644 index 000000000..3534188da --- /dev/null +++ b/app/controllers/admins/auth_schools_controller.rb @@ -0,0 +1,57 @@ +class Admins::AuthSchoolsController < Admins::BaseController + + def index + schools = School.where(ec_auth: 1).includes(:users).order("updated_at desc") + @params_page = params[:page] || 1 + @schools = paginate schools + end + + def destroy + ActiveRecord::Base.transaction do + school = School.where(id: params[:id]).first + school.destroy + end + end + + # 工程认证单位列表搜索学校 + def search_school + @schools = School.where("ec_auth != 1 and name like '%#{params[:name]}%'").limit(10) + end + + # 添加认证学校 + def add_school + all_schools = School.all + all_schools.where(id: params[:school_id]).update_all(ec_auth: 1) + schools = all_schools.where(ec_auth: 1).order("updated_at desc") + @params_page = params[:page] || 1 + @schools = paginate schools + end + + # 搜索用户 + def search_manager + school = School.find_by(id: params[:school_id]) + user_ids = school&.ec_school_users&.pluck(:user_id) + @users = User.where.not(id: user_ids).where("concat(lastname, firstname) like ?", "%#{params[:name].strip.to_s}%").limit(10) + end + + # 添加认证学校管理员 + def add_manager + ActiveRecord::Base.transaction do + user_ids = params[:user_id] + @school_id = params[:school_id] + user_ids.each do |id| + EcSchoolUser.create(user_id: id, school_id: @school_id) + end + @school_users = User.where(id: user_ids) + end + end + + # 删除学校管理员 + def remove_manager + ActiveRecord::Base.transaction do + manager = EcSchoolUser.where(school_id: params[:school_id], user_id: params[:user_id]).first + manager&.destroy + end + end + +end \ No newline at end of file diff --git a/app/controllers/admins/major_informations_controller.rb b/app/controllers/admins/major_informations_controller.rb new file mode 100644 index 000000000..931476c8c --- /dev/null +++ b/app/controllers/admins/major_informations_controller.rb @@ -0,0 +1,8 @@ +class Admins::MajorInformationsController < Admins::BaseController + + def index + disciplines = EcDiscipline.includes(ec_discipline_firsts: {ec_majors: :schools}).order("ec_disciplines.code asc") + @disciplines = paginate disciplines + end + +end \ No newline at end of file diff --git a/app/helpers/admins/base_helper.rb b/app/helpers/admins/base_helper.rb index 0da80f5f6..d79456ac8 100644 --- a/app/helpers/admins/base_helper.rb +++ b/app/helpers/admins/base_helper.rb @@ -103,4 +103,8 @@ module Admins::BaseHelper def unsafe_params params.except(:controller, :action).to_unsafe_h end + + def list_index_no(page,index) + (page - 1) * 20 + index + 1 + end end \ No newline at end of file diff --git a/app/models/ec_discipline.rb b/app/models/ec_discipline.rb new file mode 100644 index 000000000..449098ce1 --- /dev/null +++ b/app/models/ec_discipline.rb @@ -0,0 +1,12 @@ +class EcDiscipline < ActiveRecord::Base + validates_presence_of :code, :name + + has_many :ec_discipline_firsts + + # 专业数目 + def major_count + count = 0 + self.ec_discipline_firsts.map{|f| count += f.ec_majors.count} + count + end +end diff --git a/app/models/ec_discipline_first.rb b/app/models/ec_discipline_first.rb new file mode 100644 index 000000000..7c111d2c9 --- /dev/null +++ b/app/models/ec_discipline_first.rb @@ -0,0 +1,6 @@ +class EcDisciplineFirst < ActiveRecord::Base + validates_presence_of :code, :name + + has_many :ec_majors + belongs_to :ec_discipline +end diff --git a/app/models/ec_major.rb b/app/models/ec_major.rb index 4842f7d70..ae854a4c8 100644 --- a/app/models/ec_major.rb +++ b/app/models/ec_major.rb @@ -1,7 +1,10 @@ class EcMajor < ApplicationRecord # 主页对应的学校,不同学校可以选用同样的专业,而每个专业又各具特色 - has_many :schools, through: :ec_major_schools has_many :ec_major_schools, dependent: :destroy + has_many :schools, through: :ec_major_schools + + # 一级专业 + belongs_to :ec_discipline_first scope :search_name_or_code, -> (keyword) { where('name LIKE :keyword OR code LIKE :keyword', keyword: "%#{keyword.strip}%") } end diff --git a/app/views/admins/auth_schools/add_manager.js.erb b/app/views/admins/auth_schools/add_manager.js.erb new file mode 100644 index 000000000..d0abab3ac --- /dev/null +++ b/app/views/admins/auth_schools/add_manager.js.erb @@ -0,0 +1,6 @@ +if($(".auth-schools-user-add").length > 0){ + $(".auth-schools-user-add").modal("hide") +} +<% if @school_users.size > 0 %> + $("#table-school-<%= @school_id %>").find(".school_user_list").html("<%= j render partial: "admins/auth_schools/shared/school_user_list", locals: {users: @school_users, school_id: @school_id} %> ") +<% end %> diff --git a/app/views/admins/auth_schools/add_school.js.erb b/app/views/admins/auth_schools/add_school.js.erb new file mode 100644 index 000000000..c4de6e795 --- /dev/null +++ b/app/views/admins/auth_schools/add_school.js.erb @@ -0,0 +1,2 @@ +$(".auth-schools-list-container").html("<%= j render partial: "admins/auth_schools/shared/list", locals: {schools: @schools} %>") +$(".auth-schools-new-add").modal("hide") diff --git a/app/views/admins/auth_schools/destroy.js.erb b/app/views/admins/auth_schools/destroy.js.erb new file mode 100644 index 000000000..9500aacf1 --- /dev/null +++ b/app/views/admins/auth_schools/destroy.js.erb @@ -0,0 +1 @@ +$("#table-school-<%= params[:id] %>").remove() diff --git a/app/views/admins/auth_schools/index.html.erb b/app/views/admins/auth_schools/index.html.erb new file mode 100644 index 000000000..5f0f5e46b --- /dev/null +++ b/app/views/admins/auth_schools/index.html.erb @@ -0,0 +1,14 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('认证单位列表') %> +<% end %> + +
+ <%= javascript_void_link '新增', class: 'btn btn-primary', data: { toggle: 'modal', target: '.auth-schools-new-add' } %> +
+ +
+ <%= render(partial: 'admins/auth_schools/shared/list', locals: { schools: @schools }) %> +
+ +<%= render partial: "admins/auth_schools/shared/new_modal" %> +<%= render partial: "admins/auth_schools/shared/user_add_modal" %> \ No newline at end of file diff --git a/app/views/admins/auth_schools/index.js.erb b/app/views/admins/auth_schools/index.js.erb new file mode 100644 index 000000000..d96cad477 --- /dev/null +++ b/app/views/admins/auth_schools/index.js.erb @@ -0,0 +1 @@ +$(".auth-schools-list-container").html("<%= j render partial: "admins/auth_schools/shared/list", locals: {schools: @schools} %>") \ No newline at end of file diff --git a/app/views/admins/auth_schools/remove_manager.js.erb b/app/views/admins/auth_schools/remove_manager.js.erb new file mode 100644 index 000000000..c2ebddb89 --- /dev/null +++ b/app/views/admins/auth_schools/remove_manager.js.erb @@ -0,0 +1,2 @@ + +$("#table-school-<%= params[:school_id] %>").find("#manager-<%= params[:user_id] %>").remove() \ No newline at end of file diff --git a/app/views/admins/auth_schools/search_manager.js.erb b/app/views/admins/auth_schools/search_manager.js.erb new file mode 100644 index 000000000..9a37394d5 --- /dev/null +++ b/app/views/admins/auth_schools/search_manager.js.erb @@ -0,0 +1,4 @@ + +if($("#add-users-list").length > 0){ + $("#add-users-list").html("<%= j render partial: "admins/auth_schools/shared/add_users_list", locals: {users: @users, school_id: params[:school_id]} %>") +} \ No newline at end of file diff --git a/app/views/admins/auth_schools/search_school.js.erb b/app/views/admins/auth_schools/search_school.js.erb new file mode 100644 index 000000000..bc42e27b5 --- /dev/null +++ b/app/views/admins/auth_schools/search_school.js.erb @@ -0,0 +1,3 @@ +if($("#add-schools-list").length > 0){ + $("#add-schools-list").html("<%= j render partial: "admins/auth_schools/shared/add_schools_list", locals: {schools: @schools} %>") +} \ No newline at end of file diff --git a/app/views/admins/auth_schools/shared/_add_schools_list.html.erb b/app/views/admins/auth_schools/shared/_add_schools_list.html.erb new file mode 100644 index 000000000..7db127efd --- /dev/null +++ b/app/views/admins/auth_schools/shared/_add_schools_list.html.erb @@ -0,0 +1,23 @@ + +<%= form_tag(add_school_admins_auth_schools_path, method: :post, remote: true) do %> +
+
单位名称
+
+ <% if schools.size > 0 %> + <% schools.each do |school| %> +
+ <%= check_box_tag("school_id[]", school.id, false, id: "check_school_#{school.id}") %> + +
+ <% end %> + <% else %> +

没有相关的单位

+ <% end %> +
+
+
+ <%= submit_tag("确认",class: "btn btn-primary submit-btn") %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admins/auth_schools/shared/_add_users_list.html.erb b/app/views/admins/auth_schools/shared/_add_users_list.html.erb new file mode 100644 index 000000000..25bb4e85d --- /dev/null +++ b/app/views/admins/auth_schools/shared/_add_users_list.html.erb @@ -0,0 +1,31 @@ +<%= form_tag(add_manager_admins_auth_schools_path, method: :post, remote: true) do %> + <%= hidden_field_tag("school_id",school_id) %> +
+
+ 姓名 + 单位 +
+
+ <% if users.size > 0 %> + <% users.each do |user| %> +
+ <%= check_box_tag("user_id[]", user.id, false, id: "check_user_#{user.id}") %> + +
+ <% end %> + <% else %> +

没有相关的单位

+ <% end %> +
+
+
+ <%= submit_tag("确认",class: "btn btn-primary submit-btn") %> +
+<% end %> \ No newline at end of file diff --git a/app/views/admins/auth_schools/shared/_list.html.erb b/app/views/admins/auth_schools/shared/_list.html.erb new file mode 100644 index 000000000..d56f6a732 --- /dev/null +++ b/app/views/admins/auth_schools/shared/_list.html.erb @@ -0,0 +1,38 @@ + + + + + + + + + + <% if schools.size > 0 %> + <% schools.each_with_index do |school, index| %> + + + + + + + <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> + +
序号学校名称学校管理员操作
<%= list_index_no(@params_page.to_i, index) %> + <%= link_to "#{school.name}", "/ecs/department?school_id=#{school.id}", target: "_blank" %> + +
+ <%= link_to "".html_safe, "javascript:void(0)", class: "action", onclick: "show_add_manager('#{school.id}')" %> +
+
+ <% if school.users.size > 0 %> + <%= render partial: "admins/auth_schools/shared/school_user_list", locals: {users: school.users, school_id: school.id} %> + <% end %> +
+
+ <%= link_to "".html_safe, admins_auth_school_path(school), method: :delete, data: {confirm: "确认删除吗?"}, remote: true %> +
+ +<%= render partial: 'admins/shared/paginate', locals: { objects: schools } %> \ No newline at end of file diff --git a/app/views/admins/auth_schools/shared/_new_modal.html.erb b/app/views/admins/auth_schools/shared/_new_modal.html.erb new file mode 100644 index 000000000..3bec99303 --- /dev/null +++ b/app/views/admins/auth_schools/shared/_new_modal.html.erb @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/app/views/admins/auth_schools/shared/_school_user_list.html.erb b/app/views/admins/auth_schools/shared/_school_user_list.html.erb new file mode 100644 index 000000000..13e6ff905 --- /dev/null +++ b/app/views/admins/auth_schools/shared/_school_user_list.html.erb @@ -0,0 +1,6 @@ +<% users.each do |user| %> + + <%= link_to user.show_real_name, "/users/#{user.login}", target: "_blank" %> + <%= link_to "×", remove_manager_admins_auth_schools_path(user_id: user.id, school_id: school_id),method: :post, class: "font-16 ml3", remote: true %> + +<% end %> \ No newline at end of file diff --git a/app/views/admins/auth_schools/shared/_user_add_modal.html.erb b/app/views/admins/auth_schools/shared/_user_add_modal.html.erb new file mode 100644 index 000000000..39dd7d1b7 --- /dev/null +++ b/app/views/admins/auth_schools/shared/_user_add_modal.html.erb @@ -0,0 +1,36 @@ + \ No newline at end of file diff --git a/app/views/admins/major_informations/index.html.erb b/app/views/admins/major_informations/index.html.erb new file mode 100644 index 000000000..41570ec06 --- /dev/null +++ b/app/views/admins/major_informations/index.html.erb @@ -0,0 +1,7 @@ +<% define_admin_breadcrumbs do %> + <% add_admin_breadcrumb('本科专业目录') %> +<% end %> + +
+ <%= render(partial: 'admins/major_informations/shared/list', locals: { majors: @disciplines }) %> +
diff --git a/app/views/admins/major_informations/shared/_list.html.erb b/app/views/admins/major_informations/shared/_list.html.erb new file mode 100644 index 000000000..0821f7478 --- /dev/null +++ b/app/views/admins/major_informations/shared/_list.html.erb @@ -0,0 +1,48 @@ +
+ <% if @disciplines.size > 0 %> + <% @disciplines.each_with_index do |d,index| %> +
+ +
+
+ + + + + + + + + + <% d.ec_discipline_firsts.each do |f| %> + <% f.ec_majors.each_with_index do |m, index| %> + + + + + + + + <% end %> + <% end %> + + +
一级学科代码一级学科名称专业代码专业名称认证学校数量
<%= index == 0 ? f.code : "" %><%= index == 0 ? f.name : "" %><%= m.code %><%= m.name %><%= m.schools.size.to_i %>
+
+
+
+ <% end %> + <% else %> + <%= render 'admins/shared/no_data_for_table' %> + <% end %> +
+<%= render partial: 'admins/shared/paginate', locals: { objects: @disciplines } %> \ No newline at end of file diff --git a/app/views/admins/shared/_sidebar.html.erb b/app/views/admins/shared/_sidebar.html.erb index 3d932cb74..7164a673f 100644 --- a/app/views/admins/shared/_sidebar.html.erb +++ b/app/views/admins/shared/_sidebar.html.erb @@ -66,6 +66,12 @@ <% end %> +
  • + <%= sidebar_item_group('#major-identification-submenu', '工程认证', icon: 'anchor') do %> +
  • <%= sidebar_item(admins_major_informations_path, '本科专业目录', icon: 'outdent', controller: 'admins-major_informations') %>
  • +
  • <%= sidebar_item(admins_auth_schools_path, '认证单位列表', icon: 'th', controller: 'admins-auth_schools') %>
  • + <% end %> +
  • <%= sidebar_item_group('#helps-submenu', '帮助中心', icon: 'info-circle') do %> diff --git a/app/views/admins/shixuns/shared/_list.html.erb b/app/views/admins/shixuns/shared/_list.html.erb index b5c7cec3b..7e96eb0fa 100644 --- a/app/views/admins/shixuns/shared/_list.html.erb +++ b/app/views/admins/shixuns/shared/_list.html.erb @@ -17,7 +17,7 @@ <% if shixuns.present? %> <% shixuns.each_with_index do |shixun,index| %> - <%= (@params_page.to_i - 1) * 20 + index + 1%> + <%= list_index_no(@params_page.to_i, index) %> <%= shixun.identifier %> <%= link_to overflow_hidden_span(shixun.name), "/shixuns/#{shixun.identifier}", :target => "_blank", :title => shixun.name %> diff --git a/config/routes.rb b/config/routes.rb index 0d6e108ad..34e60f089 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -802,6 +802,17 @@ Rails.application.routes.draw do namespace :admins do get '/', to: 'dashboards#index' + resources :major_informations, only: [:index] + resources :auth_schools, only: [:index, :destroy] do + collection do + get :search_school + post :add_school + get :search_manager + post :add_manager + post :remove_manager + end + + end resources :dashboards, only: [:index] do collection do get :month_active_user