Commit 391a274d by liyijie

feat: export_association_headers use array

parent 2aea9d55
...@@ -67,14 +67,21 @@ module TalltyImportExport ...@@ -67,14 +67,21 @@ module TalltyImportExport
# 是否导出详细子表 # 是否导出详细子表
# export_association_headers的结构,是association结合 # export_association_headers的结构,是association结合
if respond_to?(:export_association_headers) if respond_to?(:export_association_headers)
export_association_headers(**options).each do |export_association, association_headers| records.each do |record|
records.each do |record| context.record = record
association_records = record.send(:export_association) 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( export_workbook(
workbook, workbook,
association_records, association_records,
sheet_name: record.try(:name), sheet_name: sheet_name || record.try(:name),
export_headers: association_headers, export_headers: association_headers[:headers],
**options, **options,
) )
end 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