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