educode_sales 0.5.4 → 0.5.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 660c43183c6a1edf9d5aab4b549bce9d2b68edf789010d85379198372be1a120
4
- data.tar.gz: 28beeb3a7026076f4e6da6dc966bf75523e7be06717b787041d2e14500902532
3
+ metadata.gz: c060696641e16a80fea2b02631788112e85082b8ccba0a037a2635d6563dbe24
4
+ data.tar.gz: 07230a0582b71a0ebfceddc1ce347a667651f778fed3640a0c82b22ee952f620
5
5
  SHA512:
6
- metadata.gz: d7f6b1515f819aac77b135ba6d52a3562c4fef76d650fd1a74c44bf3dcaffacc41ec34e1623337538a36bf40cff2591d14d40e83575cd7920a69fcfadb5662c4
7
- data.tar.gz: ff102c87e89e482809f4b8e84e0f27c5f42a3dd22863f6ebfe0a4fd115eae1d026de70cd738c5b0d83e9e3ab78aee3a276eb0fed4f6a66c467ab8926c7737ed2
6
+ metadata.gz: 110a25d3261f894f5ce6c5fed8e08d7afd62dd186ce6e18a10fe8d7f68033f03e48e2bdeca23df1408495e608899fc1383e5f3a0da25f1c13736b04488179820
7
+ data.tar.gz: 876c22dbca43a2624dbb2407cd5520c1ea0e044d696b4e3adb9571d65220560b0de3c13ecb337a9d914097b93cce6373db0a598dc5be440bbd925ee8744f995e
@@ -176,6 +176,7 @@ module EducodeSales
176
176
  last_follow.reception_at,
177
177
  last_follow.bidded_date,
178
178
  last_follow.signed_date,
179
+ last_follow.actual_amount,
179
180
  last_follow.total_amount").joins("
180
181
  LEFT JOIN educode_sales_follow_ups AS last_follow ON educode_sales_businesses.last_follow_up_id = last_follow.id
181
182
  ").page(params[:page]).per(params[:limit])
@@ -16,31 +16,40 @@ module EducodeSales
16
16
  @business_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ? AND educode_sales_follow_ups.clazz_id != ?", x, o).sum(:total_amount).round(2)
17
17
  stage_ids = Common.where(clazz: '商机阶段', name: ['已中标','已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
18
18
  @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)
19
+ @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)
19
20
  s_stage_ids = Common.where(clazz: '商机阶段', name: ['已签单','已验收','回款中', '服务中','已结束']).pluck(:id)
20
21
  @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)
22
+ @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)
21
23
  @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)
22
24
  a = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::ATYPE)&.name).pluck(:id)
23
25
  @a_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", a).sum(:total_amount).round(2)
24
26
  b = Common.where(clazz: '商机类型', name: Common.find_by(extras: EducodeSales::Common::BTYPE)&.name).pluck(:id)
25
27
  @b_amount = Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id IN (?)", b).sum(:total_amount).round(2)
26
28
 
29
+ count_type = params[:count_type] || "actual_amount"
27
30
  common = Common.find_by(clazz: 'staff_type', name: '销售')
28
31
  names = Staff.includes(:user).where(job_type: common.id).map { |d| [d.user.real_name, d.id] }
29
32
  x_business_ids = []
30
- default_dates = (7.day.ago.to_date..Date.today).to_a #默认时间范围
33
+ default_dates = (30.day.ago.to_date..Date.today).map { |d| d.strftime("%Y-%W")}.uniq #默认时间范围
31
34
  Business.all.each do |d|
32
35
  if d.last_follow_up&.clazz&.id == x
33
36
  x_business_ids << d.id
34
37
  end
35
38
  end
36
- colors = ['#44D7B6','#4CACFF','#F7B500','#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#8B00FF', 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)']
37
- @follow_count_range = params[:follow_count_range] || "day"
38
- @goal_count_range = params[:goal_count_range] || "day"
39
+ colors = ['#44D7B6','#4CACFF','#F7B500','#FF0000', '#FF7F00', '#FFFF00', '#00FF00', '#00FFFF', '#0000FF', '#8B00FF', 'rgba(255, 99, 132, 1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)' ,'rgba(255, 0, 250, 1)']
40
+ @follow_count_range = params[:follow_count_range] || "week"
41
+ @goal_count_range = params[:goal_count_range] || "month"
39
42
  # 商机跟进数图表
