educode_sales 0.9.98 → 1.0.0

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: dc83991c421ec745be1b0b4e1b78bd38327b29c3463e1ed43e0253a602305ffa
4
- data.tar.gz: 237c8dfda5375b0ca1fdf8672361890f2acbb2054fa974b089d41de26fbbb130
3
+ metadata.gz: 424093f43324c2f4af4d4989f4ff829a9cf10bd9ad1ea4b42bd46c86031c8aed
4
+ data.tar.gz: cc722d4ff970b1cfb81d06f46be5b4463da9bb129ca5710dbcfc93c91e893de6
5
5
  SHA512:
6
- metadata.gz: 5798c8ef35a26bbd366b2ff2e5fcca79a16d55984ba9a13ae4a2d9b2161bdd1bd45bd285b914f8b9bfa11c1e10b3f4d1d7114fb18c086065562f85afe71cfbaf
7
- data.tar.gz: 2469abce54faa1b52c5431a276ee01752829fb3e399c1831f6d33a84ef5b52aed43abb6980baf679afd3fd3d00dbc5a032ef4eb5157cf77469b7527c71de575b
6
+ metadata.gz: 3fe4801f732d17d747152c861f101527f3160c71c7d63168bd1beec408b5f4b19f4a3f0355f1283edb5d2e125bf5e836f9b9f6ad68eff30f50095a24cb0371ef
7
+ data.tar.gz: a975715e196da44618cad0d5d6cc453f3aefbf236b58f51473b2ec2f4b1b60a6259bcd705a1bef425f844edb5d9140765cbc842f3bda03c5188a952f654e50a1
@@ -429,31 +429,24 @@ module EducodeSales
429
429
  gon.department = {value: @business.department_id, name: "#{@business.department&.school&.name}-#{@business.department&.name}"}
430
430
  gon.value = @business.department_id
431
431
 
432
-
433
-
434
- if @business.activity
435
- gon.activity = [{value: @business.activity_id, name: @business.activity.name}]
436
- gon.activity_id = @business.activity_id
437
- else
438
- gon.activity = []
439
- gon.activity_id = ''
440
- end
441
-
442
- if @business.place
443
- gon.place = [{value: @business.place_id, name: @business.place.name}]
444
- gon.place_id = @business.place_id
445
- else
446
- gon.place = []
447
- gon.place_id = ''
448
- end
449
-
450
- if @business.customer
451
- gon.customer = [{value: @business.customer_id, name: "#{@business.customer.school.name} #{@business.customer.name}"}]
452
- gon.customer_id = @business.customer_id
432
+ if ['会议活动', '渠道代理', '客户'].include?(@business.source_way) && @business.sourcable.present?
433
+ if @business.source_way == '客户'
434
+ gon.sourcable = [{name: "#{@business.sourcable.school.name} #{@business.sourcable.name}", value: @business.sourcable_id}]
435
+ else
436
+ gon.sourcable = [{name: @business.sourcable.name, value: @business.sourcable_id}]
437
+ end
438
+
439
+ gon.sourcable_id = @business.sourcable_id
440
+ elsif @business.sourcable_type.present?
441
+ gon.sourcable = [{value: @business.sourcable_type, name: @business.sourcable_type}]
442
+ gon.sourcable_id = @business.sourcable_type
453
443
  else
454
- gon.customer = []
455
- gon.customer_id = ''
444
+ gon.sourcable = []
445
+ gon.sourcable_id = ''
456
446
  end
447
+ gon.sourcable_type = @business.sourcable_type
448
+ gon.source_way = @business.source_way
449
+
457
450
 
458
451
  render layout: false
459
452
  end
@@ -480,10 +473,23 @@ module EducodeSales
480
473
  end
481
474
  end
482
475
  end
