index.vue 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import dayjs from 'dayjs'
  4. import { useTable } from '@/hooks/web/useTable'
  5. import { allSchemas } from './loginLog.data'
  6. import { DICT_TYPE } from '@/utils/dict'
  7. import type { LoginLogVO } from '@/api/system/loginLog/types'
  8. import { getLoginLogPageApi, exportLoginLogApi } from '@/api/system/loginLog'
  9. import { useI18n } from '@/hooks/web/useI18n'
  10. const { t } = useI18n() // 国际化
  11. // ========== 列表相关 ==========
  12. const { register, tableObject, methods } = useTable<LoginLogVO>({
  13. getListApi: getLoginLogPageApi,
  14. exportListApi: exportLoginLogApi
  15. })
  16. const { getList, setSearchParams } = methods
  17. // 详情操作
  18. const dialogVisible = ref(false) // 是否显示弹出层
  19. const dialogTitle = ref(t('action.detail')) // 弹出层标题
  20. const detailRef = ref() // 详情 Ref
  21. const handleDetail = async (row: LoginLogVO) => {
  22. // 设置数据
  23. detailRef.value = row
  24. dialogVisible.value = true
  25. }
  26. getList()
  27. </script>
  28. <template>
  29. <ContentWrap>
  30. <Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
  31. </ContentWrap>
  32. <ContentWrap>
  33. <Table
  34. :columns="allSchemas.tableColumns"
  35. :selection="false"
  36. :data="tableObject.tableList"
  37. :loading="tableObject.loading"
  38. :pagination="{
  39. total: tableObject.total
  40. }"
  41. v-model:pageSize="tableObject.pageSize"
  42. v-model:currentPage="tableObject.currentPage"
  43. @register="register"
  44. >
  45. <template #logType="{ row }">
  46. <DictTag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="row.logType" />
  47. </template>
  48. <template #result="{ row }">
  49. <DictTag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="row.result" />
  50. </template>
  51. <template #createTime="{ row }">
  52. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  53. </template>
  54. <template #action="{ row }">
  55. <el-button link type="primary" @click="handleDetail(row)">
  56. <Icon icon="ep:view" class="mr-1px" /> {{ t('action.detail') }}
  57. </el-button>
  58. </template>
  59. </Table>
  60. </ContentWrap>
  61. <Dialog v-model="dialogVisible" :title="dialogTitle" maxHeight="500px" width="50%">
  62. <!-- 对话框(详情) -->
  63. <Descriptions :schema="allSchemas.detailSchema" :data="detailRef">
  64. <template #logType="{ row }">
  65. <DictTag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="row.logType" />
  66. </template>
  67. <template #result="{ row }">
  68. <DictTag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="row.result" />
  69. </template>
  70. <template #createTime="{ row }">
  71. <span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
  72. </template>
  73. </Descriptions>
  74. <!-- 操作按钮 -->
  75. <template #footer>
  76. <el-button @click="dialogVisible = false">{{ t('dialog.close') }}</el-button>
  77. </template>
  78. </Dialog>
  79. </template>