educode_sales 0.9.59 → 0.9.60

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.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/educode_sales/activities_controller.rb +54 -1
  3. data/app/controllers/educode_sales/home_controller.rb +4 -0
  4. data/app/controllers/educode_sales/ideas_controller.rb +86 -1
  5. data/app/controllers/educode_sales/upload_files_controller.rb +1 -1
  6. data/app/models/educode_sales/activity.rb +6 -0
  7. data/app/models/educode_sales/activity_staff.rb +9 -0
  8. data/app/models/educode_sales/idea.rb +23 -10
  9. data/app/views/educode_sales/activities/edit.html.erb +69 -2
  10. data/app/views/educode_sales/activities/index.html.erb +27 -1
  11. data/app/views/educode_sales/activities/index.json.jbuilder +5 -0
  12. data/app/views/educode_sales/activities/new.html.erb +100 -15
  13. data/app/views/educode_sales/businesses/time_line.html.erb +30 -0
  14. data/app/views/educode_sales/home/search_edu_user.json.jbuilder +13 -0
  15. data/app/views/educode_sales/idea_recycles/detail.html.erb +25 -4
  16. data/app/views/educode_sales/idea_recycles/index.html.erb +3 -3
  17. data/app/views/educode_sales/idea_recycles/index.json.jbuilder +1 -1
  18. data/app/views/educode_sales/ideas/detail.html.erb +25 -4
  19. data/app/views/educode_sales/ideas/edit.html.erb +134 -27
  20. data/app/views/educode_sales/ideas/index.html.erb +3 -3
  21. data/app/views/educode_sales/ideas/index.json.jbuilder +4 -4
  22. data/app/views/educode_sales/ideas/new.html.erb +118 -15
  23. data/config/routes.rb +1 -0
  24. data/db/migrate/20230319050647_add_clazz_to_educode_sales_activities.rb +6 -0
  25. data/db/migrate/20230319105048_create_educode_sales_activity_staffs.rb +13 -0
  26. data/db/migrate/20230322034022_add_to_school_name_to_ideas.rb +17 -0
  27. data/lib/educode_sales/version.rb +1 -1
  28. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ab7dabca09ad8e4d8ba3ece235b1be8ad3b7e2065999b7879772b5b4a5611227
4
- data.tar.gz: c1ae726218dca8cefab50d9d9cc4c9885e10dbe241ec2b2a19fde104b26c79cd
3
+ metadata.gz: 38a087d439337d97172f9dedbd4c7bc35c85d88d96379f0361bff0da95658d4b
4
+ data.tar.gz: fd6bc9fd073b19ad2e1be53e2d905fbd0001f759c563cabedf26c27e14f108bc
5
5
  SHA512:
6
- metadata.gz: 66a79c1b395f00a333e6f10a683ceb527157742c044344cf4dd884ce78ce3f21d6100cd59d269fe92129bb854bffc48a9ff324adf9262933beb9f44368a9af47
7
- data.tar.gz: bfec90166d1b05c0f2d3e92f144d582ce2353b0da1aeae2e7386f09fe9f9320e0d38d2fc124d9ecae186d6c2eee6f0b37c6f8d7bd60da66163774ac48071eb50
6
+ metadata.gz: 4eec669e7e2fcf022da895cb512c8f59041ea02fdeab2b792a3f393d4dc24b753e6b142e9c818ee6c73b127057ab40dd609a785c1179cb1b4862da42a17c6cec
7
+ data.tar.gz: 8759062ab1edd1b677746bd518e1d71919782b1dd1684c9b9580156f457847bad22cdd1c87eb5bfdc7ac166992ce8c0a48d169b5ac4b70c4a03beadc51934bff
@@ -19,17 +19,43 @@ module EducodeSales
19
19
  end
20
20
 
21
21
  def new
22
+ @clazz = ['全国会议', '区域会议', '单校会议', '国赛', '省赛', '夏令营']
23
+ gon.staff_manage = Staff.all.map { |d| {name: d.user&.real_name, value: d.id}}
22
24
  render layout: false
23
25
  end
24
26
 
25
27
  def edit
