From 43117e7ca10cc64cb5bb57b753378e1bc73bc267 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 4 Apr 2019 15:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AE=A1=E7=90=86=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 29 +++++++++++---- .../managements/_partner_addManage.html.erb | 36 +++++++++---------- .../managements/_partner_member_list.html.erb | 8 +++++ .../managements/add_partner_member.js.erb | 1 + .../managements/add_partner_member_box.js.erb | 2 +- app/views/managements/partners.html.erb | 18 ++++------ 6 files changed, 57 insertions(+), 37 deletions(-) create mode 100644 app/views/managements/_partner_member_list.html.erb create mode 100644 app/views/managements/add_partner_member.js.erb diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 75ee3edf..94d2b962 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1232,7 +1232,6 @@ end school.update_attributes(:partner_id => partner.id) end end - render :json => {status: 1, message: "创建成功!"} end end @@ -1279,13 +1278,18 @@ end @partner = Partner.where(:id => params[:partner]).first @members = if params[:search] - User.where("LOWER(concat(lastname, firstname, nickname, mail)) LIKE '%#{params[:search]}%'") + User.where("LOWER(concat(lastname, firstname, nickname, mail)) LIKE ?", "%#{params[:search]}%"). + where(:certification => 1, :partner_id => nil) else - User.where(:certification => 1) + User.where(:certification => 1, :partner_id => nil) end - @members = paginateHelper @members, 8 + @total_pages = (@members.count / 10.0).ceil + @members = paginateHelper @members, 10 respond_to do |format| format.js + format.json { + render json: member_json_data(@members) + } end end @@ -1298,8 +1302,6 @@ end user.update_attributes(partner_id: @partner.id) if !@partner.nil? && !user.nil? end end - - redirect_to partners_managements_path end # check 部门 identifier是否重复 @@ -4319,4 +4321,19 @@ end book.write xls_report xls_report.string end + + def member_json_data mmebers + mmebers.map do |member| + real_name = member.show_real_name + identity = member.identity + school_name = member.school_name + user_phone = member.phone || "" + member.attributes.dup.except("login", "hashed_password", "salt", "status", "mail", "experience", "grade", + "authentication", "professional_certification").merge({real_name: real_name, + identity: identity, + school_name: school_name, + user_phone: user_phone}) + end + end + end diff --git a/app/views/managements/_partner_addManage.html.erb b/app/views/managements/_partner_addManage.html.erb index 9c8769ae..54a141a4 100644 --- a/app/views/managements/_partner_addManage.html.erb +++ b/app/views/managements/_partner_addManage.html.erb @@ -14,7 +14,7 @@
<%= form_for @partner, :url => add_partner_member_managements_path,:html => {:id => 'add_partner_member_form', :remote => true, :method => :post} do |f| %> -