From f068ce5a8e6b81179875a9e1364d9455b3db6211 Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 3 Apr 2019 15:17:01 +0800 Subject: [PATCH 01/35] =?UTF-8?q?ADD=20=E5=90=88=E4=BD=9C=E4=BC=99?= =?UTF-8?q?=E4=BC=B4=E8=B7=AF=E7=94=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 5 +++++ app/helpers/application_helper.rb | 2 ++ app/views/layouts/base_management.html.erb | 1 + app/views/managements/partners.html.erb | 1 + config/routes.rb | 1 + 5 files changed, 10 insertions(+) create mode 100644 app/views/managements/partners.html.erb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 0d17ccf6..91687217 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1171,6 +1171,11 @@ end end end + def partners + @menu_type = 6 + @sub_type = 3 + end + # 删除部门管理员 def delete_depart_member DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b0417e5f..e5409bbe 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -708,6 +708,8 @@ module ApplicationHelper when 6 if sub_type == 1 link_to('单位列表', departments_part_managements_path()) + "#{grandchild_type[:next_type] == 1 ? " > #{grandchild_type[:school].name}" : ""}" + elsif sub_type == 3 + "合作伙伴" else "单位部门列表" end diff --git a/app/views/layouts/base_management.html.erb b/app/views/layouts/base_management.html.erb index c6e87870..45f570d2 100644 --- a/app/views/layouts/base_management.html.erb +++ b/app/views/layouts/base_management.html.erb @@ -71,6 +71,7 @@
  • 用户 diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb new file mode 100644 index 00000000..3220089f --- /dev/null +++ b/app/views/managements/partners.html.erb @@ -0,0 +1 @@ +nice \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 051ed500..d600fc11 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -544,6 +544,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 match 'classroom', :via => [:get, :post] post 'import_departments' match 'departments', :via => [:get, :post] + get 'partners' delete 'delete_depart_member' get 'add_depart_member_box' post 'add_depart_member' From 00dadf753101ea254565e09444cc27171f4b3c3a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 3 Apr 2019 16:18:00 +0800 Subject: [PATCH 02/35] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/cooperates_controller.rb | 16 ++++++++++- app/models/school.rb | 32 ++++++++++++++++++++++ app/views/cooperates/partner_list.html.erb | 0 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 app/views/cooperates/partner_list.html.erb diff --git a/app/controllers/cooperates_controller.rb b/app/controllers/cooperates_controller.rb index aecbb293..1f43fcaa 100644 --- a/app/controllers/cooperates_controller.rb +++ b/app/controllers/cooperates_controller.rb @@ -1,6 +1,20 @@ class CooperatesController < ApplicationController - def show + def partner_list + search = params[:search] + @schools = School.where(id: [179, 3181, 3216]).where("name like ?", "'%#{search}%'") + @all_count = @schools.size + unless search.blank? + @schools = @schools.where("name like ?", "'%#{search}%'") + end + @search_count = @schools.size + @schools = paginateHelper @schools, 15 + @schools = @schools.includes(:courses, users: :user_extensions) + + respond_to do |format| + format.js + format.html{render :layout => "base_edu"} + end end end diff --git a/app/models/school.rb b/app/models/school.rb index 2a33acac..2d69bf00 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -26,4 +26,36 @@ class School < ActiveRecord::Base def to_s self.name.to_s end + + def teacher_count + User.find_by_sql("SELECT COUNT(users.`id`) AS teacher_count FROM users LEFT JOIN user_extensions ON + users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{self.id} AND + user_extensions.`identity` = 0").first.try(:teacher_count) + end + + def student_count + User.find_by_sql("SELECT COUNT(users.`id`) AS student_count FROM users LEFT JOIN user_extensions ON + users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{self.id} AND + user_extensions.`identity` = 1").first.try(:student_count) + end + + def course_count + Course.find_by_sql("SELECT COUNT(courses.`id`) AS course_count FROM courses LEFT JOIN user_extensions ON + courses.tea_id=user_extensions.user_id WHERE user_extensions.`school_id` = #{self.id} AND + courses.id != 1309").first.try(:course_count) + end + + def shixun_count + Shixun.find_by_sql("select count(s.id) as shixun_count from users u right join shixuns s on u.id=s.user_id and + s.status in (2, 3) inner join user_extensions ue on u.id=ue.user_id and + ue.school_id=#{self.id}").first.try(:shixun_count) + end + + def shixun_report_count + StudentWork.find_by_sql("SELECT count(*) as sw_count FROM `student_works` where user_id in + (SELECT users.id FROM users RIGHT JOIN user_extensions ON users.id=user_extensions.user_id + WHERE user_extensions.`school_id`=#{self.id}) and work_status between 1 and 2 and + myshixun_id !=0").first.try(:sw_count) + end + end diff --git a/app/views/cooperates/partner_list.html.erb b/app/views/cooperates/partner_list.html.erb new file mode 100644 index 00000000..e69de29b From 47e3f87308d896bbe5ae136d864a185a11f63008 Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 3 Apr 2019 17:32:30 +0800 Subject: [PATCH 03/35] =?UTF-8?q?ADD=20=E6=B7=BB=E5=8A=A0=E5=85=B3?= =?UTF-8?q?=E8=81=94=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/customer.rb | 5 +++++ app/models/message.rb | 5 +++++ app/models/partner.rb | 5 +++++ app/models/school.rb | 3 +++ app/models/user.rb | 1 + db/migrate/20190403085155_create_partners.rb | 9 +++++++++ db/migrate/20190403085807_create_customers.rb | 10 ++++++++++ ...091639_add_partner_id_and_customer_id_to_schools.rb | 8 ++++++++ db/migrate/20190403092802_add_partner_id_to_users.rb | 6 ++++++ 9 files changed, 52 insertions(+) create mode 100644 app/models/customer.rb create mode 100644 app/models/partner.rb create mode 100644 db/migrate/20190403085155_create_partners.rb create mode 100644 db/migrate/20190403085807_create_customers.rb create mode 100644 db/migrate/20190403091639_add_partner_id_and_customer_id_to_schools.rb create mode 100644 db/migrate/20190403092802_add_partner_id_to_users.rb diff --git a/app/models/customer.rb b/app/models/customer.rb new file mode 100644 index 00000000..dab10ac9 --- /dev/null +++ b/app/models/customer.rb @@ -0,0 +1,5 @@ +class Customer < ActiveRecord::Base + belongs_to :partner + has_one :scholl + has_many :users +end diff --git a/app/models/message.rb b/app/models/message.rb index 6fb9bb59..63a7ce5f 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -53,6 +53,7 @@ class Message < ActiveRecord::Base has_many :tidings, :as => :container , :dependent => :destroy belongs_to :reply, :class_name => 'Message', :foreign_key => 'reply_id' + has_one :message_detail, :dependent => :destroy #转发表 has_many :forwards, :as => :from, :dependent => :destroy @@ -117,6 +118,10 @@ class Message < ActiveRecord::Base self.content end + def content + self.message_detail.try(:content) + end + def topic? parent_id.nil? end diff --git a/app/models/partner.rb b/app/models/partner.rb new file mode 100644 index 00000000..e838e464 --- /dev/null +++ b/app/models/partner.rb @@ -0,0 +1,5 @@ +class Partner < ActiveRecord::Base + attr_accessible :name + has_one :school + has_many :customers +end diff --git a/app/models/school.rb b/app/models/school.rb index 2a33acac..0cce7390 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -15,6 +15,9 @@ class School < ActiveRecord::Base has_many :ec_majors, :through => :ec_major_schools has_many :ec_major_schools, :dependent => :destroy + belongs_to :partner + belongs_to :customer + # banner图片信息 has_many :school_images, :dependent => :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 31c58f26..752ea113 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -160,6 +160,7 @@ class User < Principal ## added by xianbo for delete # has_many :biding_projects, :dependent => :destroy belongs_to :softapplication, :foreign_key => 'id', :dependent => :destroy + belongs_to :partner ##ended by xianbo #####fq diff --git a/db/migrate/20190403085155_create_partners.rb b/db/migrate/20190403085155_create_partners.rb new file mode 100644 index 00000000..17516692 --- /dev/null +++ b/db/migrate/20190403085155_create_partners.rb @@ -0,0 +1,9 @@ +class CreatePartners < ActiveRecord::Migration + def change + create_table :partners do |t| + t.string :name + + t.timestamps + end + end +end diff --git a/db/migrate/20190403085807_create_customers.rb b/db/migrate/20190403085807_create_customers.rb new file mode 100644 index 00000000..51460758 --- /dev/null +++ b/db/migrate/20190403085807_create_customers.rb @@ -0,0 +1,10 @@ +class CreateCustomers < ActiveRecord::Migration + def change + create_table :customers do |t| + t.references :partner + + t.timestamps + end + add_index :customers, :partner_id + end +end diff --git a/db/migrate/20190403091639_add_partner_id_and_customer_id_to_schools.rb b/db/migrate/20190403091639_add_partner_id_and_customer_id_to_schools.rb new file mode 100644 index 00000000..1633f149 --- /dev/null +++ b/db/migrate/20190403091639_add_partner_id_and_customer_id_to_schools.rb @@ -0,0 +1,8 @@ +class AddPartnerIdAndCustomerIdToSchools < ActiveRecord::Migration + def change + add_column :schools, :partner_id, :integer + add_index :schools, :partner_id + add_column :schools, :customer_id, :integer + add_index :schools, :customer_id + end +end diff --git a/db/migrate/20190403092802_add_partner_id_to_users.rb b/db/migrate/20190403092802_add_partner_id_to_users.rb new file mode 100644 index 00000000..22a5d101 --- /dev/null +++ b/db/migrate/20190403092802_add_partner_id_to_users.rb @@ -0,0 +1,6 @@ +class AddPartnerIdToUsers < ActiveRecord::Migration + def change + add_column :users, :partner_id, :integer + add_index :users, :partner_id + end +end From 946755f9e09278d1c2dc5b8c891931e9cdea57cb Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 3 Apr 2019 18:03:47 +0800 Subject: [PATCH 04/35] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/cooperates_controller.rb | 4 +- app/models/school.rb | 4 + .../_partner_item.html.erb} | 33 ++++--- app/views/cooperates/partner_list.html.erb | 42 +++++++++ app/views/cooperates/partner_list.js.erb | 2 + app/views/managements/users_list.html.erb | 86 ------------------- config/routes.rb | 10 +++ 7 files changed, 75 insertions(+), 106 deletions(-) rename app/views/{managements/_users_list.html.erb => cooperates/_partner_item.html.erb} (54%) create mode 100644 app/views/cooperates/partner_list.js.erb delete mode 100644 app/views/managements/users_list.html.erb diff --git a/app/controllers/cooperates_controller.rb b/app/controllers/cooperates_controller.rb index 1f43fcaa..09895193 100644 --- a/app/controllers/cooperates_controller.rb +++ b/app/controllers/cooperates_controller.rb @@ -2,11 +2,11 @@ class CooperatesController < ApplicationController def partner_list search = params[:search] - @schools = School.where(id: [179, 3181, 3216]).where("name like ?", "'%#{search}%'") + @schools = School.where(id: [117, 179, 3181, 3216]) @all_count = @schools.size unless search.blank? - @schools = @schools.where("name like ?", "'%#{search}%'") + @schools = @schools.where("name like ?", "%#{search}%") end @search_count = @schools.size @schools = paginateHelper @schools, 15 diff --git a/app/models/school.rb b/app/models/school.rb index 2d69bf00..98158c5d 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -58,4 +58,8 @@ class School < ActiveRecord::Base myshixun_id !=0").first.try(:sw_count) end + def statistic_url + dep = departments.where("identifier is not null").first + url = dep.present? ? "/colleges/#{dep.identifier}/statistics" : "" + end end diff --git a/app/views/managements/_users_list.html.erb b/app/views/cooperates/_partner_item.html.erb similarity index 54% rename from app/views/managements/_users_list.html.erb rename to app/views/cooperates/_partner_item.html.erb index 993c6db3..a094c452 100644 --- a/app/views/managements/_users_list.html.erb +++ b/app/views/cooperates/_partner_item.html.erb @@ -9,29 +9,26 @@ 使用详情

      + <% @schools.each_with_index do |school, index| %>
    • - 1 - 国防科技大学 - 22 - - 33 - - - 44 - - - 55 - - - 66 - + <%= index + 1 %> + <%= school.name %> + <%= school.teacher_count %> + <%= school.student_count %> + <%= school.course_count %> + <%= school.shixun_count %> + <%= school.shixun_report_count %> - 查看 + <% if school.statistic_url != "" %> + 查看 + <% else %> + -- + <% end %>
    • - - + <% end %>
    +
      diff --git a/app/views/cooperates/partner_list.html.erb b/app/views/cooperates/partner_list.html.erb index e69de29b..40b581b3 100644 --- a/app/views/cooperates/partner_list.html.erb +++ b/app/views/cooperates/partner_list.html.erb @@ -0,0 +1,42 @@ +
      +
      + +
      + + <%= @obj_count %> + 个检索结果(<%= @all_count %> 单位) + +
      + + +
      +
      + +
      + <%= render :partial => "partner_item" %> +
      +
      + +
      + + \ No newline at end of file diff --git a/app/views/cooperates/partner_list.js.erb b/app/views/cooperates/partner_list.js.erb new file mode 100644 index 00000000..7b44c9df --- /dev/null +++ b/app/views/cooperates/partner_list.js.erb @@ -0,0 +1,2 @@ +$("#partner_school_list").html("<%= j(render :partial => "partner_item") %>"); +$("#search_partner_count").html("<%= @obj_count %>"); \ No newline at end of file diff --git a/app/views/managements/users_list.html.erb b/app/views/managements/users_list.html.erb deleted file mode 100644 index f990cca8..00000000 --- a/app/views/managements/users_list.html.erb +++ /dev/null @@ -1,86 +0,0 @@ -
      -
      -
      - - - - - - - - - - - - - - - - - - - -
      - -
      - - - - -
      - -
      - - <%= @obj_count %> - 个检索结果(<%= @major_count %> 单位) - -
      - - -
      -
      - -
      - <%= render :partial => "department_list" %> -
      -
      - -
      - - \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index d600fc11..1df8d0d6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -40,6 +40,16 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'ecloud/ps_update', to: 'ecloud#ps_update' + resources :cooperates do + member do + + end + + collection do + get 'partner_list' + end + end + resources :ec_course_evaluations do member do match 'import_score', :via => [:post] From 0e8b1d5ee8c5b4a8bbc3ba5eacdc96252b6281c2 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 3 Apr 2019 18:21:25 +0800 Subject: [PATCH 05/35] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/cooperates_controller.rb | 18 +++++++++++++++++- app/views/layouts/_logined_header.html.erb | 3 +++ config/routes.rb | 3 +-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/app/controllers/cooperates_controller.rb b/app/controllers/cooperates_controller.rb index 09895193..8a014d62 100644 --- a/app/controllers/cooperates_controller.rb +++ b/app/controllers/cooperates_controller.rb @@ -1,8 +1,11 @@ class CooperatesController < ApplicationController + before_filter :require_login + before_filter :find_partner, only: [:partner_list] + before_filter :is_admin, only: [:partner_list] def partner_list search = params[:search] - @schools = School.where(id: [117, 179, 3181, 3216]) + @schools = School.where(customer_id: @partner.customer_ids) @all_count = @schools.size unless search.blank? @@ -17,4 +20,17 @@ class CooperatesController < ApplicationController format.html{render :layout => "base_edu"} end end + + def find_partner + @partner = Partner.find_by_id(params[:id]) + render_404 if @partner.nil? || @partner.status == -1 + rescue ActiveRecord::RecordNotFound + render_404 + end + + def is_admin + unless User.current.admin? || (User.current.partner.present? && User.current.partner == @partner) + render_403 + end + end end diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index 9c8f4a8d..9e07db32 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -52,6 +52,9 @@
    • <%= link_to '我的课堂', user_path(User.current) %>
    • <%= link_to '我的实训', user_path(User.current, :type => 'a_shixun') %>
    • <%= link_to '我的实训课程', user_path(User.current, :type => 'a_path') %>
    • + <% if User.current.partner.present? %> +
    • <%= link_to '客户管理', partner_list_cooperate_path(User.current.partner) %>
    • + <% end %>
    • <%= link_to '我的项目', user_path(User.current, :type => 'a_project') %>
    • 客户管理
    • diff --git a/config/routes.rb b/config/routes.rb index 1df8d0d6..57410238 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,11 +42,10 @@ RedmineApp::Application.routes.draw do ## oauth相关 resources :cooperates do member do - + get 'partner_list' end collection do - get 'partner_list' end end From 8ccfee1299eaf395d8865b4b1d1915d49817fa86 Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 3 Apr 2019 22:20:12 +0800 Subject: [PATCH 06/35] FIX --- app/controllers/managements_controller.rb | 1 + app/views/managements/_partners_list.html.erb | 0 app/views/managements/partners.html.erb | 74 ++++++++++++++++++- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 app/views/managements/_partners_list.html.erb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 91687217..9a42aae4 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1174,6 +1174,7 @@ end def partners @menu_type = 6 @sub_type = 3 + @partners = Partner.includes(:school) end # 删除部门管理员 diff --git a/app/views/managements/_partners_list.html.erb b/app/views/managements/_partners_list.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index 3220089f..d1b23af1 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -1 +1,73 @@ -nice \ No newline at end of file +
      +
      + + 搜索 + 清除 +
      +
      +
      + +添加 + +
      +
      +
      +
      +
      +

      添加时间2019-04-03 15:40

      +
      + 管理员 +
        +
      • +
      • +
      • +
      +
      +
      +
      +
    • + 序号 + 客户名称 + +添加 + 添加时间 +
    • +
    • + 1 + 国防科技大学 + + 删除 + + + 2019-04-03 16:04 + +
    • +
      +
      +
      +
      +
      +
      + \ No newline at end of file From 450876fd3966d019ceec022eacfa78b8d410e990 Mon Sep 17 00:00:00 2001 From: jasder Date: Wed, 3 Apr 2019 22:23:44 +0800 Subject: [PATCH 07/35] FIX --- app/views/managements/partners.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index d1b23af1..049f1fdd 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -9,7 +9,7 @@ +添加
    From 828ac000e09686ff800257de16ed2ed24f227c88 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 09:11:51 +0800 Subject: [PATCH 08/35] =?UTF-8?q?=E5=90=88=E4=BD=9C=E4=BC=99=E4=BC=B4?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 38 +++++++++ app/controllers/poll_controller.rb | 8 +- app/helpers/poll_helper.rb | 8 +- app/models/customer.rb | 2 +- app/views/courses/index.js.erb | 2 +- .../managements/_partner_addUnit.html.erb | 80 ++++++++++++------- .../managements/_profession_index.html.erb | 14 ++-- app/views/managements/partners.html.erb | 3 +- config/routes.rb | 2 + ...20180920093851_create_graduation_group.rb} | 0 lib/dalli-2.7.2/.rakeTasks | 4 +- lib/gitlab-cli/.rakeTasks | 4 +- lib/grack/.rakeTasks | 4 +- lib/grape-swagger-0.25.3/.rakeTasks | 4 +- lib/plugins/acts-as-taggable-on/.rakeTasks | 4 +- lib/rails_kindeditor/.rakeTasks | 4 +- lib/wechat/.rakeTasks | 4 +- 17 files changed, 122 insertions(+), 63 deletions(-) rename db/migrate/{20180920093851_create_graduation_groups.rb => 20180920093851_create_graduation_group.rb} (100%) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9a42aae4..95bf2f58 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,8 +1175,46 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school) + @schools = School.where("partner_id IS NULL").all + @page = (params['page'] || 1).to_i + @schools_count = @schools.count + @limit = 10 + @is_remote = true + @schools_pages = Paginator.new @schools_count, @limit, @page + @offset ||=@schools_pages.offset + @schools = paginateHelper @schools, @limit + end + + def all_partners + @schools = School.where("partner_id IS NULL").all + @page = (params['page'] || 1).to_i + @schools_count = @schools.count + @limit = 10 + @is_remote = true + @schools_pages = Paginator.new @schools_count, @limit, @page + @offset ||=@schools_pages.offset + @schools = paginateHelper @schools, @limit + render :json => @schools + end + + + def add_partner + school_ids = params[:ids] + if school_ids.count > 0 + print school_ids + school_ids.each do |s| + school = School.where("id = ?",s).first + @partner = Partner.new(name: school.name) + @partner.save + school.partner_id = @partner.id + school.save + end + render :json => {status: 1, message: "创建成功!"} + end end + + # 删除部门管理员 def delete_depart_member DepartmentMember.where(:department_id => params[:depart], :user_id => params[:user_id]).destroy_all diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index 78fb4a63..367b3e99 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -9,6 +9,7 @@ class PollController < ApplicationController before_filter :require_login, :only => [:student_poll_list, :show] include PollHelper include ApplicationHelper + def index if @course.is_public == 0 && !(User.current.member_of_course?(@course)||User.current.admin?) render_403 @@ -18,13 +19,13 @@ class PollController < ApplicationController if @is_teacher polls = @course.polls.order("IF(ISNULL(publish_time),0,1), publish_time DESC, created_at DESC") - elsif User.current.member_of_course?(@course) + elsif User.current.member_of_course?(@course) # 课堂成员显示为发布的和已发布的 member = @course.members.where(:user_id => User.current.id).first if member.try(:course_group_id).to_i == 0 polls = @course.polls.where("publish_time <= '#{Time.now}' and unified_setting = 1").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") - else + else # 已分班的成员 not_poll_ids = @course.poll_group_settings.where("course_group_id = #{member.try(:course_group_id)} and (publish_time > '#{Time.now}' or publish_time is null)") - not_poll_ids = not_poll_ids.blank? ? "(-1)" : "(" + not_poll_ids.map(&:poll_id).join(",") + ")" + not_poll_ids = not_poll_ids.blank? ? "(-1)" : "(" + not_poll_ids.map(&:poll_id).join(",") + ")" # 已分班,但是成员不再 polls = @course.polls.where("publish_time <= '#{Time.now}' and id not in #{not_poll_ids}").order("IF(ISNULL(publish_time),0,1),publish_time DESC, created_at DESC") end else @@ -414,7 +415,6 @@ class PollController < ApplicationController def update_poll_question @poll_question = PollQuestion.find params[:poll_question] @poll = @poll_question.poll - @poll_question.is_necessary = params[:is_necessary] == "1" ? 1 : 0 @poll_question.question_title = params[:question_title].nil? || params[:question_title].empty? ? l(:label_enter_single_title) : params[:question_title] @poll_question.max_choices = params[:max_choices].to_i || 0 @poll_question.min_choices = params[:min_choices].to_i || 0 diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 411fc3c3..1ac26aa6 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -20,11 +20,11 @@ module PollHelper def un_commit_num poll course = poll.course - member = course.members.where(:user_id => User.current.id).first - poll_users = poll.poll_users - student_count = course.student.count + member = course.members.where(:user_id => User.current.id).first ## 当前用户是否为课堂成员 + poll_users = poll.poll_users # 问卷的全部用户,包含已回答的/为回答,但是浏览的 + student_count = course.student.count # 课堂的学生数 if member.present? && member.teacher_course_groups.count > 0 - group_students = course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) + group_students = course.members.where(:course_group_id => member.teacher_course_groups.pluck(:course_group_id)).map(&:user_id) ## 统计当前用户所在班级的全部学生 student_count = group_students.size poll_users = poll_users.where(:user_id => group_students) end diff --git a/app/models/customer.rb b/app/models/customer.rb index dab10ac9..bbfe45c6 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,5 +1,5 @@ class Customer < ActiveRecord::Base belongs_to :partner - has_one :scholl + has_one :school has_many :users end diff --git a/app/views/courses/index.js.erb b/app/views/courses/index.js.erb index 7ed24fff..f211e3ae 100644 --- a/app/views/courses/index.js.erb +++ b/app/views/courses/index.js.erb @@ -1 +1 @@ -$("#intelligence_course_list").html("<%= j(render :partial => "courses/courseList") %>"); \ No newline at end of file +$("#intelligence_course_list").html("<%= j(render :partial => "courses/courseList") %>"); diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index 1001d32c..e18890dc 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -1,7 +1,7 @@
    添加合作伙伴
    -
    +
    地区: @@ -14,42 +14,26 @@
    搜索
    -
    +

    单位 地区

    -

    - - - - - - - 湖南 -

    -

    - - - - - - - 湖南 -

    -

    - - - - - - - 湖南 -

    +

    +
    +
    +
      + <%= pagination_links_full @schools_pages, @schools_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> +
    +
    +
    +
    +
    +
  • 取消 确定 @@ -60,12 +44,46 @@ $(function() { unitDownOption(); showprovince("province"); - }) + get_schools() + + }); + function get_schools() { + $.getJSON("/managements/all_partners",function(schools){ + let s_html = ""; + $.each(schools,function (index,array) { + s_html =s_html+ "

    " + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " "+array["school"]["province"]+"" + + "

    " + }) + $("#serch_user_list").html(s_html) + }) + } function submit_add_partner(){ - if($("input[name='user_id[]']:checked").length==0){ + if($("input[name='school[id]']:checked").length==0){ $("#checkNotice").html("请选择需要添加的内容").removeClass("none"); return; + }else{ + let checked_array = []; + $("input[name='school[id]']:checked").each(function () { + checked_array.push($(this).val()) + }); + let check_ids = {ids:checked_array}; + $.ajax({ + url: "/managements/add_partner", + type: 'POST', + data: check_ids, + success: function (e) { + if(e.status === 1){} + $("#popupAll").remove() + } + }) } } \ No newline at end of file diff --git a/app/views/managements/_profession_index.html.erb b/app/views/managements/_profession_index.html.erb index 668aa0f1..f8f906b3 100644 --- a/app/views/managements/_profession_index.html.erb +++ b/app/views/managements/_profession_index.html.erb @@ -37,13 +37,13 @@ <%= format_time career.created_at %> <%= format_time career.published_at %> - <% if !career.status %> - 发布 - <% end %> - 编辑 - <% if !career.status %> - 删除 - <% end %> + <%# if !career.status %> + + <%# end %> + + <%# if !career.status %> + + <%# end %> <% end %> \ No newline at end of file diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index 049f1fdd..1d39b899 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -9,7 +9,7 @@ +添加 @@ -66,6 +66,7 @@ }) $(".manageList").on("click",".addManage",function(){ + var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; pop_box_new(html,572,500); }) diff --git a/config/routes.rb b/config/routes.rb index 57410238..f254f9b5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -554,6 +554,8 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'import_departments' match 'departments', :via => [:get, :post] get 'partners' + get 'all_partners' + post 'add_partner' delete 'delete_depart_member' get 'add_depart_member_box' post 'add_depart_member' diff --git a/db/migrate/20180920093851_create_graduation_groups.rb b/db/migrate/20180920093851_create_graduation_group.rb similarity index 100% rename from db/migrate/20180920093851_create_graduation_groups.rb rename to db/migrate/20180920093851_create_graduation_group.rb diff --git a/lib/dalli-2.7.2/.rakeTasks b/lib/dalli-2.7.2/.rakeTasks index b6b932e2..c6865d9a 100644 --- a/lib/dalli-2.7.2/.rakeTasks +++ b/lib/dalli-2.7.2/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/gitlab-cli/.rakeTasks b/lib/gitlab-cli/.rakeTasks index afa9557a..f349995e 100644 --- a/lib/gitlab-cli/.rakeTasks +++ b/lib/gitlab-cli/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/grack/.rakeTasks b/lib/grack/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/grack/.rakeTasks +++ b/lib/grack/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/grape-swagger-0.25.3/.rakeTasks b/lib/grape-swagger-0.25.3/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/grape-swagger-0.25.3/.rakeTasks +++ b/lib/grape-swagger-0.25.3/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/plugins/acts-as-taggable-on/.rakeTasks b/lib/plugins/acts-as-taggable-on/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/plugins/acts-as-taggable-on/.rakeTasks +++ b/lib/plugins/acts-as-taggable-on/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/rails_kindeditor/.rakeTasks b/lib/rails_kindeditor/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/rails_kindeditor/.rakeTasks +++ b/lib/rails_kindeditor/.rakeTasks @@ -1,7 +1,7 @@ - + +--> diff --git a/lib/wechat/.rakeTasks b/lib/wechat/.rakeTasks index 6be95750..c6865d9a 100644 --- a/lib/wechat/.rakeTasks +++ b/lib/wechat/.rakeTasks @@ -1,7 +1,7 @@ - + +--> From 7af1176280371fb76a5ff91807d473f7ad2281f8 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 09:26:46 +0800 Subject: [PATCH 09/35] partners --- app/controllers/managements_controller.rb | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 95bf2f58..3259c66b 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,24 +1175,28 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school) - @schools = School.where("partner_id IS NULL").all - @page = (params['page'] || 1).to_i - @schools_count = @schools.count - @limit = 10 - @is_remote = true - @schools_pages = Paginator.new @schools_count, @limit, @page - @offset ||=@schools_pages.offset - @schools = paginateHelper @schools, @limit end def all_partners + @search = params[:search] + @province = params[:province] @schools = School.where("partner_id IS NULL").all + + + if params[:search] + @schools = @schools.where("name like ?", "%#{@search}%") + end + + if params[:province] + @schools = @schools.where("province like ?", "%#{@province}%") + end + @page = (params['page'] || 1).to_i @schools_count = @schools.count + @total_pages = (@schools_count / 10.0).ceil @limit = 10 @is_remote = true @schools_pages = Paginator.new @schools_count, @limit, @page - @offset ||=@schools_pages.offset @schools = paginateHelper @schools, @limit render :json => @schools end From 2c1bd03c4651f5aa9d441c54b1841fcf34ba2584 Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 4 Apr 2019 09:27:08 +0800 Subject: [PATCH 10/35] ADD --- app/controllers/managements_controller.rb | 12 +++++++ .../managements/_partner_addManage.html.erb | 34 +++++++++---------- .../managements/add_partner_member_box.js.erb | 7 ++++ config/routes.rb | 1 + 4 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 app/views/managements/add_partner_member_box.js.erb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 9a42aae4..6fcc149a 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1206,6 +1206,18 @@ end end end + # 添加合作伙伴管理员- 弹框 + def add_partner_member_box + @partner = Partner.first + @members = + if params[:search] + User.where("LOWER(concat(lastname, firstname, nickname, mail)) LIKE '%#{params[:search]}%'") + else + User.where(:certification => 1) + end + @members = paginateHelper @members, 8 + end + # check 部门 identifier是否重复 def check_depart_identifier logger.info("###############{params}") diff --git a/app/views/managements/_partner_addManage.html.erb b/app/views/managements/_partner_addManage.html.erb index 818a4777..4f7e145f 100644 --- a/app/views/managements/_partner_addManage.html.erb +++ b/app/views/managements/_partner_addManage.html.erb @@ -33,24 +33,22 @@ 手机号

    -

    - - - - - 学生 - 湖北工业大学 - 156****9087 -

    -

    - - - - - 学生 - 湖北工业大学 - -

    + + <%= form_for @partner, :url => add_depart_member_managements_path,:html => {:id => 'add_depart_member_form', :remote => true, :method => :post} do |f| %> + <% @members.each do |member| %> +

    + + + + + <%= member.identity %> + <%= member.school_name %> + <%= member.phone %> +

    + <% end %> + <% end %> + +

    diff --git a/app/views/managements/add_partner_member_box.js.erb b/app/views/managements/add_partner_member_box.js.erb new file mode 100644 index 00000000..72197cd0 --- /dev/null +++ b/app/views/managements/add_partner_member_box.js.erb @@ -0,0 +1,7 @@ + +<% if params[:search] || params[:page] %> +$("#depart_member_search_list").html("<%= j(render :partial => "depart_member_search_list") %>") +<% else %> + var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; + pop_box_new(html,572,500); +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 57410238..f98c6e4f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -554,6 +554,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'import_departments' match 'departments', :via => [:get, :post] get 'partners' + get 'add_partner_member_box' delete 'delete_depart_member' get 'add_depart_member_box' post 'add_depart_member' From b3621125d5ce7ea029db5166d7ab3d402f67e0f9 Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 09:32:14 +0800 Subject: [PATCH 11/35] partners --- app/controllers/managements_controller.rb | 7 ++++++- app/views/managements/_partner_addUnit.html.erb | 9 --------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 3259c66b..d5212ea1 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1198,7 +1198,12 @@ end @is_remote = true @schools_pages = Paginator.new @schools_count, @limit, @page @schools = paginateHelper @schools, @limit - render :json => @schools + respond_to do |format| + format.js + format.json { + render json: @schools + } + end end diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index e18890dc..11a9c669 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -23,15 +23,6 @@

    -
    -
    -
      - <%= pagination_links_full @schools_pages, @schools_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %> -
    -
    -
    -
    -
  • From 367b3a619723ba658e819182b80550b37b55bd20 Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 4 Apr 2019 09:54:48 +0800 Subject: [PATCH 12/35] FIX --- app/controllers/managements_controller.rb | 7 ++++++- app/views/managements/_partner_addManage.html.erb | 2 +- app/views/managements/partners.html.erb | 8 +++----- config/routes.rb | 1 + 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 84df89dd..dc1d39e3 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1174,7 +1174,7 @@ end def partners @menu_type = 6 @sub_type = 3 - @partners = Partner.includes(:school) + @partners = Partner.includes(:school).order("created_at desc") end def all_partners @@ -1219,6 +1219,7 @@ end school.save end render :json => {status: 1, message: "创建成功!"} + redirects_to partners_path end end @@ -1265,6 +1266,10 @@ end @members = paginateHelper @members, 8 end + def add_partner_member + + end + # check 部门 identifier是否重复 def check_depart_identifier logger.info("###############{params}") diff --git a/app/views/managements/_partner_addManage.html.erb b/app/views/managements/_partner_addManage.html.erb index 4f7e145f..4f2b9fad 100644 --- a/app/views/managements/_partner_addManage.html.erb +++ b/app/views/managements/_partner_addManage.html.erb @@ -34,7 +34,7 @@

    - <%= form_for @partner, :url => add_depart_member_managements_path,:html => {:id => 'add_depart_member_form', :remote => true, :method => :post} do |f| %> + <%= form_for "", :url => add_partner_member_managements_path,:html => {:id => 'add_partner_member_form', :remote => true, :method => :post} do |f| %> <% @members.each do |member| %>

    diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index 1d39b899..cf16ead1 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -21,7 +21,9 @@

    管理员
      -
    • +
    • +
    • + <%= link_to '+', add_partner_member_box_managements_path(:partner => 1), :remote => true, :class => "addManage" %> +
    @@ -65,10 +67,6 @@ pop_box_new(html,572,500); }) - $(".manageList").on("click",".addManage",function(){ - var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; - pop_box_new(html,572,500); - }) }) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index b539fdf5..efc9756e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -555,6 +555,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 match 'departments', :via => [:get, :post] get 'partners' get 'add_partner_member_box' + post 'add_partner_member' get 'all_partners' post 'add_partner' delete 'delete_depart_member' From 0aec53dda74a8e3e3ac8c0f2cd70e38a65bfecbe Mon Sep 17 00:00:00 2001 From: caishi <1149225589@qq.com> Date: Thu, 4 Apr 2019 10:08:45 +0800 Subject: [PATCH 13/35] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E6=90=9C=E7=B4=A2=E6=9D=A1=E4=BB=B6=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../managements/_partner_addManage.html.erb | 26 +++---------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/app/views/managements/_partner_addManage.html.erb b/app/views/managements/_partner_addManage.html.erb index 4f2b9fad..94e3ba0b 100644 --- a/app/views/managements/_partner_addManage.html.erb +++ b/app/views/managements/_partner_addManage.html.erb @@ -1,29 +1,9 @@
    添加管理员
    -
    -
  • - - -

    - 姓名: - 单位: -

    -
    - 职业: -
    - - -
    -

    请选择职业

    -

    教师

    -

    学生

    -

    专业人士

    -
    -
    - 搜索 -
    -
  • +
    + + 搜索

    From 45bdbab053cc9fe3c4e63a23340c9a3f264f56fe Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 11:08:40 +0800 Subject: [PATCH 14/35] partners --- app/controllers/managements_controller.rb | 14 +-- .../managements/_partner_addUnit.html.erb | 88 +++++++++++++------ .../managements/_partner_search_form.html.erb | 19 ++++ app/views/managements/all_partners.js.erb | 7 ++ app/views/managements/partners.html.erb | 8 +- 5 files changed, 95 insertions(+), 41 deletions(-) create mode 100644 app/views/managements/_partner_search_form.html.erb create mode 100644 app/views/managements/all_partners.js.erb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index d5212ea1..b9a44e7d 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,6 +1175,12 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school) + @limit = 10 + @page = params['page'] || 1 + @partners_count = @partners.count + + @total_pages = (@partners_count / 10.0).ceil + @partners = paginateHelper @partners, @limit end def all_partners @@ -1182,7 +1188,6 @@ end @province = params[:province] @schools = School.where("partner_id IS NULL").all - if params[:search] @schools = @schools.where("name like ?", "%#{@search}%") end @@ -1191,12 +1196,11 @@ end @schools = @schools.where("province like ?", "%#{@province}%") end - @page = (params['page'] || 1).to_i + @limit = 10 + @page = params[:page] || 1 @schools_count = @schools.count + @total_pages = (@schools_count / 10.0).ceil - @limit = 10 - @is_remote = true - @schools_pages = Paginator.new @schools_count, @limit, @page @schools = paginateHelper @schools, @limit respond_to do |format| format.js diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index 11a9c669..6ad69b66 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -2,15 +2,8 @@

    添加合作伙伴
    -
    -
    - 地区: - -
    -
    - 单位: - -
    +
    + <%= render partial: "managements/partner_search_form" %>
    搜索
    @@ -19,7 +12,7 @@ 单位 地区

    -
    +

    @@ -35,27 +28,60 @@ $(function() { unitDownOption(); showprovince("province"); + submit_add_partner(); - get_schools() + var i = 1; //设置当前页数 + var msg_list_loading = false; + $(function() { + var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动 + var winH = $(window).height(); //页面可视区域高度 + get_schools(1) + $("#search_user_list").scroll(function() { + if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载 + var pageH = $(document.body).height(); - }); - function get_schools() { - $.getJSON("/managements/all_partners",function(schools){ - let s_html = ""; - $.each(schools,function (index,array) { - s_html =s_html+ "

    " + - " " + - " " + - " " + - " " + - " \n" + - " \n" + - " "+array["school"]["province"]+"" + - "

    " - }) - $("#serch_user_list").html(s_html) - }) - } + var scrollT = $(window).scrollTop(); //滚动条top + var aa = (pageH - winH - scrollT) / winH; + console.log(aa) + if ( !msg_list_loading ){ + if (aa < 0.01 ) { + get_schools(i+1) + } + } + } + }); + }); + function get_schools(page) { + var msg_list = $('#search_user_list'); + var limit_page = 1 + if (page > 1){ + limit_page = page + }else{ + limit_page = 1 + } + if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) { + msg_list_loading = true; + $.getJSON("<%= all_path %>?page="+limit_page, function(schools) { + if (schools) { + msg_list_loading = false; + let s_html = ""; + $.each(schools,function (index,array) { + s_html =s_html+ "

    " + + " " + + " " + + " " + + " " + + " \n" + + " \n" + + " "+array["school"]["province"]+"" + + "

    " + }); + $("#search_user_list").html(s_html); + i ++; + } + }); + } + } function submit_add_partner(){ if($("input[name='school[id]']:checked").length==0){ $("#checkNotice").html("请选择需要添加的内容").removeClass("none"); @@ -77,4 +103,8 @@ }) } } + + }); + + \ No newline at end of file diff --git a/app/views/managements/_partner_search_form.html.erb b/app/views/managements/_partner_search_form.html.erb new file mode 100644 index 00000000..629faa11 --- /dev/null +++ b/app/views/managements/_partner_search_form.html.erb @@ -0,0 +1,19 @@ +<%= labelled_form_for @schools, :url =>{:controller=> 'managements', :action => 'add_partners', :type => @type}, :html => {:id => 'partners_search_form'}, :method => "get", :remote => true do |f| %> +
    + 地区: + +
    +
    + 单位: + +
    + +<% end %> + + \ No newline at end of file diff --git a/app/views/managements/all_partners.js.erb b/app/views/managements/all_partners.js.erb new file mode 100644 index 00000000..b38d6f2f --- /dev/null +++ b/app/views/managements/all_partners.js.erb @@ -0,0 +1,7 @@ +var html="<%= escape_javascript(render :partial => "managements/partner_addUnit",locals: {all_path: all_partners_managements_path}) %>"; +pop_box_new(html,572,500); + + + + + diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index 1d39b899..1fcb6104 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -6,7 +6,7 @@
    - +添加 + <%= link_to "+添加",all_partners_managements_path,remote:true,class:"color-blue addOperation" %>
      <% @partners.each_with_index do |partner,index| %>
    • <%= partner.name %>
    • @@ -60,13 +60,7 @@ $(this).parents("li").remove(); }) - $(".addOperation").on("click",function(){ - var html="<%= escape_javascript(render :partial => "managements/partner_addUnit") %>"; - pop_box_new(html,572,500); - }) - $(".manageList").on("click",".addManage",function(){ - var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; pop_box_new(html,572,500); }) From 744c021e1ce02d26cb07e4762f757603409212bc Mon Sep 17 00:00:00 2001 From: SylorHuang Date: Thu, 4 Apr 2019 11:15:02 +0800 Subject: [PATCH 15/35] partners --- app/controllers/managements_controller.rb | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 3040c347..433d2921 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1174,17 +1174,7 @@ end def partners @menu_type = 6 @sub_type = 3 -<<<<<<< HEAD - @partners = Partner.includes(:school) - @limit = 10 - @page = params['page'] || 1 - @partners_count = @partners.count - - @total_pages = (@partners_count / 10.0).ceil - @partners = paginateHelper @partners, @limit -======= @partners = Partner.includes(:school).order("created_at desc") ->>>>>>> 0aec53dda74a8e3e3ac8c0f2cd70e38a65bfecbe end def all_partners From 3d347f7f15e6ebf2881e0f3a5606b6c9ef5d9297 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 4 Apr 2019 11:17:48 +0800 Subject: [PATCH 16/35] rename --- ...uation_group.rb => 20180920093851_create_graduation_groups.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/migrate/{20180920093851_create_graduation_group.rb => 20180920093851_create_graduation_groups.rb} (100%) diff --git a/db/migrate/20180920093851_create_graduation_group.rb b/db/migrate/20180920093851_create_graduation_groups.rb similarity index 100% rename from db/migrate/20180920093851_create_graduation_group.rb rename to db/migrate/20180920093851_create_graduation_groups.rb From f5746f08398edd673576c99c4591ced37281f72a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 4 Apr 2019 11:19:05 +0800 Subject: [PATCH 17/35] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/managements/partners.html.erb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index a16d117e..28105434 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -62,18 +62,14 @@ $(this).parents("li").remove(); }) -<<<<<<< HEAD $(".manageList").on("click",".addManage",function(){ var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>"; pop_box_new(html,572,500); }) -======= $(".addOperation").on("click",function(){ var html="<%= escape_javascript(render :partial => "managements/partner_addUnit") %>"; pop_box_new(html,572,500); }) - ->>>>>>> 0aec53dda74a8e3e3ac8c0f2cd70e38a65bfecbe }) \ No newline at end of file From 9f417e17cdf93f8b76bbacf707a1ed1837ba7ac1 Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 4 Apr 2019 11:28:01 +0800 Subject: [PATCH 18/35] FIX UI --- app/controllers/managements_controller.rb | 36 ++++++++++++++++++- app/controllers/partners_controller.rb | 29 +++++++++++++++ app/models/partner.rb | 5 ++- .../managements/_partner_addManage.html.erb | 19 ++++++++-- app/views/managements/partners.html.erb | 33 ++++++++++++----- config/routes.rb | 1 + 6 files changed, 110 insertions(+), 13 deletions(-) create mode 100644 app/controllers/partners_controller.rb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index dc1d39e3..290c2bd7 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1175,6 +1175,24 @@ end @menu_type = 6 @sub_type = 3 @partners = Partner.includes(:school).order("created_at desc") + + @current_partner = nil + if params[:partner] + @current_partner = @partners.find params[:partner] + else + @current_partner = @partners[0] if @partners.size > 0 + end + + @partners.each do |part| + if part.id == @current_partner.id + part.active = "active" + end + end + end + + def get_partner + @partner = Partner.find partner + end def all_partners @@ -1219,7 +1237,7 @@ end school.save end render :json => {status: 1, message: "创建成功!"} - redirects_to partners_path + redirect_to partners_path end end @@ -1252,6 +1270,13 @@ end @department.department_members << DepartmentMember.new(:user_id => member) end end + redirect_to partners_managments_path + + # respond_to do |format| + # format.html {render :layout => "base_edu"} + # format.js + # end + end # 添加合作伙伴管理员- 弹框 @@ -1266,8 +1291,17 @@ end @members = paginateHelper @members, 8 end + # 合作伙伴添加管理员 def add_partner_member + if params[:partner] && params[:partner_member] + @partner = Partner.find_by_id params[:partner] + params[:partner_member].each do |member| + user = User.find_by_id member + user.update_attributes(partner_id: @partner.id) if !@partner.nil? && !user.nil? + end + end + redirects_to end # check 部门 identifier是否重复 diff --git a/app/controllers/partners_controller.rb b/app/controllers/partners_controller.rb new file mode 100644 index 00000000..214948cf --- /dev/null +++ b/app/controllers/partners_controller.rb @@ -0,0 +1,29 @@ +class PartnersController < ApplicationController + layout 'base_management' + + def index + @menu_type = 6 + @sub_type = 3 + + @partners = Partner.includes(:school) + end + + def new + + end + + def edit + + end + + def create + + end + + def destroy + + end + + private + +end diff --git a/app/models/partner.rb b/app/models/partner.rb index e838e464..217bc1a7 100644 --- a/app/models/partner.rb +++ b/app/models/partner.rb @@ -1,5 +1,8 @@ class Partner < ActiveRecord::Base - attr_accessible :name + # attr_accessible :name, :active + attr_accessor :active + has_one :school has_many :customers + has_many :users end diff --git a/app/views/managements/_partner_addManage.html.erb b/app/views/managements/_partner_addManage.html.erb index 94e3ba0b..e6de3cec 100644 --- a/app/views/managements/_partner_addManage.html.erb +++ b/app/views/managements/_partner_addManage.html.erb @@ -14,7 +14,8 @@

      - <%= form_for "", :url => add_partner_member_managements_path,:html => {:id => 'add_partner_member_form', :remote => true, :method => :post} do |f| %> + <%= form_for @partner, :url => add_partner_member_managements_path,:html => {:id => 'add_partner_member_form', :remote => true, :method => :post} do |f| %> + <% @members.each do |member| %>

      @@ -31,7 +32,7 @@

    -

    +

    请至少选择一个用户

  • 取消 确定 @@ -39,6 +40,17 @@
  • \ No newline at end of file diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index cf16ead1..40c3cbf4 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -9,7 +9,9 @@ +添加
      <% @partners.each_with_index do |partner,index| %> -
    • <%= partner.name %>
    • +
    • + <%= link_to "#{partner.name}", partners_managements_path(:partner => partner), :class => "#{partner.active}" %> +
    • <% end %>
    @@ -22,9 +24,19 @@ 管理员
    @@ -35,16 +47,19 @@ +添加 添加时间 -
  • - 1 - 国防科技大学 - + <% @current_partner.customers.each do |customer| %> +
  • + <%= customer.school.id %> + <%= customer.school.name %> + 删除 - + 2019-04-03 16:04 -
  • + + <% end %> + diff --git a/config/routes.rb b/config/routes.rb index efc9756e..2b826b52 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -556,6 +556,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 get 'partners' get 'add_partner_member_box' post 'add_partner_member' + get 'get_partner' get 'all_partners' post 'add_partner' delete 'delete_depart_member' From 3d408ac563a2c612b43627bbd92022d5f8b04bf0 Mon Sep 17 00:00:00 2001 From: jasder Date: Thu, 4 Apr 2019 11:48:08 +0800 Subject: [PATCH 19/35] FIX merger --- app/controllers/managements_controller.rb | 6 ++---- app/views/managements/partners.html.erb | 10 +--------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 341ac98c..b6d0602a 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1184,9 +1184,7 @@ end end @partners.each do |part| - if part.id == @current_partner.id - part.active = "active" - end + part.active = "active" if part.id == @current_partner.id end end @@ -1299,7 +1297,7 @@ end end end - redirects_to + redirect_to partners_managements_path end # check 部门 identifier是否重复 diff --git a/app/views/managements/partners.html.erb b/app/views/managements/partners.html.erb index c7ba2b8e..a7f55eed 100644 --- a/app/views/managements/partners.html.erb +++ b/app/views/managements/partners.html.erb @@ -24,7 +24,7 @@ 管理员 -
    -
  • - 序号 - 客户名称 - +添加 - 添加时间 -
  • - <% @current_partner.try(:customers).try(:each) do |customer| %> -
  • - <%= customer.school.id %> - <%= customer.school.name %> - - 删除 - - - <%= format_time customer.created_at %> - -
  • - <% end %> - +
    + <%= render :partial => "partner_customer_list" %>
    diff --git a/config/routes.rb b/config/routes.rb index ff0be82f..3acb9123 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -713,6 +713,7 @@ RedmineApp::Application.routes.draw do ## oauth相关 post 'delete_subject_level' post 'update_level_for_subject' post :add_customers + delete :delete_customers get :customers_list end end