26
28
  @activity = Activity.find(params[:id])
29
+ manage_ids = @activity.manages.pluck(:staff_id)
30
+ assist_ids = @activity.assists.pluck(:staff_id)
31
+ gon.staff_manage = Staff.all.map { |d| {name: d.user&.real_name, value: d.id, selected: manage_ids.include?(d.id)}}
32
+ gon.assists = Staff.all.map { |d| {name: d.user&.real_name, value: d.id, selected: assist_ids.include?(d.id)}}
33
+ gon.experts = @activity.experts.map { |d| {name: d.name, value: d.user_id || d.name, selected: true}}
27
34
  render layout: false
28
35
  end
29
36
 
30
37
  def create
31
- activity = @current_admin.activities.new(name: params[:name], start_at: params[:start_at], days: params[:days])
38
+ activity = @current_admin.activities.new(activity_params)
39
+
40
+ # render_success
32
41
  if activity.save
42
+ params[:staff_manage_id].each do |d|
43
+ EducodeSales::ActivityStaff.create(staff_id: d, clazz_id: 'manage', activity_id: activity.id)
44
+ end
45
+ params[:staff_assist_id].each do |d|
46
+ EducodeSales::ActivityStaff.create(staff_id: d, clazz_id: 'assist', activity_id: activity.id)
47
+ end
48
+ params[:expert_ids].each do |d|
49
+ if d[0].to_i > 0
50
+ u = User.find(d[0].to_i)
51
+ EducodeSales::ActivityStaff.create(name: u.real_name, clazz_id: 'expert', user_id: d[0].to_i, activity_id: activity.id)
52
+ else
53
+ EducodeSales::ActivityStaff.create(name: d[1], clazz_id: 'expert', activity_id: activity.id)
54
+ end
55
+ end
56
+ # file_path = Util::FileManage.disk_filename('educode_sales_activtiy', activity.id)
57
+ # Util.write_file(params[:file], file_path)
58
+ # activity.update(filename: file_path)
33
59
  render_success
34
60
  else
35
61
  render_failure activity
@@ -39,6 +65,27 @@ module EducodeSales
39
65
  def update
40
66
  activity = Activity.find(params[:id])
41
67
  activity.assign_attributes(name: params[:name], start_at: params[:start_at], days: params[:days])
68
+ manages = []
69
+ experts = []
70
+ assists = []
71
+ params[:staff_manage_id].each do |d|
72
+ manages << EducodeSales::ActivityStaff.find_or_initialize_by(staff_id: d, clazz_id: 'manage', activity_id: activity.id)
73
+ end
74
+
75
+ params[:staff_assist_id].each do |d|
76
+ assists << EducodeSales::ActivityStaff.find_or_initialize_by(staff_id: d, clazz_id: 'assist', activity_id: activity.id)
77
+ end
78
+ params[:expert_ids].each do |d|
79
+ if d[0].to_i > 0
80
+ u = User.find(d[0].to_i)
81
+ experts << EducodeSales::ActivityStaff.find_or_initialize_by(name: u.real_name, clazz_id: 'expert', user_id: d[0].to_i, activity_id: activity.id)
82
+ else
83
+ experts << EducodeSales::ActivityStaff.find_or_initialize_by(name: d[1], clazz_id: 'expert', activity_id: activity.id)
84
+ end
85
+ end
86
+ activity.manages = manages
87
+ activity.assists = assists
88
+ activity.experts = experts
42
89
  if activity.save
43
90
  render_success
44
91
  else
@@ -58,5 +105,11 @@ module EducodeSales
58
105
  render layout: false
59
106
  end
60
107
 
108
+ private
109
+
110
+ def activity_params
111
+ params.permit(:name, :start_at, :days, :staff_assist_id, :staff_manage_id, :clazz_id, :expert)
112
+ end
113
+
61
114
  end
62
115
  end
@@ -42,6 +42,10 @@ module EducodeSales
42
42
  @data = User.joins(:user_extension).where("identity='teacher'").where("concat(lastname, firstname) like :q OR phone like :q OR mail like :q", q: "%#{params[:q]}%").limit(50)
