CardItem2.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <div class="card">
  3. <div :class="{TitleCardBox: true, is_hover: hover, is_selected: is_selected}" @click="clickHandle">
  4. <span class="icon"><img :src="icon"/></span>
  5. <span class="title" :style="{color: color}">{{ title }}</span>
  6. <span class="numbers" :style="{color: color}">{{value}}</span>
  7. <span class="unit" :style="{color: color}">{{ unit }}</span>
  8. </div>
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: 'CardItem',
  14. props: {
  15. icon: {
  16. type: [Object, String],
  17. default() {
  18. return null
  19. }
  20. },
  21. hover: {
  22. type: Boolean,
  23. default: false
  24. },
  25. is_selected: {
  26. type: Boolean,
  27. default: false
  28. },
  29. color: {
  30. type: String,
  31. default: '#4ADEFF'
  32. },
  33. value: {
  34. type: [String, Number],
  35. },
  36. title: {
  37. type: String,
  38. default: ''
  39. },
  40. unit: {
  41. type: String,
  42. default: '个'
  43. },
  44. secondValue:{
  45. type: [String, Number],
  46. default: 22.2
  47. },
  48. percent:{
  49. type: [String, Number],
  50. default: 22.2
  51. }
  52. },
  53. data(){
  54. return{
  55. selected:false
  56. }
  57. },
  58. methods: {
  59. clickHandle() {
  60. this.selected=!this.selected
  61. this.$emit('click')
  62. },
  63. clearActive(){
  64. this.selected=false
  65. }
  66. }
  67. }
  68. </script>
  69. <style lang="scss" scoped>
  70. .card {
  71. border: 1px solid #3D77DC;
  72. margin-bottom: 12px;
  73. .TitleCardBox {
  74. height: 50px;
  75. //background: #193E86;
  76. display: flex;
  77. color: #fff;
  78. align-items: center;
  79. padding: 0px 10px;
  80. &.is_hover {
  81. cursor: pointer;
  82. }
  83. &.is_hover:hover {
  84. background: linear-gradient(90deg, #0E66BF 0%, #153981 100%);
  85. border-left: 3px solid #3BAAFF;
  86. }
  87. &.selected{
  88. background: linear-gradient(90deg, #0E66BF 0%, #153981 100%);
  89. border-left: 3px solid #3BAAFF;
  90. }
  91. &.is_selected{
  92. background: linear-gradient(90deg, #0E66BF 0%, #153981 100%);
  93. border-left: 3px solid #3BAAFF;
  94. }
  95. > span {
  96. &.icon {
  97. width: 34px;
  98. height: 34px;
  99. margin-right: 10px;
  100. > img {
  101. width: 100%;
  102. height: 100%;
  103. }
  104. }
  105. &.title {
  106. font-size: 20px;
  107. font-weight: bold;
  108. color: #FFFFFF;
  109. flex: 1;
  110. }
  111. }
  112. .label{
  113. font-size: 18px;
  114. font-family: Alibaba PuHuiTi;
  115. font-weight: bold;
  116. color: #FFFFFF;
  117. margin-right: 15px;
  118. }
  119. .numbers{
  120. font-size: 22px;
  121. font-family: Alibaba PuHuiTi;
  122. font-weight: bold;
  123. margin-right: 5px;
  124. }
  125. > .unit {
  126. font-size: 20px;
  127. margin-left: 3px;
  128. width: 50px;
  129. }
  130. }
  131. }
  132. </style>