40
- @follow_count_data = day_follow_count_chart(default_dates,names,x_business_ids,colors)
43
+ @follow_count_data = week_follow_count_chart(default_dates,names,x_business_ids,colors)
41
44
  if params[:follow_count_range].present?
42
45
  case params[:follow_count_range]
43
- when "week"
46
+ when "week" #按周
47
+ if params[:date_week].present?
48
+ date = params[:date_week].split(" - ")
49
+ dates = (date[0].to_date..date[1].to_date).map { |d|
50
+ d.strftime("%Y-%W")}.uniq
51
+ @follow_count_data = week_follow_count_chart(dates,names,x_business_ids,colors)
52
+ end
44
53
  when "month" #按月
45
54
  if params[:date_month].present?
46
55
  # (Date.new(2020,12,1)..Date.new(2021,12,1)).map { |d| d.strftime("%Y-%m")}.uniq
@@ -67,27 +76,8 @@ module EducodeSales
67
76
  # 已中标图表
68
77
  goal_default_dates = ("#{Time.now.year}-01".."#{Time.now.year}-#{Time.now.month}").to_a
69
78
  sale_names = ['已中标','已签单','已回款']
70
- @goal_count_data =
71
- {
72
- labels: goal_default_dates,
73
- datasets: sale_names.map do |name|{
74
- label: name,
75
- data: goal_default_dates.map{ |d|
76
- case sale_names.index(name)
77
- when 0
78
- 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 (?)", "#{d}-01", "#{d}-31", stage_ids).sum(:total_amount).round(2)
79
- when 1
80
- 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 (?)", "#{d}-01", "#{d}-31", s_stage_ids).sum(:total_amount).round(2)
81
- else
82
- 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 <= ? ", "#{d}-01", "#{d}-31").sum(:amount).round(2)
83
- end
84
- },
85
- backgroundColor: colors[sale_names.index(name)],
86
- borderColor: colors[sale_names.index(name)],
87
- borderWidth: 1
88
- }
89
- end
90
- }
79
+ 10.times{p count_type}
80
+ @goal_count_data = month_sale_chart(goal_default_dates,sale_names,colors,x,stage_ids,s_stage_ids,count_type)
91
81
  if params[:goal_count_range].present?
92
82
  case params[:goal_count_range]
93
83
  when "week"
@@ -95,49 +85,13 @@ module EducodeSales
95
85
  if params[:goal_date_month].present?
96
86
  date = params[:goal_date_month].split(" - ")
97
87
  dates = ((date[0]+"-01").to_date..(date[1]+"-01").to_date).map { |d| d.strftime("%Y-%m")}.uniq
98
- @goal_count_data = {
99
- labels: dates,
100
- datasets: sale_names.map do |name|{
101
- label: name,
102
- data: dates.map{ |d|
103
- case sale_names.index(name)
104
- when 0
105
- 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 (?)", "#{d}-01", "#{d}-31", stage_ids).sum(:total_amount).round(2)
106
- when 1
107
- 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 (?)", "#{d}-01", "#{d}-31", s_stage_ids).sum(:total_amount).round(2)
108
- else
109
- 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 <= ? ", "#{d}-01", "#{d}-31").sum(:amount).round(2)
110
- end },
111
- backgroundColor: colors[sale_names.index(name)],
112
- borderColor: colors[sale_names.index(name)],
113
- borderWidth: 1
114
- }
115
- end
116
- }
88
+ @goal_count_data = month_sale_chart(dates,sale_names,colors,x,stage_ids,s_stage_ids,count_type)
117
89
  end
118
- else #按年
90
+ else #按年
119
91
  if params[:goal_date_year].present?
120
92
  date = params[:goal_date_year].split(" - ")
121
93
  dates = (date[0]..date[1]).to_a
122
- @goal_count_data = {
123
- labels: dates,
124
- datasets:sale_names.map do |name| {
125
- label: name,
126
- data: dates.map{ |d|
127
- case sale_names.index(name)
128
- when 0
129
- 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 (?)", "#{d}-01-01", "#{d}-12-31", stage_ids).sum(:total_amount).round(2)
130
- when 1
131
- 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 (?)", "#{d}-01-01", "#{d}-12-31", s_stage_ids).sum(:total_amount).round(2)
132
- else
133
- 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 <= ? ", "#{d}-01-01", "#{d}-12-31").sum(:amount).round(2)
134
- end },
135
- backgroundColor: colors[sale_names.index(name)],
136
- borderColor: colors[sale_names.index(name)],
137
- borderWidth: 1
138
- }
139
- end
140
- }
94
+ @goal_count_data = year_sale_chart(dates,sale_names,colors,x,stage_ids,s_stage_ids,count_type)
141
95
  end
142
96
  end
143
97
  end
@@ -165,16 +119,42 @@ module EducodeSales
165
119
  def day_follow_count_chart(dates,names,x_business_ids,colors)
166
120
  {
167
121
  labels: dates,
168
- datasets:names.map do |name|
122
+ datasets:names.map.with_index do |name,i|
169
123
  {
170
- hidden: names.index(name) < 3 ? false : true,
124
+ hidden: i < 3 ? false : true,
171
125
  label: name[0],
172
126
  data: dates.map{ |d| @follow_up = FollowUp.where(staff_id: name[1], created_at: d.beginning_of_day..d.end_of_day).where.not(business: x_business_ids).count },
173
127
  backgroundColor: "#fff",
174
- pointBorderColor: colors[names.index(name)%15],
175
- borderColor: colors[names.index(name)%15],
176
- pointBackgroundColor: colors[names.index(name)%15],
177
- borderWidth: 4
128
+ pointBorderColor: colors[i%15+1],
129
+ borderColor: colors[i%15+1],
130
+ pointBackgroundColor: colors[i%15+1],
131
+ borderWidth: 2
132
+ }
133
+ end
134
+ }
135
+ end
136
+ def week_follow_count_chart(dates,names,x_business_ids,colors)
137
+ {
138
+ labels: dates,
139
+ datasets:names.map.with_index do |name,i|
140
+ {
141
+ hidden: i < 3 ? false : true,
142
+ label: name[0],
143
+ data: dates.map{ |d|
144
+ d = d.split("-")
145
+ year = d[0].to_i
146
+ week = d[1].to_i
147
+ if week == 0
148
+ @follow_up = 0
149
+ else
150
+ @follow_up = FollowUp.where(staff_id: name[1]).where("created_at >= ? AND created_at <= ?", Date.commercial(year,week).strftime("%Y-%m-%d"), Date.commercial(year,week,7).strftime("%Y-%m-%d")).where.not(business: x_business_ids).count
151
+ end
152
+ },
153
+ backgroundColor: "#fff",
154
+ pointBorderColor: colors[i%15+1],
155
+ borderColor: colors[i%15+1],
156
+ pointBackgroundColor: colors[i%15+1],
157
+ borderWidth: 2
178
158
  }
179
159
  end
180
160
  }
@@ -182,16 +162,16 @@ module EducodeSales
182
162
  def month_follow_count_chart(dates,names,x_business_ids,colors)
183
163
  {
184
164
  labels: dates,
185
- datasets:names.map do |name|
165
+ datasets:names.map.with_index do |name,i|
186
166
  {
187
- hidden: names.index(name) < 3 ? false : true,
167
+ hidden: i < 3 ? false : true,
188
168
  label: name[0],
189
169
  data: dates.map { |d| @follow_up = FollowUp.where( staff_id: name[1]).where("created_at >= ? AND created_at <= ?", "#{d}-01", "#{d}-31").where.not(business: x_business_ids).count },
190
170
  backgroundColor: "#fff",
191
- pointBorderColor: colors[names.index(name)%15],
192
- borderColor: colors[names.index(name)%15],
193
- pointBackgroundColor: colors[names.index(name)%15],
194
- borderWidth: 4,
171
+ pointBorderColor: colors[i%15+1],
172
+ borderColor: colors[i%15+1],
173
+ pointBackgroundColor: colors[i%15+1],
174
+ borderWidth: 2,
195
175
  }
196
176
  end
197
177
  }
@@ -199,21 +179,66 @@ module EducodeSales
199
179
  def year_follow_count_chart(dates,names,x_business_ids,colors)
