Card.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <template>
  2. <div
  3. class="o-card has-padding u-pointer"
  4. @click="go"
  5. >
  6. <div class="o-card__title">
  7. <i
  8. class="l-flex__none o-card__icon"
  9. :class="type"
  10. />
  11. <div class="l-flex__fill u-text-center">
  12. <div class="u-relative">
  13. <auto-text :text="title" />
  14. <i
  15. v-if="count"
  16. class="o-card__count"
  17. >
  18. {{ count }}
  19. </i>
  20. </div>
  21. <auto-text
  22. v-if="tip"
  23. :text="tip"
  24. />
  25. </div>
  26. </div>
  27. <auto-text
  28. v-if="desc"
  29. class="o-card__desc"
  30. :text="desc"
  31. />
  32. </div>
  33. </template>
  34. <script>
  35. import AutoText from '@/components/AutoText'
  36. export default {
  37. name: 'Card',
  38. components: {
  39. AutoText
  40. },
  41. props: {
  42. type: {
  43. type: String,
  44. default: ''
  45. },
  46. title: {
  47. type: String,
  48. default: ''
  49. },
  50. tip: {
  51. type: String,
  52. default: ''
  53. },
  54. desc: {
  55. type: String,
  56. default: ''
  57. },
  58. count: {
  59. type: [String, Number],
  60. default: null
  61. }
  62. },
  63. methods: {
  64. go () {
  65. // this.$router.push({
  66. // name: 'abnormal',
  67. // params: { type: 'a' }
  68. // })
  69. }
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. .o-card {
  75. display: inline-flex;
  76. flex-direction: column;
  77. align-items: center;
  78. height: 100px;
  79. color: $black;
  80. font-size: 16px;
  81. font-weight: bold;
  82. border-radius: 8px;
  83. background-color: #fff;
  84. &__title {
  85. display: inline-flex;
  86. align-items: flex-start;
  87. max-width: 100%;
  88. line-height: 36px;
  89. }
  90. &__count {
  91. position: absolute;
  92. top: -4px;
  93. right: -10px;
  94. min-width: 20px;
  95. padding: 2px 4px;
  96. color: #fff;
  97. font-size: 12px;
  98. font-style: normal;
  99. line-height: 1;
  100. border: 2px solid #fff;
  101. border-radius: 10px;
  102. background-color: $error--dark;
  103. }
  104. &__icon {
  105. display: inline-block;
  106. width: 36px;
  107. height: 36px;
  108. margin-right: $spacing;
  109. background-position: 0 0;
  110. background-size: 100% 100%;
  111. background-repeat: no-repeat;
  112. &.info {
  113. background-image: url("~@/assets/icon_info.png");
  114. }
  115. &.safety {
  116. background-image: url("~@/assets/icon_safety.png");
  117. }
  118. &.performance {
  119. background-image: url("~@/assets/icon_performance.png");
  120. }
  121. &.log {
  122. background-image: url("~@/assets/icon_log.png");
  123. }
  124. &.date {
  125. background-image: url("~@/assets/icon_date.png");
  126. }
  127. }
  128. &__desc {
  129. margin-top: $spacing;
  130. color: $gray;
  131. font-size: 12px;
  132. font-weight: normal;
  133. }
  134. }
  135. </style>