PageTaskTemplate.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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-prevention/disaster-precaution/template-detail',
  30. params: {
  31. id,
  32. },
  33. query: {
  34. operate: 'view',
  35. },
  36. });
  37. };
  38. </script>
  39. <style lang="scss" scoped>
  40. @use '../style/disaster.scss' as *;
  41. .template-card-list {
  42. display: flex;
  43. gap: 32cpx;
  44. }
  45. .template-card-item {
  46. @include flex-center;
  47. flex-direction: column;
  48. width: 245cpx;
  49. cursor: pointer;
  50. transition: all 0.3s ease-in-out;
  51. &:hover {
  52. box-shadow: 0 0 10px 5px rgba(0, 0, 0, 0.1);
  53. }
  54. .img-container,
  55. .footer {
  56. width: 100%;
  57. }
  58. .img-container {
  59. height: 147cpx;
  60. background-size: cover;
  61. background-position: center center;
  62. }
  63. .footer {
  64. height: 55cpx;
  65. line-height: 55cpx;
  66. text-align: center;
  67. font-size: 16cpx;
  68. color: rgba(0, 0, 0, 0.85);
  69. outline: 1px solid #e9e9e9;
  70. }
  71. }
  72. </style>