AccidentRecords.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <div class="accident-records-container">
  3. <div class="container-title">
  4. <span class="line"></span>
  5. <span class="title">本月交通事故记录</span>
  6. <span class="more" @click="handleClickMore"
  7. >查看全部<el-icon><ArrowRight /></el-icon
  8. ></span>
  9. </div>
  10. <div class="table-container">
  11. <el-table :data="accidentRecords" style="width: 100%; height: 100%">
  12. <el-table-column prop="accidentLocation" label="事故地点" />
  13. <el-table-column prop="accidentTime" label="事故时间" width="200px" />
  14. <el-table-column prop="accidentDescription" label="事故描述" />
  15. <el-table-column prop="action" label="操作" width="140px" align="center" fixed="right">
  16. <template #default="scope">
  17. <el-button link type="primary" @click="handleViewDetail(scope.row.id)"> 查看详情 </el-button>
  18. </template>
  19. </el-table-column>
  20. </el-table>
  21. </div>
  22. </div>
  23. </template>
  24. <script setup lang="ts">
  25. import { ref, onMounted } from 'vue';
  26. import router from '@/router';
  27. import { ElIcon } from 'element-plus';
  28. import { ArrowRight } from '@element-plus/icons-vue';
  29. import {
  30. QueryPageParams,
  31. QueryTrafficAccidentRecordOverviewPageRes,
  32. getTrafficAccidentRecordOverview,
  33. } from '@/api/traffic-overview';
  34. const queryPageParams = ref<QueryPageParams>({
  35. pageNumber: 1,
  36. pageSize: 20,
  37. });
  38. const accidentRecords = ref<QueryTrafficAccidentRecordOverviewPageRes[]>([]);
  39. const handleClickMore = () => {
  40. router.push({
  41. path: '/traffic/accident',
  42. });
  43. };
  44. const handleViewDetail = (id: number) => {
  45. router.push({
  46. path: '/traffic/accident-item',
  47. query: { id: id },
  48. });
  49. };
  50. const getTrafficAccidentRecordOverviewData = () => {
  51. getTrafficAccidentRecordOverview(queryPageParams.value).then((res) => {
  52. accidentRecords.value = res.records;
  53. });
  54. };
  55. onMounted(() => {
  56. getTrafficAccidentRecordOverviewData();
  57. });
  58. </script>
  59. <style scoped lang="scss">
  60. .container-title {
  61. height: 24px;
  62. display: flex;
  63. align-items: center;
  64. font-weight: 500;
  65. font-size: 16px;
  66. color: #000000;
  67. .line {
  68. width: 3px;
  69. height: 16px;
  70. background: #1777ff;
  71. margin-right: 10px;
  72. }
  73. .title {
  74. margin-right: 12px;
  75. }
  76. .more {
  77. margin-left: auto;
  78. margin-right: 17px;
  79. font-weight: 400;
  80. font-size: 16px;
  81. color: #1777ff;
  82. display: flex;
  83. align-items: center;
  84. cursor: pointer;
  85. }
  86. .more:hover {
  87. background-color: #1777ff;
  88. color: #fff;
  89. border-radius: 4px;
  90. padding: 2px 4px 2px 6px;
  91. }
  92. }
  93. .accident-records-container {
  94. width: 100%;
  95. height: 100%;
  96. padding: 14px 0;
  97. .table-container {
  98. width: 100%;
  99. height: calc(100% - 24px - 18px);
  100. margin-top: 18px;
  101. padding: 0 16px;
  102. overflow: auto;
  103. }
  104. }
  105. </style>