feat: 文件上传
parent
9b2fe7f3ac
commit
ecf98298a2
|
@ -2,7 +2,15 @@
|
||||||
<div>
|
<div>
|
||||||
<BasicTable @register="registerTable">
|
<BasicTable @register="registerTable">
|
||||||
<template #toolbar>
|
<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>
|
||||||
<template #bodyCell="{ column, record }">
|
<template #bodyCell="{ column, record }">
|
||||||
<template v-if="column.key === 'action'">
|
<template v-if="column.key === 'action'">
|
||||||
|
@ -27,16 +35,25 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup name="InfraFile">
|
<script lang="ts" setup name="InfraFile">
|
||||||
|
import { ref } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import { IconEnum } from '@/enums/appEnum'
|
import { IconEnum } from '@/enums/appEnum'
|
||||||
|
import { BasicUpload } from '@/components/Upload'
|
||||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||||
import { deleteFile, getFilePage } from '@/api/infra/file'
|
import { deleteFile, getFilePage } from '@/api/infra/file'
|
||||||
import { columns, searchFormSchema } from './file.data'
|
import { columns, searchFormSchema } from './file.data'
|
||||||
|
import { getAccessToken, getTenantId } from '@/utils/auth'
|
||||||
|
import { uploadApi } from '@/api/base/upload'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const { createMessage } = useMessage()
|
const { createMessage } = useMessage()
|
||||||
|
|
||||||
|
const uploadParams = ref({
|
||||||
|
Authorization: 'Bearer ' + getAccessToken(),
|
||||||
|
'tenant-id': getTenantId()
|
||||||
|
})
|
||||||
|
|
||||||
const [registerTable, { reload }] = useTable({
|
const [registerTable, { reload }] = useTable({
|
||||||
title: '文件列表',
|
title: '文件列表',
|
||||||
api: getFilePage,
|
api: getFilePage,
|
||||||
|
@ -53,8 +70,8 @@ const [registerTable, { reload }] = useTable({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleAdd() {
|
function handleChange() {
|
||||||
console.info(1)
|
reload()
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleDelete(record: Recordable) {
|
async function handleDelete(record: Recordable) {
|
||||||
|
|
Loading…
Reference in New Issue