Commit efc2555a by Ivan Lan

fix: 导出支持 headers 传入

parent 690b3080
......@@ -28,7 +28,7 @@ module TalltyImportExport
def export_xlsx records, **options
records = with_scope records
exportable_defaults(options)
process_options(options)
options = options.with_indifferent_access
......@@ -90,7 +90,7 @@ module TalltyImportExport
end
end
def exportable_defaults options = {}
def process_options options = {}
options = options.with_indifferent_access
@row_height ||= options.delete(:row_height) || 35
......@@ -98,16 +98,13 @@ module TalltyImportExport
@filename ||= options.delete(:filename)
@group_by ||= options.delete(:group_by)
@group_where = "#{@group_by}_eq" if @group_by.present?
@headers ||= options.delete(:headers)
end
def with_scope records
records
end
def headers= val
@headers = val.map { |header| header.with_indifferent_access }
end
def export_headers
@headers || klass.try(:headers) || klass.try(:model_headers)
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