476
+ if params[:sourcable_type].present?
477
+ if params[:source_way] == '会议活动'
478
+ params[:sourcable_type] = 'EducodeSales::Activity'
479
+ elsif params[:source_way] == '渠道代理'
480
+ params[:sourcable_type] = 'EducodeSales::Place'
481
+ elsif params[:source_way] == '客户'
482
+ params[:sourcable_type] = 'EducodeSales::Department'
483
+ else
484
+ params[:sourcable_id] = ""
485
+ end
486
+ end
487
+ if params[:sourcable_type].blank?
488
+ params[:sourcable_id] = ""
489
+ end
483
490
 
484
491
  if business.update(name: params[:name], department_id: department.id, source: params[:source], school_id: department.school_id,
485
- activity_id: params[:activity_id], place_id: params[:place_id], customer_id: params[:customer_id],
486
- company_source: params[:company_source], phone: params[:phone], email: params[:email], partner: params[:partner], invite_info: params[:invite_info], friend: params[:friend]
492
+ sourcable_type: params[:sourcable_type], sourcable_id: params[:sourcable_id], source_way: params[:source_way]
487
493
  )
488
494
  if params[:merge_business_ids].present?
489
495
  merge_business = Business.where(id: params[:merge_business_ids].split(","))
@@ -496,11 +496,9 @@ module EducodeSales
496
496
  xlsx = Roo::Spreadsheet.open(params[:file])
497
497
  ods = xlsx.sheet(0)
498
498
  rows = ods.last_row - 1
499
- i = 0
500
499
  rows.times do |r| #行数
501
- i += 1
502
- next unless ods.row(r+1)[0]
503
- EducodeSales::ProductCatalog.create(name: ods.row(r+1)[0].to_s.strip, item_clazz: ods.row(r+1)[1].to_s.strip, brand: ods.row(r+1)[2].to_s.strip, specification: ods.row(r+1)[3].to_s.strip, unit: ods.row(r+1)[4].to_s.strip, param: ods.row(r+1)[5].to_s.strip, source_method: ods.row(r+1)[6].to_s.strip, supplier: ods.row(r+1)[7].to_s.strip)
500
+ next unless ods.row(r+2)[0]
501
+ EducodeSales::ProductCatalog.create(name: ods.row(r+2)[0].to_s.strip, item_clazz: ods.row(r+2)[1].to_s.strip, brand: ods.row(r+2)[2].to_s.strip, specification: ods.row(r+2)[3].to_s.strip, unit: ods.row(r+2)[4].to_s.strip, param: ods.row(r+2)[5].to_s.strip, source_method: ods.row(r+2)[6].to_s.strip, supplier: ods.row(r+2)[7].to_s.strip)
504
502
  end
505
503
 
506
504
  render json: { succcess: true}
@@ -516,7 +514,7 @@ module EducodeSales
516
514
  end
517
515
 
518
516
  def sales_detail_params
519
- params.permit(:amount, :price, :total_price, :custom_clazz, :delivery_date, :product_catalog_id, :business_id)
517
+ params.permit(:amount, :price, :total_price, :custom_clazz, :delivery_date, :product_catalog_id, :business_id, :proprietorship)
520
518
  end
521
519
 
522
520
  end
@@ -98,11 +98,17 @@ module EducodeSales
98
98
  end
99
99
 
100
100
  def search_customer
101
- part_a_ids = EducodeSales::CustomerFollow.all.pluck(:school_id)
102
- part_b_ids = EducodeSales::Business.pluck(:school_id)
103
- school_ids = (part_a_ids + part_b_ids + EducodeSales::CustomerAdd.all.pluck(:school_id)).uniq
104
- @data = Department.joins(:school).where("schools.name like ?", "%#{params[:q]}%").where("schools.id in (?)", school_ids).limit(20)
105
- p @data
101
+ if params[:type] == 'customer'
102
+ part_a_ids = EducodeSales::CustomerFollow.all.pluck(:school_id)
103
+ part_b_ids = EducodeSales::Business.pluck(:school_id)
104
+ school_ids = (part_a_ids + part_b_ids + EducodeSales::CustomerAdd.all.pluck(:school_id)).uniq
105
+ @data = Department.joins(:school).where("schools.name like ?", "%#{params[:q]}%").where("schools.id in (?)", school_ids).limit(20)
106
+ elsif params[:type] == 'active'
107
+ @data = Activity.where("name like ?", "%#{params[:q]}%").limit(20)
108
+ elsif params[:type] == 'place'
109
+ @data = EducodeSales::Place
110
+ @data = @data.where("name like :q", q: "%#{params[:q].strip}%").limit(20)
111
+ end
106
112
  end