43
43
  end
44
44
 
45
+ def search_edu_user
46
+ @data = User.joins(:user_extension).where("identity='teacher'").where("concat(lastname, firstname) like :q OR phone like :q OR mail like :q", q: "%#{params[:q]}%").limit(20)
47
+ end
48
+
45
49
  def sales_staff
46
50
  @staffs = Staff
47
51
  if params[:teacher_assist].present?
@@ -58,6 +58,8 @@ module EducodeSales
58
58
  end
59
59
 
60
60
  def new
61
+ staffs = Staff.where.not(role_id: 11).includes(:user)
62
+ gon.staffs = staffs.map { |d| { name: d.user.real_name, value: d.id } }
61
63
  gon.department = { value: '', name: '' }
62
64
  gon.value = ''
63
65
  render layout: false
@@ -67,6 +69,8 @@ module EducodeSales
67
69
  idea = Idea.new(idea_params)
68
70
  idea.school_id = Department.find_by_id(idea.department_id)&.school_id
69
71
  idea.creator = current_user
72
+ assist_staff_ids = Array(params[:assist_staff_ids].to_s.split(","))
73
+ idea.assist_staff_ids = assist_staff_ids
70
74
  idea.save
71
75
  render_success
72
76
  end
@@ -82,6 +86,8 @@ module EducodeSales
82
86
  def update
83
87
  @idea.assign_attributes(idea_params)
84
88
  @idea.school_id = Department.find_by_id(@idea.department_id)&.school_id
89
+ assist_staff_ids = Array(params[:assist_staff_ids].to_s.split(","))
90
+ @idea.assist_staff_ids = assist_staff_ids
85
91
  check_changes
86
92
  @idea.save
87
93
  render_success
@@ -93,6 +99,11 @@ module EducodeSales
93
99
  end
94
100
 
95
101
  def edit
102
+ staffs = Staff.where.not(role_id: 11).includes(:user)
103
+ gon.staffs = staffs.map { |d| { name: d.user.real_name, value: d.id } }
104
+ gon.staff_value = [{ name: @idea.staff&.user&.real_name, value: @idea.staff_id }]
105
+ gon.sale_staff_value = [{ name: @idea.sale_staff&.user&.real_name, value: @idea.sale_staff_id }]
106
+ gon.assist_staff_value = @idea.assist_staffs.map {|d|{ name: d&.user&.real_name, value: d.id }}
96
107
  gon.department = { value: @idea&.department_id, name: "#{@idea&.department&.school&.name}-#{@idea&.department&.name}" }
97
108
  gon.value = @idea.department_id
98
109
  render layout: false
@@ -104,7 +115,7 @@ module EducodeSales
104
115
  params.permit(:name, :level, :staff_id,
105
116
  :status, :types, :model, :hardware, :project,
106
117
  :money, :end_time, :content, :department_id,
107
- :manager_name, :manager_phone)
118
+ :manager_name, :manager_phone,:school_name,:department_name,:sale_staff_id,:attachment_id)
108
119
  end
109
120
 
110
121
  def find_idea
@@ -126,5 +137,79 @@ module EducodeSales
126
137
  end
127
138
  end
128
139
 
