mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-02-08 05:20:05 +08:00
feat: export
This commit is contained in:
parent
9794d1cfd7
commit
4065387b54
@ -4,6 +4,7 @@ import { useAppStore } from '@/store/modules/app'
|
|||||||
import { VxeAllSchemas } from './useVxeCrudSchemas'
|
import { VxeAllSchemas } from './useVxeCrudSchemas'
|
||||||
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 download from '@/utils/download'
|
||||||
|
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
@ -144,11 +145,24 @@ export const useVxeGrid = <T = any>(config?: UseVxeGridConfig<T>) => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
// 导出
|
||||||
|
const exportList = async (ref, fileName?: string) => {
|
||||||
|
await nextTick()
|
||||||
|
const queryParams = Object.assign(
|
||||||
|
{},
|
||||||
|
JSON.parse(JSON.stringify(ref.value?.getProxyInfo()?.form))
|
||||||
|
)
|
||||||
|
message.exportConfirm().then(async () => {
|
||||||
|
const res = await (config?.exportListApi && config?.exportListApi(queryParams))
|
||||||
|
download.excel(res as unknown as Blob, fileName ? fileName : 'excel.xls')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
gridOptions,
|
gridOptions,
|
||||||
reloadList,
|
reloadList,
|
||||||
getSearchData,
|
getSearchData,
|
||||||
delList
|
delList,
|
||||||
|
exportList
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,21 +30,19 @@
|
|||||||
// 全局相关的 import
|
// 全局相关的 import
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
|
||||||
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||||
import { VxeGridInstance } from 'vxe-table'
|
import { VxeGridInstance } from 'vxe-table'
|
||||||
// 业务相关的 import
|
// 业务相关的 import
|
||||||
import { allSchemas } from './loginLog.data'
|
import { allSchemas } from './loginLog.data'
|
||||||
import { getLoginLogPageApi, exportLoginLogApi, LoginLogVO } from '@/api/system/loginLog'
|
import { getLoginLogPageApi, exportLoginLogApi, LoginLogVO } from '@/api/system/loginLog'
|
||||||
import download from '@/utils/download'
|
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, getSearchData } = useVxeGrid<LoginLogVO>({
|
const { gridOptions, exportList } = useVxeGrid<LoginLogVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: getLoginLogPageApi
|
getListApi: getLoginLogPageApi,
|
||||||
|
exportListApi: exportLoginLogApi
|
||||||
})
|
})
|
||||||
|
|
||||||
// 详情操作
|
// 详情操作
|
||||||
@ -60,10 +58,6 @@ const handleDetail = async (row: LoginLogVO) => {
|
|||||||
|
|
||||||
// 导出操作
|
// 导出操作
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
message.exportConfirm().then(async () => {
|
exportList(xGrid, '登录列表.xls')
|
||||||
const queryParams = await getSearchData(xGrid)
|
|
||||||
const res = await exportLoginLogApi(queryParams)
|
|
||||||
download.excel(res, '登录列表.xls')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -45,21 +45,19 @@
|
|||||||
// 全局相关的 import
|
// 全局相关的 import
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
|
||||||
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||||
import { VxeGridInstance } from 'vxe-table'
|
import { VxeGridInstance } from 'vxe-table'
|
||||||
// 业务相关的 import
|
// 业务相关的 import
|
||||||
import * as OperateLogApi from '@/api/system/operatelog'
|
import * as OperateLogApi from '@/api/system/operatelog'
|
||||||
import { allSchemas } from './operatelog.data'
|
import { allSchemas } from './operatelog.data'
|
||||||
import download from '@/utils/download'
|
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, getSearchData } = useVxeGrid<OperateLogApi.OperateLogVO>({
|
const { gridOptions, exportList } = useVxeGrid<OperateLogApi.OperateLogVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: OperateLogApi.getOperateLogPageApi
|
getListApi: OperateLogApi.getOperateLogPageApi,
|
||||||
|
exportListApi: OperateLogApi.exportOperateLogApi
|
||||||
})
|
})
|
||||||
|
|
||||||
// 弹窗相关的变量
|
// 弹窗相关的变量
|
||||||
@ -76,10 +74,6 @@ const handleDetail = (row: OperateLogApi.OperateLogVO) => {
|
|||||||
|
|
||||||
// 导出操作
|
// 导出操作
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
message.exportConfirm().then(async () => {
|
exportList(xGrid, '岗位列表.xls')
|
||||||
const queryParams = await getSearchData(xGrid)
|
|
||||||
const res = await OperateLogApi.exportOperateLogApi(queryParams)
|
|
||||||
download.excel(res, '岗位列表.xls')
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -84,16 +84,16 @@ import { FormExpose } from '@/components/Form'
|
|||||||
// 业务相关的 import
|
// 业务相关的 import
|
||||||
import * as PostApi from '@/api/system/post'
|
import * as PostApi from '@/api/system/post'
|
||||||
import { rules, allSchemas } from './post.data'
|
import { rules, allSchemas } from './post.data'
|
||||||
import download from '@/utils/download'
|
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
const message = useMessage() // 消息弹窗
|
const message = useMessage() // 消息弹窗
|
||||||
// 列表相关的变量
|
// 列表相关的变量
|
||||||
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
const { gridOptions, reloadList, delList, getSearchData } = useVxeGrid<PostApi.PostVO>({
|
const { gridOptions, reloadList, delList, exportList } = useVxeGrid<PostApi.PostVO>({
|
||||||
allSchemas: allSchemas,
|
allSchemas: allSchemas,
|
||||||
getListApi: PostApi.getPostPageApi,
|
getListApi: PostApi.getPostPageApi,
|
||||||
delListApi: PostApi.deletePostApi
|
delListApi: PostApi.deletePostApi,
|
||||||
|
exportListApi: PostApi.exportPostApi
|
||||||
})
|
})
|
||||||
// 弹窗相关的变量
|
// 弹窗相关的变量
|
||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
@ -117,9 +117,7 @@ const handleCreate = () => {
|
|||||||
|
|
||||||
// 导出操作
|
// 导出操作
|
||||||
const handleExport = async () => {
|
const handleExport = async () => {
|
||||||
const queryParams = await getSearchData(xGrid)
|
await exportList(xGrid, '岗位列表.xls')
|
||||||
const res = await PostApi.exportPostApi(queryParams)
|
|
||||||
download.excel(res, '岗位列表.xls')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 修改操作
|
// 修改操作
|
||||||
|
Loading…
Reference in New Issue
Block a user