HomeCard.vue 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <script setup lang="ts">
  2. import { toRefs, computed } from "vue";
  3. import _ from "lodash";
  4. const props = withDefaults(
  5. defineProps<{
  6. title?: string;
  7. color?: "info" | "skyblue" | "white";
  8. span?: number;
  9. }>(),
  10. {
  11. color: "info",
  12. span: 24,
  13. }
  14. );
  15. const { title, color } = toRefs(props);
  16. const styles = computed(() => {
  17. return _.get(
  18. {
  19. info: {
  20. backgroundColor: "#f5f9ff",
  21. borderColor: "#e2eeff",
  22. },
  23. skyblue: {
  24. backgroundColor: "#f6fdff",
  25. borderColor: "#e3f8f4",
  26. },
  27. white: {
  28. borderColor: "#e2eeff",
  29. backgroundColor: "#fff",
  30. },
  31. },
  32. color.value
  33. );
  34. });
  35. </script>
  36. <template>
  37. <el-col tag="div" :span="span">
  38. <div class="card" :style="styles">
  39. <slot name="title">
  40. <h2 v-if="title">
  41. {{ title }}
  42. </h2>
  43. </slot>
  44. <el-row :gutter="20" tag="section">
  45. <slot></slot>
  46. </el-row>
  47. </div>
  48. </el-col>
  49. </template>
  50. <style lang="scss" scoped>
  51. h2 {
  52. border: none;
  53. margin: 0;
  54. padding: 0;
  55. }
  56. .card {
  57. display: flex;
  58. flex-direction: column;
  59. align-items: stretch;
  60. gap: 24px;
  61. border-radius: 20px;
  62. padding: 32px;
  63. background: #f5f9ff;
  64. border: 1px solid #e2eeff;
  65. min-height: 240px;
  66. :deep(.card) {
  67. min-height: 162px;
  68. }
  69. h2 {
  70. display: flex;
  71. align-items: center;
  72. .prefix {
  73. margin-right: 8px;
  74. }
  75. .suffix {
  76. width: 24px;
  77. height: 24px;
  78. margin-left: 8px;
  79. color: #00000042;
  80. }
  81. }
  82. .el-row {
  83. row-gap: 20px;
  84. align-items: stretch;
  85. }
  86. }
  87. </style>