140
+ # def upload_file(file)
141
+ # folder = File.join(Rails.root, "public", "files", 'educode_sales')
142
+ # upload_file = file
143
+ # raise "未上传文件" unless upload_file
144
+ # save_path = File.join(folder)
145
+ # ext = file_ext(upload_file.original_filename)
146
+ # local_path, digest = file_save_to_local(save_path, upload_file.tempfile, ext)
147
+ # content_type = upload_file.content_type.presence || 'application/octet-stream'
148
+ # disk_filename = local_path[save_path.size + 1, local_path.size]
149
+ # @attachment = Attachment.where(disk_filename: disk_filename,
150
+ # author_id: current_user.id).first
151
+ # if @attachment.blank?
152
+ # @attachment = Attachment.new
153
+ # @attachment.filename = upload_file.original_filename
154
+ # @attachment.description = "popup_windows"
155
+ # @attachment.disk_filename = local_path[save_path.size + 1, local_path.size]
156
+ # @attachment.filesize = upload_file.tempfile.size
157
+ # @attachment.content_type = content_type
158
+ # @attachment.digest = digest
159
+ # @attachment.author_id = current_user.id
160
+ # @attachment.container_id = current_user.id
161
+ # @attachment.save!
162
+ # else
163
+ # logger.info "文件已存在,id = #{@attachment.id}, filename = #{@attachment.filename}"
164
+ # end
165
+ # @attachment.id
166
+ # # render_ok
167
+ # end
168
+ # def edu_setting name
169
+ # EduSetting.get(name)
170
+ # end
171
+ #
172
+ #
173
+ # def file_ext(file_name)
174
+ # ext = ''
175
+ # exts = file_name.split(".")
176
+ # if exts.size > 1
177
+ # ext = ".#{exts.last}"
178
+ # end
179
+ # ext
180
+ # end
181
+ #
182
+ # def file_save_to_local(save_path, temp_file, ext)
183
+ # unless Dir.exists?(save_path)
184
+ # FileUtils.mkdir_p(save_path) ##不成功这里会抛异常
185
+ # end
186
+ #
187
+ # digest = md5_file(temp_file)
188
+ # digest = "#{digest}_#{(Time.now.to_f * 1000).to_i}"
189
+ # local_file_path = File.join(save_path, digest) + ext
190
+ # save_temp_file(temp_file, local_file_path)
191
+ #
192
+ # [local_file_path, digest]
193
+ # end
194
+ #
195
+ #
196
+ # def md5_file(temp_file)
197
+ # md5 = Digest::MD5.new
198
+ # temp_file.rewind
199
+ # while (buffer = temp_file.read(8192))
200
+ # md5.update(buffer)
201
+ # end
202
+ # md5.hexdigest
203
+ # end
204
+ #
205
+ # def save_temp_file(temp_file, save_file_path)
206
+ # File.open(save_file_path, 'wb') do |f|
207
+ # temp_file.rewind
208
+ # while (buffer = temp_file.read(8192))
209
+ # f.write(buffer)
210
+ # end
211
+ # end
212
+ # end
213
+
129
214
  end
130
215
  end
@@ -44,7 +44,7 @@ module EducodeSales
44
44
  else
45
45
  logger.info "文件已存在,id = #{@attachment.id}, filename = #{@attachment.filename}"
46
46
  end
47
- render_success
47
+ render json: { success: true, attachment_id: @attachment.id ,filename: @attachment.filename}
48
48
  end
49
49
 
50
50
  def destroy
@@ -3,5 +3,11 @@ module EducodeSales
3
3
  belongs_to :staff
4
4
  has_many :activity_teachers, dependent: :destroy
5
5
  has_many :teachers, through: :activity_teachers, dependent: :restrict_with_exception
6
+ has_many :manages, -> {where("educode_sales_activity_staffs.clazz_id = 0")}, dependent: :destroy, class_name: 'ActivityStaff'
7
+ has_many :assists, -> {where("educode_sales_activity_staffs.clazz_id = 1")}, dependent: :destroy, class_name: 'ActivityStaff'
8
+ has_many :experts , -> {where("educode_sales_activity_staffs.clazz_id = 2")}, dependent: :destroy, class_name: 'ActivityStaff'
9
+ has_many :activity_staffs
10
+
11
+ enum clazz_id: ['全国会议', '区域会议', '单校会议', '国赛', '省赛', '夏令营']
6
12
  end
7
13
  end
@@ -0,0 +1,9 @@
1
+ module EducodeSales
2
+ class ActivityStaff < ApplicationRecord
3
+ belongs_to :activity
4
+ belongs_to :staff, optional: true
5
+ belongs_to :user, optional: true
6
+
7
+ enum clazz_id: ['manage', 'assist', 'expert']
8
+ end
9
+ end
@@ -3,8 +3,11 @@ module EducodeSales
3
3
  belongs_to :department, optional: true
4
4
  belongs_to :staff, optional: true
5
5
  belongs_to :school, optional: true
6
+ belongs_to :attachment, optional: true
6
7
  belongs_to :creator, class_name: 'Staff', optional: true
