index.vue 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <template>
  2. <view class="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 v-if="formData?.traceId" title="链路追踪" :value="formData.traceId" />
  14. <wd-cell title="操作人编号" :value="String(formData?.userId ?? '-')" />
  15. <wd-cell title="操作人类型">
  16. <dict-tag :type="DICT_TYPE.USER_TYPE" :value="formData?.userType" />
  17. </wd-cell>
  18. <wd-cell title="操作人名字" :value="formData?.userName || '-'" />
  19. <wd-cell title="操作人 IP" :value="formData?.userIp || '-'" />
  20. <wd-cell title="操作人 UA" :value="formData?.userAgent || '-'" />
  21. <wd-cell title="操作模块" :value="formData?.type || '-'" />
  22. <wd-cell title="操作名" :value="formData?.subType || '-'" />
  23. <wd-cell title="操作内容" :value="formData?.action || '-'" />
  24. <wd-cell v-if="formData?.extra" title="操作拓展参数" :value="formData.extra" />
  25. <wd-cell title="请求 URL" :value="getRequestUrl()" />
  26. <wd-cell title="操作时间" :value="formatDateTime(formData?.createTime) || '-'" />
  27. <wd-cell title="业务编号" :value="String(formData?.bizId ?? '-')" />
  28. </wd-cell-group>
  29. </view>
  30. </view>
  31. </template>
  32. <script lang="ts" setup>
  33. import type { OperateLog } from '@/api/system/operate-log'
  34. import { onMounted, ref } from 'vue'
  35. import { useToast } from 'wot-design-uni'
  36. import { getOperateLog } from '@/api/system/operate-log'
  37. import { navigateBackPlus } from '@/utils'
  38. import { DICT_TYPE } from '@/utils/constants'
  39. import { formatDateTime } from '@/utils/date'
  40. const props = defineProps<{
  41. id?: number | any
  42. }>()
  43. definePage({
  44. style: {
  45. navigationBarTitleText: '',
  46. navigationStyle: 'custom',
  47. },
  48. })
  49. const toast = useToast()
  50. const formData = ref<OperateLog>()
  51. /** 返回上一页 */
  52. function handleBack() {
  53. navigateBackPlus('/pages-system/operate-log/index')
  54. }
  55. /** 获取请求 URL */
  56. // TODO @AI:放在界面里,这里不要这么搞;
  57. function getRequestUrl() {
  58. if (formData.value?.requestMethod && formData.value?.requestUrl) {
  59. return `${formData.value.requestMethod} ${formData.value.requestUrl}`
  60. }
  61. return '-'
  62. }
  63. /** 加载操作日志详情 */
  64. async function getDetail() {
  65. if (!props.id) {
  66. return
  67. }
  68. try {
  69. toast.loading('加载中...')
  70. formData.value = await getOperateLog(props.id)
  71. } finally {
  72. toast.close()
  73. }
  74. }
  75. /** 初始化 */
  76. onMounted(() => {
  77. getDetail()
  78. })
  79. </script>
  80. <style lang="scss" scoped>
  81. </style>