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
86c7dca0
Commit
86c7dca0
authored
May 23, 2021
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
try_method support try_method
parent
08348a6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
export.rb
lib/tallty_import_export/export.rb
+11
-2
No files found.
lib/tallty_import_export/export.rb
View file @
86c7dca0
...
...
@@ -18,7 +18,7 @@ module TalltyImportExport
# { key: 'score', name: '考核分' },
# ]
# export_headers_result / headers
# key: 属性的英文名
# key: 属性的英文名
,可以支持user.name这样的方式
# name: 属性的中文名
# attr_type: 属性的类型
# format: excel是否需要特定的格式,目前主要是类似于身份证号,可以用string
...
...
@@ -156,13 +156,22 @@ module TalltyImportExport
elsif
header
[
:json
]
record
.
send
(
header
[
:json
])[
header
[
:key
]]
else
record
.
send
(
header
[
:key
])
try_method
(
record
,
header
[
:key
])
end
handle_format
(
data
,
header
)
rescue
''
end
def
try_chain
record
,
arr
arr
.
inject
(
record
,
:try
)
end
def
try_method
record
,
method
arr
=
method
.
to_s
.
split
(
/\./
)
try_chain
record
,
arr
end
# 根据数据类型 attr_type 进行数据的格式化
def
handle_format
data
,
header
case
header
[
:attr_type
].
to_s
...
...
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