7
8
  belongs_to :deleter, class_name: 'Staff', optional: true
9
+ belongs_to :sale_staff, class_name: 'Staff', optional: true
10
+ belongs_to :idea_staff, class_name: 'Staff', optional: true
8
11
 
9
12
  has_many :idea_histories, dependent: :destroy
10
13
 
@@ -12,16 +15,22 @@ module EducodeSales
12
15
  scope :not_deleted, -> { where(is_deleted: false) }
13
16
 
14
17
  enum level: %w[高 中 低]
15
- enum status: %w[已完成 未完成]
18
+ enum status: %w[未完成 已完成]
16
19
  enum types: %w[定制 非定制]
17
20
  enum model: %w[本地版 线上版 混合版]
18
21
 
22
+ serialize :assist_staff_ids,Array
23
+
19
24
  # before_save :check_changes
20
25
 
21
26
  def recycle
22
27
  self.update(deleted_at: nil, deleter_id: nil, is_deleted: false)
23
28
  end
24
29
 
30
+ def assist_staffs
31
+ Staff.where(id: self.assist_staff_ids)
32
+ end
33
+
25
34
  def soft_destroy(staff_id)
26
35
  self.update(deleted_at: Time.now, deleter_id: staff_id, is_deleted: true)
27
36
  end
@@ -43,10 +52,14 @@ module EducodeSales
43
52
 
44
53
  def save_history(attr, old_value, new_value)
45
54
  case attr
46
- when "school_id"
47
- old_value = School.find_by(id: old_value)&.name
48
- new_value = School.find_by(id: new_value)&.name
55
+ when "school_name"
49
56
  "学校/单位由“#{old_value}”变更为“#{new_value}”"
57
+ when "department_name"
58
+ "院系/部门由“#{old_value}”变更为“#{new_value}”"
59
+ # when "school_id"
60
+ # old_value = School.find_by(id: old_value)&.name
61
+ # new_value = School.find_by(id: new_value)&.name
62
+ # "学校/单位由“#{old_value}”变更为“#{new_value}”"
50
63
  when "name"
51
64
  "项目名称由“#{old_value}”变更为“#{new_value}”"
52
65
  when "level"
@@ -54,7 +67,7 @@ module EducodeSales
54
67
  when "staff_id"
55
68
  old_value = Staff.find_by(id: old_value)&.user&.real_name
56
69
  new_value = Staff.find_by(id: new_value)&.user&.real_name
57
- "指派人由“#{old_value}”变更为“#{new_value}”"
70
+ "方案指派人由“#{old_value}”变更为“#{new_value}”"
58
71
  when "status"
59
72
  "状态由“#{old_value}”变更为“#{new_value}”"
60
73
  when "types"
@@ -64,17 +77,17 @@ module EducodeSales
64
77
  when "hardware"
65
78
  "硬件规模(万)由“#{old_value}”变更为“#{new_value}”"
66
79
  when "project"
67
- "项目规模(人)由“#{old_value}”变更为“#{new_value}”"
80
+ "并发规模(人)由“#{old_value}”变更为“#{new_value}”"
68
81
  when "money"
69
82
  "项目预算(万)由“#{old_value}”变更为“#{new_value}”"
70
83
  when "end_time"
71
84
  "截止时间由“#{old_value}”变更为“#{new_value}”"
72
85
  when "content"
73
86
  "反馈情况由“#{old_value}”变更为“#{new_value}”"
74
- when "department_id"
75
- old_value = Department.find_by(id: old_value)&.name
76
- new_value = Department.find_by(id: new_value)&.name
77
- "院系/部门由“#{old_value}”变更为“#{new_value}”"
87
+ # when "department_id"
88
+ # old_value = Department.find_by(id: old_value)&.name
89
+ # new_value = Department.find_by(id: new_value)&.name
90
+ # "院系/部门由“#{old_value}”变更为“#{new_value}”"
78
91
  when "manager_name"
79
92
  "学校负责人由“#{old_value}”变更为“#{new_value}”"
80
93
  when "manager_phone"
