Merge branch 'dev_partners' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_partners

Conflicts:
	app/views/managements/partners.html.erb
dev_local
caishi 6 years ago
commit afc456c9a3

@ -254,7 +254,10 @@ class CollegesController < ApplicationController
def manager_auth def manager_auth
# unless (User.current.admin? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present?) # unless (User.current.admin? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present?)
unless (User.current.admin? || DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present? || (User.current.user_extensions.try(:school_id) == @department.school_id && User.current.user_extensions.try(:identity) == 0)) unless (User.current.admin? ||
DepartmentMember.where(:user_id => User.current.id, :department_id => @department.id).first.present? ||
(User.current.user_extensions.try(:school_id) == @department.school_id && User.current.user_extensions.try(:identity) == 0) ||
@department.school.try(:partner_id) == User.current.partner_id)
render_403 render_403
end end
end end

@ -23,7 +23,7 @@ class CooperatesController < ApplicationController
def find_partner def find_partner
@partner = Partner.find_by_id(params[:id]) @partner = Partner.find_by_id(params[:id])
render_404 if @partner.nil? || @partner.status == -1 render_404 if @partner.nil?
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
render_404 render_404
end end

@ -792,12 +792,22 @@ class ManagementsController < ApplicationController
@menu_type = 8 @menu_type = 8
@sub_type = 2 @sub_type = 2
@search = params[:search] @search = params[:search]
@beginTime = params[:beginTime]
@endTime = params[:endTime]
if @search.present? if @search.present?
shixun_ids = Shixun.where("name like ?", "%#{params[:search]}%").pluck(:id) shixun_ids = Shixun.where("name like ?", "%#{params[:search]}%").pluck(:id)
@discusses = Discuss.where(:dis_type => "Shixun", :dis_id => shixun_ids).reorder("created_at desc") @discusses = Discuss.where(:dis_type => "Shixun", :dis_id => shixun_ids).reorder("created_at desc")
else else
@discusses = Discuss.where(:dis_type => "Shixun").reorder("created_at desc") @discusses = Discuss.where(:dis_type => "Shixun").reorder("created_at desc")
end end
if params[:beginTime] && params[:beginTime].strip != ""
@discusses = @discusses.where("created_at >= '#{Time.parse(params[:beginTime])}'")
end
if params[:endTime] && params[:endTime].strip != ""
@discusses = @discusses.where("created_at <= '#{Time.parse(params[:endTime])}'")
end
@all_discusses = @discusses @all_discusses = @discusses
@discusses_count = @discusses.count @discusses_count = @discusses.count
@limit = 20 @limit = 20
@ -1175,6 +1185,7 @@ end
@menu_type = 6 @menu_type = 6
@sub_type = 3 @sub_type = 3
@partners = Partner.includes(:school).order("created_at desc") @partners = Partner.includes(:school).order("created_at desc")
@partners = @partners.where("concat(schools.name) like ? ", "%#{params[:search]}%") unless params[:search].blank?
@current_partner = nil @current_partner = nil
if params[:partner] if params[:partner]
@ -1241,6 +1252,15 @@ end
end end
end end
def delete_customers
if params[:customer]
customer = Customer.where(id: params[:customer]).first
@current_partner = customer.partner
customer.school.update_attributes(:customer_id => nil)
customer.destroy
end
end
def all_partners def all_partners
@search = params[:search] @search = params[:search]
@province = params[:province] @province = params[:province]
@ -1274,13 +1294,14 @@ end
if school_ids.length > 0 if school_ids.length > 0
school_ids.each do |s| school_ids.each do |s|
school = School.where("id = ?",s).first school = School.where("id = ?",s).first
if school.present? if school.present? && school.partner_id.nil?
partner = Partner.new(name: school.name) partner = Partner.new(name: school.name)
partner.save partner.save
school.update_attributes(:partner_id => partner.id) school.update_attributes(:partner_id => partner.id)
end end
end end
end end
render :json => {status: 1, message: "创建成功!"}
end end
@ -4241,7 +4262,8 @@ end
sheet1[count_row, 5] = discusses.count sheet1[count_row, 5] = discusses.count
discusses.each_with_index do |discuss, j| discusses.each_with_index do |discuss, j|
user = discuss.user user = discuss.user
sheet1[count_row, 6] = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】") content = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】")
sheet1[count_row, 6] = strip_html content
sheet1[count_row, 7] = "#{discuss.position}" sheet1[count_row, 7] = "#{discuss.position}"
sheet1[count_row, 8] = user.show_real_name sheet1[count_row, 8] = user.show_real_name
sheet1[count_row, 9] = user.identity sheet1[count_row, 9] = user.identity

