educode_sales 0.6.6 → 0.7.0
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/controllers/educode_sales/activities_controller.rb +0 -2
- data/app/controllers/educode_sales/businesses_controller.rb +259 -43
- data/app/controllers/educode_sales/customers_controller.rb +48 -15
- data/app/controllers/educode_sales/home_controller.rb +6 -0
- data/app/controllers/educode_sales/money_plans_controller.rb +3 -3
- data/app/controllers/educode_sales/operation_plans_controller.rb +1 -1
- data/app/controllers/educode_sales/plans_controller.rb +1 -1
- data/app/controllers/educode_sales/sale_trends_controller.rb +107 -18
- data/app/controllers/educode_sales/staffs_controller.rb +29 -0
- data/app/controllers/educode_sales/teacher_follows_controller.rb +1 -93
- data/app/controllers/educode_sales/teachers_controller.rb +1 -1
- data/app/models/educode_sales/business_export_record.rb +5 -0
- data/app/models/educode_sales/customer_add.rb +4 -0
- data/app/models/educode_sales/staff.rb +1 -0
- data/app/models/educode_sales/staff_school.rb +6 -0
- data/app/views/educode_sales/activities/index.html.erb +7 -1
- data/app/views/educode_sales/activities/new.html.erb +1 -1
- data/app/views/educode_sales/businesses/edit_follow_record.html.erb +4 -4
- data/app/views/educode_sales/businesses/edit_plan.html.erb +5 -2
- data/app/views/educode_sales/businesses/export_records.html.erb +53 -0
- data/app/views/educode_sales/businesses/export_records.json.jbuilder +11 -0
- data/app/views/educode_sales/businesses/get_export_data.json.jbuilder +30 -0
- data/app/views/educode_sales/businesses/index.html.erb +161 -8
- data/app/views/educode_sales/businesses/index.json.jbuilder +10 -7
- data/app/views/educode_sales/businesses/new_follow_record.html.erb +6 -5
- data/app/views/educode_sales/businesses/show_follow.html.erb +37 -3
- data/app/views/educode_sales/businesses/show_follow.json.jbuilder +1 -0
- data/app/views/educode_sales/commons/index.html.erb +7 -1
- data/app/views/educode_sales/customers/index.html.erb +31 -1
- data/app/views/educode_sales/customers/index.json.jbuilder +12 -0
- data/app/views/educode_sales/customers/new.html.erb +106 -53
- data/app/views/educode_sales/home/staff_schools.json.jbuilder +9 -0
- data/app/views/educode_sales/money_plans/index.html.erb +2 -2
- data/app/views/educode_sales/roles/edit.html.erb +16 -10
- data/app/views/educode_sales/roles/index.html.erb +7 -1
- data/app/views/educode_sales/sale_trends/trends.html.erb +96 -44
- data/app/views/educode_sales/sale_trends/trends.json.jbuilder +2 -1
- data/app/views/educode_sales/sales/index.json.jbuilder +1 -1
- data/app/views/educode_sales/staffs/edit.html.erb +46 -5
- data/app/views/educode_sales/staffs/index.html.erb +74 -2
- data/app/views/educode_sales/staffs/index.json.jbuilder +1 -0
- data/app/views/educode_sales/teachers/index.html.erb +1 -1
- data/app/views/layouts/educode_sales/application.html.erb +1 -1
- data/config/routes.rb +4 -0
- data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +7 -0
- data/db/migrate/20220121060006_create_educode_sales_business_export_records.rb +10 -0
- data/db/migrate/20220125013811_create_educode_sales_staff_schools.rb +10 -0
- data/db/migrate/20220125033552_create_educode_sales_customer_adds.rb +9 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +12 -2
@@ -7,24 +7,41 @@ module EducodeSales
|
|
7
7
|
def trends
|
8
8
|
# authorize! :trends, EducodeSales::SaleTrend
|
9
9
|
@year = params[:year] ? params[:year] : Time.now.year
|
10
|
-
@years = (1..(Time.now.year - 2014)).reverse_each.map { |d| 2014 + d }
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
10
|
+
@years = ['全部'] + (1..(Time.now.year - 2014)).reverse_each.map { |d| 2014 + d }
|
11
|
+
if(@year == '全部')
|
12
|
+
x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
13
|
+
o = Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
|
14
|
+
@business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).sum(:total_amount).round(2)
|
15
|
+
stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
16
|
+
@goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", stage_ids).sum(:total_amount).round(2)
|
17
|
+
@actual_goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", stage_ids).sum(:actual_amount).round(2)
|
18
|
+
s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
19
|
+
@service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", s_stage_ids).sum(:total_amount).round(2)
|
20
|
+
@actual_service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.stage_id IN (?)", s_stage_ids).sum(:actual_amount).round(2)
|
21
|
+
@return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).sum(:amount).round(2)
|
22
|
+
a = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name).pluck(:id)
|
23
|
+
@a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).sum(:total_amount).round(2)
|
24
|
+
b = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name).pluck(:id)
|
25
|
+
@b_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", b).sum(:total_amount).round(2)
|
26
|
+
else
|
27
|
+
year_time = "#{@year}-01-01 00:00:00"
|
28
|
+
year_over_time = "#{@year}-12-31 23:59:59"
|
29
|
+
x = Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
30
|
+
o = Common.find_by(extras: EducodeSales::Common::OTYPE)&.id
|
31
|
+
@sale_trend = SaleTrend.find_or_create_by(year: @year)
|
32
|
+
@business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.year = ?",@year).sum(:total_amount).round(2)
|
33
|
+
stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
34
|
+
@goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:total_amount).round(2)
|
35
|
+
@actual_goal_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.bidded_date >= ? AND educode_sales_follow_ups.bidded_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", stage_ids).sum(:actual_amount).round(2)
|
36
|
+
s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
|
37
|
+
@service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids).sum(:total_amount).round(2)
|
38
|
+
@actual_service_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", x).where("educode_sales_follow_ups.signed_date >= ? AND educode_sales_follow_ups.signed_date <= ? AND educode_sales_follow_ups.stage_id IN (?)", "#{@year}-01-01", "#{@year}-12-31", s_stage_ids).sum(:actual_amount).round(2)
|
39
|
+
@return_amount = Business.joins(last_follow_up: :money_plans).where("educode_sales_follow_ups.clazz_id != ?", x).where.not("educode_sales_money_plans.clazz!= ?", 1).where("educode_sales_money_plans.date_at >= ? AND educode_sales_money_plans.date_at <= ? ", year_time, year_over_time).sum(:amount).round(2)
|
40
|
+
a = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name).pluck(:id)
|
41
|
+
@a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).where("educode_sales_follow_ups.year = ?",@year).sum(:total_amount).round(2)
|
42
|
+
b = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name).pluck(:id)
|
43
|
+
@b_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", b).where("educode_sales_follow_ups.year = ?",@year).sum(:total_amount).round(2)
|
44
|
+
end
|
28
45
|
|
29
46
|
count_type = params[:count_type] || "actual_amount"
|
30
47
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
@@ -116,6 +133,78 @@ module EducodeSales
|
|
116
133
|
|
117
134
|
|
118
135
|
|
136
|
+
# 销售人员跟进分析
|
137
|
+
begin_time = Time.now.at_beginning_of_year.to_s
|
138
|
+
end_time = Time.now.at_end_of_year.to_s
|
139
|
+
customer_time_range = params[:customer_time_range]
|
140
|
+
case customer_time_range
|
141
|
+
when 'last_week'
|
142
|
+
begin_time = (Time.now - 1.week).at_beginning_of_week.to_s
|
143
|
+
end_time = (Time.now - 1.week).at_end_of_week.to_s
|
144
|
+
when 'this_week'
|
145
|
+
begin_time = Time.now.at_beginning_of_week.to_s
|
146
|
+
end_time = Time.now.at_end_of_week.to_s
|
147
|
+
when 'last_month'
|
148
|
+
begin_time = (Time.now - 1.month).at_beginning_of_month.to_s
|
149
|
+
end_time = (Time.now - 1.month).at_end_of_month.to_s
|
150
|
+
when 'this_month'
|
151
|
+
begin_time = Time.now.at_beginning_of_month.to_s
|
152
|
+
end_time = Time.now.at_end_of_month.to_s
|
153
|
+
when 'last_year'
|
154
|
+
begin_time = (Time.now - 1.year).at_beginning_of_year.to_s
|
155
|
+
end_time = (Time.now - 1.year).at_end_of_year.to_s
|
156
|
+
when 'this_year'
|
157
|
+
begin_time = Time.now.at_beginning_of_year.to_s
|
158
|
+
end_time = Time.now.at_end_of_year.to_s
|
159
|
+
when 'all'
|
160
|
+
begin_time = (Time.now - 5.year).at_beginning_of_year.to_s
|
161
|
+
end_time = (Time.now + 5.year).at_end_of_year.to_s
|
162
|
+
when 'diy'
|
163
|
+
if params[:customer_date].present?
|
164
|
+
date = params[:customer_date].split(" - ")
|
165
|
+
begin_time = date[0] + "00:00:00"
|
166
|
+
end_time = date[1] + "23:59:59"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
100.times{p begin_time}
|
170
|
+
100.times{p end_time}
|
171
|
+
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
172
|
+
staff_names = Staff.joins(:user).where(job_type: common.id).map { |d| d.user.real_name}
|
173
|
+
staff_ids = Staff.joins(:user).where(job_type: common.id).pluck(:id)
|
174
|
+
if params[:customer_count_type] == 'money' || params[:customer_count_type].blank?
|
175
|
+
@customer_data = {
|
176
|
+
labels: staff_names,
|
177
|
+
datasets:[
|
178
|
+
{
|
179
|
+
label: "跟进客户数",
|
180
|
+
data: staff_ids.map{|staff_id|
|
181
|
+
(EducodeSales::CustomerFollow.where(staff_id: staff_id).where("created_at >= ? AND created_at <= ?", begin_time, end_time).pluck(:school_id) + EducodeSales::Business.where(id: EducodeSales::FollowUp.where(staff_id: staff_id).where("created_at >= ? AND created_at <= ?", begin_time, end_time).pluck(:business_id).uniq).pluck(:school_id)).uniq.size
|
182
|
+
},
|
183
|
+
backgroundColor: colors[0],
|
184
|
+
borderColor: colors[0],
|
185
|
+
borderWidth: 1
|
186
|
+
}
|
187
|
+
]
|
188
|
+
}
|
189
|
+
else
|
190
|
+
@customer_data = {
|
191
|
+
labels: staff_names,
|
192
|
+
datasets:[
|
193
|
+
{
|
194
|
+
label: "跟进客户次数",
|
195
|
+
data: staff_ids.map{|staff_id|
|
196
|
+
EducodeSales::CustomerFollow.where(staff_id: staff_id).where("created_at >= ? AND created_at <= ?", begin_time, end_time).size + EducodeSales::FollowUp.where(staff_id: staff_id).where("created_at >= ? AND created_at <= ?", begin_time, end_time).size
|
197
|
+
},
|
198
|
+
backgroundColor: colors[0],
|
199
|
+
borderColor: colors[0],
|
200
|
+
borderWidth: 1
|
201
|
+
}
|
202
|
+
]
|
203
|
+
}
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
|
119
208
|
# 已中标图表
|
120
209
|
goal_default_dates = ("#{Time.now.year}-01".."#{Time.now.year}-#{Time.now.month}").to_a
|
121
210
|
sale_names = ['已中标','已签单','已回款']
|
@@ -9,6 +9,25 @@ module EducodeSales
|
|
9
9
|
end
|
10
10
|
format.json do
|
11
11
|
@staffs = Staff.where(is_admin: false, deleted_at: nil).page(params[:page]).per(params[:limit])
|
12
|
+
if params[:q].present? && params[:q][:name].present?
|
13
|
+
@staffs = @staffs.joins(:user).where('CONCAT(lastname, firstname) LIKE :name', name: "%#{params[:q][:name]}%")
|
14
|
+
end
|
15
|
+
if params[:q].present? && params[:q][:role].present?
|
16
|
+
@staffs = @staffs.where(role: params[:q][:role])
|
17
|
+
end
|
18
|
+
if params[:q].present? && params[:q][:staff_id].present?
|
19
|
+
@staffs = @staffs.where(staff_id: params[:q][:staff_id])
|
20
|
+
end
|
21
|
+
if params[:q].present? && params[:q][:staff_type].present?
|
22
|
+
@staffs = @staffs.where(job_type: params[:q][:staff_type])
|
23
|
+
end
|
24
|
+
if params[:q].present? && params[:q][:banned].present?
|
25
|
+
if params[:q][:banned] == "0"
|
26
|
+
@staffs = @staffs.where("educode_sales_staffs.expired_at is null or educode_sales_staffs.expired_at > ?", Time.now)
|
27
|
+
else
|
28
|
+
@staffs = @staffs.where("educode_sales_staffs.expired_at is null or educode_sales_staffs.expired_at < ?", Time.now)
|
29
|
+
end
|
30
|
+
end
|
12
31
|
end
|
13
32
|
end
|
14
33
|
end
|
@@ -27,6 +46,10 @@ module EducodeSales
|
|
27
46
|
@staff = Staff.find(params[:id])
|
28
47
|
gon.area_ids = @staff.area_ids
|
29
48
|
gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'})
|
49
|
+
gon.school_ids = @staff.staff_schools.ids
|
50
|
+
gon.schools = @staff.staff_schools.pluck(:school_id).map { |d| { value: d, name: "#{School.find(d)&.name}-#{School.find(d)&.province}" } } #.unshift({value: -1, title: '全国'})
|
51
|
+
# gon.school_ids = School.all.ids
|
52
|
+
# gon.schools = School.all.first(100).map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'})
|
30
53
|
@staff_types = Common.where(clazz: 'staff_type').pluck(:name, :id)
|
31
54
|
render layout: false
|
32
55
|
end
|
@@ -58,6 +81,12 @@ module EducodeSales
|
|
58
81
|
commons << Common.find(d)
|
59
82
|
end
|
60
83
|
staff.areas = commons
|
84
|
+
if params[:school_ids].present?
|
85
|
+
staff.staff_schools.destroy_all
|
86
|
+
params[:school_ids].each do |d|
|
87
|
+
staff.staff_schools.create(school_id: d)
|
88
|
+
end
|
89
|
+
end
|
61
90
|
if staff.save
|
62
91
|
render_success
|
63
92
|
else
|
@@ -34,114 +34,22 @@ module EducodeSales
|
|
34
34
|
def update
|
35
35
|
follow_up = TeacherFollow.find(params[:id])
|
36
36
|
follow_up.assign_attributes(follow_up_params)
|
37
|
-
# follow_up.profit_amount = follow_up.actual_amount * (100-follow_up.divide_amount.to_i) * 0.01 if follow_up.actual_amount
|
38
37
|
if follow_up.save
|
39
38
|
render_success
|
40
39
|
else
|
41
40
|
render_failure follow_up
|
42
41
|
end
|
43
42
|
end
|
44
|
-
#
|
45
|
-
# def teachers
|
46
|
-
# follow_up = @current_admin.follow_ups.find_by(id: params[:id])
|
47
|
-
# if follow_up.present?
|
48
|
-
# @teachers = follow_up.key_person.includes(:teacher).page(params[:page]).per(params[:limit])
|
49
|
-
# else
|
50
|
-
# @teachers = FollowUp.none
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# def money_plans
|
55
|
-
# follow_up = @current_admin.follow_ups.find_by(id: params[:id])
|
56
|
-
# @money_plans = follow_up.money_plans.page(params[:page]).per(params[:limit])
|
57
|
-
# end
|
58
|
-
#
|
59
|
-
# def add_money
|
60
|
-
# follow_up = @current_admin.follow_ups.find(params[:id])
|
61
|
-
# money_plan = follow_up.money_plans.build(date_at: params[:date_at], amount: params[:amount], clazz: params[:clazz])
|
62
|
-
# money_plan.staff = @current_admin
|
63
|
-
# if money_plan.save
|
64
|
-
# render_success
|
65
|
-
# else
|
66
|
-
# render_failure money_plan
|
67
|
-
# end
|
68
|
-
# end
|
69
|
-
#
|
70
|
-
# def update_money
|
71
|
-
# follow_up = @current_admin.follow_ups.find_by(id: params[:id])
|
72
|
-
# money_plan = follow_up.money_plans.find(params[:plan_id])
|
73
|
-
# if money_plan.update(date_at: params[:date_at], amount: params[:amount], clazz: params[:clazz])
|
74
|
-
# render_success
|
75
|
-
# else
|
76
|
-
# render_failure money_plan
|
77
|
-
# end
|
78
|
-
# end
|
79
|
-
#
|
80
|
-
# def delete_money
|
81
|
-
# follow_up = @current_admin.follow_ups.find_by(id: params[:id])
|
82
|
-
# money_plan = follow_up.money_plans.find(params[:plan_id])
|
83
|
-
# if money_plan.destroy
|
84
|
-
# render_success
|
85
|
-
# else
|
86
|
-
# render_failure money_plan
|
87
|
-
# end
|
88
|
-
# end
|
89
|
-
#
|
90
|
-
# def add_keys
|
91
|
-
# follow_up = @current_admin.follow_ups.find(params[:id])
|
92
|
-
# if params[:name].blank?
|
93
|
-
# return render_failure '请从平台里选择教师'
|
94
|
-
# end
|
95
|
-
#
|
96
|
-
# names = params[:name].split("-")
|
97
|
-
# if names[0] == 't'
|
98
|
-
# # 从教师列表里选择的用户
|
99
|
-
# teacher = Teacher.find(names[1])
|
100
|
-
# key_peprson = KeyPerson.new(teacher_params)
|
101
|
-
# key_peprson.teacher = teacher
|
102
|
-
# else
|
103
|
-
# # 从头歌平台选择的用户
|
104
|
-
# user = User.find(names[1])
|
105
|
-
# teacher = Teacher.new(staff: @current_admin,
|
106
|
-
# professional_title: params[:professional_title],
|
107
|
-
# job: params[:job],
|
108
|
-
# user_id: user.id,
|
109
|
-
# is_key: true,
|
110
|
-
# department_id: user.department_id,
|
111
|
-
# name: user.real_name
|
112
|
-
# )
|
113
|
-
# teacher.save
|
114
|
-
# key_peprson = KeyPerson.new(teacher_params)
|
115
|
-
# key_peprson.teacher = teacher
|
116
|
-
# end
|
117
|
-
#
|
118
|
-
# follow_up.key_person << key_peprson
|
119
|
-
# if follow_up.save!
|
120
|
-
# render_success
|
121
|
-
# else
|
122
|
-
# render_failure follow_up
|
123
|
-
# end
|
124
|
-
# rescue ActiveRecord::RecordInvalid => e
|
125
|
-
# if e.message.include?("Teacher已经被使用") || e.message.include?('Key person是无效的')
|
126
|
-
# render_failure '该老师已在关键人列表中'
|
127
|
-
# else
|
128
|
-
# render_failure e.message
|
129
|
-
# end
|
130
|
-
# end
|
131
43
|
|
132
44
|
private
|
133
45
|
|
134
46
|
def load_teacher
|
135
47
|
@teacher = Teacher.find(params[:teacher_id])
|
136
48
|
end
|
137
|
-
|
49
|
+
|
138
50
|
def follow_up_params
|
139
51
|
params.permit(:attitude_id, :follow_id, :course_plan_id, :course_build_id, :description)
|
140
52
|
end
|
141
|
-
#
|
142
|
-
# def teacher_params
|
143
|
-
# params.permit(:professional_title, :job, :attitude_id, :sex, :birth_date, :remark)
|
144
|
-
# end
|
145
53
|
|
146
54
|
end
|
147
55
|
end
|
@@ -48,7 +48,7 @@ module EducodeSales
|
|
48
48
|
teacher_ids = EducodeSales::Teacher.where(staff_id: 0).pluck(:id) - EducodeSales::TeacherAssignFollow.all.pluck(:Teacher_id) + EducodeSales::TeacherAssignFollow.where(staff_id: @current_admin.id).pluck(:teacher_id) + @teachers.ids
|
49
49
|
@teachers = Teacher.where(id: teacher_ids)
|
50
50
|
when '区域'
|
51
|
-
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
|
51
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id) + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
|
52
52
|
@teachers = Teacher.joins("JOIN departments ON educode_sales_teachers.department_id = departments.id").where(is_key: false).where("departments.school_id in (?) OR educode_sales_teachers.staff_id = #{@current_admin.id}", school_ids)
|
53
53
|
teacher_ids = EducodeSales::Teacher.where(staff_id: 0).pluck(:id) - EducodeSales::TeacherAssignFollow.all.pluck(:Teacher_id) + EducodeSales::TeacherAssignFollow.where(staff_id: @current_admin.id).pluck(:teacher_id) + @teachers.ids
|
54
54
|
@teachers = Teacher.where(id: teacher_ids)
|
@@ -14,6 +14,7 @@ module EducodeSales
|
|
14
14
|
has_many :businesses, dependent: :destroy
|
15
15
|
has_many :activities, dependent: :destroy
|
16
16
|
has_many :sale_plans, dependent: :destroy
|
17
|
+
has_many :staff_schools, dependent: :destroy
|
17
18
|
|
18
19
|
has_many :areas, through: :market_areas
|
19
20
|
validates :user_id, uniqueness: { message: '已存在' }
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<div class="layui-inline">
|
13
13
|
<label class="layui-form-label required">活动时间</label>
|
14
14
|
<div class="layui-input-block">
|
15
|
-
<input type="text" name="start_at" required lay-verify="required" class="layui-input" id="new_time" placeholder="请选择时间">
|
15
|
+
<input type="text" name="start_at" autocomplete="off" required lay-verify="required" class="layui-input" id="new_time" placeholder="请选择时间">
|
16
16
|
</div>
|
17
17
|
</div>
|
18
18
|
<div class="layui-inline">
|
@@ -81,10 +81,9 @@
|
|
81
81
|
<br>
|
82
82
|
<div class="layui-inline place_select">
|
83
83
|
<label class="layui-form-label">渠道</label>
|
84
|
-
<div class="layui-input-inline" style="
|
84
|
+
<div class="layui-input-inline" style="">
|
85
85
|
<div id="edit_place" style="width: 190px;"></div>
|
86
86
|
</div>
|
87
|
-
总额里,渠道拿到的部分。
|
88
87
|
</div>
|
89
88
|
<br>
|
90
89
|
<div class="layui-inline">
|
@@ -92,6 +91,7 @@
|
|
92
91
|
<div class="layui-input-inline">
|
93
92
|
<input name="divide_amount" class="layui-input" value="<%= @follow_up.divide_amount%>">
|
94
93
|
</div>
|
94
|
+
总额里,渠道拿到的部分。
|
95
95
|
</div>
|
96
96
|
<div class="layui-form-item">
|
97
97
|
<div class="layui-inline">
|
@@ -105,10 +105,10 @@
|
|
105
105
|
</div>
|
106
106
|
<div class="layui-form-item">
|
107
107
|
<label class="layui-form-label">指定跟进人</label>
|
108
|
-
<div class="layui-input-inline" style="
|
108
|
+
<div class="layui-input-inline" style="">
|
109
109
|
<div id="edit_assign_follow" style="width: 512px;"></div>
|
110
110
|
</div>
|
111
|
-
<div class="layui-inline" style="padding: 9px 15px">
|
111
|
+
<div class="layui-inline" style="padding: 9px 15px;z-index: -1">
|
112
112
|
<label class="layui-form-label" style="padding-left: 220px"></label>
|
113
113
|
指定跟进人和商机创建者,同时拥有对该商机的管理权限
|
114
114
|
</div>
|
@@ -12,12 +12,15 @@
|
|
12
12
|
</div>
|
13
13
|
</div>
|
14
14
|
<div class="layui-input-inline" style="width: 300px;">
|
15
|
-
<label class="layui-form-label required"
|
15
|
+
<label class="layui-form-label required">回款金额</label>
|
16
16
|
<div class="layui-input-block">
|
17
17
|
<input type="number" name="amount" autocomplete="off" lay-verify="required" lay-reqtext="回款金额不能为空"
|
18
18
|
placeholder="请输入回款金额" value="" class="layui-input" id="return_money_amount">
|
19
19
|
</div>
|
20
20
|
</div>
|
21
|
+
<div class="layui-input-inline" style="width: 0;!important;">
|
22
|
+
<label class="layui-form-label" style="padding-left: 0;width: 10px;!important;">万</label>
|
23
|
+
</div>
|
21
24
|
<div class="layui-input-inline" style="width: 300px;" id="professional_title_div">
|
22
25
|
<label class="layui-form-label required">状态</label>
|
23
26
|
<div class="layui-input-block">
|
@@ -115,7 +118,7 @@
|
|
115
118
|
}, {
|
116
119
|
field: 'amount',
|
117
120
|
width: 200,
|
118
|
-
title: '回款金额',
|
121
|
+
title: '回款金额(万)',
|
119
122
|
edit: true
|
120
123
|
}, {
|
121
124
|
field: 'clazz',
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<script type="text/html" id="activity_toolbar">
|
2
|
+
<div class="layui-btn-container">
|
3
|
+
<span class="table-label">导出记录</span>
|
4
|
+
</div>
|
5
|
+
</script>
|
6
|
+
<div class="min-height-table">
|
7
|
+
<table class="layui-hide" id="activities_table" lay-filter="activities_table"></table>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<script type="text/html" id="currentTableBar">
|
11
|
+
</script>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
layui.use(['form', 'table', 'miniPage', 'element', 'request'], function () {
|
15
|
+
var $ = layui.jquery,
|
16
|
+
form = layui.form,
|
17
|
+
table = layui.table,
|
18
|
+
request = layui.request,
|
19
|
+
miniPage = layui.miniPage;
|
20
|
+
|
21
|
+
table.render({
|
22
|
+
elem: '#activities_table',
|
23
|
+
url: '/missions/businesses/export_records',
|
24
|
+
toolbar: '#activity_toolbar',
|
25
|
+
defaultToolbar: [],
|
26
|
+
cols: [
|
27
|
+
[
|
28
|
+
{
|
29
|
+
field: 'id',
|
30
|
+
title:'序号',type: 'numbers',
|
31
|
+
},
|
32
|
+
{
|
33
|
+
field: 'name',
|
34
|
+
title: '文件名',
|
35
|
+
},
|
36
|
+
{
|
37
|
+
field: 'staff',
|
38
|
+
title: '导出人',
|
39
|
+
},
|
40
|
+
{
|
41
|
+
field: 'created_at',
|
42
|
+
title: '导出时间',
|
43
|
+
},
|
44
|
+
]
|
45
|
+
],
|
46
|
+
limit: 20,
|
47
|
+
limits: [10,15,20,30,40,50,60,70,80,90],
|
48
|
+
page: true
|
49
|
+
});
|
50
|
+
|
51
|
+
|
52
|
+
});
|
53
|
+
</script>
|
@@ -0,0 +1,30 @@
|
|
1
|
+
json.data do
|
2
|
+
json.array! @businesses do |d|
|
3
|
+
json.id d.id
|
4
|
+
json.name d.name
|
5
|
+
json.department d.department.name
|
6
|
+
json.school d.department.school.name
|
7
|
+
json.school_id d.department.school.id
|
8
|
+
follow_ups_count = d.follow_ups.where(deleted_at: nil).size
|
9
|
+
json.follow_ups_count follow_ups_count
|
10
|
+
json.follow_up_id d.last_follow_up_id
|
11
|
+
json.clazz d.last_follow_up&.clazz&.name || ""
|
12
|
+
json.stage d.last_follow_up&.stage&.name
|
13
|
+
json.invitation_at d.last_follow_up&.invitation_at.to_s
|
14
|
+
json.reception_at d.last_follow_up&.reception_at.to_s
|
15
|
+
json.bidded_date d.last_follow_up&.bidded_date.to_s
|
16
|
+
json.signed_date d.last_follow_up&.signed_date.to_s
|
17
|
+
json.total_amount d.last_follow_up&.total_amount
|
18
|
+
json.actual_amount d.last_follow_up&.actual_amount
|
19
|
+
json.return_money d.return_money
|
20
|
+
json.wait_return_money d.wait_return_money.to_i.round(2)
|
21
|
+
json.return_money_days d.last_follow_up&.reception_at.present? && d.last_follow_up.money_plans.where(clazz: '已完成').present? ? (d.last_follow_up.money_plans.where(clazz: '已完成').order(created_at: :asc).first.date_at.to_s(:date).to_date - d.last_follow_up&.reception_at).to_i : ''
|
22
|
+
json.place d.last_follow_up&.place&.name
|
23
|
+
json.last_follow_person d.last_follow_up.present? ? d.last_follow_up.staff.user.real_name : EducodeSales::Staff.find(d.staff_id).user.real_name
|
24
|
+
json.source d.source
|
25
|
+
json.assign_follow_ups d.last_follow_up.present? ? d.last_follow_up.assign_follow_ups.pluck(:staff_id) : []
|
26
|
+
json.current_staff_id @current_admin.id
|
27
|
+
json.staff_id d.staff_id
|
28
|
+
json.latest_time d.last_follow_up.present? ? d.last_follow_up.created_at.to_s : ''
|
29
|
+
end
|
30
|
+
end
|