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
b680fa0e
Commit
b680fa0e
authored
Nov 08, 2021
by
liyijie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 支持source的配置,判断association_record 还是 record
parent
d24a60ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
2 deletions
+6
-2
export.rb
lib/tallty_import_export/export.rb
+6
-2
No files found.
lib/tallty_import_export/export.rb
View file @
b680fa0e
...
...
@@ -15,7 +15,7 @@ module TalltyImportExport
# { key: 'user_code', name: '考核人工号' },
# { key: 'user_department_name', name: '考核人部门' },
# { key: 'state', name: '考核状态', method: :state_zh },
# { key: 'score', name: '考核分' },
# { key: 'score', name: '考核分'
, source: true
},
# ]
# export_headers_result / headers
# key: 属性的英文名,可以支持user.name这样的方式
...
...
@@ -28,6 +28,7 @@ module TalltyImportExport
# merge: true/false,默认false,某一列,如果上下行的内容相同,则直接合并单元格
# json: model_payload,代表存储在某一个列中
# select: [{ label: '已报备', value: 'submitted'}, ...],需要转换的枚举类型
# source: true,如果source为true,代表从association_record 进行属性查询
def
export_xlsx
records
,
**
options
records
=
with_scope
records
...
...
@@ -96,7 +97,10 @@ module TalltyImportExport
records
=
@each_method
.
present?
?
association_record
.
try_method
(
@each_method
)
:
[
association_record
]
records
.
each
do
|
record
|
index
+=
1
_data
=
handle_data
(
record
,
header
,
index
)
_data
=
header
[
:source
]
?
handle_data
(
association_record
,
header
,
index
)
:
handle_data
(
record
,
header
,
index
)
if
header
[
:merge
].
present?
&&
last_row
.
present?
&&
_data
==
last_row
[
col_index
]
# 这里使用二维数组,每个数组里都是列内容相同的各行
merge_column_hash
[
col_index
]
||=
[]
...
...
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