oper-info-dialog.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <el-dialog v-model="open" title="操作日志详细" width="700px" append-to-body close-on-click-modal @closed="info = null">
  3. <el-descriptions v-if="info" :column="1" border>
  4. <el-descriptions-item label="操作状态">
  5. <template #default>
  6. <el-tag v-if="info.status === 0" type="success">正常</el-tag>
  7. <el-tag v-else-if="info.status === 1" type="danger">失败</el-tag>
  8. </template>
  9. </el-descriptions-item>
  10. <el-descriptions-item label="登录信息">
  11. <template #default> {{ info.operName }} / {{ info.deptName }} / {{ info.operIp }} / {{ info.operLocation }} </template>
  12. </el-descriptions-item>
  13. <el-descriptions-item label="请求信息">
  14. <template #default> {{ info.requestMethod }} {{ info.operUrl }} </template>
  15. </el-descriptions-item>
  16. <el-descriptions-item label="操作模块">
  17. <template #default> {{ info.title }} / {{ typeFormat(info) }} </template>
  18. </el-descriptions-item>
  19. <el-descriptions-item label="操作方法">
  20. <template #default>
  21. {{ info.method }}
  22. </template>
  23. </el-descriptions-item>
  24. <el-descriptions-item label="请求参数">
  25. <template #default>
  26. <div class="max-h-300px overflow-y-auto">
  27. <VueJsonPretty :data="formatToJsonObject(info.operParam)" />
  28. </div>
  29. </template>
  30. </el-descriptions-item>
  31. <el-descriptions-item label="返回参数">
  32. <template #default>
  33. <div class="max-h-300px overflow-y-auto">
  34. <VueJsonPretty :data="formatToJsonObject(info.jsonResult)" />
  35. </div>
  36. </template>
  37. </el-descriptions-item>
  38. <el-descriptions-item label="消耗时间">
  39. <template #default>
  40. <span> {{ info.costTime }}ms </span>
  41. </template>
  42. </el-descriptions-item>
  43. <el-descriptions-item label="操作时间">
  44. <template #default> {{ parseTime(info.operTime) }}</template>
  45. </el-descriptions-item>
  46. <el-descriptions-item v-if="info.status === 1" label="异常信息">
  47. <template #default>
  48. <span class="text-danger"> {{ info.errorMsg }}</span>
  49. </template>
  50. </el-descriptions-item>
  51. </el-descriptions>
  52. </el-dialog>
  53. </template>
  54. <script setup lang="ts">
  55. import type { OperLogForm } from '@/api/monitor/operlog/types';
  56. import VueJsonPretty from 'vue-json-pretty';
  57. import 'vue-json-pretty/lib/styles.css';
  58. const open = ref(false);
  59. const info = ref<OperLogForm | null>(null);
  60. function openDialog(row: OperLogForm) {
  61. info.value = row;
  62. open.value = true;
  63. }
  64. function closeDialog() {
  65. open.value = false;
  66. }
  67. defineExpose({
  68. openDialog,
  69. closeDialog
  70. });
  71. /**
  72. * json转为对象
  73. * @param data 原始数据
  74. */
  75. function formatToJsonObject(data: string) {
  76. try {
  77. return JSON.parse(data);
  78. } catch (error) {
  79. return data;
  80. }
  81. }
  82. /**
  83. * 字典信息
  84. */
  85. const { proxy } = getCurrentInstance() as ComponentInternalInstance;
  86. const { sys_oper_type } = toRefs<any>(proxy?.useDict('sys_oper_type'));
  87. const typeFormat = (row: OperLogForm) => {
  88. return proxy?.selectDictLabel(sys_oper_type.value, row.businessType);
  89. };
  90. </script>
  91. <style scoped>
  92. /**
  93. label宽度固定
  94. */
  95. :deep(.el-descriptions__label) {
  96. min-width: 100px;
  97. }
  98. /**
  99. 文字超过 换行显示
  100. */
  101. :deep(.el-descriptions__content) {
  102. max-width: 300px;
  103. }
  104. </style>