commit
d02fec75db
@ -1,6 +1,36 @@
|
||||
class CooperatesController < ApplicationController
|
||||
before_filter :require_login
|
||||
before_filter :find_partner, only: [:partner_list]
|
||||
before_filter :is_admin, only: [:partner_list]
|
||||
|
||||
def show
|
||||
def partner_list
|
||||
search = params[:search]
|
||||
@schools = School.where(customer_id: @partner.customer_ids)
|
||||
@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
|
||||
|
||||
def find_partner
|
||||
@partner = Partner.find_by_id(params[:id])
|
||||
render_404 if @partner.nil?
|
||||
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
|
||||
|
@ -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
|
@ -0,0 +1,5 @@
|
||||
class Customer < ActiveRecord::Base
|
||||
belongs_to :partner
|
||||
has_one :school
|
||||
has_many :users
|
||||
end
|
@ -0,0 +1,8 @@
|
||||
class Partner < ActiveRecord::Base
|
||||
# attr_accessible :name, :active
|
||||
attr_accessor :active
|
||||
|
||||
has_one :school
|
||||
has_many :customers
|
||||
has_many :users
|
||||
end
|
@ -0,0 +1,42 @@
|
||||
<div id="Auth_main">
|
||||
<div class="educontent mb30 mt20">
|
||||
|
||||
<div class="clearfix padding20-30 bor-bottom-greyE edu-back-white">
|
||||
<span class="fl font-12 mt5">
|
||||
<span class="color-orange-tip mr3" id="search_partner_count"><%= @obj_count %></span>
|
||||
<span class="color-grey-9">个检索结果(<span id="all_major_count"><%= @all_count %></span> 单位)</span>
|
||||
</span>
|
||||
<div class="fr" id="pollingPanel">
|
||||
<input type="text" name="search" maxlength="20" placeholder="请输入单位名称搜索" />
|
||||
<a href="javascript:void(0)" onclick="submit_search_major()"><i class="iconfont icon-sousuo font-16 color-grey-9"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ListTableLine ListTableLines" id="partner_school_list">
|
||||
<%= render :partial => "partner_item" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
|
||||
$("#pollingPanel").on("keydown", "input[name='search']", function(e){
|
||||
// 兼容FF和IE和Opera
|
||||
var theEvent = e || window.event;
|
||||
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
||||
if (code == 13) {
|
||||
//回车执行查询
|
||||
submit_search_major()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function submit_search_major(){
|
||||
$.get('/cooperates/partner_list',
|
||||
{ search: $("input[name='search']").val().trim()});
|
||||
}
|
||||
|
||||
</script>
|
@ -0,0 +1,2 @@
|
||||
$("#partner_school_list").html("<%= j(render :partial => "partner_item") %>");
|
||||
$("#search_partner_count").html("<%= @obj_count %>");
|
@ -0,0 +1,100 @@
|
||||
<div class="task-popup" style="width: 572px;">
|
||||
<div class="task-popup-title clearfix">添加客户</div>
|
||||
<div class="task_popup_con">
|
||||
<div class="clearfix mb5 df">
|
||||
<div class="flex1">
|
||||
<%= render partial: "managements/customers_search_form" %>
|
||||
</div>
|
||||
<a href="javascript:void(0);" onclick="$('#partners_search_form').submit()" class="white-btn mt6 edu-blueback-btn fl ml15 mt55">搜索</a>
|
||||
</div>
|
||||
<div class="mb4 clearfix">
|
||||
<p class="pl10 color-grey-6 clearfix">
|
||||
<span class="fl ml25">单位</span>
|
||||
<span class="fr with30">地区</span>
|
||||
</p>
|
||||
<div class="edu-back-skyblue clearfix pl10 over280" id="search_customers_list">
|
||||
<%= render :partial => "partners_list" %>
|
||||
</div>
|
||||
<p class="clearfix" style="height: 20px;"><span class="fl lineh-20 none color-red" id="checkNotice"></span></p>
|
||||
</div>
|
||||
|
||||
<li class="clearfix mt10 edu-txt-center">
|
||||
<a href="javascript:void(0);" class="task-btn mr10" onclick="hideModal()">取消</a>
|
||||
<a href="javascript:void(0);" class="task-btn task-btn-orange ml20" onclick="submit_add_partner()">确定</a>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var i = 1; //设置当前页数
|
||||
var msg_list_loading = false;
|
||||
$(function() {
|
||||
$(function() {
|
||||
var totalpage = <%= @total_pages.to_i %>; //总页数,防止超过总页数继续滚动
|
||||
var winH = $(window).height(); //页面可视区域高度
|
||||
|
||||
$("#search_customers_list").scroll(function() {
|
||||
if (i < totalpage) { // 当滚动的页数小于总页数的时候,继续加载
|
||||
var pageH = $(document.body).height();
|
||||
|
||||
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_customers_list');
|
||||
if (msg_list.height() + msg_list[0].scrollTop >= msg_list[0].scrollHeight - 60) {
|
||||
msg_list_loading = true;
|
||||
$.getJSON("<%= all_path %>?partner_id=<%= @partner.id %>page="+page+"&search="+$("#partner_name_search").val()+"&province="+$("#partner_province").val(), function(schools) {
|
||||
if (schools) {
|
||||
msg_list_loading = false;
|
||||
var s_html = "";
|
||||
$.each(schools,function (index,array) {
|
||||
s_html = s_html+ "<p class='clearfix mt5'>" +
|
||||
" <span class='fl with70'>" +
|
||||
" <span>" +
|
||||
" <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>" +
|
||||
" </span>\n" +
|
||||
" </span>\n" +
|
||||
" <span class='fl with30'>"+array["school"]["province"]+"</span>" +
|
||||
" </p>"
|
||||
});
|
||||
$("#search_customers_list").append(s_html);
|
||||
i ++;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function submit_add_partner(){
|
||||
if($("input[name='school[]']:checked").length==0){
|
||||
$("#checkNotice").html("请选择需要添加的内容").removeClass("none");
|
||||
return;
|
||||
}else{
|
||||
var checked_array = [];
|
||||
$("input[name='school[]']:checked").each(function () {
|
||||
checked_array.push($(this).val())
|
||||
});
|
||||
$.ajax({
|
||||
url: "/managements/add_customers",
|
||||
type: 'POST',
|
||||
data: {school_ids: checked_array, partner_id: <%= @partner.id %>},
|
||||
success: function (e) {
|
||||
if(e.status === 1){
|
||||
hideModal();
|
||||
window.location.href = "<%= partners_managements_path(partner: @partner.id) %>";
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
@ -0,0 +1,19 @@
|
||||
<%= form_for "", :url => {:controller=> 'managements', :action => 'customers_list', :partner_id => @partner.id}, :html => {:id => 'partners_search_form'}, :method => "get", :remote => true do |f| %>
|
||||
<div class="df">
|
||||
<span class="fl lineh-35">地区:</span>
|
||||
<select placeholder="请选择地区" name="province" id="partner_province" class="flex1"></select>
|
||||
</div>
|
||||
<div class="df mt15">
|
||||
<span class="fl lineh-35">单位:</span>
|
||||
<input type="text" class="input-flex-35" name="search" placeholder="请输入单位关键字" id="partner_name_search"/>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
unitDownOption();
|
||||
showprovince("partner_province");
|
||||
})
|
||||
|
||||
</script>
|
@ -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 %>
|
@ -0,0 +1,10 @@
|
||||
<% partner.users.each do |user| %>
|
||||
<li>
|
||||
<%= image_tag(url_to_avatar(user)) %>
|
||||
<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>
|
||||
</a>
|
||||
<span class="task-hide managementName"><%= user.show_real_name %></span>
|
||||
</li>
|
||||
<% end %>
|
@ -0,0 +1,11 @@
|
||||
<% @members.each do |member| %>
|
||||
<p class="clearfix">
|
||||
<span class="fl edu-txt-w90">
|
||||
<input type="checkbox" name="partner_member[]" value="<%= member.id %>" id="user_<%= member.id %>" class="magic-checkbox">
|
||||
<label for="user_<%= member.id %>"><%= member.show_real_name %></label>
|
||||
</span>
|
||||
<span class="fl edu-txt-w90 mt5 edu-txt-center color-grey-6 pointer"><%= member.identity %></span>
|
||||
<span class="fl task-hide edu-txt-w200 mt5 edu-txt-left color-grey-9"><%= member.school_name %> </span>
|
||||
<span class="fl edu-txt-w100 mt5 edu-txt-center color-grey-9"><%= member.phone %></span>
|
||||
</p>
|
||||
<% end %>
|
@ -0,0 +1,19 @@
|
||||
<%= form_for "", :url => {:controller=> 'managements', :action => 'all_partners', :type => @type}, :html => {:id => 'partners_search_form'}, :method => "get", :remote => true do |f| %>
|
||||
<div class="df">
|
||||
<span class="fl lineh-35">地区:</span>
|
||||
<select placeholder="请选择地区" name="province" id="partner_province" class="flex1"></select>
|
||||
</div>
|
||||
<div class="df mt15">
|
||||
<span class="fl lineh-35">单位:</span>
|
||||
<input type="text" class="input-flex-35" name="search" placeholder="请输入单位关键字" id="partner_name_search"/>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
$(function () {
|
||||
unitDownOption();
|
||||
showprovince("partner_province");
|
||||
})
|
||||
|
||||
</script>
|
@ -0,0 +1,11 @@
|
||||
<% @schools.each do |school| %>
|
||||
<p class='clearfix mt5'>
|
||||
<span class='fl with70'>
|
||||
<span>
|
||||
<input type='checkbox' name='school[]' value='<%= school.id %>' id='school_<%= school.id %>' class='magic-checkbox'>
|
||||
<label for='school_<%= school.id %>'><%= school.name %></label>
|
||||
</span>
|
||||
</span>
|
||||
<span class='fl with30'><%= school.province %></span>
|
||||
</p>
|
||||
<% end %>
|
@ -0,0 +1 @@
|
||||
$("#partner_member_list").html("<%= j(render :partial => "partner_member_list", :locals => {partner: @partner}) %>")
|
@ -0,0 +1,6 @@
|
||||
<% if params[:search] %>
|
||||
$("#member_search_user_list").html("<%= j(render :partial => "partner_member_search_list") %>")
|
||||
<% else %>
|
||||
var html="<%= escape_javascript(render :partial => "managements/partner_addManage") %>";
|
||||
pop_box_new(html,572,500);
|
||||
<% end %>
|
@ -0,0 +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}) %>";
|
||||
pop_box_new(html,572,500);
|
||||
<% end %>
|
@ -0,0 +1,6 @@
|
||||
<% if params[:search] %>
|
||||
$("#search_customers_list").html("<%= j(render :partial => "partners_list") %>")
|
||||
<% else %>
|
||||
var html="<%= escape_javascript(render :partial => "managements/customer_addUnit",locals: {all_path: customers_list_managements_path}) %>";
|
||||
pop_box_new(html,572,500);
|
||||
<% end %>
|
@ -0,0 +1 @@
|
||||
$("#partner_customer_list").html("<%= j(render :partial => "partner_customer_list") %>")
|
@ -0,0 +1 @@
|
||||
$("#partner_member_list").html("<%= j(render :partial => "partner_member_list", :locals => {partner: @partner}) %>")
|
@ -0,0 +1,53 @@
|
||||
<div class="mt20">
|
||||
<div class="clearfix edu-back-white padding20-30">
|
||||
<input class="fl task-form-20 task-height-30" placeholder="输入合作伙伴名称进行搜索">
|
||||
<a href="javascript:void(0)" class="fl task-btn task-btn-orange ml10">搜索</a>
|
||||
<a href="javascript:void(0)" class="fl task-btn ml10">清除</a>
|
||||
</div>
|
||||
<div class="clearfix mt20">
|
||||
<div class="with25 fl edu-back-white">
|
||||
<%= link_to "+添加",all_partners_managements_path,remote:true,class:"color-blue addOperation" %>
|
||||
<ul class="partnerList">
|
||||
<% @partners.each_with_index do |partner,index| %>
|
||||
<li>
|
||||
<%= link_to "#{partner.name}", partners_managements_path(:partner => partner), :class => "#{partner.active}" %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% if @current_partner.present? %>
|
||||
<div class="with75 fl pl20">
|
||||
<div class="edu-back-white">
|
||||
<div>
|
||||
<div class="padding10-20">
|
||||
<p class="mb20"><span class="mr30 color-grey-9">添加时间</span><span class="color-grey-6"><%= format_time @current_partner.try(:created_at) %></span></p>
|
||||
<div class="clearfix">
|
||||
<span class="mr45 color-grey-9 fl">管理员</span>
|
||||
<ul class="manageList">
|
||||
<li>
|
||||
<%= link_to '+', add_partner_member_box_managements_path(:partner => @current_partner.try(:id)), :remote => true, :class => "addManage" %>
|
||||
</li>
|
||||
<div id="partner_member_list" class="fl">
|
||||
<%= render :partial => "partner_member_list", :locals => {partner: @current_partner} %>
|
||||
</div>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="tableList" id="partner_customer_list">
|
||||
<%= render :partial => "partner_customer_list" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
$(function(){
|
||||
$(".partnerList li").on("click","a",function(){
|
||||
$(".partnerList li a").removeClass("active");
|
||||
$(this).addClass("active");
|
||||
})
|
||||
})
|
||||
</script>
|
@ -1,2 +1,2 @@
|
||||
$("#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") %>")
|
@ -1,86 +0,0 @@
|
||||
<div id="Auth_main">
|
||||
<div class="educontent clearfix edu-back-white bor-bottom-greyE">
|
||||
<div class="padding20-30">
|
||||
<!-- <p class="mb20"><span class="font-18 mr20">管理员</span><span class="font-12 color-grey-9"></span></p>-->
|
||||
<!-- <ul class="clearfix managerPanels">-->
|
||||
|
||||
<!-- <a class="fl relative">-->
|
||||
<!-- <img alt="头像" class="radius" height="48" src="https://www.educoder.net/images/avatars/User/6?1543479003" width="48" />-->
|
||||
<!-- <i class="iconfont icon-shanchudiao userimg color-grey-9" ></i>-->
|
||||
<!-- <span class="color-black">达达老师</span>-->
|
||||
<!-- </a>-->
|
||||
|
||||
<!-- <a class="fl relative">-->
|
||||
<!-- <i class="iconfont icon-tianjiafangda useradd color-grey-9"></i>-->
|
||||
<!-- </a>-->
|
||||
|
||||
<!-- </ul>-->
|
||||
|
||||
<!-- <ul class="clearfix managerPanels">-->
|
||||
<!-- <a class="fl font-16 padding5-20 block mr30 navItem active color-blue"><span class="fl">实训回复</span></a>-->
|
||||
<!-- </ul>-->
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="educontent mb30">
|
||||
|
||||
<div class="clearfix padding20-30 bor-bottom-greyE edu-back-white">
|
||||
<span class="fl font-12 mt5">
|
||||
<span class="color-orange-tip mr3" id="search_major_count"><%= @obj_count %></span>
|
||||
<span class="color-grey-9">个检索结果(<span id="all_major_count"><%= @major_count %></span> 单位)</span>
|
||||
</span>
|
||||
<div class="fr" id="pollingPanel">
|
||||
<input type="text" name="search" placeholder="请输入单位名称搜索" />
|
||||
<a href="javascript:void(0)" onclick="submit_search_major()"><i class="iconfont icon-sousuo font-16 color-grey-9"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ListTableLine ListTableLines" id="school_major_list">
|
||||
<%= render :partial => "department_list" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function(){
|
||||
|
||||
$(".MajorName i").click(function(){
|
||||
$(this).parents(".MajorName").remove();
|
||||
});
|
||||
|
||||
$("#school_major_list").on("click", ".addMajorManager", function(){
|
||||
if($("#major_managers_"+$(this).attr("data-major-id")).children("span").length < 5){
|
||||
var html="<%= escape_javascript(render :partial => "ecs/authList_addUnit") %>";
|
||||
pop_box_new(html,572,500);
|
||||
$("#object_id").val($(this).attr("data-major-id"));
|
||||
$("#object_type").val('major');
|
||||
$("input[name='school']").val('<%= @school.name %>');
|
||||
} else {
|
||||
notice_box("只能配置5个专业管理员");
|
||||
}
|
||||
});
|
||||
|
||||
$("#pollingPanel").on("keydown", "input[name='search']", function(e){
|
||||
// 兼容FF和IE和Opera
|
||||
var theEvent = e || window.event;
|
||||
var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
|
||||
if (code == 13) {
|
||||
//回车执行查询
|
||||
submit_search_major()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
function submit_search_major(){
|
||||
$.get('/ecs/department?school_id=<%= @school.id %>',
|
||||
{ search: $("input[name='search']").val().trim()});
|
||||
}
|
||||
|
||||
</script>
|
@ -0,0 +1,9 @@
|
||||
class CreatePartners < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :partners do |t|
|
||||
t.string :name
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
@ -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
|
@ -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
|
@ -0,0 +1,6 @@
|
||||
class AddPartnerIdToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :partner_id, :integer
|
||||
add_index :users, :partner_id
|
||||
end
|
||||
end
|
Loading…
Reference in new issue