Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

sso
cxt 5 years ago
commit db16bf5cf2

@ -3,9 +3,13 @@ $(document).on('turbolinks:load', function() {
// ============= 添加销售人员 ============== // ============= 添加销售人员 ==============
var $addMemberModal = $('.admin-add-salesman-channel-user-modal'); var $addMemberModal = $('.admin-add-salesman-channel-user-modal');
var searchscForm = $(".saleman-channel-list-form .search-form");
var scFormUrl = searchscForm.data('data-search-form-url');
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-channel-user-form'); var $addMemberForm = $addMemberModal.find('.admin-add-salesman-channel-user-form');
var $memberSelect = $addMemberModal.find('.salesman-channel-user-select'); var $memberSelect = $addMemberModal.find('.salesman-channel-user-select');
var $salesmanIdInput = $('.salesman-channel-list-form').find(".btn-primary"); var $salesmanIdInput = $('.salesman-channel-list-form').find(".btn-primary");
var $start_time = $('#start_time');
var $end_time = $('#end_time');
$addMemberModal.on('show.bs.modal', function(event){ $addMemberModal.on('show.bs.modal', function(event){
var $link = $(event.relatedTarget); var $link = $(event.relatedTarget);
@ -48,6 +52,7 @@ $(document).on('turbolinks:load', function() {
// var salesmanId = $salesmanIdInput.val(); // var salesmanId = $salesmanIdInput.val();
var memberIds = $memberSelect.val(); var memberIds = $memberSelect.val();
if (memberIds && memberIds.length > 0) { if (memberIds && memberIds.length > 0) {
alert(start_time);
$.ajax({ $.ajax({
method: 'POST', method: 'POST',
dataType: 'json', dataType: 'json',
@ -70,5 +75,40 @@ $(document).on('turbolinks:load', function() {
$addMemberModal.modal('hide'); $addMemberModal.modal('hide');
} }
}); });
// 时间跨度
var baseOptions = {
autoclose: true,
language: 'zh-CN',
format: 'yyyy-mm-dd',
startDate: '2017-04-01'
};
var defineDateRangeSelect = function(element){
var options = $.extend({inputs: $(element).find('.start-date, .end-date')}, baseOptions);
$(element).datepicker(options);
$(element).find('.start-date').datepicker().on('changeDate', function(e){
$(element).find('.end-date').datepicker('setStartDate', e.date);
});
};
defineDateRangeSelect('.grow-date-input-daterange');
// 区间搜索
searchscForm.on('click', ".search-btn", function(){
submitForm();
});
var submitForm = function(){
var form = searchscForm;
var url = "/admins/salesman_channels";
$.ajax({
url: url,
data: form.serialize(),
dataType: "script"
})
};
} }
}); });

@ -29,6 +29,23 @@ $(document).on('turbolinks:load', function () {
} }
}); });
$(".action-container").on("change", '.subject-mobile-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
var s_index = $(this).parent("td").siblings(".shixun-line-no").text();
json[s_name] = s_value;
json["page_no"] = s_index;
$.ajax({
url: "/admins/subject_settings/update_mobile_show?subject_id=" + s_id,
type: "POST",
dataType:'script',
data: json
});
});
$(".subject-setting-list-container").on("change", '.subject-setting-form', function () { $(".subject-setting-list-container").on("change", '.subject-setting-form', function () {
var s_id = $(this).attr("data-id"); var s_id = $(this).attr("data-id");
var s_value = $(this).val(); var s_value = $(this).val();

@ -3,6 +3,9 @@ class Admins::SalesmanChannelsController < Admins::BaseController
def index def index
@channels = SalesmanChannel.all @channels = SalesmanChannel.all
@start_time = params[:start_time]
@end_time = params[:end_time] || Time.now
@keyword = params[:keyword]
end end
def batch_add def batch_add

@ -8,6 +8,12 @@ class Admins::SubjectSettingsController < Admins::BaseController
end end
def update def update
# 为了复用代码
if params["show_moblie"]
subject.find(params[:id]).update_attributes(:show_moblie => params[:show_moblie])
return
end
sub_discipline_ids = params[:sub_disciplines] || [] sub_discipline_ids = params[:sub_disciplines] || []
sub_ids = sub_discipline_ids.reject(&:blank?).map(&:to_i) sub_ids = sub_discipline_ids.reject(&:blank?).map(&:to_i)
old_sub_ids = current_subject.sub_discipline_containers.pluck(:sub_discipline_id) old_sub_ids = current_subject.sub_discipline_containers.pluck(:sub_discipline_id)
@ -20,6 +26,11 @@ class Admins::SubjectSettingsController < Admins::BaseController
end end
end end
def update_mobile_show
subject = Subject.find(params[:subject_id])
subject.update_attributes(:show_mobile => params[:show_mobile])
end
private private
def current_subject def current_subject

@ -6,20 +6,23 @@ class SalesmanChannel < ApplicationRecord
school.name school.name
end end
def teacher_count def teacher_count(start_time, end_time, keyword)
UserExtension.where(school_id: school_id).where.not(identity: 1).count UserExtension.joins(:school).where("schools.name like '%#{keyword}%' and user_extensions.identity=0
and user_extensions.created_at between '#{start_time}' and '#{end_time}'").count
# UserExtension.where(school_id: school_id).where(query).count
end end
def student_count def student_count(start_time, end_time, keyword)
UserExtension.where(school_id: school_id, identity: 1).count UserExtension.joins(:school).where("schools.name like '%#{keyword}%' and user_extensions.identity=1
and user_extensions.created_at between '#{start_time}' and '#{end_time}'").count
end end
def course_count def course_count(start_time, end_time, keyword)
Course.where(school_id: school_id).count Course.joins(:school).where("schools.name like '%#{keyword}%' and courses.created_at between '#{start_time}' and '#{end_time}'").count
end end
def shixuns_count def shixuns_count(start_time, end_time, keyword)
ShixunMember.joins("join user_extensions on user_extensions.user_id = shixun_members.user_id") ShixunMember.joins("join user_extensions on user_extensions.user_id = shixun_members.user_id and shixun_members.created_at between '#{start_time}' and '#{end_time}'")
.where(user_extensions: {school_id: school_id}).pluck(:shixun_id).uniq.count .where(user_extensions: {school_id: school_id}).pluck(:shixun_id).uniq.count
end end

@ -2,12 +2,32 @@
<% add_admin_breadcrumb("#{@salesman.name}的渠道", admins_salesmans_path) %> <% add_admin_breadcrumb("#{@salesman.name}的渠道", admins_salesmans_path) %>
<% end %> <% end %>
<div class="box search-form-container salesman-channel-list-form rig"> <% define_admin_breadcrumbs do %>
<div class="flex-1"> <% add_admin_breadcrumb('数据变化报表', admins_school_statistics_path) %>
<% end %>
<div class="box search-form-container saleman-channel-list-form">
<form class="form-inline search-form d-flex" data-search-form-url="<%= admins_salesman_channels_path %>">
<div class="time-select">
<div class="form-group grow-date-container">
<div class="input-group input-daterange grow-date-input-daterange">
<%= text_field_tag :start_date, params[:start_date], class: 'form-control start-date mx-0', placeholder: '开始时间' %>
<div class="input-group-prepend"><span class="input-group-text">到</span></div>
<%= text_field_tag :end_date, params[:start_date], class: 'form-control end-date mx-0', placeholder: '结束时间' %>
</div>
</div>
</div>
<%= text_field_tag :keyword, params[:keyword], placeholder: 'ID/单位名称检索', class: 'form-control mx-3 search-input' %>
<%= javascript_void_link '搜索', class: 'btn btn-primary search-btn', target: '' %>
</form>
<div class="flex-12">
<%= javascript_void_link '新增渠道', class: 'btn btn-primary', data: {salesman_id: @salesman.id, toggle: 'modal', target: '.admin-add-salesman-channel-user-modal' } %> <%= javascript_void_link '新增渠道', class: 'btn btn-primary', data: {salesman_id: @salesman.id, toggle: 'modal', target: '.admin-add-salesman-channel-user-modal' } %>
</div> </div>
</div> </div>
<div class="box admin-list-container salesman-channel-list-container"> <div class="box admin-list-container salesman-channel-list-container">
<%= render(partial: 'admins/salesman_channels/shared/list') %> <%= render(partial: 'admins/salesman_channels/shared/list') %>
</div> </div>

@ -0,0 +1 @@
$(".salesman-channel-list-container").html("<%= j(render partial: 'admins/salesman_channels/shared/list') %>")

@ -19,16 +19,16 @@
<span><%= channel.school_name %></span> <span><%= channel.school_name %></span>
</td> </td>
<td class="text-left"> <td class="text-left">
<span><%= channel.teacher_count %></span> <span><%= channel.teacher_count(@start_time, @end_time, @keyword) %></span>
</td> </td>
<td class="text-left"> <td class="text-left">
<span><%= channel.student_count %></span> <span><%= channel.student_count(@start_time, @end_time, @keyword) %></span>
</td> </td>
<td> <td>
<%= channel.course_count %> <%= channel.course_count(@start_time, @end_time, @keyword) %>
</td> </td>
<td> <td>
<%= channel.shixuns_count %> <%= channel.shixuns_count(@start_time, @end_time, @keyword) %>
</td> </td>
<td> <td>
<%= delete_link '删除', admins_salesman_channel_path(channel, salesman_id: channel.salesman_id, element: ".salesman-channel-item-#{channel.id}"), class: 'delete-salesman-action' %> <%= delete_link '删除', admins_salesman_channel_path(channel, salesman_id: channel.salesman_id, element: ".salesman-channel-item-#{channel.id}"), class: 'delete-salesman-action' %>

@ -2,9 +2,9 @@
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th width="6%">序号</th> <th width="6%">序号</th>
<th width="20%" class="text-left">名称</th> <th width="20%" class="text-left">业务员</th>
<th width="30%" class="text-left">客户(点击数字客户列表)</th> <th width="30%" class="text-left">重点跟踪客户(点击数字客户列表)</th>
<th width="30%" class="text-left">渠道数(点击数字渠道列表)</th> <th width="30%" class="text-left">重点跟踪院校(点击数字渠道列表)</th>
<th width="14%">操作</th> <th width="14%">操作</th>
</tr> </tr>
</thead> </thead>

@ -1,14 +1,14 @@
<table class="table table-hover text-center subject-list-table"> <table class="table table-hover text-center subject-list-table">
<thead class="thead-light"> <thead class="thead-light">
<tr> <tr>
<th width="4%">序号</th> <th width="5%">序号</th>
<th width="25%" class="text-left">名称</th> <th width="23%" class="text-left">名称</th>
<th width="12%">技术体系</th> <th width="10%">老版技术体系</th>
<th width="10%">等级体系</th> <th width="10%">状态</th>
<th width="25%">课程体系</th> <th width="25%">课程体系</th>
<th width="10%">封面</th> <th width="10%">封面</th>
<th width="8%">开课人数</th> <th width="5%">开课人数</th>
<th width="6%">操作</th> <th width="12%">操作</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

@ -5,7 +5,7 @@
<span class="badge badge-pill badge-info excellent-badge" style="<%= subject.excellent? ? '' : 'display:none' %>">金课</span> <span class="badge badge-pill badge-info excellent-badge" style="<%= subject.excellent? ? '' : 'display:none' %>">金课</span>
</td> </td>
<td><%= display_text subject.repertoire&.name %></td> <td><%= display_text subject.repertoire&.name %></td>
<td><%= display_text subject.subject_level_system&.name %></td> <td><%= display_text subject.status == 2 ? "已发布" : "未发布" %></td>
<td> <td>
<%= select_tag(:sub_disciplines, options_for_select(@sub_disciplines, subject.sub_disciplines.pluck(:id)),multiple:true,class:"form-control subject-setting-form",data:{id:subject.id},id:"tags-chosen-#{subject.id}") %> <%= select_tag(:sub_disciplines, options_for_select(@sub_disciplines, subject.sub_disciplines.pluck(:id)),multiple:true,class:"form-control subject-setting-form",data:{id:subject.id},id:"tags-chosen-#{subject.id}") %>
</td> </td>
@ -16,6 +16,8 @@
</td> </td>
<td><%= subject.student_count %></td> <td><%= subject.student_count %></td>
<td class="action-container"> <td class="action-container">
<%= check_box_tag :show_mobile, !subject.show_mobile, subject.show_mobile, remote: true,
data: {id: subject.id, toggle: "tooltip", placement: "top"}, class: "subject-mobile-form mr10", title: "小程序端显示" %>
<%= link_to('编辑', edit_admins_subject_path(subject), remote: true, class: 'edit-action') %> <%= link_to('编辑', edit_admins_subject_path(subject), remote: true, class: 'edit-action') %>
</td> </td>

@ -0,0 +1 @@
$.notify({ message: '更新成功' });

@ -1328,7 +1328,9 @@ Rails.application.routes.draw do
post :drag, on: :collection post :drag, on: :collection
end end
resources :subject_settings, only: [:index, :update] resources :subject_settings, only: [:index, :update] do
post :update_mobile_show, on: :collection
end
resources :subjects, only: [:index, :edit, :update, :destroy] do resources :subjects, only: [:index, :edit, :update, :destroy] do
member do member do

@ -0,0 +1,5 @@
class AddShowMoblieToSubjects < ActiveRecord::Migration[5.2]
def change
add_column :subjects, :show_mobile, :boolean, :default => false
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save