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
e493e4fe
Commit
e493e4fe
authored
Mar 30, 2021
by
Ivan Lan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add export_header_result and import_header_result
parent
0802ca29
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
9 deletions
+9
-9
export.rb
lib/tallty_import_export/export.rb
+4
-4
import.rb
lib/tallty_import_export/import.rb
+5
-5
No files found.
lib/tallty_import_export/export.rb
View file @
e493e4fe
...
...
@@ -17,7 +17,7 @@ module TalltyImportExport
# { key: 'state', name: '考核状态', method: :state_zh },
# { key: 'score', name: '考核分' },
# ]
# export_headers / headers
# export_headers
_result
/ headers
# key: 属性的英文名
# name: 属性的中文名
# attr_type: 属性的类型
...
...
@@ -67,7 +67,7 @@ module TalltyImportExport
title1
=
workbook
.
styles
.
add_style
(
alignment:
alignment
,
border:
border
,
sz:
12
,
b:
true
)
title2
=
workbook
.
styles
.
add_style
(
alignment:
alignment
,
border:
border
,
bg_color:
"2a5caa"
,
sz:
12
,
fg_color:
"fffffb"
)
title3
=
workbook
.
styles
.
add_style
(
alignment:
alignment
.
merge
(
wrap_text:
true
),
border:
border
,
sz:
10
)
headers
=
export_headers
headers
=
export_headers
_result
_sheet_name
=
respond_to?
(
:sheet_name
)
?
self
.
sheet_name
:
nil
...
...
@@ -105,8 +105,8 @@ module TalltyImportExport
records
end
def
export_headers
@headers
||
klass
.
try
(
:headers
)
||
klass
.
try
(
:model_headers
)
def
export_headers
_result
@headers
||
klass
.
try
(
:
export_headers
)
||
klass
.
try
(
:
headers
)
||
klass
.
try
(
:model_headers
)
end
# 处理一个记录的数据
...
...
lib/tallty_import_export/import.rb
View file @
e493e4fe
...
...
@@ -5,7 +5,7 @@ module TalltyImportExport
def
initialize
klass
@klass
=
klass
@headers
=
import_headers
.
map
{
|
header
|
header
.
with_indifferent_access
}
@headers
=
import_headers
_result
.
map
{
|
header
|
header
.
with_indifferent_access
}
@context
=
Context
.
new
({})
end
...
...
@@ -96,14 +96,14 @@ module TalltyImportExport
true
end
def
import_headers
klass
.
try
(
:headers
)
||
klass
.
try
(
:
model_headers
)
||
(
raise
ArgumentError
.
new
(
'missing import_headers
'
))
def
import_headers
_result
klass
.
try
(
:headers
)
||
klass
.
try
(
:
import_headers
)
||
klass
.
try
(
:model_headers
)
||
(
raise
ArgumentError
.
new
(
'missing import_headers_result
'
))
end
# 只保留 key, name, json, 合并到 import_header
def
headers
=
val
if
val
.
empty?
@headers
=
import_headers
.
map
{
|
header
|
header
.
with_indifferent_access
}
@headers
=
import_headers
_result
.
map
{
|
header
|
header
.
with_indifferent_access
}
return
end
...
...
@@ -114,7 +114,7 @@ module TalltyImportExport
result
=
[]
val
.
map
do
|
header
|
if
(
exist_header
=
import_headers
.
find
{
|
model_header
|
model_header
[
:key
]
===
header
[
:key
]
})
if
(
exist_header
=
import_headers
_result
.
find
{
|
model_header
|
model_header
[
:key
]
===
header
[
:key
]
})
result
.
push
(
exist_header
.
merge
(
name:
header
[
:name
],
json:
header
[
:json
]))
else
result
.
push
({
key:
header
[
:key
],
name:
header
[
:name
],
json:
header
[
:json
]})
...
...
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