educode_sales 0.9.98 → 0.9.99

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: 8d3b1f62cddc62c5e2d319320a0b53622d8c610a565923613fee6cf6cedcacb9
4
+ data.tar.gz: 882b25401c7319bed2b1de0eca8e331a58ed46976ea6d1fff5425758ddd6ced5
5
5
  SHA512:
6
- metadata.gz: 5798c8ef35a26bbd366b2ff2e5fcca79a16d55984ba9a13ae4a2d9b2161bdd1bd45bd285b914f8b9bfa11c1e10b3f4d1d7114fb18c086065562f85afe71cfbaf
7
- data.tar.gz: 2469abce54faa1b52c5431a276ee01752829fb3e399c1831f6d33a84ef5b52aed43abb6980baf679afd3fd3d00dbc5a032ef4eb5157cf77469b7527c71de575b
6
+ metadata.gz: 866d6f020e66dd334e039e2ac2cb67a059f03712c3ad92cd632a249d96f7076661238d7b418ca9eab87907954f81a01dea8508df86bf12169fe91f7540d151ae
7
+ data.tar.gz: e0559ef009cbf4b4e0b718d00783d2d513a0ef8722831065e7b42d654c48f143c1411f6617252aae4a8b20d681e6687061a771a58ddbc1fee01967159b897cea
@@ -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}
@@ -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)
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
@@ -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,
@@ -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: '金额',
@@ -223,14 +226,42 @@
223
226
  title: '销售明细数据表',
224
227
  totalRow: true, //开启合并行
225
228
  cols: cols_table,
226
- toolbar: '#toolbar_contract',
229
+ toolbar: '#toolbar_sales',
227
230
  limit: 20,
228
231
  limits: [10, 15, 20, 30, 40, 50, 60, 70, 80, 90],
229
232
  page: true,
230
233
  skin: 'line',
234
+ done: function() {
235
+ if ($('#upload_sales_btn').length > 0) {
236
+ uploadSales();
237
+ }
238
+ }
231
239
  });
232
240
 
233
-
241
+ function uploadSales() {
242
+ upload.render({
243
+ elem: '#upload_sales_btn'
244
+ ,url: '/missions/sales_details/upload'
245
+ ,accept: 'file' //普通文件
246
+ ,acceptMime: 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/vnd.ms-excel'
247
+ ,headers: {
248
+ 'X-CSRF-Token': $('meta[name=csrf-token]').attr('content')
249
+ }
250
+ ,before: function(obj){
251
+ layer.load();
252
+ }
253
+ ,done: function(res){
254
+ layer.msg('导入成功');
255
+ table.reload('sales_details_table');
256
+ layer.closeAll('loading'); //关闭loading
257
+ }
258
+ ,error: function(index, upload){
259
+ table.reload('file');
260
+ layer.closeAll('loading'); //关闭loading
261
+ layer.alert('导入失败,请检查文件格式')
262
+ }
263
+ });
264
+ }
234
265
  var sort = {},
235
266
  search = data;
236
267
 
@@ -20,6 +20,7 @@ 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
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
@@ -1,3 +1,3 @@
1
1
  module EducodeSales
2
- VERSION = '0.9.98'
2
+ VERSION = '0.9.99'
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: 0.9.99
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-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -705,7 +705,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
705
705
  - !ruby/object:Gem::Version
706
706
  version: '0'
707
707
  requirements: []
708
- rubygems_version: 3.0.9
708
+ rubygems_version: 3.0.0
709
709
  signing_key:
710
710
  specification_version: 4
711
711
  summary: Summary of EducodeSales.