Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tallty_import_export
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
tallty_import_export
Commits
bc77df7b
Commit
bc77df7b
authored
Sep 20, 2021
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add handle_select
parent
3a13f44b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
35 deletions
+47
-35
Gemfile.lock
Gemfile.lock
+32
-31
export.rb
lib/tallty_import_export/export.rb
+13
-2
import.rb
lib/tallty_import_export/import.rb
+1
-1
version.rb
lib/tallty_import_export/version.rb
+1
-1
No files found.
Gemfile.lock
View file @
bc77df7b
PATH
remote: .
specs:
tallty_import_export (
0.1.0
)
tallty_import_export (
1.0.22
)
activesupport
caxlsx
redis
...
...
@@ -14,33 +14,35 @@ PATH
GEM
remote: https://gems.ruby-china.com/
specs:
activemodel (6.
0.3.4
)
activesupport (= 6.
0.3.4
)
activesupport (6.
0.3.4
)
activemodel (6.
1.4.1
)
activesupport (= 6.
1.4.1
)
activesupport (6.
1.4.1
)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>=
0.7
, < 2)
minitest (
~>
5.1)
tzinfo (~>
1.1
)
zeitwerk (~> 2.
2, >= 2.2.2
)
caxlsx (3.
0.2
)
i18n (>=
1.6
, < 2)
minitest (
>=
5.1)
tzinfo (~>
2.0
)
zeitwerk (~> 2.
3
)
caxlsx (3.
1.0
)
htmlentities (~> 4.3, >= 4.3.4)
m
imemagic (~> 0.3
)
m
arcel (~> 1.0
)
nokogiri (~> 1.10, >= 1.10.4)
rubyzip (>= 1.3.0, < 3)
concurrent-ruby (1.1.
7
)
concurrent-ruby (1.1.
9
)
diff-lcs (1.4.4)
htmlentities (4.3.4)
i18n (1.8.
5
)
i18n (1.8.
10
)
concurrent-ruby (~> 1.0)
mimemagic (0.3.5)
mini_portile2 (2.4.0)
minitest (5.14.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
marcel (1.0.1)
mini_portile2 (2.6.1)
minitest (5.14.4)
nokogiri (1.12.4)
mini_portile2 (~> 2.6.1)
racc (~> 1.4)
racc (1.5.2)
rake (12.3.3)
redis (4.
2.5
)
redis-objects (1.5.
0
)
redis (~> 4.
0
)
redis (4.
4.0
)
redis-objects (1.5.
1
)
redis (~> 4.
2
)
roo (2.8.3)
nokogiri (~> 1)
rubyzip (>= 1.3.0, < 3.0.0)
...
...
@@ -62,18 +64,17 @@ GEM
rspec-support (~> 3.10.0)
rspec-support (3.10.0)
ruby-ole (1.2.12.2)
rubyzip (2.3.
0
)
spreadsheet (1.2.
6
)
ruby-ole
(>= 1.0)
tallty_duck_record (1.
0.2
)
activemodel (
~> 6.0.3
)
activesupport (
~> 6.0.3
)
rubyzip (2.3.
2
)
spreadsheet (1.2.
9
)
ruby-ole
tallty_duck_record (1.
1.3
)
activemodel (
>= 5.0
)
activesupport (
>= 5.0
)
tallty_form (1.0.0)
tallty_duck_record
thread_safe (0.3.6)
tzinfo (1.2.8)
thread_safe (~> 0.1)
zeitwerk (2.4.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
zeitwerk (2.4.2)
zip-zip (0.3)
rubyzip (>= 1.0.0)
...
...
@@ -86,4 +87,4 @@ DEPENDENCIES
tallty_import_export!
BUNDLED WITH
2.
1.4
2.
2.15
lib/tallty_import_export/export.rb
View file @
bc77df7b
...
...
@@ -27,6 +27,7 @@ module TalltyImportExport
# index: 数组方式,需要嵌套拿到里面的
# merge: true/false,默认false,某一列,如果上下行的内容相同,则直接合并单元格
# json: model_payload,代表存储在某一个列中
# select: [{ label: '已报备', value: 'submitted'}, ...],需要转换的枚举类型
def
export_xlsx
records
,
**
options
records
=
with_scope
records
...
...
@@ -138,7 +139,7 @@ module TalltyImportExport
end
def
export_headers_result
@headers
||
export_header
s
@headers
||
=
export_headers
&
.
with_indifferent_acces
s
end
def
export_headers
**
args
...
...
@@ -159,7 +160,8 @@ module TalltyImportExport
else
try_method
(
record
,
header
[
:key
])
end
handle_format
(
data
,
header
)
data
=
handle_format
(
data
,
header
)
data
=
handle_select
(
data
,
header
)
rescue
''
end
...
...
@@ -186,5 +188,14 @@ module TalltyImportExport
data
end
end
def
handle_select
data
,
header
if
header
[
:select
].
present?
select_option
=
header
[
:select
].
find
{
|
option
|
option
[
:value
].
to_s
==
data
.
to_s
}
select_option
.
present?
?
select_option
[:
label
]
:
data
else
data
end
end
end
end
lib/tallty_import_export/import.rb
View file @
bc77df7b
...
...
@@ -104,7 +104,7 @@ module TalltyImportExport
end
def
import_headers_result
@headers
||=
import_headers
@headers
||=
import_headers
&
.
with_indifferent_access
end
def
import_headers
**
args
...
...
lib/tallty_import_export/version.rb
View file @
bc77df7b
module
TalltyImportExport
VERSION
=
"1.0.2
2
"
VERSION
=
"1.0.2
3
"
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment