PageTaskTemplate.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div class="disaster-precaution-container">
  3. <header class="disaster-precaution-container__header">
  4. <span class="disaster-precaution-container__title">灾害预防检查任务模板</span>
  5. </header>
  6. <main class="disaster-precaution-container__main">
  7. <div class="template-card-list">
  8. <div
  9. class="template-card-item"
  10. v-for="item in TASK_TEMPLATE_LIST"
  11. :key="item.id"
  12. @click="toTemplateDetail(item.id)"
  13. >
  14. <div class="img-container" :style="{ backgroundImage: `url(${item.img})` }"></div>
  15. <footer class="footer">
  16. <span>{{ item.name }}</span>
  17. </footer>
  18. </div>
  19. </div>
  20. </main>
  21. </div>
  22. </template>
  23. <script lang="ts" setup>
  24. import { useRouter } from 'vue-router';
  25. import { TASK_TEMPLATE_LIST } from './src/constants/template-detail';
  26. const router = useRouter();
  27. const toTemplateDetail = (id: number) => {
  28. router.push({
  29. name: 'disaster-precaution-template-detail',
  30. params: {
  31. id,
  32. },
  33. });
  34. };
  35. </script>
  36. <style lang="scss" scoped>
  37. @use '../style/disaster.scss' as *;
  38. .template-card-list {
  39. display: flex;
  40. gap: 32cpx;
  41. }
  42. .template-card-item {
  43. @include flex-center;
  44. flex-direction: column;
  45. width: 245cpx;
  46. cursor: pointer;
  47. transition: all 0.3s ease-in-out;
  48. &:hover {
  49. box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.1);
  50. }
  51. .img-container,
  52. .footer {
  53. width: 100%;
  54. }
  55. .img-container {
  56. height: 147cpx;
  57. background-size: cover;
  58. background-position: center center;
  59. }
  60. .footer {
  61. height: 55cpx;
  62. line-height: 55cpx;
  63. text-align: center;
  64. font-size: 16cpx;
  65. color: rgba(0, 0, 0, 0.85);
  66. outline: 1px solid #e9e9e9;
  67. }
  68. }
  69. </style>