You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

84 lines
2.2 KiB

<template>
2 years ago
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<BasicUpload
:maxSize="20"
:maxNumber="10"
:emptyHidePreview="true"
@change="handleChange"
:uploadParams="uploadParams"
:api="uploadApi"
class="my-5"
:accept="['image/*']"
/>
2 years ago
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
icon: IconEnum.DELETE,
color: 'error',
label: t('action.delete'),
auth: 'infra:file:delete',
2 years ago
popConfirm: {
title: t('common.delMessage'),
placement: 'left',
confirm: handleDelete.bind(null, record)
}
}
]"
/>
</template>
</template>
</BasicTable>
</div>
</template>
<script lang="ts" setup name="InfraFile">
import { ref } from 'vue'
2 years ago
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { IconEnum } from '@/enums/appEnum'
import { BasicUpload } from '@/components/Upload'
2 years ago
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { deleteFile, getFilePage } from '@/api/infra/file'
2 years ago
import { columns, searchFormSchema } from './file.data'
import { getAccessToken, getTenantId } from '@/utils/auth'
import { uploadApi } from '@/api/base/upload'
2 years ago
const { t } = useI18n()
const { createMessage } = useMessage()
const uploadParams = ref({
Authorization: 'Bearer ' + getAccessToken(),
'tenant-id': getTenantId()
})
2 years ago
const [registerTable, { reload }] = useTable({
title: '文件列表',
api: getFilePage,
2 years ago
columns,
formConfig: { labelWidth: 120, schemas: searchFormSchema },
2 years ago
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 140,
title: t('common.action'),
dataIndex: 'action',
fixed: 'right'
}
})
function handleChange() {
reload()
2 years ago
}
async function handleDelete(record: Recordable) {
await deleteFile(record.id)
2 years ago
createMessage.success(t('common.delSuccessText'))
reload()
}
</script>