Commit 391a274d by liyijie

feat: export_association_headers use array

parent 2aea9d55
......@@ -67,14 +67,21 @@ module TalltyImportExport
# 是否导出详细子表
# export_association_headers的结构,是association结合
if respond_to?(:export_association_headers)
export_association_headers(**options).each do |export_association, association_headers|
records.each do |record|
association_records = record.send(:export_association)
context.record = record
Array(export_association_headers(**options)).each do |association_headers|
association_headers.with_indifferent_access!
association_records = record.send(association_headers[:association])
sheet_name = if association_headers[:sheet_name].present?
association_headers[:sheet_name].respond_to?(:call) ?
association_headers[:sheet_name].call(record, context) :
association_headers[:sheet_name]
end
export_workbook(
workbook,
association_records,
sheet_name: record.try(:name),
export_headers: association_headers,
sheet_name: sheet_name || record.try(:name),
export_headers: association_headers[:headers],
**options,
)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment