educode_sales 1.10.48 → 1.10.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/educode_sales/modules/easyeditor/easyeditor.css +130 -0
- data/app/assets/stylesheets/educode_sales/modules/easyeditor/fangge-style.css +4 -0
- data/app/controllers/educode_sales/application_controller.rb +12 -0
- data/app/controllers/educode_sales/business_courses_controller.rb +230 -0
- data/app/controllers/educode_sales/home_controller.rb +7 -0
- data/app/controllers/educode_sales/shixun_dectects_controller.rb +111 -0
- data/app/controllers/educode_sales/shixuns_controller.rb +157 -0
- data/app/controllers/educode_sales/subject_trends_controller.rb +937 -0
- data/app/controllers/educode_sales/subjects_controller.rb +202 -0
- data/app/helpers/educode_sales/application_helper.rb +8 -0
- data/app/helpers/educode_sales/business_courses_helper.rb +37 -0
- data/app/helpers/educode_sales/subject_helper.rb +29 -0
- data/app/models/educode_sales/business.rb +22 -0
- data/app/models/educode_sales/business_deliver_subject.rb +48 -0
- data/app/models/educode_sales/business_subject.rb +62 -0
- data/app/models/educode_sales/business_subject_shixun.rb +46 -0
- data/app/models/educode_sales/business_subject_staff.rb +35 -0
- data/app/models/educode_sales/permission.rb +2 -1
- data/app/models/educode_sales/shixun_dectect.rb +12 -0
- data/app/views/educode_sales/business_courses/edit.html.erb +148 -0
- data/app/views/educode_sales/business_courses/index.html.erb +312 -0
- data/app/views/educode_sales/business_courses/index.json.jbuilder +16 -0
- data/app/views/educode_sales/business_courses/list_shixuns.html.erb +224 -0
- data/app/views/educode_sales/business_courses/list_shixuns.json.jbuilder +17 -0
- data/app/views/educode_sales/business_courses/list_subjects.html.erb +217 -0
- data/app/views/educode_sales/business_courses/list_subjects.json.jbuilder +12 -0
- data/app/views/educode_sales/business_courses/new.html.erb +212 -0
- data/app/views/educode_sales/shixun_dectects/index.html.erb +466 -0
- data/app/views/educode_sales/shixun_dectects/index.json.jbuilder +22 -0
- data/app/views/educode_sales/shixun_dectects/markdown.html.erb +60 -0
- data/app/views/educode_sales/shixuns/edit.html.erb +186 -0
- data/app/views/educode_sales/shixuns/index.html.erb +513 -0
- data/app/views/educode_sales/shixuns/index.json.jbuilder +22 -0
- data/app/views/educode_sales/shixuns/new.html.erb +251 -0
- data/app/views/educode_sales/subject_trends/trends.html.erb +1074 -0
- data/app/views/educode_sales/subjects/edit.html.erb +86 -0
- data/app/views/educode_sales/subjects/index.html.erb +247 -0
- data/app/views/educode_sales/subjects/index.json.jbuilder +16 -0
- data/app/views/educode_sales/subjects/list_shixuns.html.erb +228 -0
- data/app/views/educode_sales/subjects/list_shixuns.json.jbuilder +17 -0
- data/app/views/educode_sales/subjects/new.html.erb +254 -0
- data/app/views/layouts/educode_sales/application.html.erb +38 -0
- data/config/routes.rb +37 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +37 -1
@@ -0,0 +1,157 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# 实践项目管理
|
4
|
+
module EducodeSales
|
5
|
+
class ShixunsController < ApplicationController
|
6
|
+
before_action :subject_members, :subject_staffs, :create_filter
|
7
|
+
def index
|
8
|
+
|
9
|
+
# 判断类型是否存在 1 管培 2 全职 3 专职 如果不存在就默认为1
|
10
|
+
category = params[:q].present? ? params[:q][:category].to_i : BusinessSubjectShixun::CATEGORY_TYPE::TRAINING
|
11
|
+
@shixuns = BusinessSubjectShixun.left_joins(:school, :shixun , business_subject: [:subject, business: :last_follow_up])
|
12
|
+
.where(category: category)
|
13
|
+
|
14
|
+
# 项目级别 0 全部
|
15
|
+
if params[:q].present? && params[:q][:level].present? && params[:q][:level].to_i != 0
|
16
|
+
@shixuns = @shixuns.where(level: params[:q][:level])
|
17
|
+
end
|
18
|
+
# 项目状态 0 全部
|
19
|
+
if params[:q].present? && params[:q][:status].present? && params[:q][:status].to_i != 0
|
20
|
+
@shixuns = @shixuns.where(shixun_status: params[:q][:status])
|
21
|
+
end
|
22
|
+
if params[:q] && params[:q][:time].present?
|
23
|
+
start_time = params[:q][:time].split(" - ")[0]
|
24
|
+
end_time = params[:q][:time].split(" - ")[-1]
|
25
|
+
# @shixuns = @shixuns.where("educode_sales_follow_ups.reception_at BETWEEN '#{start_time}' AND '#{end_time}'
|
26
|
+
# or educode_sales_business_subject_shixuns.deliver_date BETWEEN '#{start_time}' AND '#{end_time}' ")
|
27
|
+
@shixuns = @shixuns.where("educode_sales_follow_ups.reception_at BETWEEN '#{start_time}' AND '#{end_time}'")
|
28
|
+
end
|
29
|
+
if params[:q].present? && params[:q][:shixun_name].present?
|
30
|
+
@shixuns = @shixuns.where("educode_sales_business_subject_shixuns.name like '%#{params[:q][:shixun_name]}%'")
|
31
|
+
end
|
32
|
+
if params[:q].present? && params[:q][:subject_name].present?
|
33
|
+
@shixuns = @shixuns.where("subjects.name like '%#{params[:q][:subject_name]}%'")
|
34
|
+
end
|
35
|
+
@shixuns = @shixuns.select("educode_sales_business_subject_shixuns.*,
|
36
|
+
educode_sales_follow_ups.reception_at,
|
37
|
+
schools.name as school_name,
|
38
|
+
subjects.name as subject_name,
|
39
|
+
shixuns.name as shixun_name,
|
40
|
+
shixuns.identifier")
|
41
|
+
.page(params[:page])
|
42
|
+
.per(params[:limit])
|
43
|
+
end
|
44
|
+
|
45
|
+
def edit
|
46
|
+
@item = BusinessSubjectShixun.find(params[:id])
|
47
|
+
@producer_list = BusinessSubjectStaff.where(container_type: BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN,
|
48
|
+
container_id: params[:id],
|
49
|
+
category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER)
|
50
|
+
.select(:staff_id)
|
51
|
+
.map { |item| item[:staff_id] }
|
52
|
+
|
53
|
+
@manage_list = BusinessSubjectStaff.where(container_type: BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN,
|
54
|
+
container_id: params[:id],
|
55
|
+
category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_MANAGE)
|
56
|
+
.select(:staff_id)
|
57
|
+
.map { |item| item[:staff_id] }
|
58
|
+
gon.staffs = @manages
|
59
|
+
render layout: false
|
60
|
+
end
|
61
|
+
|
62
|
+
def update
|
63
|
+
ActiveRecord::Base.transaction do
|
64
|
+
|
65
|
+
if params[:id].present?
|
66
|
+
item = BusinessSubjectShixun.find(params[:id])
|
67
|
+
if item.present?
|
68
|
+
item.update!(category: params[:category],
|
69
|
+
level: params[:level],
|
70
|
+
deliver_money: params[:money],
|
71
|
+
shixun_status: params[:status],
|
72
|
+
deliver_date: params[:time],
|
73
|
+
shixun_type: params[:type])
|
74
|
+
item.staffs.where(category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_MANAGE).destroy_all
|
75
|
+
item.staffs.where(category: BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER).destroy_all
|
76
|
+
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
77
|
+
params[:manage_id].split(",").each do |m|
|
78
|
+
d.add [m.to_i, params[:id], BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_MANAGE]
|
79
|
+
end
|
80
|
+
end
|
81
|
+
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
82
|
+
params[:producer_id].split(",").each do |m|
|
83
|
+
d.add [m.to_i, params[:id], BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
render_success
|
88
|
+
else
|
89
|
+
render_failure("操作失败")
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def new
|
95
|
+
gon.manage = @manages
|
96
|
+
gon.staffs = @staffs
|
97
|
+
render layout: false
|
98
|
+
end
|
99
|
+
|
100
|
+
def create
|
101
|
+
begin
|
102
|
+
ActiveRecord::Base.transaction do
|
103
|
+
|
104
|
+
attr = {
|
105
|
+
name: params[:name].to_s,
|
106
|
+
category: params[:category].to_i,
|
107
|
+
shixun_type: params[:type].to_i,
|
108
|
+
shixun_status: params[:status].to_i,
|
109
|
+
level: params[:level].to_i,
|
110
|
+
link: params[:link].to_s,
|
111
|
+
deliver_money: params[:money].to_s,
|
112
|
+
deliver_date: params[:time],
|
113
|
+
school_id: params[:school_id]
|
114
|
+
}
|
115
|
+
|
116
|
+
if params[:shixun_type].to_i == 1
|
117
|
+
# 目前支持名称关联实训
|
118
|
+
origin_shixun = Shixun.unhidden.find_by_name(params[:name].to_s)
|
119
|
+
attr = origin_shixun.blank? ? attr : attr.merge({shixun_id: origin_shixun.id})
|
120
|
+
end
|
121
|
+
shixun = BusinessSubjectShixun.create!(attr)
|
122
|
+
|
123
|
+
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
124
|
+
params[:manage_id].split(",").each do |m|
|
125
|
+
d.add [m.to_i, shixun.id, BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_MANAGE]
|
126
|
+
end
|
127
|
+
end
|
128
|
+
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
129
|
+
params[:producer_id].split(",").each do |m|
|
130
|
+
d.add [m.to_i, shixun.id, BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_PRODUCER]
|
131
|
+
end
|
132
|
+
end
|
133
|
+
BusinessSubjectStaff.bulk_insert(:staff_id, :container_id, :container_type, :created_at, :updated_at, :category) do |d|
|
134
|
+
params[:staff_id].split(",").each do |m|
|
135
|
+
d.add [m.to_i, shixun.id, BusinessSubjectStaff::CONTAINER_TYPES::SHIXUN, Time.now, Time.now, BusinessSubjectStaff::CATEGORY_TYPES::SHIXUN_STAFF]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
render_success
|
140
|
+
rescue => e
|
141
|
+
Rails.logger.error("操作失败:#{e}")
|
142
|
+
render_failure("操作失败")
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
def create_filter
|
148
|
+
filter_data = { "school_name" => 0, "subject_name" => 0, "reception_at" => 0, "shixun_name" => 0, "level" => 0, "shixun_status" => 0,
|
149
|
+
"deliver_date" => 0, "commit_dectect_time" => 0, "dectect_feedback" => 0, "shixun_producer" => 0, "shixun_manages" => 0,
|
150
|
+
"max_manage"=> 0, "shixun_staff" => 0 }
|
151
|
+
filter = Filter.create_with(extras: filter_data).find_or_create_by(staff_id: @current_admin.id, clazz: "shixuns")
|
152
|
+
|
153
|
+
gon.filter = filter.extras
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|