msgTrack.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <a-card >
  3. <div class="subtitle" > 消息跟踪可记录设备在运行过程中的各类操作信息,状态和结果。当数据上报、响应命令等业务场景中出现故障时,消息跟踪功能可帮助您快速进行故障定位和原因分析</div>
  4. <div class="subtitle" >为避免占用读写计算、存储资源,同时保证数据有效,平台限制最长可跟踪3天的数据,且单个用户下,仅支持同时启动10个设备的消息跟踪。</div>
  5. <AlertTsx style="margin-top: 20px;" >
  6. <template #valueSlot>
  7. <div v-if="state.formatStartTime" >
  8. <!-- 执行情况[ 中止 ] -->
  9. 结束时间: {{state.formatStartTime}}
  10. </div>
  11. <div v-else >
  12. 尚未追踪
  13. </div>
  14. </template>
  15. <template #operaSlot>
  16. <a-space>
  17. <a-button type="link" @click="clearDataSource">清除数据</a-button>
  18. </a-space>
  19. </template>
  20. </AlertTsx>
  21. <a-row style="margin: 20px 0px;" justify="space-between" >
  22. <a-col>
  23. <a-space>
  24. </a-space>
  25. </a-col>
  26. <a-col>
  27. <a-space>
  28. <a-button type="primary" @click="addEventTrace" >新增事件跟踪</a-button>
  29. </a-space>
  30. </a-col>
  31. </a-row>
  32. <a-table
  33. :columns="columns"
  34. :loading="state.loading"
  35. :dataSource="state.dataSource"
  36. >
  37. </a-table>
  38. </a-card>
  39. </template>
  40. <script lang="ts" setup >
  41. import { AlertTsx } from '@/components/MicroComponents/index'
  42. import { EventController } from '@/controller'
  43. import { onMounted, reactive } from 'vue'
  44. import { useRoute } from 'vue-router'
  45. import dayjs from 'dayjs'
  46. const route = useRoute()
  47. const deviceId = route.query.id as string
  48. const columns = [
  49. {
  50. title: '业务类型',
  51. dataIndex: 'eventType'
  52. },
  53. {
  54. title: '业务步骤',
  55. dataIndex: 'setup'
  56. },
  57. {
  58. title: '业务详情',
  59. dataIndex: 'detail'
  60. },
  61. {
  62. title: '记录时间',
  63. dataIndex: 'date'
  64. },
  65. {
  66. title: '消息状态',
  67. dataIndex: 'status'
  68. },
  69. {
  70. title: '操作',
  71. dataIndex: 'action',
  72. key: 'action'
  73. }
  74. ]
  75. const state = reactive({
  76. loading: false,
  77. dataSource: [],
  78. total: 0,
  79. startTime: 0,
  80. lastId: '',
  81. formatStartTime: ''
  82. })
  83. const clearDataSource = () => {
  84. state.dataSource = []
  85. }
  86. const addEventTrace = async () => {
  87. await EventController.addTrace({ deviceId: deviceId })
  88. getEventTraceList()
  89. }
  90. const getEventList = async () => {
  91. const { data, sum } = await EventController.list({ deviceId: deviceId, startTime: state.startTime, lastId: state.lastId })
  92. state.dataSource = data
  93. state.total = 0
  94. }
  95. const getEventTraceList = async () => {
  96. const data = await EventController.listTrace({ deviceId: deviceId }) as unknown as Number
  97. state.formatStartTime = data ? dayjs(data).format('YYYY-MM-DD hh:mm:ss') : ''
  98. getEventList()
  99. }
  100. onMounted(() => {
  101. getEventTraceList()
  102. getEventList()
  103. })
  104. </script>
  105. <style lang="less" scoped >
  106. @import '~@/styles/theme.less';
  107. .subtitle {
  108. color: @sublabel-color;
  109. font-size: 14px;
  110. }
  111. </style>