recordDetail.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="container">
  3. <Breadcrumb :items="['乐跑记录', '记录详情']" />
  4. <a-card title="记录详情">
  5. <a-skeleton animation :loading="loading">
  6. <a-space direction="vertical" :style="{ width: '100%' }" size="large">
  7. <a-skeleton-shape size="large" />
  8. <a-skeleton-line :rows="5" />
  9. </a-space>
  10. </a-skeleton>
  11. <a-descriptions :data="info" :column="2" />
  12. <MapContainer
  13. v-if="showMap"
  14. :point_list="pointListForMap"
  15. :log_list="logListForMap"
  16. :pathData="pathForMap"
  17. threeD
  18. style="margin-top: 10px;"
  19. />
  20. </a-card>
  21. </div>
  22. </template>
  23. <script setup>
  24. import { ref, computed, onMounted } from 'vue'
  25. import { GetRecordDetail } from '@/api/lepao'
  26. import { Notification } from '@arco-design/web-vue'
  27. import { useRoute } from 'vue-router'
  28. import MapContainer from '@/components/Map/MapContainer.vue'
  29. import {
  30. buildRecordDetailInfo,
  31. parseLepaoRecordRow,
  32. normalizePointData
  33. } from '@/utils/lepaoRecord'
  34. import { useUserStore } from '@/store/modules/user'
  35. const route = useRoute()
  36. const loading = ref(false)
  37. const showMap = ref(false)
  38. const data = ref({})
  39. const info = ref([])
  40. const isAdmin = ref(false)
  41. const pathForMap = computed(() => {
  42. const poly = data.value.path_polyline
  43. if (Array.isArray(poly) && poly.length > 0) return poly
  44. return []
  45. })
  46. const pointListForMap = computed(() => {
  47. const row = parseLepaoRecordRow({
  48. result: data.value.result,
  49. jkes_record: data.value.jkes_record,
  50. run_zone_name: data.value.run_zone_name,
  51. path_run_zone_name: data.value.path_run_zone_name,
  52. path_distance: data.value.path_distance
  53. })
  54. return row.pointList || []
  55. })
  56. const logListForMap = computed(() => normalizePointData(data.value.point_data))
  57. const getRecordDetail = async (id) => {
  58. try {
  59. loading.value = true
  60. showMap.value = false
  61. const res = await GetRecordDetail({ id })
  62. if (!res || res.code !== 0)
  63. return Notification.error({
  64. title: '获取路径数据失败!',
  65. content: res?.msg ?? '请稍后再试'
  66. })
  67. data.value = res.data
  68. showMap.value = true
  69. info.value = buildRecordDetailInfo(res.data, { isAdmin: isAdmin.value })
  70. } catch (error) {
  71. Notification.error({
  72. title: '获取路径数据失败!',
  73. content: error.message || '请稍后再试'
  74. })
  75. } finally {
  76. loading.value = false
  77. }
  78. }
  79. onMounted(async () => {
  80. const userStore = useUserStore()
  81. const userInfo = await userStore.getInfo()
  82. isAdmin.value = Array.isArray(userInfo?.roles) && userInfo.roles.includes('admin')
  83. getRecordDetail(route.params.id)
  84. })
  85. </script>
  86. <style scoped lang="less">
  87. .container {
  88. padding: 0 20px 20px 20px;
  89. }
  90. </style>