ImportModal 导入弹窗
包含模板下载的通用导入弹窗组件。
使用
<template>
<dg-import-modal :api="uploadFile" :template-file-url="templateFileUrl" title="导入excel" @success="handleSuccess">
导入excel
</dg-import-modal>
</template>
<script setup lang="ts">
const uploadFile = () => {}
const templateFileUrl = ''
const handleSuccess = (files, uid) => {
console.log(files, uid)
}
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
trigger
<dg-import-modal :api="uploadFile" :template-file-url="templateFileUrl" title="导入excel" @success="handleSuccess">
<template #trigger>
<el-button type="danger">导入excel</el-button>
</template>
</dg-import-modal>
1
2
3
4
5
Attributes
| 参数 | 类型 | 说明 | 可选值 | 默认值 |
|---|
| api | Function | 导入接口 | - | - |
| filename | string | 调用api的传参属性 | - | 'file' |
| templateFileUrl | string | 导入模板下载地址 | - | - |
| isXhrDownload | boolean | 导入模板是否使用xhr下载, 传true要传入downloadTemplateApi | true、false | false |
| downloadTemplateApi | Function | 导入模板下载接口 | - | - |
| title | string | 弹窗标题 | - | - |
Slot
| name | 说明 | 参数 |
|---|
| trigger | 触发打开弹窗的内容 | - |
Events
| 事件名 | 说明 | 参数 |
|---|
| success | 调用api接口导入成功后的回调事件 | files、uid |