@@ -1,4 +1,4 @@
1
- <%#= Gon::Base.render_data %>
1
+ <%= Gon::Base.render_data %>
2
2
  <div class="layuimini-main">
3
3
  <form class="layui-form layuimini-form" action="">
4
4
  <div class="layui-form-item" style="padding: 25px">
@@ -23,6 +23,30 @@
23
23
  class="layui-input" value="<%= @activity.days %>">
24
24
  </div>
25
25
  </div>
26
+ <div class="layui-inline">
27
+ <label class="layui-form-label">生态经理</label>
28
+ <div class="layui-input-block">
29
+ <div id="staff_manage_list" style="width: 163px;"></div>
30
+ </div>
31
+ </div>
32
+ <div class="layui-inline">
33
+ <label class="layui-form-label">协助人员</label>
34
+ <div class="layui-input-block">
35
+ <div id="staff_assist_list" style="width: 193px;"></div>
36
+ </div>
37
+ </div>
38
+ <div class="layui-inline">
39
+ <label class="layui-form-label">报告专家</label>
40
+ <div class="layui-input-block">
41
+ <div id="expert_list" style="width: 600px;"></div>
42
+ </div>
43
+ </div>
44
+ <div class="layui-inline">
45
+ <label class="layui-form-label">上传附件</label>
46
+ <div class="layui-input-block">
47
+ <button type="button" class="layui-btn" id="upload_file">上传文件</button>
48
+ </div>
49
+ </div>
26
50
  <div class="layui-inline" style="padding-left: 30px">
27
51
  <button type="submit" class="layui-btn layui-btn-normal" lay-submit lay-filter="data-reset-btn">提交
28
52
  </button>
@@ -32,7 +56,7 @@
32
56
  </div>
33
57
  <script>
34
58
 
35
- layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'selectInput', 'transfer'], function () {
59
+ layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'selectInput', 'transfer', 'xmSelect'], function () {
36
60
  var form = layui.form,
37
61
  layer = layui.layer,
38
62
  table = layui.table,
@@ -40,6 +64,7 @@
40
64
  laytpl = layui.laytpl,
41
65
  request = layui.request,
42
66
  $ = layui.$,
67
+ xmSelect = layui.xmSelect,
43
68
  laydate = layui.laydate;
44
69
 
45
70
  //常规用法
@@ -64,9 +89,51 @@
64
89
  }
65
90
  })
66
91
 
92
+ var staff_manage = xmSelect.render({
93
+ el: '#staff_manage_list',
94
+ data: gon.staff_manage,
95
+ filterable: true,
96
+ })
97
+
98
+ var staff_assist = xmSelect.render({
99
+ el: '#staff_assist_list',
100
+ data: gon.assists,
101
+ filterable: true,
102
+ })
103
+ var expert = xmSelect.render({
104
+ el: '#expert_list',
105
+ filterable: true,
106
+ name: 'expert_ids',
107
+ remoteSearch: true,
108
+ remoteMethod: function(val, cb, show){
109
+ if(!val){
110
+ return cb([]);
111
+ }
112
+ request.get('missions/search_edu_user?q=' + val, {}, function (res) {
113
+ if (res.data.length == 0) {
114
+ cb([{value: val, name: val}])
115
+ } else {
116
+ cb(res.data);
117
+ }
118
+
119
+ })
120
+ },
121
+ data: gon.experts
122
+ })
67
123
 
68
124
  //监听提交
