educode_sales 0.6.3 → 0.6.4
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/images/educode_sales/money_plans.png +0 -0
- data/app/controllers/educode_sales/money_plans_controller.rb +64 -0
- data/app/controllers/educode_sales/roles_controller.rb +4 -1
- data/app/controllers/educode_sales/sale_trends_controller.rb +40 -12
- data/app/controllers/educode_sales/staffs_controller.rb +3 -4
- data/app/models/educode_sales/permission.rb +2 -1
- data/app/models/educode_sales/role_area.rb +1 -0
- data/app/views/educode_sales/businesses/_follows.html.erb +15 -15
- data/app/views/educode_sales/businesses/index.html.erb +6 -2
- data/app/views/educode_sales/businesses/show_follow.html.erb +1 -0
- data/app/views/educode_sales/customers/edit.html.erb +687 -10
- data/app/views/educode_sales/customers/index.json.jbuilder +2 -1
- data/app/views/educode_sales/customers/new.html.erb +688 -11
- data/app/views/educode_sales/money_plans/index.html.erb +183 -0
- data/app/views/educode_sales/money_plans/index.json.jbuilder +20 -0
- data/app/views/educode_sales/plans/_monthPlan.html.erb +2 -1
- data/app/views/educode_sales/plans/_weekPlan.html.erb +2 -1
- data/app/views/educode_sales/roles/edit.html.erb +8 -0
- data/app/views/educode_sales/sale_trends/trends.html.erb +73 -13
- data/app/views/educode_sales/sale_trends/trends.json.jbuilder +3 -14
- data/app/views/educode_sales/sales/index.html.erb +2 -0
- data/app/views/educode_sales/sales/operations.json.jbuilder +2 -2
- data/app/views/layouts/educode_sales/application.html.erb +13 -2
- data/config/routes.rb +2 -0
- data/db/migrate/20210902064109_create_educode_sales_role_permissions.rb +3 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cd066340676e40c41aa18730eacf453f8bf228ceb4416179f0e916581525999
|
4
|
+
data.tar.gz: a30becf3c8cc2c925c21b66948d429a241d3750289f5e921ab3c0cde5aeea3f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adabc609d925eb080964dc566815134c5384f258fde90b7008296ceacf178a1435be37c553f49291844ce7043f6dfc4745f7713da687f40da40871acc67a6f8e
|
7
|
+
data.tar.gz: 042b06433756725fad2b2bd4bb612bca89616f3e18e6055e5c2df4a89d8ece4810f9fe80899047a52c86d60c6e263b14bdb92ee9107efe63bb662ee51dd73041
|
Binary file
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require_dependency "educode_sales/application_controller"
|
2
|
+
|
3
|
+
module EducodeSales
|
4
|
+
class MoneyPlansController < ApplicationController
|
5
|
+
|
6
|
+
def index
|
7
|
+
follow_up_ids = Business.pluck(:last_follow_up_id)
|
8
|
+
authorize! :read, MoneyPlan
|
9
|
+
respond_to do |format|
|
10
|
+
format.html do
|
11
|
+
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
12
|
+
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
13
|
+
end
|
14
|
+
format.json do
|
15
|
+
if @current_admin.is_admin?
|
16
|
+
@money_plans = MoneyPlan.where(follow_up_id: follow_up_ids)
|
17
|
+
else
|
18
|
+
level = @current_admin.role.role_areas.find_by(clazz: '回款管理').level
|
19
|
+
case level
|
20
|
+
when '自己'
|
21
|
+
@money_plans = MoneyPlan.where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.staff_id)
|
22
|
+
when '区域'
|
23
|
+
a_ids = MoneyPlan.where(follow_up_id: follow_up_ids).where(staff_id: @current_admin.staff_id).ids
|
24
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
|
25
|
+
b_ids = Business.where(school_id: school_ids).pluck(:last_follow_up_id)
|
26
|
+
ids = a_ids + b_ids
|
27
|
+
@money_plans = MoneyPlan.where(id: ids)
|
28
|
+
else
|
29
|
+
@money_plans = MoneyPlan.where(follow_up_id: follow_up_ids)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
if params[:q].present? && params[:q][:business].present?
|
34
|
+
follow_up_ids = Business.where("name like ?", "%#{params[:q][:business]}%").pluck(:last_follow_up_id)
|
35
|
+
@money_plans = @money_plans.where(follow_up_id: follow_up_ids)
|
36
|
+
end
|
37
|
+
if params[:q].present? && params[:q][:school].present?
|
38
|
+
school_ids = School.where("name like ?", "%#{params[:q][:school]}%").pluck(:id)
|
39
|
+
follow_up_ids = Business.where(school_id: school_ids).pluck(:last_follow_up_id)
|
40
|
+
@money_plans = @money_plans.where(follow_up_id: follow_up_ids)
|
41
|
+
end
|
42
|
+
if params[:q].present? && params[:q][:staff_id].present?
|
43
|
+
@money_plans = @money_plans.where(staff_id: params[:q][:staff_id])
|
44
|
+
end
|
45
|
+
if params[:q].present? && params[:q][:clazz].present?
|
46
|
+
@money_plans = @money_plans.where(clazz: params[:q][:clazz])
|
47
|
+
end
|
48
|
+
if params[:q].present? && params[:q][:date].present?
|
49
|
+
date = params[:q][:date].split(" - ")
|
50
|
+
@money_plans = @money_plans.where("educode_sales_money_plans.created_at > ? AND educode_sales_money_plans.created_at < ?", date[0], date[1] + '23:59:59')
|
51
|
+
end
|
52
|
+
|
53
|
+
if params[:sort].present? && params[:sort][:field]
|
54
|
+
@money_plans = @money_plans.order("#{params[:sort][:field]} #{params[:sort][:order]}")
|
55
|
+
else
|
56
|
+
@money_plans = @money_plans.order(created_at: :desc)
|
57
|
+
end
|
58
|
+
@total_amount = @money_plans.sum(:amount)
|
59
|
+
@money_plans = @money_plans.page(params[:page]).per(params[:limit])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -16,7 +16,7 @@ module EducodeSales
|
|
16
16
|
|
17
17
|
def create
|
18
18
|
role = Role.new(name: params[:name])
|
19
|
-
role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}])
|
19
|
+
role.role_areas.build([{ clazz: 'Business' }, { clazz: 'SalePlan' }, { clazz: 'Teacher' }, { clazz: 'Operation' }, {clazz:'Customer'}, {clazz:'MoneyPlan'}])
|
20
20
|
if role.save
|
21
21
|
render_success
|
22
22
|
else
|
@@ -81,6 +81,9 @@ module EducodeSales
|
|
81
81
|
r = role.role_areas.find_or_initialize_by(clazz: 'Customer')
|
82
82
|
r.level = params[:customer]
|
83
83
|
r.save
|
84
|
+
r = role.role_areas.find_or_initialize_by(clazz: 'MoneyPlan')
|
85
|
+
r.level = params[:money_plan]
|
86
|
+
r.save
|
84
87
|
render_success
|
85
88
|
end
|
86
89
|
|
@@ -74,18 +74,46 @@ module EducodeSales
|
|
74
74
|
|
75
75
|
#商机区域分布图表
|
76
76
|
provinces = EducodeSales::Common.where(clazz: 'area').pluck(:name)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
77
|
+
if params[:business_count_type] == 'money' || params[:business_count_type].blank?
|
78
|
+
@business_data = {
|
79
|
+
labels: provinces,
|
80
|
+
datasets:[
|
81
|
+
{
|
82
|
+
label: "商机总额",
|
83
|
+
data: provinces.map{|province|
|
84
|
+
if params[:business_type].blank?
|
85
|
+
Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id != ?", x).sum(:total_amount).round(2)
|
86
|
+
else
|
87
|
+
Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id = ?", params[:business_type]).sum(:total_amount).round(2)
|
88
|
+
end
|
89
|
+
},
|
90
|
+
backgroundColor: colors[0],
|
91
|
+
borderColor: colors[0],
|
92
|
+
borderWidth: 1
|
93
|
+
}
|
94
|
+
]
|
95
|
+
}
|
96
|
+
else
|
97
|
+
@business_data = {
|
98
|
+
labels: provinces,
|
99
|
+
datasets:[
|
100
|
+
{
|
101
|
+
label: "商机数量",
|
102
|
+
data: provinces.map{|province|
|
103
|
+
if params[:business_type].blank?
|
104
|
+
Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id != ?", x).count
|
105
|
+
else
|
106
|
+
Business.joins(:last_follow_up).where("educode_sales_businesses.department_id in (?)", School.joins(:departments).where(province: province).pluck("departments.id")).where("educode_sales_follow_ups.clazz_id = ?", params[:business_type]).count
|
107
|
+
end
|
108
|
+
},
|
109
|
+
backgroundColor: colors[0],
|
110
|
+
borderColor: colors[0],
|
111
|
+
borderWidth: 1
|
112
|
+
}
|
113
|
+
]
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
89
117
|
|
90
118
|
|
91
119
|
# 已中标图表
|
@@ -67,14 +67,13 @@ module EducodeSales
|
|
67
67
|
|
68
68
|
def follow_up_schools
|
69
69
|
staff = Staff.find(params[:id])
|
70
|
-
|
71
|
-
@
|
72
|
-
@count = EducodeSales::Business.joins(:last_follow_up, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("departments.school_id").count
|
70
|
+
@schools = EducodeSales::Teacher.joins(:follow_up, :department).where("educode_sales_teacher_follows.staff_id = #{staff.id}").group("departments.school_id").select("departments.school_id, max(educode_sales_teacher_follows.updated_at) AS updated_at") + EducodeSales::Business.joins(:follow_ups, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("departments.school_id").select("departments.school_id, max(educode_sales_follow_ups.updated_at) AS updated_at")
|
71
|
+
@count = EducodeSales::Business.joins(:follow_ups, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("departments.school_id").count
|
73
72
|
end
|
74
73
|
|
75
74
|
def follow_up_departments
|
76
75
|
staff = Staff.find(params[:id])
|
77
|
-
@schools = EducodeSales::Business.joins(:
|
76
|
+
@schools = (EducodeSales::Business.joins(:follow_ups, [department: :school]).where("educode_sales_follow_ups.staff_id = #{staff.id}").select("departments.id, departments.name, schools.name AS school, educode_sales_follow_ups.updated_at") + EducodeSales::Teacher.joins(:follow_up, [department: :school]).where("educode_sales_teacher_follows.staff_id = #{staff.id}").select("departments.id, departments.name, schools.name AS school, educode_sales_teacher_follows.updated_at")).uniq{|s| s.id}
|
78
77
|
end
|
79
78
|
|
80
79
|
|
@@ -100,10 +100,16 @@
|
|
100
100
|
templet:'<div><span title="{{d.description}}">{{d.description}}</span></div>'
|
101
101
|
},
|
102
102
|
{
|
103
|
-
field: '
|
103
|
+
field: 'business',
|
104
104
|
width: 120,
|
105
|
-
title: '
|
106
|
-
templet:'
|
105
|
+
title: '所属商机',
|
106
|
+
templet:'#business'
|
107
|
+
},
|
108
|
+
{
|
109
|
+
field: 'school',
|
110
|
+
width: 120,
|
111
|
+
title: '单位',
|
112
|
+
templet:'#school'
|
107
113
|
},
|
108
114
|
{
|
109
115
|
field: 'clazz',
|
@@ -117,24 +123,18 @@
|
|
117
123
|
width: 90,
|
118
124
|
templet:'<div><span title="{{d.stage}}">{{d.stage}}</span></div>'
|
119
125
|
},
|
126
|
+
{
|
127
|
+
field: 'advise',
|
128
|
+
width: 120,
|
129
|
+
title: '团队建议',
|
130
|
+
templet:'<div><span title="{{d.advise}}">{{d.advise}}</span></div>'
|
131
|
+
},
|
120
132
|
{
|
121
133
|
field: 'key_people',
|
122
134
|
width: 90,
|
123
135
|
title: '关键人',
|
124
136
|
templet:'<div><span title="{{d.key_people}}">{{d.key_people}}</span></div>'
|
125
137
|
},
|
126
|
-
{
|
127
|
-
field: 'business',
|
128
|
-
width: 120,
|
129
|
-
title: '所属商机',
|
130
|
-
templet:'#business'
|
131
|
-
},
|
132
|
-
{
|
133
|
-
field: 'school',
|
134
|
-
width: 120,
|
135
|
-
title: '单位',
|
136
|
-
templet:'#school'
|
137
|
-
},
|
138
138
|
{
|
139
139
|
field: 'staff',
|
140
140
|
width: 90,
|
@@ -28,7 +28,7 @@
|
|
28
28
|
</div>
|
29
29
|
</div>
|
30
30
|
<div class="layui-inline">
|
31
|
-
<label class="layui-form-label"
|
31
|
+
<label class="layui-form-label">最新跟进人</label>
|
32
32
|
<div class="layui-input-inline">
|
33
33
|
<%= select_tag "staff_id", options_for_select(@staffs, params[:staff_id]), { 'lay-filter': 'staff_id', include_blank: true } %>
|
34
34
|
</div>
|
@@ -58,7 +58,7 @@
|
|
58
58
|
</div>
|
59
59
|
</div>
|
60
60
|
<div class="layui-inline">
|
61
|
-
<label class="layui-form-label"
|
61
|
+
<label class="layui-form-label">创建时间</label>
|
62
62
|
<div class="layui-input-inline">
|
63
63
|
<input type="text" class="layui-input" id="date" name="date" placeholder=" - ">
|
64
64
|
</div>
|
@@ -189,6 +189,10 @@
|
|
189
189
|
defaultToolbar: ['filter'],
|
190
190
|
toolbar: '#bussinessBar',
|
191
191
|
totalRow: true,//开启合并行
|
192
|
+
initSort: {
|
193
|
+
field: 'latest_time' //排序字段,对应 cols 设定的各字段名
|
194
|
+
,type: 'desc' //排序方式 asc: 升序、desc: 降序、null: 默认排序
|
195
|
+
},
|
192
196
|
cols: [
|
193
197
|
[
|
194
198
|
{
|