index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <script setup lang="ts">
  2. import { ref } from 'vue'
  3. import { onLoad } from '@dcloudio/uni-app'
  4. // 日志详情数据
  5. interface LogDetail {
  6. id: number
  7. content: string
  8. imageUrl?: string
  9. date: string
  10. status: '已处理' | '处理中' | '待处理'
  11. level: 'info' | 'warning' | 'error'
  12. handler?: string
  13. handleDate?: string
  14. remarks?: string
  15. }
  16. const logDetail = ref<LogDetail>({
  17. id: 0,
  18. content: '',
  19. imageUrl: '',
  20. date: '',
  21. status: '待处理',
  22. level: 'info'
  23. })
  24. // 返回上一页
  25. const goBack = () => {
  26. uni.navigateBack()
  27. }
  28. // 使用UniApp的onLoad钩子获取页面参数
  29. onLoad((options) => {
  30. if (options && options.id) {
  31. // 模拟根据ID获取详情数据
  32. // 实际项目中这里应该调用API获取数据
  33. setTimeout(() => {
  34. const id = parseInt(options.id)
  35. if (id === 1) {
  36. logDetail.value = {
  37. id: id,
  38. content: '系统运行正常,未发现异常情况。系统各模块运行稳定,资源使用率在正常范围内。',
  39. imageUrl: '',
  40. date: '2025-10-28 14:30',
  41. status: '已处理',
  42. level: 'info',
  43. handler: '张三',
  44. handleDate: '2025-10-28 16:45',
  45. remarks: '已确认系统运行正常,关闭此日志。'
  46. }
  47. } else if (id === 2) {
  48. logDetail.value = {
  49. id: id,
  50. content: '警告:内存使用率超过80%,请注意监控。当前内存使用率达到85%,接近系统预警线,请及时处理。',
  51. imageUrl: '/static/plus.png',
  52. date: '2025-10-29 09:15',
  53. status: '处理中',
  54. level: 'warning',
  55. handler: '李四',
  56. handleDate: '2025-10-29 10:30',
  57. remarks: '正在监控内存使用情况,准备扩容方案。'
  58. }
  59. } else {
  60. logDetail.value = {
  61. id: id,
  62. content: '严重错误:数据库连接失败,导致部分功能不可用。多个用户反馈无法访问订单查询功能。',
  63. imageUrl: '',
  64. date: '2025-10-29 15:42',
  65. status: '待处理',
  66. level: 'error'
  67. }
  68. }
  69. }, 500)
  70. }
  71. })
  72. </script>
  73. <template>
  74. <view class="bg-gray-50 min-h-screen">
  75. <!-- 详情内容 -->
  76. <view class="p-4">
  77. <view class="bg-white rounded-lg shadow-sm p-4 mb-4">
  78. <view class="flex justify-between items-start mb-3">
  79. <text class="text-gray-900 font-medium">日志 #{{ logDetail.id }}</text>
  80. <text class="text-xs px-2 py-1 rounded" :class="{
  81. 'bg-green-100 text-green-800': logDetail.status === '已处理',
  82. 'bg-yellow-100 text-yellow-800': logDetail.status === '处理中',
  83. 'bg-red-100 text-red-800': logDetail.status === '待处理'
  84. }">{{ logDetail.status }}</text>
  85. </view>
  86. <view class="mb-3">
  87. <view class="text-gray-700 text-sm mb-2 flex items-start">
  88. <text class="mr-2 mt-0.5" :class="{
  89. 'text-blue-500': logDetail.level === 'info',
  90. 'text-yellow-500': logDetail.level === 'warning',
  91. 'text-red-500': logDetail.level === 'error'
  92. }">●</text>
  93. <text>{{ logDetail.content }}</text>
  94. </view>
  95. </view>
  96. <view v-if="logDetail.imageUrl" class="mb-4">
  97. <image
  98. :src="logDetail.imageUrl"
  99. class="w-32 h-32 rounded object-cover"
  100. mode="aspectFill"
  101. />
  102. </view>
  103. <view class="grid grid-cols-2 gap-2 text-xs mb-3">
  104. <view class="text-gray-500">上报时间:</view>
  105. <view class="text-gray-900">{{ logDetail.date }}</view>
  106. <view class="text-gray-500">日志级别:</view>
  107. <view class="text-gray-900 capitalize">{{ logDetail.level }}</view>
  108. </view>
  109. </view>
  110. <!-- 处理信息 -->
  111. <view
  112. v-if="logDetail.handler"
  113. class="bg-white rounded-lg shadow-sm p-4 mb-4"
  114. >
  115. <view class="font-medium text-gray-900 mb-3 border-b border-gray-100 pb-2">处理信息</view>
  116. <view class="grid grid-cols-2 gap-2 text-xs mb-2">
  117. <view class="text-gray-500">处理人:</view>
  118. <view class="text-gray-900">{{ logDetail.handler }}</view>
  119. <view class="text-gray-500">处理时间:</view>
  120. <view class="text-gray-900">{{ logDetail.handleDate }}</view>
  121. </view>
  122. <view class="text-gray-500 text-xs mb-1">备注:</view>
  123. <view class="text-gray-700 text-sm bg-gray-50 p-2 rounded">
  124. {{ logDetail.remarks }}
  125. </view>
  126. </view>
  127. <view
  128. v-else
  129. class="bg-white rounded-lg shadow-sm p-4"
  130. >
  131. <view class="text-gray-500 text-center py-6">
  132. 暂无处理信息
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </template>
  138. <style scoped>
  139. </style>