ListCard.vue 4.0 KB

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