@ -57,8 +57,6 @@
<% end %> <% end %>
<li><%= link_to '我的项目', user_path(User.current, :type => 'a_project') %></li> <li><%= link_to '我的项目', user_path(User.current, :type => 'a_project') %></li>
<li><a>客户管理</a></li>
<% if User.current.department_members.count > 0 %> <% if User.current.department_members.count > 0 %>
<li><%= link_to '学院统计', statistics_college_path(User.current.department_members.first.try(:department)) %></li> <li><%= link_to '学院统计', statistics_college_path(User.current.department_members.first.try(:department)) %></li>
<% end %> <% end %>

@ -61,7 +61,7 @@
s_html = s_html+ "<p class='clearfix mt5'>" + s_html = s_html+ "<p class='clearfix mt5'>" +
" <span class='fl with70'>" + " <span class='fl with70'>" +
" <span>" + " <span>" +
" <input type='checkbox' name='school[id]' value='"+array["school"]["id"]+"' id='school_'"+array["school"]["id"]+"'class='magic-checkbox'>" + " <input type='checkbox' name='school[id]' value='"+array["school"]["id"]+"' id='school_"+array["school"]["id"]+"' class='magic-checkbox'>" +
" <label for='school_'"+array["school"]["id"]+">"+array["school"]["name"]+"</label>" + " <label for='school_'"+array["school"]["id"]+">"+array["school"]["name"]+"</label>" +
" </span>\n" + " </span>\n" +
" </span>\n" + " </span>\n" +

