feat: 文件上传

pull/5/MERGE
xingyu 2023-04-27 12:56:25 +08:00
parent 9b2fe7f3ac
commit ecf98298a2
1 changed files with 20 additions and 3 deletions

View File

@ -2,7 +2,15 @@
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" :preIcon="IconEnum.UPLOAD" @click="handleAdd"> </a-button>
<BasicUpload
:maxSize="20"
:maxNumber="10"
@change="handleChange"
:uploadParams="uploadParams"
:api="uploadApi"
class="my-5"
:accept="['image/*']"
/>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
@ -27,16 +35,25 @@
</div>
</template>
<script lang="ts" setup name="InfraFile">
import { ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { IconEnum } from '@/enums/appEnum'
import { BasicUpload } from '@/components/Upload'
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { deleteFile, getFilePage } from '@/api/infra/file'
import { columns, searchFormSchema } from './file.data'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { uploadApi } from '@/api/base/upload'
const { t } = useI18n()
const { createMessage } = useMessage()
const uploadParams = ref({
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
})
const [registerTable, { reload }] = useTable({
title: '文件列表',
api: getFilePage,
@ -53,8 +70,8 @@ const [registerTable, { reload }] = useTable({
}
})
function handleAdd() {
console.info(1)
function handleChange() {
reload()
}
async function handleDelete(record: Recordable) {