feat(view): post init
parent
198772973a
commit
79c65e15cf
|
|
@ -54,5 +54,5 @@ export const deletePostApi = (id: number) => {
|
|||
|
||||
// 导出岗位
|
||||
export const exportPostApi = (params: PostExportReqVO) => {
|
||||
return defHttp.download({ url: '/system/post/export', params })
|
||||
return defHttp.download({ url: '/system/post/export', params }, '导出岗位.xls')
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ export class VAxios {
|
|||
return this.request({ ...config, method: 'DELETE' }, options)
|
||||
}
|
||||
|
||||
download<T = any>(config: AxiosRequestConfig, title: string, options?: RequestOptions): Promise<T> {
|
||||
download<T = any>(config: AxiosRequestConfig, title?: string, options?: RequestOptions): Promise<T> {
|
||||
let conf: CreateAxiosOptions = cloneDeep({
|
||||
...config,
|
||||
method: 'GET',
|
||||
|
|
@ -264,7 +264,7 @@ export class VAxios {
|
|||
resolve(res as unknown as Promise<T>)
|
||||
// download file
|
||||
if (typeof res != undefined) {
|
||||
downloadByData(res?.data as unknown as BlobPart, title)
|
||||
downloadByData(res?.data as unknown as BlobPart, title || 'export')
|
||||
}
|
||||
})
|
||||
.catch((e: Error | AxiosError) => {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<BasicTable @register="registerTable">
|
||||
<template #toolbar>
|
||||
<a-button type="primary" @click="handleCreate"> 新增 </a-button>
|
||||
<a-button type="warning" @click="handleExport"> 导出 </a-button>
|
||||
</template>
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="column.key === 'action'">
|
||||
|
|
@ -31,15 +32,17 @@
|
|||
</template>
|
||||
<script lang="ts" setup name="Post">
|
||||
import { BasicTable, useTable, TableAction } from '@/components/Table'
|
||||
import { deletePostApi, getPostPageApi } from '@/api/system/post'
|
||||
import { PostExportReqVO, deletePostApi, exportPostApi, getPostPageApi } from '@/api/system/post'
|
||||
import { useModal } from '@/components/Modal'
|
||||
import PostModel from './PostModel.vue'
|
||||
import { columns, searchFormSchema } from './post.data'
|
||||
import { useI18n } from '@/hooks/web/useI18n'
|
||||
import { useMessage } from '@/hooks/web/useMessage'
|
||||
|
||||
const { createMessage } = useMessage()
|
||||
const { t } = useI18n()
|
||||
const { createConfirm, createMessage } = useMessage()
|
||||
const [registerModal, { openModal }] = useModal()
|
||||
const [registerTable, { reload }] = useTable({
|
||||
const [registerTable, { getForm, reload }] = useTable({
|
||||
title: '岗位列表',
|
||||
api: getPostPageApi,
|
||||
columns,
|
||||
|
|
@ -71,6 +74,18 @@ function handleEdit(record: Recordable) {
|
|||
})
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
createConfirm({
|
||||
title: '导出',
|
||||
iconType: 'warning',
|
||||
content: '是否要导出数据?',
|
||||
async onOk() {
|
||||
await exportPostApi(getForm().getFieldsValue() as PostExportReqVO)
|
||||
createMessage.success(t('common.exportSuccessText'))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function handleDelete(record: Recordable) {
|
||||
console.log(record)
|
||||
const res = await deletePostApi(record.id)
|
||||
|
|
|
|||
Loading…
Reference in New Issue