107
113
 
108
114
  end
@@ -131,6 +131,28 @@ module EducodeSales
131
131
  end
132
132
  end
133
133
 
134
+ def upload
135
+ xlsx = Roo::Spreadsheet.open(params[:file])
136
+ ods = xlsx.sheet(0)
137
+ rows = ods.last_row - 1
138
+ rows.times do |r| #行数
139
+ next unless ods.row(r+2)[0]
140
+ business = EducodeSales::Business.find_by(number: ods.row(r+2)[0].to_s.strip)
141
+ product_catalog = EducodeSales::ProductCatalog.find_by(item_clazz: ods.row(r+2)[7].to_s.strip,
142
+ brand: ods.row(r+2)[8].to_s.strip,
143
+ specification: ods.row(r+2)[9].to_s.strip,
144
+ unit: ods.row(r+2)[10].to_s.strip,
145
+ source_method: ods.row(r+2)[14].to_s.strip,
146
+ supplier: ods.row(r+2)[16].to_s.strip)
147
+ if business.present? && product_catalog.present?
148
+ SalesDetail.create(staff_id: @current_admin.id, business_id: business.id, product_catalog_id: product_catalog.id, price: ods.row(r+2)[12].to_s.strip, amount: ods.row(r+2)[11].to_s.strip, total_price: ods.row(r+2)[13].to_s.strip, custom_clazz: ods.row(r+2)[15].to_s.strip, delivery_date: ods.row(r+2)[17].to_s.strip, proprietorship: ods.row(r+2)[18].to_s.strip)
149
+ end
150
+ end
151
+
152
+ render json: { succcess: true}
153
+ end
154
+
155
+
134
156
  private
135
157
 
136
158
  def sales_detail_params
