CardItem.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <el-card shadow="hover" class="h-[850px] w-full min-w-0">
  3. <div
  4. class="relative overflow-hidden rounded-md mb-3 h-36 bg-cover bg-center"
  5. :style="{ backgroundImage: `url(${bg})` }"
  6. >
  7. <div class="absolute inset-0 bg-white/0"></div>
  8. <div
  9. class="relative h-full flex items-center gap-3 px-4 cursor-pointer"
  10. @click="goDetail"
  11. >
  12. <div class="min-w-0 flex-1">
  13. <div class="text-[20px] font-bold text-[#0050b3]">{{ title }}</div>
  14. <div class="text-[#606266] text-sm mt-1 leading-snug">{{ desc }}</div>
  15. </div>
  16. </div>
  17. </div>
  18. <el-collapse v-model="activeNames" accordion>
  19. <el-collapse-item
  20. v-for="(i, idx) in items"
  21. :key="idx"
  22. :name="String(idx)"
  23. :title="i.label"
  24. >
  25. <div class="text-[#606266]">{{ i.label }}</div>
  26. <template #title>
  27. <div class="flex items-center min-w-0 flex-1">
  28. <span class="truncate">{{ i.label }}</span>
  29. <el-tag
  30. v-if="i.tag"
  31. size="small"
  32. type="danger"
  33. effect="dark"
  34. class="ml-2 shrink-0"
  35. >{{ i.tag }}</el-tag
  36. >
  37. </div>
  38. </template>
  39. </el-collapse-item>
  40. </el-collapse>
  41. </el-card>
  42. </template>
  43. <script setup lang="ts">
  44. import { ref } from "vue";
  45. import { useRouter } from "vue-router";
  46. const router = useRouter();
  47. type Item = { label: string; tag?: "新" | "热" };
  48. const props = defineProps<{
  49. title: string;
  50. desc: string;
  51. items: Item[];
  52. bg: string;
  53. key: string;
  54. id: string;
  55. }>();
  56. const activeNames = ref<string[]>([]);
  57. const goDetail = () => {
  58. if (props.id === "management") {
  59. router.push({ path: "/management" });
  60. } else if (props.id === "command") {
  61. router.push({ path: "/command" });
  62. } else if (props.id === "chatbi") {
  63. router.push({ path: "/chatbi" });
  64. }
  65. };
  66. </script>
  67. <style scoped>
  68. :deep(.el-card) {
  69. width: 100%;
  70. min-width: 0;
  71. overflow: hidden;
  72. }
  73. :deep(.el-card__body) {
  74. width: 100%;
  75. min-width: 0;
  76. padding: 0;
  77. }
  78. :deep(.el-collapse) {
  79. width: 100%;
  80. min-width: 0;
  81. }
  82. :deep(.el-collapse-item) {
  83. width: 100%;
  84. min-width: 0;
  85. }
  86. :deep(.el-collapse-item) .el-collapse-item__header {
  87. padding: 10px 12px;
  88. width: 100%;
  89. min-width: 0;
  90. overflow: hidden;
  91. }
  92. :deep(.el-collapse-item) .el-collapse-item__wrap {
  93. padding: 0 12px 10px;
  94. width: 100%;
  95. min-width: 0;
  96. }
  97. :deep(.el-collapse-item__content) {
  98. width: 100%;
  99. min-width: 0;
  100. overflow: hidden;
  101. word-wrap: break-word;
  102. }
  103. </style>