educode_sales 0.1.0 → 0.1.1
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 +7 -1
- data/app/controllers/educode_sales/application_controller.rb +0 -1
- data/app/controllers/educode_sales/businesses_controller.rb +3 -2
- data/app/controllers/educode_sales/operation_plans_controller.rb +155 -0
- data/app/controllers/educode_sales/operation_reports_controller.rb +125 -0
- data/app/controllers/educode_sales/places_controller.rb +1 -0
- data/app/controllers/educode_sales/plans_controller.rb +3 -1
- data/app/controllers/educode_sales/sale_reports_controller.rb +2 -1
- data/app/controllers/educode_sales/sales_controller.rb +4 -1
- data/app/controllers/educode_sales/teacher_follows_controller.rb +6 -0
- data/app/controllers/educode_sales/teachers_controller.rb +17 -5
- data/app/models/ability.rb +4 -1
- data/app/models/educode_sales/common.rb +1 -0
- data/app/models/educode_sales/staff.rb +2 -0
- data/app/views/educode_sales/activities/index.html.erb +17 -8
- data/app/views/educode_sales/businesses/index.html.erb +136 -140
- data/app/views/educode_sales/businesses/show_follow.html.erb +18 -3
- data/app/views/educode_sales/operation_plans/_monthPlan.html.erb +60 -76
- data/app/views/educode_sales/operation_plans/_monthly.html.erb +116 -95
- data/app/views/educode_sales/operation_plans/_weekPlan.html.erb +73 -74
- data/app/views/educode_sales/operation_plans/_weekly.html.erb +108 -86
- data/app/views/educode_sales/operation_plans/edit_month.html.erb +35 -32
- data/app/views/educode_sales/operation_plans/edit_week.html.erb +40 -39
- data/app/views/educode_sales/operation_plans/index.json.jbuilder +19 -0
- data/app/views/educode_sales/operation_plans/my_month.json.jbuilder +18 -0
- data/app/views/educode_sales/operation_plans/my_week.json.jbuilder +19 -0
- data/app/views/educode_sales/operation_plans/new_month.html.erb +5 -10
- data/app/views/educode_sales/operation_plans/new_monthly.html.erb +27 -43
- data/app/views/educode_sales/operation_plans/new_week.html.erb +7 -7
- data/app/views/educode_sales/operation_plans/new_weekly.html.erb +46 -53
- data/app/views/educode_sales/operation_plans/show_month.html.erb +4 -10
- data/app/views/educode_sales/operation_plans/show_week.html.erb +20 -25
- data/app/views/educode_sales/operation_plans/show_weekly.html.erb +6 -6
- data/app/views/educode_sales/operation_reports/audit.html.erb +214 -0
- data/app/views/educode_sales/operation_reports/edit.html.erb +237 -0
- data/app/views/educode_sales/operation_reports/index.json.jbuilder +17 -0
- data/app/views/educode_sales/operation_reports/plans.json.jbuilder +19 -0
- data/app/views/educode_sales/operation_reports/show.html.erb +139 -0
- data/app/views/educode_sales/operations/trends.html.erb +8 -0
- data/app/views/educode_sales/places/index.html.erb +6 -0
- data/app/views/educode_sales/plans/_monthPlan.html.erb +8 -0
- data/app/views/educode_sales/plans/_monthly.html.erb +8 -0
- data/app/views/educode_sales/plans/_weekPlan.html.erb +10 -3
- data/app/views/educode_sales/plans/_weekly.html.erb +8 -0
- data/app/views/educode_sales/plans/audit_weekly.html.erb +6 -0
- data/app/views/educode_sales/plans/edit_monthly.html.erb +8 -0
- data/app/views/educode_sales/plans/edit_weekly.html.erb +8 -0
- data/app/views/educode_sales/plans/new_monthly.html.erb +8 -0
- data/app/views/educode_sales/plans/new_weekly.html.erb +7 -1
- data/app/views/educode_sales/sale_trends/trends.html.erb +8 -0
- data/app/views/educode_sales/teachers/index.html.erb +3 -5
- data/app/views/layouts/educode_sales/application.html.erb +23 -2
- data/config/routes.rb +11 -4
- data/lib/educode_sales/version.rb +1 -1
- metadata +14 -5
@@ -21,11 +21,23 @@ module EducodeSales
|
|
21
21
|
def index
|
22
22
|
respond_to do |format|
|
23
23
|
format.html do
|
24
|
-
|
25
|
-
# @teachers = Teacher.joins(:user).map { |d| [d.user.real_name, d.id] }
|
26
24
|
end
|
27
25
|
format.json do
|
28
|
-
@
|
26
|
+
if @current_admin.is_admin?
|
27
|
+
@teachers = Teacher.where(is_key: false)
|
28
|
+
else
|
29
|
+
level = @current_admin.role.role_areas.find_by(clazz: '教师运营').level
|
30
|
+
case level
|
31
|
+
when '自己'
|
32
|
+
@teachers = Teacher.where(is_key: false)
|
33
|
+
@teachers = @teachers.where(staff_id: @current_admin.id)
|
34
|
+
when '区域'
|
35
|
+
school_ids = School.where(province: @current_admin.areas.pluck(:name)).pluck(:id)
|
36
|
+
@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)
|
37
|
+
else
|
38
|
+
@teachers = Teacher.where(is_key: false)
|
39
|
+
end
|
40
|
+
end
|
29
41
|
|
30
42
|
if params[:q].present? && params[:q][:name].present?
|
31
43
|
@teachers = @teachers.where("educode_sales_teachers.name like ?", "%#{params[:q][:name]}%")
|
@@ -36,8 +48,8 @@ module EducodeSales
|
|
36
48
|
if params[:q].present? && params[:q][:regist_at].present?
|
37
49
|
@teachers = @teachers.where("educode_sales_teachers.regist_at like ?", "%#{params[:q][:regist_at]}%")
|
38
50
|
end
|
39
|
-
if params[:q].present? && params[:q][:
|
40
|
-
@teachers = @teachers.where("educode_sales_teachers.attitude_id = ?", "#{params[:q][:
|
51
|
+
if params[:q].present? && params[:q][:attitude].present?
|
52
|
+
@teachers = @teachers.where("educode_sales_teachers.attitude_id = ?", "#{params[:q][:attitude]}")
|
41
53
|
end
|
42
54
|
if params[:q].present? && params[:q][:teacher_source].present?
|
43
55
|
@teachers = @teachers.where("educode_sales_teachers.source_id = ?", "#{params[:q][:teacher_source]}")
|
data/app/models/ability.rb
CHANGED
@@ -6,11 +6,14 @@
|
|
6
6
|
#
|
7
7
|
# user ||= User.new # guest user (not logged in)
|
8
8
|
alias_action :index, :trends, :show, :to => :read
|
9
|
-
|
9
|
+
p "----------"
|
10
|
+
p staff.is_admin
|
10
11
|
if staff.is_admin
|
11
12
|
can :manage, :all
|
12
13
|
else
|
13
14
|
staff.role.permissions.each do |ps|
|
15
|
+
p ps.action
|
16
|
+
p "EducodeSales::#{ps.subject}".constantize
|
14
17
|
can ps.action.to_sym, "EducodeSales::#{ps.subject}".constantize
|
15
18
|
# level = @current_admin.role.role_areas.find_by(clazz: 'name')&.level
|
16
19
|
# if level == '自己'
|
@@ -5,6 +5,8 @@ module EducodeSales
|
|
5
5
|
|
6
6
|
has_many :market_areas, dependent: :destroy
|
7
7
|
has_many :sale_plans, dependent: :restrict_with_exception
|
8
|
+
has_many :operation_plans, dependent: :restrict_with_exception
|
9
|
+
has_many :operation_reports, dependent: :restrict_with_exception
|
8
10
|
has_many :sale_reports, dependent: :restrict_with_exception
|
9
11
|
has_many :follow_ups, dependent: :restrict_with_exception
|
10
12
|
has_many :teacher_follows, dependent: :restrict_with_exception
|
@@ -5,7 +5,7 @@
|
|
5
5
|
</div>
|
6
6
|
</script>
|
7
7
|
|
8
|
-
<table class="layui-hide" id="
|
8
|
+
<table class="layui-hide" id="activities_table" lay-filter="activities_table"></table>
|
9
9
|
|
10
10
|
<script type="text/html" id="currentTableBar">
|
11
11
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
|
@@ -28,7 +28,7 @@
|
|
28
28
|
miniPage = layui.miniPage;
|
29
29
|
|
30
30
|
table.render({
|
31
|
-
elem: '#
|
31
|
+
elem: '#activities_table',
|
32
32
|
url: '/educode_sales/activities',
|
33
33
|
toolbar: '#activity_toolbar',
|
34
34
|
defaultToolbar: [],
|
@@ -47,6 +47,7 @@
|
|
47
47
|
},
|
48
48
|
{
|
49
49
|
field: 'start_at',
|
50
|
+
width: 180,
|
50
51
|
title: '时间',
|
51
52
|
sort: true,
|
52
53
|
},
|
@@ -85,10 +86,18 @@
|
|
85
86
|
page: true
|
86
87
|
});
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
89
|
+
var sort = {};
|
90
|
+
table.on('sort(activities_table)', function (obj) {
|
91
|
+
sort.field = obj.field;
|
92
|
+
sort.order = obj.type;
|
93
|
+
table.reload('activities_table', {
|
94
|
+
initSort: obj,
|
95
|
+
where: {
|
96
|
+
sort: sort
|
97
|
+
}
|
98
|
+
});
|
99
|
+
})
|
100
|
+
table.on('toolbar(activities_table)', function (obj) {
|
92
101
|
if (obj.event === 'add') { // 监听添加操作
|
93
102
|
var content = miniPage.getHrefContent('/educode_sales/activities/new');
|
94
103
|
var openWH = miniPage.getOpenWidthHeight();
|
@@ -111,7 +120,7 @@
|
|
111
120
|
}
|
112
121
|
});
|
113
122
|
|
114
|
-
table.on('tool(
|
123
|
+
table.on('tool(activities_table)', function (obj) {
|
115
124
|
var data = obj.data;
|
116
125
|
var id = data.id
|
117
126
|
if (obj.event === 'edit') {
|
@@ -141,7 +150,7 @@
|
|
141
150
|
layer.confirm('确定删除' + data.name, function (index) {
|
142
151
|
request.delete('educode_sales/activities/' + data.id, {}, function (res) {
|
143
152
|
layer.close(index);
|
144
|
-
table.reload("
|
153
|
+
table.reload("activities_table")
|
145
154
|
})
|
146
155
|
});
|
147
156
|
} else if (obj.event === 'teachers') {
|
@@ -65,14 +65,22 @@
|
|
65
65
|
<script type="text/html" id="bussinessBar">
|
66
66
|
<div class="layui-btn-container">
|
67
67
|
<span class="table-label">商机列表</span>
|
68
|
+
<% if can? :create, EducodeSales::Business %>
|
68
69
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add"> 添加商机</button>
|
70
|
+
<% end %>
|
69
71
|
</div>
|
70
72
|
</script>
|
71
73
|
<script type="text/html" id="currentTableBar">
|
74
|
+
<% if can? :create, EducodeSales::SalePlan %>
|
72
75
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="addWeek">添加周计划</a>
|
73
76
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="addMonth">添加月计划</a>
|
77
|
+
<% end %>
|
78
|
+
<% if can? :update, EducodeSales::Business %>
|
74
79
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
|
80
|
+
<% end %>
|
81
|
+
<% if can? :destroy, EducodeSales::SalePlan %>
|
75
82
|
<a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
|
83
|
+
<% end %>
|
76
84
|
</script>
|
77
85
|
<script type="text/html" id="show_keys">
|
78
86
|
<a href="javascript:void(0);" lay-event="show_keys" class="layui-table-link">{{ d.teachers_count }}</a>
|
@@ -83,154 +91,146 @@
|
|
83
91
|
|
84
92
|
|
85
93
|
<script>
|
86
|
-
layui.use('laydate', function () {
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
});
|
93
|
-
})
|
94
|
+
layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate'], function () {
|
95
|
+
var $ = layui.jquery,
|
96
|
+
form = layui.form,
|
97
|
+
request = layui.request,
|
98
|
+
miniPage = layui.miniPage,
|
99
|
+
laydate = layui.laydate;
|
94
100
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
miniPage = layui.miniPage;
|
101
|
+
laydate.render({
|
102
|
+
elem: '#date',
|
103
|
+
range: true
|
104
|
+
});
|
100
105
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
106
|
+
table = layui.table;
|
107
|
+
table.render({
|
108
|
+
elem: '#businesses_table',
|
109
|
+
url: '/educode_sales/businesses',
|
110
|
+
where: {q: form.val('search_form')},
|
111
|
+
toolbar: '#bussinessBar',
|
112
|
+
defaultToolbar: [],
|
113
|
+
cols: [
|
114
|
+
[
|
115
|
+
{
|
116
|
+
field: 'id',
|
117
|
+
width: 60,
|
118
|
+
title: '序号',
|
119
|
+
},
|
120
|
+
{
|
121
|
+
field: 'name',
|
122
|
+
width: 170,
|
123
|
+
title: '名称'
|
124
|
+
},
|
125
|
+
{
|
126
|
+
field: 'school',
|
127
|
+
width: 200,
|
128
|
+
title: '单位',
|
129
|
+
},
|
130
|
+
{
|
131
|
+
field: 'department',
|
132
|
+
width: 140,
|
133
|
+
title: '部门'
|
134
|
+
},
|
135
|
+
{
|
136
|
+
field: 'follow_ups_count',
|
137
|
+
title: '跟进',
|
138
|
+
width: 60,
|
139
|
+
templet: '#show_follow'
|
140
|
+
},
|
141
|
+
{
|
142
|
+
field: 'teachers_count',
|
143
|
+
width: 100,
|
144
|
+
title: '关键人',
|
145
|
+
templet: '#show_keys'
|
146
|
+
},
|
147
|
+
{
|
148
|
+
field: 'clazz',
|
149
|
+
width: 80,
|
150
|
+
title: '类型'
|
151
|
+
},
|
152
|
+
{
|
153
|
+
field: 'stage',
|
154
|
+
width: 100,
|
155
|
+
title: '阶段'
|
156
|
+
},
|
157
|
+
{
|
158
|
+
field: 'invitation_at',
|
159
|
+
width: 120,
|
160
|
+
title: '招标时间',
|
161
|
+
sort: true
|
162
|
+
},
|
163
|
+
{
|
164
|
+
field: 'reception_at',
|
165
|
+
width: 120,
|
166
|
+
title: '验收时间',
|
167
|
+
sort: true
|
168
|
+
},
|
169
|
+
{
|
170
|
+
field: 'total_amount',
|
171
|
+
width: 100,
|
172
|
+
title: '总额(万)',
|
173
|
+
sort: true
|
174
|
+
},
|
175
|
+
{
|
176
|
+
field: 'return_money',
|
177
|
+
width: 100,
|
178
|
+
title: '回款(万)',
|
179
|
+
sort: true
|
180
|
+
},
|
181
|
+
{
|
182
|
+
field: 'place',
|
183
|
+
width: 110,
|
184
|
+
title: '渠道'
|
185
|
+
},
|
186
|
+
{
|
187
|
+
title: '操作',
|
188
|
+
minWidth: 300,
|
189
|
+
toolbar: '#currentTableBar',
|
190
|
+
align: "center",
|
191
|
+
fixed: 'right'
|
192
|
+
}
|
193
|
+
]
|
194
|
+
],
|
195
|
+
page: true,
|
196
|
+
skin: 'line'
|
197
|
+
});
|
141
198
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
},
|
153
|
-
{
|
154
|
-
field: 'invitation_at',
|
155
|
-
width: 120,
|
156
|
-
title: '招标时间',
|
157
|
-
sort: true
|
158
|
-
},
|
159
|
-
{
|
160
|
-
field: 'reception_at',
|
161
|
-
width: 120,
|
162
|
-
title: '验收时间',
|
163
|
-
sort: true
|
164
|
-
},
|
165
|
-
{
|
166
|
-
field: 'total_amount',
|
167
|
-
width: 100,
|
168
|
-
title: '总额(万)',
|
169
|
-
sort: true
|
170
|
-
},
|
171
|
-
{
|
172
|
-
field: 'return_money',
|
173
|
-
width: 100,
|
174
|
-
title: '回款(万)',
|
175
|
-
sort: true
|
176
|
-
},
|
177
|
-
{
|
178
|
-
field: 'place',
|
179
|
-
width: 110,
|
180
|
-
title: '渠道'
|
181
|
-
},
|
182
|
-
{
|
183
|
-
title: '操作',
|
184
|
-
minWidth: 300,
|
185
|
-
toolbar: '#currentTableBar',
|
186
|
-
align: "center",
|
187
|
-
fixed: 'right'
|
188
|
-
}
|
189
|
-
]
|
190
|
-
],
|
191
|
-
page: true,
|
192
|
-
skin: 'line'
|
199
|
+
var sort = {}, search = {};
|
200
|
+
table.on('sort(businesses_table)', function (obj) {
|
201
|
+
sort.field = obj.field;
|
202
|
+
sort.order = obj.type;
|
203
|
+
table.reload('businesses_table', {
|
204
|
+
initSort: obj,
|
205
|
+
where: {
|
206
|
+
sort: sort,
|
207
|
+
q: search
|
208
|
+
}
|
193
209
|
});
|
194
|
-
|
195
|
-
var sort = {}, search = {};
|
196
|
-
table.on('sort(businesses_table)', function (obj) {
|
197
|
-
sort.field = obj.field;
|
198
|
-
sort.order = obj.type;
|
199
|
-
table.reload('businesses_table', {
|
200
|
-
initSort: obj,
|
201
|
-
where: {
|
202
|
-
sort: sort,
|
203
|
-
q: search
|
204
|
-
}
|
205
|
-
});
|
206
|
-
})
|
210
|
+
})
|
207
211
|
|
208
212
|
// 监听搜索操作
|
209
213
|
form.on('submit(search_bussiness)', function (data) {
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
}, 'data');
|
214
|
+
search = data.field
|
215
|
+
table.reload('businesses_table', {
|
216
|
+
page: {
|
217
|
+
curr: 1
|
218
|
+
},
|
219
|
+
where: {q: search, sort: sort}
|
220
|
+
}, 'data');
|
218
221
|
|
219
|
-
|
222
|
+
return false;
|
220
223
|
});
|
221
224
|
|
222
225
|
form.on('submit(reset_business_search)', function (data) {
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
226
|
+
var field = data.field;
|
227
|
+
form.val('search_form', {
|
228
|
+
name: '', department: '', staff_id: '', business_type: '', business_step: '',
|
229
|
+
place_id: '', date: '', area: ''
|
230
|
+
})
|
231
|
+
return false;
|
229
232
|
});
|
230
233
|
|
231
|
-
/**
|
232
|
-
* toolbar事件监听
|
233
|
-
*/
|
234
234
|
table.on('toolbar(businesses_table)', function (obj) {
|
235
235
|
if (obj.event === 'add') { // 监听添加操作
|
236
236
|
var content = miniPage.getHrefContent('/educode_sales/businesses/new');
|
@@ -348,11 +348,7 @@
|
|
348
348
|
shadeClose: true,
|
349
349
|
area: [openWH[0] + 'px', openWH[1] + 'px'],
|
350
350
|
offset: [openWH[2] + 'px', openWH[3] + 'px'],
|
351
|
-
content: content
|
352
|
-
success: function (layero, index) {
|
353
|
-
// 重新渲染弹层中的下拉选择框select
|
354
|
-
// form.render('select');
|
355
|
-
}
|
351
|
+
content: content
|
356
352
|
});
|
357
353
|
$(window).on("resize", function () {
|
358
354
|
layer.full(index);
|