|
|
|
@ -909,16 +909,20 @@ class ShixunsController < ApplicationController
|
|
|
|
|
# 搜索成员
|
|
|
|
|
if request.get?
|
|
|
|
|
@collaborators = @shixun.shixun_members.where("user_id != #{@shixun.user_id}")
|
|
|
|
|
else
|
|
|
|
|
if params[:user_id]
|
|
|
|
|
man_member = ShixunMember.where(:shixun_id => @shixun.id, :user_id => @shixun.user_id).first
|
|
|
|
|
cha_member = ShixunMember.where(:user_id => params[:user_id], :shixun_id => @shixun.id).first
|
|
|
|
|
if man_member && cha_member
|
|
|
|
|
man_member.update_attribute(:role, 2)
|
|
|
|
|
cha_member.update_attribute(:role, 1)
|
|
|
|
|
@shixun.update_attribute(:user_id, cha_member.user_id)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
begin
|
|
|
|
|
raise("请先选择成员") if params[:user_id].blank?
|
|
|
|
|
man_member = ShixunMember.where(:shixun_id => @shixun.id, :user_id => @shixun.user_id).first
|
|
|
|
|
cha_member = ShixunMember.where(:user_id => params[:user_id], :shixun_id => @shixun.id).first
|
|
|
|
|
if man_member && cha_member
|
|
|
|
|
man_member.update_attribute(:role, 2)
|
|
|
|
|
cha_member.update_attribute(:role, 1)
|
|
|
|
|
@shixun.update_attribute(:user_id, cha_member.user_id)
|
|
|
|
|
end
|
|
|
|
|
rescue => e
|
|
|
|
|
logger.error("######change_manager_error: #{e.message}")
|
|
|
|
|
render_error(e.message)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|