index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <template>
  2. <ContentWrap>
  3. <!-- 列表 -->
  4. <vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
  5. <template #toolbar_buttons>
  6. <XButton
  7. type="warning"
  8. preIcon="ep:download"
  9. :title="t('action.export')"
  10. @click="handleExport()"
  11. />
  12. </template>
  13. <template #actionbtns_default="{ row }">
  14. <!-- 操作:详情 -->
  15. <XTextButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
  16. </template>
  17. </vxe-grid>
  18. </ContentWrap>
  19. <!-- 弹窗 -->
  20. <XModal id="postModel" v-model="dialogVisible" :title="dialogTitle">
  21. <!-- 表单:详情 -->
  22. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef" />
  23. <template #footer>
  24. <!-- 按钮:关闭 -->
  25. <XButton :title="t('dialog.close')" @click="dialogVisible = false" />
  26. </template>
  27. </XModal>
  28. </template>
  29. <script setup lang="ts">
  30. // 全局相关的 import
  31. import { ref } from 'vue'
  32. import { useI18n } from '@/hooks/web/useI18n'
  33. import { useMessage } from '@/hooks/web/useMessage'
  34. import { useVxeGrid } from '@/hooks/web/useVxeGrid'
  35. import { VxeGridInstance } from 'vxe-table'
  36. // 业务相关的 import
  37. import { allSchemas } from './loginLog.data'
  38. import { getLoginLogPageApi, exportLoginLogApi, LoginLogVO } from '@/api/system/loginLog'
  39. import download from '@/utils/download'
  40. const { t } = useI18n() // 国际化
  41. const message = useMessage() // 消息弹窗
  42. // 列表相关的变量
  43. const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
  44. const { gridOptions, getSearchData } = useVxeGrid<LoginLogVO>({
  45. allSchemas: allSchemas,
  46. getListApi: getLoginLogPageApi
  47. })
  48. // 详情操作
  49. const detailRef = ref() // 详情 Ref
  50. const dialogVisible = ref(false) // 是否显示弹出层
  51. const dialogTitle = ref(t('action.detail')) // 弹出层标题
  52. // 详情
  53. const handleDetail = async (row: LoginLogVO) => {
  54. // 设置数据
  55. detailRef.value = row
  56. dialogVisible.value = true
  57. }
  58. // 导出操作
  59. const handleExport = async () => {
  60. message.exportConfirm().then(async () => {
  61. const queryParams = await getSearchData(xGrid)
  62. const res = await exportLoginLogApi(queryParams)
  63. download.excel(res, '登录列表.xls')
  64. })
  65. }
  66. </script>