@@ -46,7 +46,7 @@ module EducodeSales
46
46
  {
47
47
  type: type,
48
48
  label: select,
49
- data: data,
49
+ data: data.map { |d| d.round(2)},
50
50
  backgroundColor:
51
51
  backgroundColor,
52
52
  borderColor:
@@ -114,7 +114,7 @@ module EducodeSales
114
114
  {
115
115
  type: type,
116
116
  label: select,
117
- data: data,
117
+ data: data.map { |d| d.round(2)},
118
118
  backgroundColor:
119
119
  backgroundColor,
120
120
  borderColor:
@@ -179,7 +179,7 @@ module EducodeSales
179
179
  {
180
180
  type: type,
181
181
  label: select,
182
- data: data,
182
+ data: data.map { |d| d.round(2)},
183
183
  backgroundColor:
184
184
  backgroundColor,
185
185
  borderColor:
@@ -228,7 +228,7 @@ module EducodeSales
228
228
  {
229
229
  type: type,
230
230
  label: select,
231
- data: data,
231
+ data: data.map { |d| d.round(2)},
232
232
  backgroundColor:
233
233
  backgroundColor,
234
234
  borderColor:
@@ -12,10 +12,6 @@ module EducodeSales
12
12
  belongs_to :p_sale_staff, class_name: 'Staff', optional: true
13
13
  belongs_to :p_deleter, class_name: 'Staff', optional: true
14
14
 
15
- belongs_to :place, class_name: 'Place', optional: true
16
- belongs_to :customer, class_name: 'Department', optional: true
17
- belongs_to :activity, class_name: 'Activity', optional: true
18
-
19
15
  has_many :sale_plans
20
16
  has_many :follow_ups
21
17
  has_many :business_clazz_changes
@@ -23,8 +19,12 @@ module EducodeSales
23
19
  has_many :business_watches, dependent: :destroy
24
20
  has_many :business_histories, dependent: :destroy
25
21
 
22
+ belongs_to :sourcable, :polymorphic => true, optional: true
23
+
26
24
  has_many :assign_staffs, as: :sourcable, dependent: :destroy # 售后人员
27
25
 
26
+ enum source_way: ['会议活动', '公司资源', '400电话', '商务邮箱', '渠道代理', '合作伙伴', '招标信息', '客户', '朋友']
27
+
28
28
  # 关联关注
29
29
  has_many :users, :class_name => 'EducodeSales::BusinessRelationShip', foreign_key: 'business_id', :dependent => :destroy
30
30
 
@@ -4,5 +4,6 @@ module EducodeSales
4
4
  belongs_to :product_catalog
5
5
  belongs_to :staff
6
6
  enum custom_clazz: ['非定制', '低定制', '高定制', '全定制']
7
+ enum proprietorship: ['头歌', '客户', '共有']
7
8
  end
8
9
  end
@@ -21,7 +21,7 @@ module EducodeSales
21
21
  department_years_2 = {} #department_users(2)
22
22
 
23
23
  years = {}
24
- (2018..Time.current.year).each do |d|
24
+ (2014..Time.current.year).each do |d|
25
25
  years[d] = {
26
26
  'year' => d,
27
27
  'user_1' => (user_years_1[d.to_s] || 0) + (years[d-1] && years[d-1]['user_1']).to_i,
@@ -17,67 +17,14 @@
17
17
  <br>
18
18
  <div class="layui-inline" style="padding-top: 20px">
19
19
  <label class="layui-form-label required">商机来源</label>
20
- <input id="source" type="text" name="source" autocomplete="off" lay-verify="required" class="layui-input" value="<%=@business.source %>" style="width: 300px;" placeholder="请输入商机来源">
21
- </div>
22
- <div class="layui-inline" style="padding-top: 20px">
23
- <p style="padding-left: 40px">请填写提供本商机的人名(如‘张明’);如果为非头歌用户,请增加单位信息(如‘张明,华为公司’)</p>
24
- </div>
25
- <div class="layui-form-item" style="padding-top: 20px">
26
- <label class="layui-form-label">会议活动</label>
27
- <div class="layui-input-inline" style="line-height: 38px;">
28
- <div id="activity" style="width: 300px"></div>
29
- </div>
30
- </div>
31
- <div class="layui-form-item">
32
- <label class="layui-form-label">渠道代理:</label>
33
- <div class="layui-input-inline" style="line-height: 38px;">
34
- <div id="place" style="width: 300px"></div>
35
- </div>
36
- </div>
37
- <div class="layui-form-item">
38
- <label class="layui-form-label">客户</label>
39
- <div class="layui-input-inline" style="line-height: 38px;">
40
- <div id="customer" style="width: 300px"></div>
41
- </div>
42
- </div>
43
- <div class="layui-inline">
44
- <label class="layui-form-label">公司资源</label>
45
- <div class="layui-input-block">
46
- <input type="text" name="company_source" autocomplete="off" class="layui-input" value="<%= @business.company_source %>">
47
- </div>
48
- </div>
49
- <div class="layui-inline">
50
- <label class="layui-form-label">400电话</label>
51
- <div class="layui-input-block">
52
- <input type="text" name="phone" autocomplete="off" class="layui-input" value="<%= @business.phone %>">
53
- </div>
54
- </div>
55
- <div class="layui-inline">
56
- <label class="layui-form-label">商务邮箱</label>
57
- <div class="layui-input-block">
58
- <input type="text" name="email" autocomplete="off" class="layui-input" value="<%= @business.email %>">
59
- </div>
60
- </div>
61
-
62
- <div class="layui-inline">
63
- <label class="layui-form-label">合作伙伴</label>
64
- <div class="layui-input-block">
65
- <input type="text" name="partner" autocomplete="off" class="layui-input" value="<%= @business.partner %>">
20
+ <div class="layui-inline">
21
+ <%= select_tag "source_way", options_for_select(EducodeSales::Business.source_ways.keys, @business.source_way), { include_blank: true, "lay-filter": 'source_id', "lay-verify": "required" } %>
66
22
  </div>
67
- </div>
68
- <div class="layui-inline">
69
- <label class="layui-form-label">招标信息</label>
70
- <div class="layui-input-block">
71
- <input type="text" name="invite_info" autocomplete="off" class="layui-input" value="<%= @business.invite_info %>">
23
+ <div class="layui-inline" style="line-height: 38px;" id="source_wraper">
24
+ <div id="customer_id" style="width: 360px"></div>
72
25
  </div>
73
26
  </div>
74
27
 
75
- <div class="layui-inline">
76
- <label class="layui-form-label">朋友</label>
77
- <div class="layui-input-block">
78
- <input type="text" name="friend" autocomplete="off" class="layui-input" value="<%= @business.friend %>">
79
- </div>
80
- </div>
81
28
  <% if can?(:merge_business, EducodeSales::Business) %>
82
29
  <div class="layui-inline-block" style="padding-top: 20px">
83
30
  <label class="layui-form-label ">合并商机</label>
@@ -149,6 +96,46 @@
149
96
  if (gon.is_secret) {
150
97
  $("#watch_ids_wraper").removeClass("layui-hide")
151
98
  }
99
+ var source_way = gon.source_way;
100
+ form.on('select(source_id)', function(data){
101
+ source_way = data.value;
102
+ setSourceWay(data.value);
103
+ $("#" + customer_select._input)[0].value = "";
104
+ });
105
+
106
+
107
+ function setSourceWay(value) {
108
+ if (value == '400电话' || value == '商务邮箱') {
109
+ $("#source_wraper").hide()
110
+ } else {
111
+ $("#source_wraper").show()
112
+ var text = "";
113
+ switch (value) {
114
+ case '会议活动':
115
+ text = "请选择活动运营";
116
+ break;
117
+ case '公司资源':
118
+ text = "请填写公司领导、部门其他同事姓名";
119
+ break;
120
+ case '渠道代理':
121
+ text = "请选择渠道";
122
+ break;
123
+ case '合作伙伴':
124
+ text = "请填写合作伙伴公司名称";
125
+ break;
126
+ case '招标信息':
127
+ text = "请填写招标信息";
128
+ break;
129
+ case '客户':
130
+ text = "请选择客户";
131
+ break;
132
+ case '朋友':
133
+ text = "请填写姓名";
134
+ break;
135
+ }
136
+ $("#" + customer_select._input)[0].placeholder = text;
137
+ }
138
+ }
152
139
 
153
140
  form.render();
154
141
  var department_id = gon.value;
@@ -172,6 +159,7 @@
172
159
  request.get('missions/search?type=department&q=' + value, {}, function (res) {
173
160
  return cb(res)
174
161
  })
162
+
175
163
  }
176
164
  });
177
165
 
@@ -189,90 +177,47 @@
189
177
  data: []
190
178
  })