200
180
  {
201
181
  labels: dates,
202
- datasets:names.map do |name|
182
+ datasets:names.map.with_index do |name,i|
203
183
  {
204
- hidden: names.index(name) < 3 ? false : true,
184
+ hidden: i < 3 ? false : true,
205
185
  label: name[0],
206
186
  data: dates.map { |d| @follow_up = FollowUp.where( staff_id: name[1]).where("created_at >= ? AND created_at <= ?", "#{d}-01-01", "#{d}-12-31").where.not(business: x_business_ids).count },
207
187
  backgroundColor: "#fff",
208
- pointBorderColor: colors[names.index(name)%15],
209
- borderColor: colors[names.index(name)%15],
210
- pointBackgroundColor: colors[names.index(name)%15],
211
- borderWidth: 4
188
+ pointBorderColor: colors[i%15+1],
189
+ borderColor: colors[i%15+1],
190
+ pointBackgroundColor: colors[i%15+1],
191
+ borderWidth: 2
212
192
  }
213
193
  end
214
194
  }
215
195
  end
216
196
 
197
+ def month_sale_chart(dates,names,colors,x,stage_ids,s_stage_ids,count_type)
198
+ {
199
+ labels: dates,
200
+ datasets: names.map.with_index do |name,i|{
201
+ label: name,
202
+ data: dates.map{ |d|
203
+ case i
204
+ when 0
205
+ 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 (?)", "#{d}-01", "#{d}-31", stage_ids).sum(count_type).round(2)
206
+ when 1
207
+ 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 (?)", "#{d}-01", "#{d}-31", s_stage_ids).sum(count_type).round(2)
208
+ else
209
+ 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 <= ? ", "#{d}-01", "#{d}-31").sum(:amount).round(2)
210
+ end
211
+ },
212
+ backgroundColor: colors[i],
213
+ borderColor: colors[i],
214
+ borderWidth: 1
215
+ }
216
+ end
217
+ }
218
+ end
219
+
220
+ def year_sale_chart(dates,names,colors,x,stage_ids,s_stage_ids,count_type)
221
+ {
222
+ labels: dates,
223
+ datasets:names.map.with_index do |name,i| {
224
+ label: name,
225
+ data: dates.map{ |d|
226
+ case i
227
+ when 0
228
+ 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 (?)", "#{d}-01-01", "#{d}-12-31", stage_ids).sum(count_type).round(2)
229
+ when 1
230
+ 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 (?)", "#{d}-01-01", "#{d}-12-31", s_stage_ids).sum(count_type).round(2)
231
+ else
232
+ 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 <= ? ", "#{d}-01-01", "#{d}-12-31").sum(:amount).round(2)
233
+ end },
234
+ backgroundColor: colors[i],
235
+ borderColor: colors[i],
236
+ borderWidth: 1
237
+ }
238
+ end
239
+ }
240
+ end
241
+
217
242
 
218
243
  end
219
244
  end
@@ -20,7 +20,7 @@ module EducodeSales
20
20
  end
21
21
 
22
22
  def create
23
- folder = File.join(Rails.root, "public", "images", 'educode_sales')
23
+ folder = File.join(Rails.root, "public", "files", 'educode_sales')
24
24
  upload_file = params["file"]
25
25
  raise "未上传文件" unless upload_file
26
26
  save_path = File.join(folder)
@@ -48,7 +48,7 @@ module EducodeSales
48
48
  end
49
49
 
50
50
  def destroy
51
- folder = File.join(Rails.root, "public", "images", 'educode_sales')
51
+ folder = File.join(Rails.root, "public", "files", 'educode_sales')
52
52
  file = Attachment.find(params[:id])
53
53
  file.destroy
54
54
  File.delete(folder + "/" +file.disk_filename) if FileTest::exist?(folder + "/" +file.disk_filename)
@@ -56,7 +56,7 @@ module EducodeSales
56
56
  end
57
57
 
58
58
  def download
59
- folder = File.join(Rails.root, "public", "images", 'educode_sales')
59
+ folder = File.join(Rails.root, "public", "files", 'educode_sales')
60
60
  file = Attachment.find_by_id(params[:id])
61
61
  raise "未找到文件" unless file
62
62
  send_file(folder + "/" +file.disk_filename, filename: file.title, stream: true, type: file.content_type.presence || 'application/octet-stream')
