添加合作者

dev_local
cxt 6 years ago
parent cf46589485
commit eece0a31ee

@ -1196,7 +1196,7 @@ end
def all_partners def all_partners
@search = params[:search] @search = params[:search]
@province = params[:province] @province = params[:province]
@schools = School.where("partner_id IS NULL").all @schools = School.where("partner_id IS NULL")
if params[:search] if params[:search]
@schools = @schools.where("name like ?", "%#{@search}%") @schools = @schools.where("name like ?", "%#{@search}%")
@ -1222,18 +1222,17 @@ end
def add_partner def add_partner
school_ids = params[:school] school_ids = params[:school_ids]
if school_ids.count > 0 if school_ids.length > 0
print school_ids
school_ids.each do |s| school_ids.each do |s|
school = School.where("id = ?",s).first school = School.where("id = ?",s).first
@partner = Partner.new(name: school.name) if school.present?
@partner.save partner = Partner.new(name: school.name)
school.partner_id = @partner.id partner.save
school.save school.update_attributes(:partner_id => partner.id)
end
end end
render :json => {status: 1, message: "创建成功!"} render :json => {status: 1, message: "创建成功!"}
redirect_to partners_path
end end
end end

@ -3,7 +3,8 @@
class School < ActiveRecord::Base class School < ActiveRecord::Base
attr_accessible :name, :province, :pinyin, :city, :address, :logo_link, attr_accessible :name, :province, :pinyin, :city, :address, :logo_link,
:auto_users_trial, :shool_code, :authorization_time, :auto_users_trial, :shool_code, :authorization_time,
:identifier, :is_online, :video_desc, :video_name,:course_link, :course_name :identifier, :is_online, :video_desc, :video_name,:course_link,
:course_name, :partner_id, :customer_id
has_many :courses has_many :courses
has_many :departments, :dependent => :destroy has_many :departments, :dependent => :destroy
has_many :shixun_schools, :dependent => :destroy has_many :shixun_schools, :dependent => :destroy

@ -13,6 +13,10 @@
<%= javascript_include_tag "edu/application",'edu/base_edu','edu/account', 'baiduTemplate', 'jquery.datetimepicker.js', "edu/management", 'educoder/edu_application' %> <%= javascript_include_tag "edu/application",'edu/base_edu','edu/account', 'baiduTemplate', 'jquery.datetimepicker.js', "edu/management", 'educoder/edu_application' %>
<%= call_hook :view_layouts_base_html_head %> <%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%> <%= yield :header_tags -%>
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>
</head> </head>
<body onload="prettyPrint();" style="height: 100%"> <body onload="prettyPrint();" style="height: 100%">
<div class="newContainer"> <!-- 页面全部内容 --> <div class="newContainer"> <!-- 页面全部内容 -->

@ -2,10 +2,10 @@
<div class="task-popup-title clearfix">添加合作伙伴</div> <div class="task-popup-title clearfix">添加合作伙伴</div>
<div class="task_popup_con"> <div class="task_popup_con">
<div class="clearfix mb5 df"> <div class="clearfix mb5 df">
<div class="flex1" id="partners_search_form"> <div class="flex1">
<%= render partial: "managements/partner_search_form" %> <%= render partial: "managements/partner_search_form" %>
</div> </div>
<a href="javascript:void(0);" onclick="submit_search_user()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a> <a href="javascript:void(0);" onclick="$('#partners_search_form').submit()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a>
</div> </div>
<div class="mb4 clearfix"> <div class="mb4 clearfix">
<p class="pl10 color-grey-6 clearfix"> <p class="pl10 color-grey-6 clearfix">
@ -13,7 +13,7 @@
<span class="fr with30">地区</span> <span class="fr with30">地区</span>
</p> </p>
<div class="edu-back-skyblue clearfix pl10 over280" id="search_user_list"> <div class="edu-back-skyblue clearfix pl10 over280" id="search_user_list">
<%= render :partial => "partners_list" %>
</div> </div>
<p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p> <p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p>
</div> </div>
@ -25,12 +25,9 @@
</div> </div>
</div> </div>
<script> <script>
var i = 1; //设置当前页数
var msg_list_loading = false;
$(function() { $(function() {
unitDownOption();
showprovince("province");
var i = 1; //设置当前页数
var msg_list_loading = false;
$(function() { $(function() {
var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动 var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动
var winH = $(window).height(); //页面可视区域高度 var winH = $(window).height(); //页面可视区域高度
@ -82,18 +79,19 @@
$("#checkNotice").html("请选择需要添加的内容").removeClass("none"); $("#checkNotice").html("请选择需要添加的内容").removeClass("none");
return; return;
}else{ }else{
let checked_array = []; var checked_array = [];
$("input[name='school[]']:checked").each(function () { $("input[name='school[]']:checked").each(function () {
checked_array.push($(this).val()) checked_array.push($(this).val())
}); });
let check_ids = {ids:checked_array};
$.ajax({ $.ajax({
url: "/managements/add_partner", url: "/managements/add_partner",
type: 'POST', type: 'POST',
data: check_ids, data: {school_ids: checked_array},
success: function (e) { success: function (e) {
if(e.status === 1){} if(e.status === 1){
$("#popupAll").remove() hideModal();
window.location.href = "<%= partners_managements_path %>";
}
} }
}) })
} }

@ -1,7 +1,7 @@
<%= labelled_form_for @schools, :url =>{:controller=> 'managements', :action => 'add_partners', :type => @type}, :html => {:id => 'partners_search_form'}, :method => "get", :remote => true do |f| %> <%= form_for "", :url => {:controller=> 'managements', :action => 'all_partners', :type => @type}, :html => {:id => 'partners_search_form'}, :method => "get", :remote => true do |f| %>
<div class="df"> <div class="df">
<span class="fl lineh-35">地区:</span> <span class="fl lineh-35">地区:</span>
<select placeholder="请选择地区" id="province" class="flex1"></select> <select placeholder="请选择地区" name="province" id="province" class="flex1"></select>
</div> </div>
<div class="df mt15"> <div class="df mt15">
<span class="fl lineh-35">单位:</span> <span class="fl lineh-35">单位:</span>

@ -1,11 +1,11 @@
<% @schools.each do |school| %> <% @schools.each do |school| %>
<p class='clearfix mt5'> <p class='clearfix mt5'>
<span class='fl with70'> <span class='fl with70'>
<span> <span>
<input type='checkbox' name='school[]' value='<%= school.id %>' id='school_<%= school.id %>' class='magic-checkbox'> <input type='checkbox' name='school[]' value='<%= school.id %>' id='school_<%= school.id %>' class='magic-checkbox'>
<label for='school_<%= school.id %>'></label> <label for='school_<%= school.id %>'><%= school.name %></label>
</span> </span>
</span> </span>
<span class='fl with30'><%= school.province %></span> <span class='fl with30'><%= school.province %></span>
</p> </p>
<% end %> <% end %>

@ -1,7 +1,6 @@
<% if params[:search] %>
$("#search_user_list").html("<%= j(render :partial => "partners_list") %>")
<% else %>
var html="<%= escape_javascript(render :partial => "managements/partner_addUnit",locals: {all_path: all_partners_managements_path}) %>"; var html="<%= escape_javascript(render :partial => "managements/partner_addUnit",locals: {all_path: all_partners_managements_path}) %>";
pop_box_new(html,572,500); pop_box_new(html,572,500);
<% end %>

Loading…
Cancel
Save