index.vue 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <view class="yd-page-container">
  3. <!-- 顶部导航栏 -->
  4. <wd-navbar
  5. title="登录日志详情"
  6. left-arrow placeholder safe-area-inset-top fixed
  7. @click-left="handleBack"
  8. />
  9. <!-- 详情内容 -->
  10. <view>
  11. <wd-cell-group border>
  12. <wd-cell title="日志编号" :value="String(formData?.id ?? '-')" />
  13. <wd-cell title="登录类型">
  14. <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_TYPE" :value="formData?.logType" />
  15. </wd-cell>
  16. <wd-cell title="用户名称" :value="formData?.username || '-'" />
  17. <wd-cell title="登录地址" :value="formData?.userIp || '-'" />
  18. <wd-cell title="浏览器" :value="formData?.userAgent || '-'" />
  19. <wd-cell title="登录结果">
  20. <dict-tag :type="DICT_TYPE.SYSTEM_LOGIN_RESULT" :value="formData?.result" />
  21. </wd-cell>
  22. <wd-cell title="登录时间" :value="formatDateTime(formData?.createTime) || '-'" />
  23. </wd-cell-group>
  24. </view>
  25. </view>
  26. </template>
  27. <script lang="ts" setup>
  28. import type { LoginLog } from '@/api/system/login-log'
  29. import { onMounted, ref } from 'vue'
  30. import { useToast } from 'wot-design-uni'
  31. import { getLoginLog } from '@/api/system/login-log'
  32. import { navigateBackPlus } from '@/utils'
  33. import { DICT_TYPE } from '@/utils/constants'
  34. import { formatDateTime } from '@/utils/date'
  35. const props = defineProps<{
  36. id?: number | any
  37. }>()
  38. definePage({
  39. style: {
  40. navigationBarTitleText: '',
  41. navigationStyle: 'custom',
  42. },
  43. })
  44. const toast = useToast()
  45. const formData = ref<LoginLog>()
  46. /** 返回上一页 */
  47. function handleBack() {
  48. navigateBackPlus('/pages-system/login-log/index')
  49. }
  50. /** 加载登录日志详情 */
  51. async function getDetail() {
  52. if (!props.id) {
  53. return
  54. }
  55. try {
  56. toast.loading('加载中...')
  57. formData.value = await getLoginLog(props.id)
  58. } finally {
  59. toast.close()
  60. }
  61. }
  62. /** 初始化 */
  63. onMounted(() => {
  64. getDetail()
  65. })
  66. </script>
  67. <style lang="scss" scoped>
  68. </style>