Card.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <script setup lang="ts">
  2. import { computed, PropType } from "vue";
  3. import shopIcon from "/@/assets/svg/shop.svg?component";
  4. import laptopIcon from "/@/assets/svg/laptop.svg?component";
  5. import serviceIcon from "/@/assets/svg/service.svg?component";
  6. import calendarIcon from "/@/assets/svg/calendar.svg?component";
  7. import userAvatarIcon from "/@/assets/svg/user_avatar.svg?component";
  8. defineOptions({
  9. name: "ReCard"
  10. });
  11. interface CardProductType {
  12. type: number;
  13. isSetup: boolean;
  14. description: string;
  15. name: string;
  16. }
  17. const props = defineProps({
  18. product: {
  19. type: Object as PropType<CardProductType>
  20. }
  21. });
  22. const emit = defineEmits(["manage-product", "delete-item"]);
  23. const handleClickManage = (product: CardProductType) => {
  24. emit("manage-product", product);
  25. };
  26. const handleClickDelete = (product: CardProductType) => {
  27. emit("delete-item", product);
  28. };
  29. const cardClass = computed(() => [
  30. "list-card-item",
  31. { "list-card-item__disabled": !props.product.isSetup }
  32. ]);
  33. const cardLogoClass = computed(() => [
  34. "list-card-item_detail--logo",
  35. { "list-card-item_detail--logo__disabled": !props.product.isSetup }
  36. ]);
  37. </script>
  38. <template>
  39. <div :class="cardClass">
  40. <div class="list-card-item_detail bg-white dark:bg-dark">
  41. <el-row justify="space-between">
  42. <div :class="cardLogoClass">
  43. <shopIcon v-if="product.type === 1" />
  44. <calendarIcon v-if="product.type === 2" />
  45. <serviceIcon v-if="product.type === 3" />
  46. <userAvatarIcon v-if="product.type === 4" />
  47. <laptopIcon v-if="product.type === 5" />
  48. </div>
  49. <div class="list-card-item_detail--operation">
  50. <el-tag
  51. :color="product.isSetup ? '#00a870' : '#eee'"
  52. effect="dark"
  53. class="mx-1 list-card-item_detail--operation--tag"
  54. >
  55. {{ product.isSetup ? "已启用" : "已停用" }}
  56. </el-tag>
  57. <el-dropdown
  58. trigger="click"
  59. :disabled="!product.isSetup"
  60. max-height="2"
  61. >
  62. <IconifyIconOffline icon="more-vertical" class="text-[24px]" />
  63. <template #dropdown>
  64. <el-dropdown-menu :disabled="!product.isSetup">
  65. <el-dropdown-item @click="handleClickManage(product)">
  66. 管理
  67. </el-dropdown-item>
  68. <el-dropdown-item @click="handleClickDelete(product)">
  69. 删除
  70. </el-dropdown-item>
  71. </el-dropdown-menu>
  72. </template>
  73. </el-dropdown>
  74. </div>
  75. </el-row>
  76. <p class="list-card-item_detail--name text-text_color_primary">
  77. {{ product.name }}
  78. </p>
  79. <p class="list-card-item_detail--desc text-text_color_regular">
  80. {{ product.description }}
  81. </p>
  82. </div>
  83. </div>
  84. </template>
  85. <style scoped lang="scss">
  86. .list-card-item {
  87. display: flex;
  88. flex-direction: column;
  89. margin-bottom: 12px;
  90. border-radius: 3px;
  91. overflow: hidden;
  92. cursor: pointer;
  93. &_detail {
  94. flex: 1;
  95. padding: 24px 32px;
  96. min-height: 140px;
  97. &--logo {
  98. width: 56px;
  99. height: 56px;
  100. border-radius: 50%;
  101. display: flex;
  102. justify-content: center;
  103. align-items: center;
  104. background: #e0ebff;
  105. font-size: 32px;
  106. color: #0052d9;
  107. &__disabled {
  108. color: #a1c4ff;
  109. }
  110. }
  111. &--operation {
  112. display: flex;
  113. height: 100%;
  114. &--tag {
  115. border: 0;
  116. }
  117. }
  118. &--name {
  119. margin: 24px 0 8px 0;
  120. font-size: 16px;
  121. font-weight: 400;
  122. }
  123. &--desc {
  124. font-size: 12px;
  125. line-height: 20px;
  126. overflow: hidden;
  127. text-overflow: ellipsis;
  128. display: -webkit-box;
  129. -webkit-line-clamp: 2;
  130. -webkit-box-orient: vertical;
  131. margin-bottom: 24px;
  132. height: 40px;
  133. }
  134. }
  135. &__disabled {
  136. .list-card-item_detail--name,
  137. .list-card-item_detail--desc {
  138. color: var(--el-text-color-disabled);
  139. }
  140. .list-card-item_detail--operation--tag {
  141. color: #bababa;
  142. }
  143. }
  144. }
  145. </style>