@ -60,7 +60,7 @@
$.each(members,function (index,array) { $.each(members,function (index,array) {
s_html = s_html+ "<p class='clearfix'>" + s_html = s_html+ "<p class='clearfix'>" +
" <span class='fl edu-txt-w90'>" + " <span class='fl edu-txt-w90'>" +
" <input type='checkbox' name='partner_member[]' value='"+array["id"]+"' id='user_'"+array["id"]+"'class='magic-checkbox'>" + " <input type='checkbox' name='partner_member[]' value='"+array["id"]+"' id='user_"+array["id"]+"' class='magic-checkbox'>" +
" <label for='user_'"+array["id"]+">"+array["real_name"]+"</label>" + " <label for='user_'"+array["id"]+">"+array["real_name"]+"</label>" +
" </span>\n" + " </span>\n" +
"<span class='fl edu-txt-w90 mt5 edu-txt-center color-grey-6 pointer'>"+array["identity"]+"</span>" + "<span class='fl edu-txt-w90 mt5 edu-txt-center color-grey-6 pointer'>"+array["identity"]+"</span>" +

@ -59,7 +59,7 @@
s_html = s_html+ "<p class='clearfix mt5'>" + s_html = s_html+ "<p class='clearfix mt5'>" +
" <span class='fl with70'>" + " <span class='fl with70'>" +
" <span>" + " <span>" +
" <input type='checkbox' name='school[id]' value='"+array["school"]["id"]+"' id='school_'"+array["school"]["id"]+"'class='magic-checkbox'>" + " <input type='checkbox' name='school[id]' value='"+array["school"]["id"]+"' id='school_"+array["school"]["id"]+"' class='magic-checkbox'>" +
" <label for='school_'"+array["school"]["id"]+">"+array["school"]["name"]+"</label>" + " <label for='school_'"+array["school"]["id"]+">"+array["school"]["name"]+"</label>" +
" </span>\n" + " </span>\n" +
" </span>\n" + " </span>\n" +

@ -0,0 +1,20 @@
<li class="clearfix tableHead">
<span>序号</span>
<span>客户名称</span>
<span><a href="<%= customers_list_managements_path(:partner_id => @current_partner.try(:id)) %>"
data-remote="true" class="color-blue">+添加</a></span>
<span>添加时间</span>
</li>
<% @current_partner.try(:customers).try(:each) do |customer| %>
<li>
<span><%= customer.school.id %></span>
<span class="task-hide"><%= customer.school.name %></span>
<span>
<a href="javascript:void(0)" onclick="delete_confirm_box_2('<%= delete_customers_managements_path(customer: customer.id) %>',
'确定要删除该客户吗')" class="color-grey-9">删除</a>
</span>
<span>
<%= format_time customer.created_at %>
</span>
</li>
<% end %>

@ -1,9 +1,10 @@
<% partner.users.each do |user| %> <% partner.users.each do |user| %>
<li> <li>
<%= image_tag(url_to_avatar(user)) %> <%= image_tag(url_to_avatar(user)) %>
<a href="javascript:void(0)" class="removeImg"> <a href="javascript:void(0)" onclick="delete_confirm_box_2('<%= delete_partner_member_managements_path(partner: partner.id,
partner_member: user.id) %>', '确定要删除该管理员吗')" class="removeImg">
<i class="iconfont icon-htmal5icon19 color-grey-9"></i> <i class="iconfont icon-htmal5icon19 color-grey-9"></i>
</a> </a>
<span class="task-hide managementName">胡莎莎</span> <span class="task-hide managementName"><%= user.show_real_name %></span>
</li> </li>
<% end %> <% end %>

@ -0,0 +1 @@
$("#partner_customer_list").html("<%= j(render :partial => "partner_customer_list") %>")

@ -1,8 +1,8 @@
<div class="mt20"> <div class="mt20">
<div class="clearfix edu-back-white padding20-30"> <div class="clearfix edu-back-white padding20-30">
<input class="fl task-form-20 task-height-30" name="partnerSearch" placeholder="输入合作伙伴名称进行搜索"> <input class="fl task-form-20 task-height-30" placeholder="输入合作伙伴名称进行搜索" id="partner_search">
<a href="javascript:void(0)" class="fl task-btn task-btn-orange ml10">搜索</a> <a href="javascript:void(0)" class="fl task-btn task-btn-orange ml10" onclick="submit_search_partner()">搜索</a>
<a href="javascript:void(0)" class="fl task-btn ml10" onclick="$('input[name=\'partnerSearch\']').val('')">清除</a> <a href="javascript:void(0)" class="fl task-btn ml10" onclick="$('#partner_search').val('')">清除</a>
</div> </div>
<div class="clearfix mt20"> <div class="clearfix mt20">
<div class="with25 fl edu-back-white"> <div class="with25 fl edu-back-white">
@ -33,27 +33,8 @@
</ul> </ul>
</div> </div>
</div> </div>
<div class="tableList"> <div class="tableList" id="partner_customer_list">
<li class="clearfix tableHead"> <%= render :partial => "partner_customer_list" %>
<span>序号</span>
<span>客户名称</span>
<span><a href="<%= customers_list_managements_path(:partner_id => @current_partner.try(:id)) %>"
data-remote="true" class="color-blue">+添加</a></span>
<span>添加时间</span>
</li>
<% @current_partner.try(:customers).try(:each) do |customer| %>
<li>
<span><%= customer.school.id %></span>
<span class="task-hide"><%= customer.school.name %></span>
<span>
<a href="javascript:void(0)" class="color-grey-9">删除</a>
</span>
<span>
2019-04-03 16:04
</span>
</li>
<% end %>
</div> </div>
</div> </div>
</div> </div>
@ -69,4 +50,8 @@
$(this).addClass("active"); $(this).addClass("active");
}) })
}) })
function submit_search_partner(){
$.get("/managements/partners?search="+$("#partner_search").val());
}
</script> </script>