191
179
 
192
- var activity_id = gon.activity_id;
193
- var activity_select = selectInput.render({
194
- elem: '#activity',
195
- name: 'activity_id', // 渲染的input的name值
196
- layFilter: 'test', //同layui form参数lay-filter
197
- // layVerify: 'required', //同layui form参数lay-verify
198
- layVerType: 'tips', // 同layui form参数lay-verType
199
- layReqText: '请填写文本', //同layui form参数lay-ReqText
200
- initValue: gon.activity_id, // 渲染初始化默认值
201
- hasSelectIcon: false,
202
- placeholder: '请输入会议活动', // 渲染的inputplaceholder值
203
- data: gon.activity,
204
- remoteSearch: true, // 是否启用远程搜索 默认是false,和远程搜索回调保存同步
205
- remoteMethod: function (value, cb) { // 远程搜索的回调函数
206
- if (!value) {
207
- activity_id = "";
208
- return cb([]);
209
- }
210
- request.get('missions/search_activity?q=' + value, {}, function (res) {
211
- if (res.data.length == 0) {
212
- activity_select.emptyValue();
213
- return cb([])
214
- }
215
- return cb(res)
216
- })
217
- }
218
- });
219
180
 
220
- var place_id = gon.place_id;
221
- var place_select = selectInput.render({
222
- elem: '#place',
223
- name: 'place_id', // 渲染的input的name值
224
- layFilter: 'test', //同layui form参数lay-filter
225
- // layVerify: 'required', //同layui form参数lay-verify
226
- layVerType: 'tips', // 同layui form参数lay-verType
227
- layReqText: '请填写文本', //同layui form参数lay-ReqText
228
- initValue: gon.place_id, // 渲染初始化默认值
229
- hasSelectIcon: false,
230
- placeholder: '请输入渠道代理', // 渲染的inputplaceholder值
231
- data: gon.place,
232
- remoteSearch: true, // 是否启用远程搜索 默认是false,和远程搜索回调保存同步
233
- remoteMethod: function (value, cb) { // 远程搜索的回调函数
234
- if (!value) {
235
- place_id = "";
236
- return cb([]);
237
- }
238
- request.get('missions/sales_place?q=' + value, {}, function (res) {
239
- if (res.data.length == 0) {
240
- place_select.emptyValue();
241
- return cb([])
242
- }
243
- return cb(res)
244
- })
245
- }
246
- });
247
-
248
- var customer_id = gon.customer_id;
181
+ var sourcable_id = gon.sourcable_id;
249
182
  var customer_select = selectInput.render({
250
- elem: '#customer',
251
- name: 'customer_id', // 渲染的input的name值
183
+ elem: '#customer_id',
184
+ name: 'sourcable_type', // 渲染的input的name值
252
185
  layFilter: 'test', //同layui form参数lay-filter
253
186
  // layVerify: 'required', //同layui form参数lay-verify
254
187
  layVerType: 'tips', // 同layui form参数lay-verType
255
188
  layReqText: '请填写文本', //同layui form参数lay-ReqText
256
- initValue: gon.customer_id, // 渲染初始化默认值
189
+ initValue: gon.sourcable_id, // 渲染初始化默认值
257
190
  hasSelectIcon: false,
258
- placeholder: '请输入客户', // 渲染的inputplaceholder值
259
- data: gon.customer,
191
+ placeholder: '请输入商机来源', // 渲染的inputplaceholder值
192
+ data: gon.sourcable,
260
193
  remoteSearch: true, // 是否启用远程搜索 默认是false,和远程搜索回调保存同步
261
194
  remoteMethod: function (value, cb) { // 远程搜索的回调函数
262
195
  if (!value) {
263
- customer_id = "";
196
+ sourcable_id = "";
264
197
  return cb([]);
265
198
  }
266
- request.get('missions/search_customer?q=' + value, {}, function (res) {
267
- if (res.data.length == 0) {
268
- customer_select.emptyValue();
269
- return cb([])
199
+ if (['会议活动', '渠道代理', '客户'].includes(source_way)) {
200
+ var type = "";
201
+ if (source_way == '客户') {
202
+ type = 'customer';
203
+ } else if (source_way == '渠道代理') {
204
+ type = 'place';
205
+ } else if (source_way == '会议活动') {
206
+ type = 'active';
270
207
  }
271
- return cb(res)
272
- })
208
+ request.get('missions/search_customer?q=' + value + "&type=" + type, {}, function (res) {
209
+ if (res.data.length == 0) {
210
+ customer_select.emptyValue();
211
+ return cb([])
212
+ }
213
+ return cb(res)
214
+ })
215
+ }
273
216
  }
274
217
  });
275
218
 
219
+ setSourceWay(source_way);
220
+
276
221
  // 当前弹出层,防止ID被覆盖
277
222
  var parentIndex = layer.index;
278
223
 
@@ -285,9 +230,7 @@
285
230
  var field = data.field;
286
231
  field.department_id = department.getValue() || department_id;
287
232
  field.merge_business_ids = data.field.merge_business_ids;
288
- field.activity_id = activity_select.getValue() || activity_id;
289
- field.place_id = place_select.getValue() || place_id;
290
- field.customer_id = customer_select.getValue() || customer_id;
233
+ field.sourcable_id = customer_select.getValue() || sourcable_id;
291
234
  request.authPut("missions/businesses/" + parent.id, field, function (res) {
292
235
  if (res.success == false) {
293
236
  layer.alert(res.msg)
@@ -44,6 +44,12 @@
44
44
  <input type="text" name="delivery_date" value="" class="layui-input" lay-verify="required" id="delivery_date">
45
45
  </div>
46
46
  </div>
47
+ <div class="layui-inline">
48
+ <label class="layui-form-label required">知识产权归属:</label>
49
+ <div class="layui-input-inline">
50
+ <%= select_tag "proprietorship", options_for_select(EducodeSales::SalesDetail.proprietorships.keys), { 'lay-filter': 'proprietorship', 'lay-verify': "required", include_blank: true, "lay-search": "" } %>
51
+ </div>
52
+ </div>
47
53
  </div>
48
54
  <div class="layui-form-item">
49
55
  <div class="layui-input-block">
@@ -1,7 +1,12 @@
1
1
  json.data do
2
2
  json.array! @data do |d|
3
- json.value d.id
4
- json.name "#{d.school.name} #{d.name}"
3
+ if params[:type] == 'customer'
4
+ json.value d.id
5
+ json.name "#{d.school.name} #{d.name}"
6
+ else
7
+ json.value d.id
8
+ json.name d.name
9
+ end
5
10
  end
6
11
  end
7
12
  json.code 0
@@ -84,19 +84,18 @@
84
84
 
85
85
  </script>
86
86
 
87
- <script type="text/html" id="toolbar_contract">
88
- <div class="layui-btn-container">
89
- <span class="table-label">销售明细</span>
90
- </div>
87
+ <script type="text/html" id="toolbar_sales">
88
+ <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn pull-right" id="upload_sales_btn" style="margin-left: 20px;">批量导入销售明细</button>
91
89
  </script>
92
90
  <script>
93
- layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate', 'dropdown', 'laytpl', 'xmSelect'], function() {
91
+ layui.use(['form', 'table', 'miniPage', 'element', 'request', 'laydate', 'dropdown', 'laytpl', 'xmSelect', 'upload'], function() {
94
92
  var $ = layui.jquery,
95
93
  form = layui.form,
96
94
  request = layui.request,
97
95
  miniPage = layui.miniPage,
98
96
  dropdown = layui.dropdown,
99
97
  xmSelect = layui.xmSelect,
98
+ upload = layui.upload,
100
99
  laydate = layui.laydate;
101
100
  var openWH = miniPage.getOpenWidthHeight();
102
101
  laydate.render({
@@ -181,6 +180,10 @@
181
180
  width: 100,
182
181
  title: '数量',
183
182
  }, {
183
+ field: 'price',
184
+ width: 100,
185
+ title: '单价',
186
+ },{
184
187
  field: 'total_price',
185
188
  width: 100,
186
189
  title: '金额',
@@ -201,7 +204,10 @@
201
204
  field: 'delivery_date',
202
205
  width: 120,
203
206
  title: '交货时间',
204
- sort: true,
207
+ }, {
208
+ field: 'proprietorship',
209
+ width: 120,
210
+ title: '知识产权归属',
205
211
  }, {
206
212
  title: '操作',
207
213
  minWidth: 350,
@@ -223,14 +229,42 @@
223
229
  title: '销售明细数据表',
224
230
  totalRow: true, //开启合并行
225
231
  cols: cols_table,
226
- toolbar: '#toolbar_contract',
232
+ toolbar: '#toolbar_sales',
227
233
  limit: 20,
228
234
  limits: [10, 15, 20, 30, 40, 50, 60, 70, 80, 90],
229
235
  page: true,
230
236
  skin: 'line',
237
+ done: function() {
238
+ if ($('#upload_sales_btn').length > 0) {
239
+ uploadSales();
240
+ }
241
+ }
231
242
  });
232
243
 
233
-
244
+ function uploadSales() {
245
+ upload.render({
246
+ elem: '#upload_sales_btn'
247
+ ,url: '/missions/sales_details/upload'
248
+ ,accept: 'file' //普通文件
249
+ ,acceptMime: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.ms-excel'
250
+ ,headers: {
251
+ 'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
252
+ }
253
+ ,before: function(obj){
254
+ layer.load();
255
+ }
256
+ ,done: function(res){
257
+ layer.msg('导入成功');
258
+ table.reload('sales_details_table');
259
+ layer.closeAll('loading'); //关闭loading
260
+ }
261
+ ,error: function(index, upload){
262
+ table.reload('file');
263
+ layer.closeAll('loading'); //关闭loading
264
+ layer.alert('导入失败,请检查文件格式')
265
+ }
266
+ });
267
+ }
234
268
  var sort = {},
235
269
  search = data;
236
270
 
@@ -20,11 +20,13 @@ json.data do
20
20
  json.specification d.product_catalog.specification
21
21
  json.unit d.product_catalog.unit
22
22
  json.amount d.amount
23
+ json.price d.price
23
24
  json.total_price d.total_price
24
25
  json.source_method d.product_catalog.source_method
25
26
  json.custom_clazz d.custom_clazz
26
27
  json.supplier d.product_catalog.supplier
27
28
  json.delivery_date d.delivery_date
29
+ json.proprietorship d.proprietorship
28
30
  end
29
31
  end
30
32
 
data/config/routes.rb CHANGED
@@ -25,6 +25,9 @@ EducodeSales::Engine.routes.draw do
25
25
  end
26
26
 
27
27
  resources :sales_details do
28
+ collection do
29
+ post :upload
30
+ end
28
31
  end
29
32
 
30
33
  resources :contracts do
@@ -0,0 +1,18 @@
1
+ class AddProprietorshipEducodeSalesSalesDetails < ActiveRecord::Migration[5.2]
2
+ def change
3
+ add_column :educode_sales_sales_details, :proprietorship, :integer
4
+ add_column :educode_sales_businesses, :source_way, :integer
5
+ add_column :educode_sales_businesses, :sourcable_type, :string
6
+ add_column :educode_sales_businesses, :sourcable_id, :integer
7
+
8
+ remove_column :educode_sales_businesses, :activity_id, :integer
9
+ remove_column :educode_sales_businesses, :place_id, :integer
10
+ remove_column :educode_sales_businesses, :customer_id, :integer
11
+ remove_column :educode_sales_businesses, :company_source, :string
12
+ remove_column :educode_sales_businesses, :phone, :string
13
+ remove_column :educode_sales_businesses, :email, :string
14
+ remove_column :educode_sales_businesses, :partner, :string
15
+ remove_column :educode_sales_businesses, :invite_info, :string
16
+ remove_column :educode_sales_businesses, :friend, :string
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.98'
2
+ VERSION = '1.0.0'
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.9.98
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - anke1460
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-20 00:00:00.000000000 Z
11
+ date: 2023-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -682,6 +682,7 @@ files:
682
682
  - db/migrate/20230502142912_create_educode_sales_product_catalogs.rb
683
683
  - db/migrate/20230510144317_create_educode_sales_sales_details.rb
684
684
  - db/migrate/20230520023902_add_activity_educode_sales_business.rb
685
+ - db/migrate/20230523115007_add_proprietorship_educode_sales_sales_details.rb
685
686
  - lib/educode_sales.rb
686
687
  - lib/educode_sales/engine.rb
687
688
  - lib/educode_sales/version.rb