@@ -118,16 +118,14 @@
118
118
  var id = data.id
119
119
  name = data.disk_filename
120
120
  folder = gon.folder
121
- console.log(folder);
122
121
  if (obj.event === 'preview') {
123
122
  if (data.content_type.split("/")[0] === "image"){
124
123
  layer.photos({
125
- photos: { "data": [{"src": '/images/educode_sales/' + name}] }
124
+ photos: { "data": [{"src": '/files/educode_sales/' + name}] }
126
125
  ,anim: 5 //0-6的选择,指定弹出图片动画类型,默认随机
127
126
  });
128
127
  }else if (data.content_type.split("/")[1] === "pdf"){
129
- var pdf = '/images/educode_sales/' + name;
130
- console.log(pdf);
128
+ var pdf = '/files/educode_sales/' + name;
131
129
  var openWH = miniPage.getOpenWidthHeight();
132
130
  layer.open({
133
131
  title: data.name,
@@ -35,7 +35,7 @@
35
35
  <div class="layui-inline">
36
36
  <label class="layui-form-label">渠道名称</label>
37
37
  <div class="layui-input-inline">
38
- <%= select_tag "place_id", options_for_select(EducodeSales::Place.pluck(:name, :id)), { include_blank: true } %>
38
+ <%= select_tag "place_id", options_for_select(EducodeSales::Place.pluck(:name, :id),params[:place_id]), { include_blank: true } %>
39
39
  </div>
40
40
  </div>
41
41
  <div class="layui-inline">
@@ -194,6 +194,13 @@
194
194
  totalRow: true,
195
195
  sort: true
196
196
  },
197
+ {
198
+ field: 'actual_amount',
199
+ width: 100,
200
+ title: '合同额',
201
+ totalRow: true,
202
+ sort: true
203
+ },
197
204
  {
198
205
  field: 'return_money',
199
206
  width: 100,
@@ -17,6 +17,7 @@ json.data do
17
17
  json.bidded_date d.last_follow_up&.bidded_date.to_s
18
18
  json.signed_date d.last_follow_up&.signed_date.to_s
19
19
  json.total_amount d.last_follow_up&.total_amount
20
+ json.actual_amount d.last_follow_up&.actual_amount
20
21
  json.return_money d.return_money
21
22
  json.place d.last_follow_up&.place&.name
22
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
@@ -17,6 +17,11 @@
17
17
  <a class="layui-btn layui-btn-xs layui-btn-danger data-count-delete" lay-event="delete">删除</a>
18
18
  <% end %>
19
19
  </script>
20
+ <script type="text/html" id="business_a">
21
+ <div class="layui-text">
22
+ <a href="/missions/businesses?place_id={{d.id}}">{{d.businesses_count}}</a>
23
+ </div>
24
+ </script>
20
25
 
21
26
  <script type="text/html" id="showchance">
22
27
  <a href="/missions/businesses" class="layui-table-link">{{ d.chance }}</a>
@@ -56,20 +61,25 @@
56
61
  {
57
62
  field: 'businesses_count',
58
63
  width: 120,
59
- totalRow:'{{ parseInt(d.TOTAL_NUMS) }}',
60
- title: '商机'
64
+ totalRow: true,
65
+ sort: true,
66
+ title: '商机',
67
+ templet: "#business_a",
68
+
61
69
  },
62
70
  {
63
71
  field: 'amount',
64
72
  width: 120,
65
73
  totalRow:true,
66
- title: '中标'
74
+ sort: true,
75
+ title: '中标金额'
67
76
  },
68
77
  {
69
78
  field: 'return_mount',
70
79
  width: 120,
71
80
  totalRow:true,
72
- title: '回款',
81
+ sort: true,
82
+ title: '回款金额',
73
83
  },
74
84
  {
75
85
  title: '操作',
@@ -1,3 +1,4 @@
1
+ all_businesses_count = 0
1
2
  area_ids = EducodeSales::Common.where(clazz: 'area').ids.sort.to_s
2
3
  json.data do
3
4
  json.array! @places do |d|
@@ -13,11 +14,16 @@ json.data do
13
14
  else
14
15
  json.area_id ''
15
16
  end
16
- json.businesses_count EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").count
17
+ business_count = EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").count
18
+ json.businesses_count business_count
19
+ all_businesses_count += business_count
17
20
  json.amount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id} AND educode_sales_follow_ups.stage_id IN (?)", @stage_ids).sum(:profit_amount).round(2)
18
21
  json.return_mount EducodeSales::Business.joins(:last_follow_up).where("educode_sales_follow_ups.clazz_id != ?", @x).where("educode_sales_follow_ups.place_id = #{d.id}").sum(:return_money).round(2)
19
22
  end
20
23
  end
21
24
 
25
+ json.totalRow do
26
+ json.businesses_count all_businesses_count.to_s
27
+ end
22
28
  json.code 0
23
29
  json.count @places.total_count
@@ -101,7 +101,7 @@
101
101
  <div class="panel layui-bg-number">
102
102
  <div class="panel-body">
103
103
  <div class="panel-title">
104
- <h5>已中标<a href="/missions/businesses?name=(销售态势-<%=@year %>-已中标商机)" style="color: #0000FF;float: right">查看商机</a></h5>
104
+ <h5>已中标(总额)<a href="/missions/businesses?name=(销售态势-<%=@year %>-已中标商机)" style="color: #0000FF;float: right">查看商机</a></h5>
105
105
  </div>
106
106
  <div class="panel-content y-t-10">
107
107
  <h1 class="no-margins"><%= @goal_amount %>万</h1>
@@ -114,7 +114,7 @@
114
114
  <div class="panel layui-bg-number">
115
115
  <div class="panel-body">
116
116
  <div class="panel-title">
117
- <h5>已签单<a href="/missions/businesses?name=(销售态势-<%=@year %>-已签单商机)" style="color: #0000FF;float: right">查看商机</a></h5>
117
+ <h5>已签单(总额)<a href="/missions/businesses?name=(销售态势-<%=@year %>-已签单商机)" style="color: #0000FF;float: right">查看商机</a></h5>
118
118
  </div>
119
119
  <div class="panel-content y-t-10">
120
120
  <h1 class="no-margins"><%= @service_amount %>万</h1>
@@ -148,6 +148,32 @@
148
148
  </div>
149
149
  </div>
150
150
  </div>
151
+ <div class="layui-col-xs3">
152
+ <div class="panel layui-bg-number">
153
+ <div class="panel-body">
154
+ <div class="panel-title">
155
+ <h5>已中标(合同额)<a href="/missions/businesses?name=(销售态势-<%=@year %>-已中标商机)" style="color: #0000FF;float: right">查看商机</a></h5>
156
+ </div>
157
+ <div class="panel-content y-t-10">
158
+ <h1 class="no-margins"><%= @actual_goal_amount %>万</h1>
159
+ </div>
160
+ </div>
161
+ </div>
162
+ </div>
163
+
164
+ <div class="layui-col-xs3">
165
+ <div class="panel layui-bg-number">
166
+ <div class="panel-body">
167
+ <div class="panel-title">
168
+ <h5>已签单(合同额)<a href="/missions/businesses?name=(销售态势-<%=@year %>-已签单商机)" style="color: #0000FF;float: right">查看商机</a></h5>
169
+ </div>
170
+ <div class="panel-content y-t-10">
171
+ <h1 class="no-margins"><%= @actual_service_amount %>万</h1>
172
+ </div>
173
+ </div>
174
+ </div>
175
+ </div>
176
+
151
177
  <div class="layui-row layui-col-space30" >
152
178
  <div class="layui-col-xs3">
153
179
  <div class="panel layui-bg-number">
@@ -181,7 +207,7 @@
181
207
  <div class="layui-inline m-t-10">
182
208
  <label class="layui-form-label">视图</label>
183
209
  <div class="layui-input-inline">
184
- <%= select_tag "follow_count_range", options_for_select([['按天','day'],['按月','month'],['按年','year']],params[:follow_count_range]), {'lay-filter': 'follow_count'}%>
210
+ <%= select_tag "follow_count_range", options_for_select([['按周','week'],['按天','day'],['按月','month'],['按年','year']],params[:follow_count_range]), {'lay-filter': 'follow_count'}%>
185
211
  </div>
186
212
  </div>
187
213
  <div class="layui-inline">
@@ -189,7 +215,8 @@
189
215
  <div class="layui-input-inline">
190
216
  <input type="text" class="layui-input month layui-hide" id="date_month" name="date_month" placeholder=" - " value="<%=params[:date_month] %>" >
191
217
  <input type="text" class="layui-input year layui-hide" id="date_year" name="date_year" placeholder=" - " value="<%=params[:date_year] %>">
192
- <input type="text" class="layui-input day" id="date" name="date" placeholder=" - " value="<%=params[:date].present? ? params[:date] : (Time.now - 7.days).to_s(:date) + ' - ' + Time.now.to_s(:date) %>">
218
+ <input type="text" class="layui-input week " id="date_week" name="date_week" placeholder=" - " value="<%=params[:date_week].present? ? params[:date_week] : (Time.now - 30.days).to_s(:date) + ' - ' + Time.now.to_s(:date) %>">
219
+ <input type="text" class="layui-input day layui-hide" id="date" name="date" placeholder=" - " value="<%=params[:date] %>">
193
220
  </div>
194
221
  </div>
195
222
  <div class="layui-inline">
@@ -214,6 +241,12 @@
214
241
  <div style="margin: 10px 10px 10px 10px">
215
242
  <form class="layui-form layui-form-pane" lay-filter="search_form">
216
243
  <div class="layui-form-item">
244
+ <div class="layui-inline m-t-10">
245
+ <label class="layui-form-label">维度</label>
246
+ <div class="layui-input-inline">
247
+ <%= select_tag "count_type", options_for_select([['按合同额统计','actual_amount'],['按总额统计','total_amount']],params[:count_type]), {'lay-filter': 'count_type'}%>
248
+ </div>
249
+ </div>
217
250
  <div class="layui-inline m-t-10">
218
251
  <label class="layui-form-label">视图</label>
219
252
  <div class="layui-input-inline">
@@ -275,15 +308,23 @@
275
308
  if(follow_type == "day"){
276
309
  $(".year").addClass('layui-hide')
277
310
  $(".month").addClass('layui-hide')
311
+ $(".week").addClass('layui-hide')
278
312
  $(".day").removeClass('layui-hide')
279
313
  }else if(follow_type == "month"){
280
314
  $(".year").addClass('layui-hide')
315
+ $(".week").addClass('layui-hide')
281
316
  $(".month").removeClass('layui-hide')
282
317
  $(".day").addClass('layui-hide')
318
+ }else if(follow_type == "week"){
319
+ $(".year").addClass('layui-hide')
320
+ $(".day").addClass('layui-hide')
321
+ $(".week").removeClass('layui-hide')
322
+ $(".month").addClass('layui-hide')
283
323
  }else {
284
324
  $(".year").removeClass('layui-hide')
285
325
  $(".month").addClass('layui-hide')
286
326
  $(".day").addClass('layui-hide')
327
+ $(".week").addClass('layui-hide')
287
328
  }
288
329
 
289
330
  if(goal_type == "year"){
@@ -330,7 +371,6 @@
330
371
  range: true
331
372
  });
332
373
  laydate.render({
333
- type: 'week',
334
374
  elem: '#date_week',
335
375
  range: true
336
376
  });
@@ -367,15 +407,24 @@
367
407
  if(value == "month"){
368
408
  $(".year").addClass('layui-hide')
369
409
  $(".day").addClass('layui-hide')
410
+ $(".week").addClass('layui-hide')
370
411
  $(".month").removeClass('layui-hide')
371
412
  }else if(value == "year"){
372
413
  $(".month").addClass('layui-hide')
373
414
  $(".day").addClass('layui-hide')
415
+ $(".week").addClass('layui-hide')
374
416
  $(".year").removeClass('layui-hide')
417
+ }else if(value == "week"){
418
+ $(".month").addClass('layui-hide')
419
+ $(".day").addClass('layui-hide')
420
+ $(".week").removeClass('layui-hide')
421
+ $(".year").addClass('layui-hide')
375
422
  }else {
376
423
  $(".month").addClass('layui-hide')
377
424
  $(".year").addClass('layui-hide')
378
425
  $(".day").removeClass('layui-hide')
426
+ $(".week").addClass('layui-hide')
427
+
379
428
  }
380
429
  })
381
430
 
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.5.4'
2
+ VERSION = '0.5.5'
3
3
  end
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.5.4
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-19 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails