Skip to content

Importer & Exporter 导入导出 ​

表格查询页通用的导入和导出组件,提供统一的上传下载交互体验。

基础用法 ​

暂无数据
共 0 条
  • 1
前往
页

Importer 导入组件 ​

用于表格数据的批量导入,提供模板下载和文件上传功能。

基础示例 ​

点击导入按钮,打开导入弹窗,可下载模板后上传文件。

vue
<hx-importer
  :upload-action="'/api/import/upload'"
  :template-url="'/api/import/template'"
  :accept="'.xlsx,.xls'"
  :max-size="10"
  @success="handleImportSuccess"
/>

Exporter 导出组件 ​

用于表格数据的批量导出,支持按页、全部、选中三种导出方式。

基础示例 ​

点击导出按钮,选择导出方式后确认导出。

vue
<hx-exporter
  :export-action="'/api/export'"
  :get-search-params="getSearchParams"
  :total-count="totalCount"
  :current-page="currentPage"
  :page-size="pageSize"
  :selected-rows="selectedRows"
  :max-export-count="10000"
  @success="handleExportSuccess"
/>

导出方式 ​

  • 按页导出:导出当前页数据
  • 全部导出:导出符合筛选条件的所有数据
  • 选中导出:导出表格中已选中的行数据(需配合 el-table 的 selection)

API ​

Importer Props ​

参数名说明类型默认值
template-url模板下载地址(有值则显示模板下载)string-
template-file-name模板文件名(用于下载显示)string-
upload-action上传接口地址string-
upload-params上传附带参数Record<string, string | Blob>-
accept接受文件类型string.xlsx,.xls
max-size最大文件大小(MB)number10
button-text按钮文本string导入
dialog-title弹窗标题string导入数据

Importer Events ​

事件名说明参数
success上传成功回调(response: any) => void
error上传失败回调(error: any) => void

Importer Expose ​

方法名说明
open打开导入弹窗
close关闭导入弹窗

Exporter Props ​

参数名说明类型默认值
export-action导出接口地址string-
max-export-count最大导出数量限制number10000
selected-rows选中行数据(用于选中导出)any[][]
row-id-field选中行 ID 字段名stringid
get-search-params获取当前检索条件的函数() => Record<string, any>-
total-count当前总数据量number0
current-page当前页码number1
page-size每页数量number10
button-text按钮文本string导出
dialog-title弹窗标题string导出数据
extra-params导出参数额外补充Record<string, any>{}
file-name-prefix导出文件名前缀stringexport

Exporter Events ​

事件名说明参数
success导出成功回调() => void
error导出失败回调(error: any) => void

Exporter Expose ​

方法名说明
open打开导出弹窗
close关闭导出弹窗

Released under the MIT License.