index.vue 2.0 KB

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