educode_sales 0.9.41 → 0.9.43
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/indexlogo.png +0 -0
- data/app/controllers/educode_sales/customers_controller.rb +59 -25
- data/app/controllers/educode_sales/staffs_controller.rb +24 -11
- data/app/models/ability.rb +1 -1
- data/app/models/educode_sales/staff.rb +9 -0
- data/app/models/educode_sales/staff_permission.rb +6 -0
- data/app/views/educode_sales/customers/edit.html.erb +14 -5
- data/app/views/educode_sales/customers/index.html.erb +33 -30
- data/app/views/educode_sales/customers/index.json.jbuilder +11 -8
- data/app/views/educode_sales/staffs/edit.html.erb +81 -16
- data/db/migrate/20230209102302_create_educode_sales_staff_permissions.rb +10 -0
- data/lib/educode_sales/version.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 392c1371a9b0cb569b25de476461924555a2d8b077a2864f1bc33145ae65bc61
|
4
|
+
data.tar.gz: 250898b5906ea9b92a41eb4bef8b9ecba8e254bcd574d37d4cdc8cdd11f25811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b66b2ee6d89ef9f63bd035843df5c6724bb34108320dbd9c2af6d3706ccc91e5a3af9940bd22eca06779e2f6ecebeb9e816beea8fb78c967cfb620666e45df9d
|
7
|
+
data.tar.gz: 2d0f88851293f938355a04ed9c8c90dceaf126dd8df3b4cd8a18c675dbd158203132dbd9e3f504c2803c25c4bb3fc57c0086372871bd3b193fc4f3ddc55cba08
|
Binary file
|
@@ -6,38 +6,39 @@ module EducodeSales
|
|
6
6
|
def new_department
|
7
7
|
render layout: false
|
8
8
|
end
|
9
|
+
|
9
10
|
def create_department
|
10
|
-
|
11
|
-
|
11
|
+
department_name = params[:department_name].to_s.strip
|
12
|
+
school = School.find(params[:school_id])
|
12
13
|
|
13
|
-
|
14
|
+
return render_failure('部门名称重复') if school.departments.exists?(name: department_name)
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
ActiveRecord::Base.transaction do
|
17
|
+
department = school.departments.create!(name: department_name, is_auth: 1)
|
18
|
+
ApplyAddDepartment.create!(school_id: school.id, status: 1, name: department.name,
|
19
|
+
department_id: department.id, user_id: current_user.id)
|
20
|
+
end
|
20
21
|
|
21
|
-
|
22
|
+
render_success
|
22
23
|
end
|
23
24
|
|
24
25
|
def edit_department
|
25
26
|
@department = Department.find(params[:id])
|
26
27
|
render layout: false
|
27
28
|
end
|
29
|
+
|
28
30
|
def update_department
|
29
31
|
department = Department.find(params[:id])
|
30
32
|
department.update(name: params[:department_name])
|
31
33
|
render_success
|
32
34
|
end
|
33
35
|
|
34
|
-
|
35
36
|
def index
|
36
37
|
authorize! :read, Customer
|
37
38
|
respond_to do |format|
|
38
39
|
format.html do
|
39
40
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
40
|
-
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
41
|
+
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id] }
|
41
42
|
end
|
42
43
|
format.json do
|
43
44
|
if @current_admin.is_admin?
|
@@ -46,11 +47,11 @@ module EducodeSales
|
|
46
47
|
level = @current_admin.role.role_areas.find_by(clazz: '客户管理').level
|
47
48
|
case level
|
48
49
|
when '自己'
|
49
|
-
school_ids = CustomerExtension.where(customer_staff_id:
|
50
|
+
school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
|
50
51
|
@customers = School.where(id: school_ids)
|
51
52
|
when '区域'
|
52
53
|
a_school_ids = School.where(province: @current_admin.areas.pluck(:name)).ids
|
53
|
-
b_school_ids = CustomerExtension.where(customer_staff_id:
|
54
|
+
b_school_ids = CustomerExtension.where(customer_staff_id: @current_admin.id).pluck(:school_id)
|
54
55
|
school_ids = a_school_ids + b_school_ids + StaffSchool.where(staff_id: @current_admin.id).pluck(:school_id)
|
55
56
|
@customers = School.where(id: school_ids)
|
56
57
|
else
|
@@ -59,7 +60,7 @@ module EducodeSales
|
|
59
60
|
end
|
60
61
|
part_a_ids = CustomerFollow.all.pluck(:school_id)
|
61
62
|
part_b_ids = Business.where(id: EducodeSales::FollowUp.pluck(:business_id)).pluck(:school_id)
|
62
|
-
ids = part_a_ids + part_b_ids
|
63
|
+
ids = part_a_ids + part_b_ids + CustomerAdd.all.pluck(:school_id)
|
63
64
|
@customers = @customers.where(id: ids)
|
64
65
|
if params[:q].present? && params[:q][:name].present?
|
65
66
|
@customers = @customers.where("schools.name like ?", "%#{params[:q][:name]}%")
|
@@ -77,19 +78,25 @@ module EducodeSales
|
|
77
78
|
property.each do |p|
|
78
79
|
case p
|
79
80
|
when 0
|
80
|
-
school_property_ids += SchoolProperty.where(
|
81
|
+
school_property_ids += SchoolProperty.where(project_985: true).ids
|
81
82
|
when 1
|
82
|
-
school_property_ids += SchoolProperty.where(
|
83
|
+
school_property_ids += SchoolProperty.where(project_211: true).ids
|
83
84
|
when 2
|
84
|
-
school_property_ids += SchoolProperty.where(
|
85
|
+
school_property_ids += SchoolProperty.where(regular_college: true).ids
|
85
86
|
when 3
|
86
|
-
school_property_ids += SchoolProperty.where(
|
87
|
+
school_property_ids += SchoolProperty.where(junior_college: true).ids
|
87
88
|
when 4
|
88
|
-
school_property_ids += SchoolProperty.where(
|
89
|
+
school_property_ids += SchoolProperty.where(secondary_school: true).ids
|
89
90
|
when 5
|
90
|
-
school_property_ids += SchoolProperty.where(
|
91
|
+
school_property_ids += SchoolProperty.where(military_school: true).ids
|
91
92
|
when 6
|
92
|
-
school_property_ids += SchoolProperty.where(
|
93
|
+
school_property_ids += SchoolProperty.where(enterprise: true).ids
|
94
|
+
when 7
|
95
|
+
school_property_ids += SchoolProperty.where(mid_school: true).ids
|
96
|
+
when 8
|
97
|
+
school_property_ids += SchoolProperty.where(ele_school: true).ids
|
98
|
+
when 9
|
99
|
+
school_property_ids += SchoolProperty.where(other: true).ids
|
93
100
|
else
|
94
101
|
end
|
95
102
|
end
|
@@ -99,7 +106,7 @@ module EducodeSales
|
|
99
106
|
if params[:q].present? && params[:q][:date].present?
|
100
107
|
ids = EducodeSales::CustomerFollow.all.pluck(:school_id)
|
101
108
|
@customers = @customers.where(id: ids)
|
102
|
-
school_ids =[]
|
109
|
+
school_ids = []
|
103
110
|
date = params[:q][:date].split(" - ")
|
104
111
|
@customers.each do |d|
|
105
112
|
business_ids = EducodeSales::Business.where(school_id: d.id).ids
|
@@ -127,7 +134,7 @@ module EducodeSales
|
|
127
134
|
|
128
135
|
def give
|
129
136
|
common = Common.find_by(clazz: 'staff_type', name: '销售')
|
130
|
-
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id]}
|
137
|
+
@staffs = Staff.joins(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id] }
|
131
138
|
render layout: false
|
132
139
|
end
|
133
140
|
|
@@ -154,7 +161,6 @@ module EducodeSales
|
|
154
161
|
@departments = @departments.page(params[:page]).per(params[:limit])
|
155
162
|
end
|
156
163
|
|
157
|
-
|
158
164
|
def new_follow_record
|
159
165
|
@school = School.find(params[:id])
|
160
166
|
render layout: false
|
@@ -215,17 +221,45 @@ module EducodeSales
|
|
215
221
|
junior_college: params[:junior_college].present? ? 1 : 0,
|
216
222
|
secondary_school: params[:secondary_school].present? ? 1 : 0,
|
217
223
|
military_school: params[:military_school].present? ? 1 : 0,
|
224
|
+
other: params[:other].present? ? 1 : 0,
|
225
|
+
mid_school: params[:mid_school].present? ? 1 : 0,
|
226
|
+
ele_school: params[:ele_school].present? ? 1 : 0,
|
218
227
|
enterprise: params[:enterprise].present? ? 1 : 0)
|
219
228
|
@school.attributes = school_params
|
220
229
|
@school.school_property = property
|
221
230
|
@school.save!
|
231
|
+
|
232
|
+
#先删除全部的标签,再添加标签
|
233
|
+
missions_school_tags = SchoolTag.where(for_missions: true)
|
234
|
+
SchoolTagMiddle.where(school_id: @school.id, school_tag_id: missions_school_tags.ids).destroy_all
|
235
|
+
#保存学校标签
|
236
|
+
|
237
|
+
keys = %w[regular_college junior_college secondary_school military_school other mid_school ele_school enterprise]
|
238
|
+
names = {
|
239
|
+
"regular_college" => "本科院校",
|
240
|
+
"junior_college" => "高职院校",
|
241
|
+
"secondary_school" => "中职院校",
|
242
|
+
"military_school" => "军事院校",
|
243
|
+
"other" => "其他",
|
244
|
+
"mid_school" => "中学",
|
245
|
+
"ele_school" => "小学",
|
246
|
+
"enterprise" => "企业"
|
247
|
+
}
|
248
|
+
property.attributes.each do |key, value|
|
249
|
+
next unless key.in?(keys)
|
250
|
+
next unless value.to_s == "true"
|
251
|
+
school_tag = SchoolTag.find_by_name(names[key])
|
252
|
+
if school_tag.present?
|
253
|
+
SchoolTagMiddle.create(school_id: @school.id, school_tag_id: school_tag.id)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
222
257
|
end
|
223
258
|
render_success
|
224
259
|
end
|
225
260
|
|
226
261
|
private
|
227
262
|
|
228
|
-
|
229
263
|
def school_property_params
|
230
264
|
params.permit(:project_985, :project_211, :regular_college, :junior_college, :secondary_school, :military_school, :enterprise)
|
231
265
|
end
|
@@ -45,6 +45,7 @@ module EducodeSales
|
|
45
45
|
|
46
46
|
def edit
|
47
47
|
@staff = Staff.find(params[:id])
|
48
|
+
@permissions = @staff.permissions.pluck(:id)
|
48
49
|
gon.area_ids = @staff.area_ids
|
49
50
|
gon.areas = Common.where(clazz: 'area').map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'})
|
50
51
|
gon.school_ids = @staff.staff_schools.ids
|
@@ -53,7 +54,8 @@ module EducodeSales
|
|
53
54
|
# gon.schools = School.all.first(100).map { |d| { value: d.id, title: d.name } } #.unshift({value: -1, title: '全国'})
|
54
55
|
@staff_types = Common.where(clazz: 'staff_type').pluck(:name, :id)
|
55
56
|
tag_ids = @staff.staff_school_tags.pluck(:school_tag_id)
|
56
|
-
|
57
|
+
names = %w[本科院校 军事院校 高职院校 中职院校 中学 小学 企业 其他]
|
58
|
+
gon.school_properties = SchoolTag.where(for_missions: true).sort_by { |tag| names.index(tag.name) }.map { |d| { value: d.id, name: d.name, selected: tag_ids.include?(d.id) } }
|
57
59
|
render layout: false
|
58
60
|
end
|
59
61
|
|
@@ -67,8 +69,8 @@ module EducodeSales
|
|
67
69
|
impressionist(staff, params)
|
68
70
|
staff.update(deleted_at: Time.now, expired_at: Time.now.days_ago(1))
|
69
71
|
render_success
|
70
|
-
|
71
|
-
|
72
|
+
# rescue ActiveRecord::DeleteRestrictionError => e
|
73
|
+
# render_failure '该用户已有数据产生,暂不能删除'
|
72
74
|
end
|
73
75
|
|
74
76
|
def disable
|
@@ -84,13 +86,13 @@ module EducodeSales
|
|
84
86
|
staff.assign_attributes(role_id: params[:role_id], job_type: params[:job_type], enabled_at: params[:enabled_at])
|
85
87
|
staff.expired_at = staff.enabled_at.months_since(params[:month].to_i)
|
86
88
|
commons = []
|
87
|
-
params[:area_ids].each do |d|
|
89
|
+
params[:area_ids].to_s.split(",").each do |d|
|
88
90
|
commons << Common.find(d)
|
89
91
|
end
|
90
92
|
staff.areas = commons
|
91
93
|
if params[:school_ids].present?
|
92
94
|
schools = []
|
93
|
-
params[:school_ids].each do |d|
|
95
|
+
params[:school_ids].to_s.split(",").each do |d|
|
94
96
|
schools << EducodeSales::StaffSchool.find_or_initialize_by(staff_id: staff.id, school_id: d)
|
95
97
|
end
|
96
98
|
staff.staff_schools = schools
|
@@ -98,10 +100,22 @@ module EducodeSales
|
|
98
100
|
staff.staff_schools.destroy_all
|
99
101
|
end
|
100
102
|
tags = []
|
101
|
-
params[:school_tag_ids].each do |tag_id|
|
102
|
-
|
103
|
+
params[:school_tag_ids].to_s.split(",").each do |tag_id|
|
104
|
+
tags << EducodeSales::StaffSchoolTag.find_or_initialize_by(staff_id: staff.id, school_tag_id: tag_id)
|
105
|
+
end
|
106
|
+
#人员额外权限
|
107
|
+
permissions = []
|
108
|
+
if params[:permission].present?
|
109
|
+
params[:permission].each do |d|
|
110
|
+
d[1].each do |c|
|
111
|
+
permissions << Permission.find_by(subject: d[0], action: c[1])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
staff.staff_permissions.delete_all
|
116
|
+
permissions.each do |permission|
|
117
|
+
staff.staff_permissions.create(staff_id: staff.id, permission_id: permission.id)
|
103
118
|
end
|
104
|
-
|
105
119
|
staff.staff_school_tags = tags
|
106
120
|
params[:current_admin] = @current_admin.id
|
107
121
|
impressionist(staff, params)
|
@@ -115,14 +129,13 @@ module EducodeSales
|
|
115
129
|
def follow_up_schools
|
116
130
|
staff = Staff.find(params[:id])
|
117
131
|
@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")
|
118
|
-
@count =
|
132
|
+
@count = EducodeSales::Business.joins(:follow_ups, :department).where("educode_sales_follow_ups.staff_id = #{staff.id}").group("departments.school_id").count
|
119
133
|
end
|
120
134
|
|
121
135
|
def follow_up_departments
|
122
136
|
staff = Staff.find(params[:id])
|
123
|
-
@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}
|
137
|
+
@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 }
|
124
138
|
end
|
125
139
|
|
126
|
-
|
127
140
|
end
|
128
141
|
end
|
data/app/models/ability.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
if staff.is_admin
|
10
10
|
can :manage, :all
|
11
11
|
else
|
12
|
-
staff.
|
12
|
+
staff.all_permissions.each do |ps|
|
13
13
|
can ps.action.to_sym, "EducodeSales::#{ps.subject}".constantize
|
14
14
|
# level = @current_admin.role.role_areas.find_by(clazz: 'name')&.level
|
15
15
|
# if level == '自己'
|
@@ -5,6 +5,10 @@ module EducodeSales
|
|
5
5
|
|
6
6
|
is_impressionable
|
7
7
|
|
8
|
+
|
9
|
+
has_many :staff_permissions, dependent: :destroy
|
10
|
+
has_many :permissions, through: :staff_permissions
|
11
|
+
|
8
12
|
has_many :follow_ups, dependent: :destroy
|
9
13
|
has_many :operation_plans, dependent: :destroy
|
10
14
|
has_many :operation_reports, dependent: :destroy
|
@@ -31,6 +35,11 @@ module EducodeSales
|
|
31
35
|
"login_user_#{self.id}"
|
32
36
|
end
|
33
37
|
|
38
|
+
def all_permissions
|
39
|
+
ids = Array(self.role&.permissions&.ids) + self.permissions.ids
|
40
|
+
Permission.where(id: ids)
|
41
|
+
end
|
42
|
+
|
34
43
|
def check_login_status(request)
|
35
44
|
unless Rails.cache.data.get(self.last_login_key)
|
36
45
|
# 第二天还在线访问,记用户登录一次
|
@@ -32,21 +32,30 @@
|
|
32
32
|
<div class="layui-form-item">
|
33
33
|
<label class="layui-form-label required">学校性质:</label>
|
34
34
|
<div class="layui-input-block">
|
35
|
-
<input type="checkbox" name="project_985" lay-skin="primary" value="1" <%= 'checked' if @school_property&.project_985 %> title="985工程">
|
36
|
-
<input type="checkbox" name="project_211" lay-skin="primary" value="1" <%= 'checked' if @school_property&.project_211 %> title="211工程" >
|
37
35
|
<input type="checkbox" name="regular_college" lay-skin="primary" value="1" <%= 'checked' if @school_property&.regular_college %> title="本科院校">
|
36
|
+
<input type="checkbox" name="military_school" lay-skin="primary" value="1" <%= 'checked' if @school_property&.military_school %> title="军事院校">
|
37
|
+
<input type="checkbox" name="junior_college" lay-skin="primary" value="1" <%= 'checked' if @school_property&.junior_college %> title="高职院校">
|
38
|
+
|
38
39
|
</div>
|
39
40
|
</div>
|
40
41
|
<div class="layui-form-item">
|
41
42
|
<div class="layui-input-block">
|
42
|
-
<input type="checkbox" name="
|
43
|
-
<input type="checkbox" name="
|
44
|
-
<input type="checkbox" name="
|
43
|
+
<input type="checkbox" name="secondary_school" lay-skin="primary" value="1" <%= 'checked' if @school_property&.secondary_school %> title="中职院校" >
|
44
|
+
<input type="checkbox" name="mid_school" lay-skin="primary" value="1" <%= 'checked' if @school_property&.mid_school %> title="中学" >
|
45
|
+
<input type="checkbox" name="ele_school" lay-skin="primary" value="1" <%= 'checked' if @school_property&.ele_school %> title="小学" >
|
46
|
+
|
45
47
|
</div>
|
46
48
|
</div>
|
47
49
|
<div class="layui-form-item">
|
48
50
|
<div class="layui-input-block">
|
49
51
|
<input type="checkbox" name="enterprise" lay-skin="primary" value="1" <%= 'checked' if @school_property&.enterprise %> title="企业">
|
52
|
+
<input type="checkbox" name="other" lay-skin="primary" value="1" <%= 'checked' if @school_property&.other %> title="其他">
|
53
|
+
</div>
|
54
|
+
</div>
|
55
|
+
<div class="layui-form-item" style="display: none;">
|
56
|
+
<div class="layui-input-block">
|
57
|
+
<input type="checkbox" style="display: none;" name="project_985" lay-skin="primary" value="1" <%= 'checked' if @school_property&.project_985 %> title="985工程">
|
58
|
+
<input type="checkbox" style="display: none;" name="project_211" lay-skin="primary" value="1" <%= 'checked' if @school_property&.project_211 %> title="211工程" >
|
50
59
|
</div>
|
51
60
|
</div>
|
52
61
|
<div class="layui-inline" style="padding-left: 120px">
|
@@ -16,15 +16,15 @@
|
|
16
16
|
<div class="layui-inline">
|
17
17
|
<label class="layui-form-label">负责人</label>
|
18
18
|
<div class="layui-input-inline">
|
19
|
-
<%= select_tag "staff_id", options_for_select(@staffs,params[:staff_id]), { include_blank: true } %>
|
19
|
+
<%= select_tag "staff_id", options_for_select(@staffs, params[:staff_id]), { include_blank: true } %>
|
20
20
|
</div>
|
21
21
|
</div>
|
22
|
-
<!-- <div class="layui-inline">-->
|
23
|
-
<!-- <label class="layui-form-label">最后跟进</label>-->
|
24
|
-
<!-- <div class="layui-input-inline">-->
|
25
|
-
<!-- <input type="text" class="layui-input" id="date" name="date" placeholder=" - ">-->
|
26
|
-
<!-- </div>-->
|
27
|
-
<!-- </div>-->
|
22
|
+
<!-- <div class="layui-inline">-->
|
23
|
+
<!-- <label class="layui-form-label">最后跟进</label>-->
|
24
|
+
<!-- <div class="layui-input-inline">-->
|
25
|
+
<!-- <input type="text" class="layui-input" id="date" name="date" placeholder=" - ">-->
|
26
|
+
<!-- </div>-->
|
27
|
+
<!-- </div>-->
|
28
28
|
<div class="layui-inline">
|
29
29
|
<label class="layui-form-label">性质</label>
|
30
30
|
<div class="layui-input-inline">
|
@@ -34,7 +34,8 @@
|
|
34
34
|
<div class="layui-inline">
|
35
35
|
<button type="reset" class="layui-btn layui-btn-primary" lay-submit lay-filter="reset_business_search">重置
|
36
36
|
</button>
|
37
|
-
<button type="submit" class="layui-btn layui-btn-primary" id="search_bt" lay-submit lay-filter="search_teachers">搜
|
37
|
+
<button type="submit" class="layui-btn layui-btn-primary" id="search_bt" lay-submit lay-filter="search_teachers">搜
|
38
|
+
索
|
38
39
|
</button>
|
39
40
|
</div>
|
40
41
|
</div>
|
@@ -48,7 +49,7 @@
|
|
48
49
|
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="add">添加客户</button>
|
49
50
|
<% end %>
|
50
51
|
<% if can? :give, EducodeSales::Customer %>
|
51
|
-
|
52
|
+
<button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" lay-event="give">分配/移交</button>
|
52
53
|
<% end %>
|
53
54
|
</button>
|
54
55
|
</div>
|
@@ -61,17 +62,17 @@
|
|
61
62
|
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_department">添加部门</a>
|
62
63
|
<% end %>
|
63
64
|
<% if can? :create_follow, EducodeSales::Customer %>
|
64
|
-
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_follow">添加跟进记录</a>
|
65
|
+
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="add_follow">添加跟进记录</a>
|
65
66
|
<% end %>
|
66
67
|
<% if can? :update, EducodeSales::Customer %>
|
67
|
-
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
|
68
|
+
<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">编辑</a>
|
68
69
|
<% end %>
|
69
70
|
</script>
|
70
71
|
<script type="text/html" id="business">
|
71
|
-
<a href="/missions/businesses?school={{d.name}}"
|
72
|
+
<a href="/missions/businesses?school={{d.name}}" class="layui-table-link">{{ d.business }}</a>
|
72
73
|
</script>
|
73
74
|
<script type="text/html" id="name">
|
74
|
-
<a href="<%= base_url%>/colleges/{{d.id}}/statistics" class="layui-table-link" target="_blank">{{ d.name }}</a>
|
75
|
+
<a href="<%= base_url %>/colleges/{{d.id}}/statistics" class="layui-table-link" target="_blank">{{ d.name }}</a>
|
75
76
|
</script>
|
76
77
|
<script type="text/html" id="department">
|
77
78
|
<a href="javascript:void(0);" lay-event="department" class="layui-table-link">{{ d.department }}</a>
|
@@ -102,13 +103,16 @@
|
|
102
103
|
var property_list = xmSelect.render({
|
103
104
|
el: '#property',
|
104
105
|
data: [
|
105
|
-
{value: 0, name: '985工程'},
|
106
|
-
{value: 1, name: '211工程'},
|
106
|
+
// {value: 0, name: '985工程'},
|
107
|
+
// {value: 1, name: '211工程'},
|
107
108
|
{value: 2, name: '本科院校'},
|
108
|
-
{value: 3, name: '大专院校'},
|
109
|
-
{value: 4, name: '中专学校'},
|
110
109
|
{value: 5, name: '军事院校'},
|
111
|
-
{value:
|
110
|
+
{value: 3, name: '高职院校'},
|
111
|
+
{value: 4, name: '中职院校'},
|
112
|
+
{value: 7, name: '中学'},
|
113
|
+
{value: 8, name: '小学'},
|
114
|
+
{value: 6, name: '企业'},
|
115
|
+
{value: 9, name: '其他'},
|
112
116
|
]
|
113
117
|
})
|
114
118
|
|
@@ -191,7 +195,7 @@
|
|
191
195
|
],
|
192
196
|
|
193
197
|
limit: 20,
|
194
|
-
limits: [10,15,20,30,40,50,60,70,80,90],
|
198
|
+
limits: [10, 15, 20, 30, 40, 50, 60, 70, 80, 90],
|
195
199
|
page: true,
|
196
200
|
});
|
197
201
|
|
@@ -200,7 +204,6 @@
|
|
200
204
|
});
|
201
205
|
|
202
206
|
|
203
|
-
|
204
207
|
function edit(id) {
|
205
208
|
var content = miniPage.getHrefContent('/missions/teachers/' + id + '/edit');
|
206
209
|
var openWH = miniPage.getOpenWidthHeight();
|
@@ -262,7 +265,7 @@
|
|
262
265
|
// 监听搜索操作
|
263
266
|
form.on('submit(search_teachers)', function (data) {
|
264
267
|
var property = [];
|
265
|
-
property_list.getValue().forEach(function(d) {
|
268
|
+
property_list.getValue().forEach(function (d) {
|
266
269
|
property.push(d.value);
|
267
270
|
})
|
268
271
|
data.field.property = property.toString();
|
@@ -314,15 +317,15 @@
|
|
314
317
|
$(window).on("resize", function () {
|
315
318
|
layer.full(index);
|
316
319
|
});
|
317
|
-
}else if (obj.event === 'give') { //
|
320
|
+
} else if (obj.event === 'give') { //
|
318
321
|
var school_ids = []
|
319
322
|
var checkStatus = table.checkStatus('customers_table')
|
320
|
-
,data = checkStatus.data;
|
321
|
-
for (var i=0,len=data.length; i<len; i++){
|
323
|
+
, data = checkStatus.data;
|
324
|
+
for (var i = 0, len = data.length; i < len; i++) {
|
322
325
|
school_ids.push(data[i].id)
|
323
326
|
}
|
324
327
|
ids = school_ids
|
325
|
-
if(ids.length == 0){
|
328
|
+
if (ids.length == 0) {
|
326
329
|
layer.msg('请选择客户')
|
327
330
|
return
|
328
331
|
}
|
@@ -361,7 +364,6 @@
|
|
361
364
|
});
|
362
365
|
|
363
366
|
|
364
|
-
|
365
367
|
table.on('tool(customers_table)', function (obj) {
|
366
368
|
var data = obj.data;
|
367
369
|
id = data.id
|
@@ -427,7 +429,7 @@
|
|
427
429
|
|
428
430
|
} else if (obj.event === 'courses') {
|
429
431
|
teacher_id = data.id
|
430
|
-
content = miniPage.getHrefContent('/missions/teachers/add_courses?id='+data.id);
|
432
|
+
content = miniPage.getHrefContent('/missions/teachers/add_courses?id=' + data.id);
|
431
433
|
openWH = miniPage.getOpenWidthHeight();
|
432
434
|
index = layer.open({
|
433
435
|
title: '课程方向',
|
@@ -487,7 +489,7 @@
|
|
487
489
|
$(window).on("resize", function () {
|
488
490
|
layer.full(index);
|
489
491
|
});
|
490
|
-
}
|
492
|
+
} else if (obj.event === 'follow' || obj.event === 'name' || obj.event === 'department') {
|
491
493
|
id = data.id
|
492
494
|
time = data.last_follow_time || ''
|
493
495
|
content = miniPage.getHrefContent('/missions/customers/show_follow?id=' + data.id);
|
@@ -515,7 +517,8 @@
|
|
515
517
|
});
|
516
518
|
</script>
|
517
519
|
<style>
|
518
|
-
.layui-table-tool-temp{
|
519
|
-
padding-right: 30px;
|
520
|
+
.layui-table-tool-temp {
|
521
|
+
padding-right: 30px;
|
522
|
+
!important;
|
520
523
|
}
|
521
524
|
</style>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
x = EducodeSales::Common.find_by(extras: EducodeSales::Common::XTYPE)&.id
|
2
2
|
json.data do
|
3
3
|
json.array! @customers do |d|
|
4
|
-
business_ids = EducodeSales::Business.where(school_id:
|
4
|
+
business_ids = EducodeSales::Business.where(school_id: d.id).ids
|
5
5
|
follow_ups = EducodeSales::FollowUp.where(business_id: business_ids)
|
6
6
|
customer_follows = EducodeSales::CustomerFollow.where(school_id: d.id)
|
7
7
|
a_last_follow_time = follow_ups.last&.created_at&.to_s
|
@@ -17,13 +17,16 @@ json.data do
|
|
17
17
|
school_property = d.school_property
|
18
18
|
property = []
|
19
19
|
if school_property.present?
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
20
|
+
# property << '985工程' if school_property.project_985
|
21
|
+
# property << '211工程' if school_property.project_211
|
22
|
+
property << '本科院校' if school_property.regular_college
|
23
|
+
property << '大专院校' if school_property.junior_college
|
24
|
+
property << '中专学校' if school_property.secondary_school
|
25
|
+
property << '军事院校' if school_property.military_school
|
26
|
+
property << '企业' if school_property.enterprise
|
27
|
+
property << '小学' if school_property.ele_school
|
28
|
+
property << '中学' if school_property.mid_school
|
29
|
+
property << '其他' if school_property.other
|
27
30
|
end
|
28
31
|
json.property property.join("、")
|
29
32
|
json.department d.departments.size
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= Gon::Base.render_data %>
|
2
2
|
<div class="layuimini-main" style="height: 100%;">
|
3
|
-
<
|
3
|
+
<form class="layui-form " action="">
|
4
4
|
<h4>编辑人员</h4>
|
5
5
|
<div class="layui-form-item">
|
6
6
|
<label class="layui-form-label required">姓名</label>
|
@@ -59,13 +59,37 @@
|
|
59
59
|
@staff.month), { 'lay-filter': 'month' } %>
|
60
60
|
</div>
|
61
61
|
</div>
|
62
|
-
|
63
|
-
<hr>
|
64
62
|
<div class="layui-form-item">
|
63
|
+
<label class="layui-form-label required">额外权限:</label>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<!-- <form class="layui-form " action="">-->
|
67
|
+
<% id = 0 %>
|
68
|
+
<% EducodeSales::Permission.all.order(position: :asc).group_by{ |d| d.clazz}.each do |k, d| %>
|
69
|
+
<div class="layui-form-item">
|
70
|
+
<label class="layui-form-label"><%= k %></label>
|
71
|
+
<div class="layui-input-block">
|
72
|
+
<% d.each do |p| %>
|
73
|
+
<% id += 1 %>
|
74
|
+
<%= check_box_tag "permission[#{p.subject}][]", p.action, @permissions.include?(p.id), {title: p.name, id: "#{id}_" } %>
|
75
|
+
<% end %>
|
76
|
+
</div>
|
77
|
+
</div>
|
78
|
+
<% end %>
|
79
|
+
|
80
|
+
<!-- <div class="m-t-20">-->
|
81
|
+
<!-- <div class="layui-input-block">-->
|
82
|
+
<!-- <button type="submit" class="layui-btn" lay-submit="" lay-filter="role">提交</button>-->
|
83
|
+
<!-- </div>-->
|
84
|
+
<!-- </div>-->
|
85
|
+
<!-- </form>-->
|
86
|
+
<div class="m-t-20">
|
65
87
|
<div class="layui-input-block">
|
66
|
-
<button class="layui-btn
|
88
|
+
<button type="submit" class="layui-btn" lay-submit="" lay-filter="role">提交</button>
|
67
89
|
</div>
|
68
90
|
</div>
|
91
|
+
</form>
|
92
|
+
|
69
93
|
</div>
|
70
94
|
</div>
|
71
95
|
<script type="text/html" id="edit_currentTableBar">
|
@@ -141,7 +165,7 @@
|
|
141
165
|
sales_list.setValue(gon.schools)
|
142
166
|
|
143
167
|
//监听提交
|
144
|
-
form.on('submit(
|
168
|
+
form.on('submit(role)', function (data) {
|
145
169
|
var area_ids = []
|
146
170
|
layui.each(transfer.getData('area_list'), function (i, v) {
|
147
171
|
area_ids.push(v.value)
|
@@ -156,22 +180,63 @@
|
|
156
180
|
tag_ids.push(d.value);
|
157
181
|
})
|
158
182
|
}
|
159
|
-
data.field['school_ids'] = schools;
|
160
|
-
data.field['area_ids'] = area_ids;
|
161
|
-
data.field['school_tag_ids'] = tag_ids;
|
162
|
-
request.authPut("missions/staffs/" + parent.staff_id, data.field, function (res) {
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
183
|
+
data.field['school_ids'] = schools.join(",");
|
184
|
+
data.field['area_ids'] = area_ids.join(",");
|
185
|
+
data.field['school_tag_ids'] = tag_ids.join(",");
|
186
|
+
// request.authPut("missions/staffs/" + parent.staff_id, data.field, function (res) {
|
187
|
+
// console.log(res.success == false)
|
188
|
+
// if (res.success == false) {
|
189
|
+
// layer.alert(res.msg)
|
190
|
+
// } else {
|
191
|
+
// layer.close(parent.index);
|
192
|
+
// parent.layer.close(parent.layer.getFrameIndex(window.name))
|
193
|
+
// parent.table.reload('staff_filter')
|
194
|
+
// }
|
195
|
+
// })
|
196
|
+
Rails.ajax({
|
197
|
+
url: '/missions/staffs/'+ parent.staff_id,
|
198
|
+
type: 'PUT',
|
199
|
+
headers: {
|
200
|
+
'Content-Type': 'application/json',
|
201
|
+
'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
|
202
|
+
},
|
203
|
+
data: $.param(data.field, true),
|
204
|
+
success: function (res) {
|
205
|
+
if (res.success == false) {
|
206
|
+
layer.alert(res.msg)
|
207
|
+
} else {
|
208
|
+
layer.close(parent.index);
|
209
|
+
parent.layer.close(parent.layer.getFrameIndex(window.name))
|
210
|
+
parent.table.reload('staff_filter')
|
211
|
+
}
|
170
212
|
}
|
171
213
|
})
|
172
214
|
return false;
|
173
215
|
});
|
174
216
|
|
217
|
+
// form.render();
|
218
|
+
// form.on('submit(role)', function (data) {
|
219
|
+
// Rails.ajax({
|
220
|
+
// url: '/missions/roles/'+ parent.role_id,
|
221
|
+
// type: 'PUT',
|
222
|
+
// headers: {
|
223
|
+
// 'Content-Type': 'application/json',
|
224
|
+
// 'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
|
225
|
+
// },
|
226
|
+
// data: $.param(data.field, true),
|
227
|
+
// success: function (res) {
|
228
|
+
// if (res.success == false) {
|
229
|
+
// layer.alert(res.msg)
|
230
|
+
// } else {
|
231
|
+
// layer.close(parent.index);
|
232
|
+
// parent.layer.close(parent.layer.getFrameIndex(window.name))
|
233
|
+
// parent.table.reload('role')
|
234
|
+
// }
|
235
|
+
// }
|
236
|
+
// })
|
237
|
+
// return false;
|
238
|
+
// })
|
239
|
+
|
175
240
|
|
176
241
|
});
|
177
242
|
</script>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: educode_sales
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.43
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- anke1460
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-02-
|
11
|
+
date: 2023-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- app/assets/images/educode_sales/icon-login.png
|
106
106
|
- app/assets/images/educode_sales/icon.png
|
107
107
|
- app/assets/images/educode_sales/indexLogo.png
|
108
|
+
- app/assets/images/educode_sales/indexlogo.png
|
108
109
|
- app/assets/images/educode_sales/loading-0.gif
|
109
110
|
- app/assets/images/educode_sales/loading-1.gif
|
110
111
|
- app/assets/images/educode_sales/loading-2.gif
|
@@ -220,6 +221,7 @@ files:
|
|
220
221
|
- app/models/educode_sales/sale_report.rb
|
221
222
|
- app/models/educode_sales/sale_trend.rb
|
222
223
|
- app/models/educode_sales/staff.rb
|
224
|
+
- app/models/educode_sales/staff_permission.rb
|
223
225
|
- app/models/educode_sales/staff_school.rb
|
224
226
|
- app/models/educode_sales/staff_school_tag.rb
|
225
227
|
- app/models/educode_sales/teacher.rb
|
@@ -491,6 +493,7 @@ files:
|
|
491
493
|
- db/migrate/20230115080730_add_origin_business_id_to_follow_ups.rb
|
492
494
|
- db/migrate/20230117144025_create_educode_sales_business_clazz_changes.rb
|
493
495
|
- db/migrate/20230206080303_create_educode_sales_staff_school_tags.rb
|
496
|
+
- db/migrate/20230209102302_create_educode_sales_staff_permissions.rb
|
494
497
|
- lib/educode_sales.rb
|
495
498
|
- lib/educode_sales/engine.rb
|
496
499
|
- lib/educode_sales/version.rb
|
@@ -499,7 +502,7 @@ homepage: https://www.educoder.net
|
|
499
502
|
licenses:
|
500
503
|
- MIT
|
501
504
|
metadata: {}
|
502
|
-
post_install_message:
|
505
|
+
post_install_message:
|
503
506
|
rdoc_options: []
|
504
507
|
require_paths:
|
505
508
|
- lib
|
@@ -514,8 +517,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
514
517
|
- !ruby/object:Gem::Version
|
515
518
|
version: '0'
|
516
519
|
requirements: []
|
517
|
-
rubygems_version: 3.0.
|
518
|
-
signing_key:
|
520
|
+
rubygems_version: 3.0.9
|
521
|
+
signing_key:
|
519
522
|
specification_version: 4
|
520
523
|
summary: Summary of EducodeSales.
|
521
524
|
test_files: []
|