@ -2,11 +2,17 @@
<%= form_tag(url_for(shixun_feedback_message_managements_path), :id => "managements_shixuns_search", :method => "post", :remote => true ) do %> <%= form_tag(url_for(shixun_feedback_message_managements_path), :id => "managements_shixuns_search", :method => "post", :remote => true ) do %>
<div class="edu-con-top clearfix mb20"> <div class="edu-con-top clearfix mb20">
<input class="fl task-form-20 task-height-30 ml25" id="shixun_Look_name" name="search" maxlength="" placeholder="输入实训名称关键字进行搜索" type="text" style="height: 21px;"> <input class="fl task-form-20 task-height-30 ml25" id="shixun_Look_name" name="search" maxlength="" placeholder="输入实训名称关键字进行搜索" type="text" style="height: 21px;">
<li class="fl">
<span class="mr10 ml10 font-14">发布时间</span>
<input type="text" name="beginTime" readonly placeholder="请选择开始时间" class="winput-150-30 mr10"/>
<input type="text" name="endTime" readonly placeholder="请选择结束时间" class="winput-150-30"/>
</li>
<li class="fl ml10"> <li class="fl ml10">
<a href="javascript:void(0)" class="task-btn task-btn-orange" onclick="$('#managements_shixuns_search').submit();">搜索</a> <a href="javascript:void(0)" class="task-btn task-btn-orange" onclick="$('#managements_shixuns_search').submit();">搜索</a>
<a href="javascript:clearSearchCondition();" class="task-btn mr10">清除</a> <a href="javascript:clearSearchCondition();" class="task-btn mr10">清除</a>
</li> </li>
<a href="<%= shixun_feedback_message_managements_path(:search => @search, :format => "xls") %>" id="shixun_search" class="task-btn mr10 task-btn-orange fr">导出</a> <a href="<%= shixun_feedback_message_managements_path(:search => @search, :beginTime => @beginTime, :endTime => @endTime,:format => "xls") %>" id="shixun_search" class="task-btn mr10 task-btn-orange fr">导出</a>
</div> </div>
<% end %> <% end %>
<div class="ex_container" id="management_shixun_feedback_list"> <div class="ex_container" id="management_shixun_feedback_list">
@ -17,4 +23,16 @@
function clearSearchCondition(){ function clearSearchCondition(){
$("#shixun_Look_name").val('') $("#shixun_Look_name").val('')
} }
$("input[name='beginTime']").datetimepicker({
allowBlank:true,
lang:'ch',
format:'Y-m-d H:i',
validateOnBlur:false
});
$("input[name='endTime']").datetimepicker({
allowBlank:true,
lang:'ch',
format:'Y-m-d H:i',
validateOnBlur:false
});
</script> </script>

@ -1,2 +1,2 @@
$("#management_shixun_feedback_list").html("<%= j(render :partial => 'shixun_feedback_list') %>"); $("#management_shixun_feedback_list").html("<%= j(render :partial => 'shixun_feedback_list') %>");
$("#shixun_search").attr("href", "<%= shixun_feedback_message_managements_path(:search => @search, :format => "xls") %>") $("#shixun_search").attr("href", "<%= shixun_feedback_message_managements_path(:search => @search, :beginTime => @beginTime, :endTime => @endTime,:format => "xls") %>")

@ -713,6 +713,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
post 'delete_subject_level' post 'delete_subject_level'
post 'update_level_for_subject' post 'update_level_for_subject'
post :add_customers post :add_customers
delete :delete_customers
get :customers_list get :customers_list
end end
end end

Loading…
Cancel
Save