69
125
  form.on('submit(data-reset-btn)', function (data) {
126
+ data.field.staff_manage_id = staff_manage.getValue('value');
127
+ data.field.staff_assist_id = staff_assist.getValue('value');
128
+ var expertids = [];
129
+ expert.getValue().forEach(function(d) {
130
+ if (typeof(d.value) == 'number') {
131
+ expertids.push([d.value, d.name]);
132
+ } else {
133
+ expertids.push(['', d.name]);
134
+ }
135
+ })
136
+ data.field.expert_ids = expertids;
70
137
  request.authPut("missions/activities/" + <%= @activity.id %>, data.field, function (res) {
71
138
  if (res.success === false) {
72
139
  layer.alert(res.msg)
@@ -46,14 +46,40 @@
46
46
  {
47
47
  field: 'id',
48
48
  title:'序号',type: 'numbers',
49
- totalRowText:'合计',
49
+ totalRowText:'合计',
50
50
  width: 60
51
51
  },
52
52
  {
53
53
  field: 'name',
54
54
  title: '活动名称',
55
+ width: 180,
55
56
  templet: '#teachers'
56
57
  },
58
+ {
59
+ field: 'clazz_id',
60
+ width: 120,
61
+ title: '会议类型'
62
+ },
63
+ {
64
+ field: 'staff',
65
+ width: 120,
66
+ title: '销售经理'
67
+ },
68
+ {
69
+ field: 'staff_manage',
70
+ width: 180,
71
+ title: '生态经理'
72
+ },
73
+ {
74
+ field: 'staff_assist',
75
+ width: 180,
76
+ title: '协助人员'
77
+ },
78
+ {
79
+ field: 'expert',
80
+ width: 180,
81
+ title: '报告专家'
82
+ },
57
83
  {
58
84
  field: 'start_at',
59
85
  width: 200,
@@ -10,6 +10,11 @@ json.data do
10
10
  json.students_count d.students_count || 0
11
11
  json.course_rate d.course_rate
12
12
  json.start_at d.start_at ? d.start_at.to_s(:date) : ''
13
+ json.clazz_id d.clazz_id
14
+ json.staff d.staff&.user&.real_name
15
+ json.staff_manage d.manages.map { |d| d.staff.user.real_name}.uniq.join("、")
16
+ json.staff_assist d.assists.map { |d| d.staff.user.real_name}.uniq.join("、")
17
+ json.expert d.experts.pluck(:name).join("、")
13
18
  end
14
19
  end
15
20
 
@@ -1,12 +1,17 @@
1
- <%#= Gon::Base.render_data %>
1
+ <%= Gon::Base.render_data %>
2
2
  <div class="layuimini-main">
3
- <form class="layui-form layuimini-form" action="">
3
+ <div class="layui-form layuimini-form">
4
4
  <div class="layui-form-item" style="padding: 25px">
5
5
  <div class="layui-inline">
6
6
  <label class="layui-form-label required">活动名称</label>
7
7
  <div class="layui-input-block">
8
- <input type="text" name="name" required lay-verify="required" placeholder="请输入"
9
- class="layui-input" id="inputFocus">
8
+ <input type="text" name="name" required lay-verify="required" placeholder="请输入" class="layui-input" id="inputFocus">
9
+ </div>
10
+ </div>
11
+ <div class="layui-inline">
12
+ <label class="layui-form-label required">活动类型</label>
13
+ <div class="layui-input-block">
14
+ <%= select_tag "clazz_id", options_for_select(@clazz), { 'lay-filter': 'clazz_id', class: 'required' } %>
10
15
  </div>
11
16
  </div>
12
17
  <div class="layui-inline">
@@ -18,22 +23,44 @@
18
23
  <div class="layui-inline">
19
24
  <label class="layui-form-label required">活动天数</label>
20
25
  <div class="layui-input-block">
21
- <input type="text" name="days" required lay-verify="required"
22
- class="layui-input">
26
+ <input type="text" name="days" required lay-verify="required" class="layui-input">
27
+ </div>
28
+ </div>
29
+ <div class="layui-inline">
30
+ <label class="layui-form-label">生态经理</label>
31
+ <div class="layui-input-block">
32
+ <div id="staff_manage_list" style="width: 163px;"></div>
33
+ </div>
34
+ </div>
35
+ <div class="layui-inline">
36
+ <label class="layui-form-label">协助人员</label>
37
+ <div class="layui-input-block">
38
+ <div id="staff_assist_list" style="width: 193px;"></div>
39
+ </div>
40
+ </div>
41
+ <div class="layui-inline">
42
+ <label class="layui-form-label">报告专家</label>
43
+ <div class="layui-input-block">
44
+ <div id="expert_list" style="width: 600px;"></div>
45
+ </div>
46
+ </div>
47
+ <div class="layui-inline">
48
+ <label class="layui-form-label">上传附件</label>
49
+ <div class="layui-input-block">
50
+ <button type="button" class="layui-btn" id="upload_file">上传文件</button>
23
51
  </div>
24
52
  </div>
25
53
  <div class="layui-inline" style="padding-left: 30px">
26
- <button type="submit" class="layui-btn layui-btn-normal" lay-submit lay-filter="data-reset-btn">提交
27
- </button>
54
+ <button class="layui-btn layui-btn-normal" lay-submit lay-filter="data-reset-btn">提交 </button>
28
55
  </div>
29
56
  </div>
30
- </form>
57
+ </div>
31
58
  </div>
32
59
 
33
60
  <script>
34
61
  document.getElementById("inputFocus").focus();
35
62
 
36
- layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'selectInput', 'transfer'], function () {
63
+ layui.use(['form', 'table', 'upload', 'laytpl', 'request', 'selectInput', 'transfer', 'xmSelect'], function () {
37
64
  var form = layui.form,
38
65
  layer = layui.layer,
39
66
  table = layui.table,
@@ -41,6 +68,9 @@
41
68
  laytpl = layui.laytpl,
42
69
  request = layui.request,
43
70
  laydate = layui.laydate,
71
+ xmSelect = layui.xmSelect,
72
+ upload = layui.upload,
73
+ selectInput = layui.selectInput
44
74
  $ = layui.$;
45
75
 
46
76
  //常规用法
@@ -48,6 +78,49 @@
48
78
  elem: '#new_time'
49
79
  });
50
80
 
81
+ var staff_manage = xmSelect.render({
82
+ el: '#staff_manage_list',
83
+ data: gon.staff_manage,
84
+ filterable: true,
85
+ })
86
+
87
+ var staff_assist = xmSelect.render({
88
+ el: '#staff_assist_list',
89
+ data: gon.staff_manage,
90
+ filterable: true,
91
+ })
92
+ var expert = xmSelect.render({
93
+ el: '#expert_list',
94
+ filterable: true,
95
+ name: 'expert_ids',
96
+ remoteSearch: true,
97
+ remoteMethod: function(val, cb, show){
98
+ if(!val){
99
+ return cb([]);
100
+ }
101
+ request.get('missions/search_edu_user?q=' + val, {}, function (res) {
102
+ if (res.data.length == 0) {
103
+ cb([{value: val, name: val}])
104
+ } else {
105
+ cb(res.data);
106
+ }
107
+
108
+ })
109
+ },
110
+ data: []
111
+ })
112
+
113
+
114
+
115
+ upload.render({
116
+ elem: '#upload_file'
117
+ ,url: '' //此处配置你自己的上传接口即可
118
+ ,accept: 'file' //普通文件
119
+ ,auto: false
120
+ ,done: function(res){
121
+ layer.msg('上传成功');
122
+ }
123
+ });
51
124
 
52
125
  form.render();
53
126
 
@@ -69,15 +142,27 @@
69
142
 
70
143
  //监听提交
71
144
  form.on('submit(data-reset-btn)', function (data) {
145
+ data.field.staff_manage_id = staff_manage.getValue('value');
146
+ data.field.staff_assist_id = staff_assist.getValue('value');
147
+ var expertids = [];
148
+ expert.getValue().forEach(function(d) {
149
+ if (typeof(d.value) == 'number') {
150
+ expertids.push([d.value, d.name]);
151
+ } else {
152
+ expertids.push(['', d.name]);
153
+
154
+ }
155
+ })
156
+ data.field.expert_ids = expertids;
72
157
  request.authPost("missions/activities", data.field, function (res) {
73
158
  if (res.success === false) {
74
- layer.alert(res.msg)
159
+ layer.alert(res.msg)
75
160
  } else {
76
- layer.closeAll(); //关闭所有层
77
- table.reload('activities_table')
161
+ layer.closeAll(); //关闭所有层
162
+ table.reload('activities_table')
78
163
  }
79
164
  })
80
- return false;
81
- });
165
+ return false;
166
+ });
82
167
  });
83
168
  </script>