index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div
  3. :class="`bs-indexCard`"
  4. style="width: 100%;height: 100%;position: relative;"
  5. >
  6. <div
  7. :style="{
  8. 'background-color':customize.bgColor,
  9. 'border-radius':customize.borderRadius + 'px',
  10. border:`${customize.borderWidth}px solid ${customize.borderColor}`,
  11. }"
  12. class="content"
  13. >
  14. <div
  15. :style="{
  16. 'margin-right':customize.distance + 'px'
  17. }"
  18. class="content-left"
  19. >
  20. <el-image
  21. :style="{
  22. width: customize.imgSize + 'px',
  23. height: customize.imgSize + 'px',
  24. }"
  25. :src="customize.src"
  26. fit="contain"
  27. />
  28. </div>
  29. <div class="content-right">
  30. <span
  31. class="content-right-first"
  32. :style="{
  33. 'font-size': customize.firstSize + 'px',
  34. 'height':customize.firstSize + 'px',
  35. color:customize.firstColor,
  36. 'font-weight':customize.firstWeight,
  37. 'margin-bottom':customize.lineDistance +'px'
  38. }"
  39. >{{ tableData?tableData:'' }}</span>
  40. <span
  41. :style="{
  42. 'font-size': customize.secondSize + 'px',
  43. 'height':customize.secondSize + 'px',
  44. color:customize.secondColor,
  45. 'font-weight':customize.secondWeight,
  46. }"
  47. class="content-right-second"
  48. >
  49. {{ customize.secondLine }}
  50. </span>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. export default {
  57. name: 'Card',
  58. components: {},
  59. props: {
  60. // 卡片的属性
  61. config: {
  62. type: Object,
  63. default: () => ({})
  64. }
  65. },
  66. data () {
  67. return {
  68. customClass: {}
  69. }
  70. },
  71. watch: {},
  72. mounted () {
  73. },
  74. computed: {
  75. option () {
  76. return this.config?.option
  77. },
  78. optionData () {
  79. return this.option?.data || []
  80. },
  81. customize () {
  82. return this.option?.customize
  83. },
  84. tableData () {
  85. let dataList = ''
  86. if (this.optionData instanceof Array && this.optionData.length > 0) {
  87. dataList = this.option?.yField
  88. ? this.optionData[0][this.option.yField]
  89. : this.optionData[0]?.value
  90. } else {
  91. dataList = this.optionData ? this.optionData[this.option.yField] : ''
  92. }
  93. return dataList
  94. }
  95. },
  96. methods: { }
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .content{
  101. display: flex;
  102. flex-direction: row;
  103. height: 100%;
  104. width: 100%;
  105. // background-color: aliceblue;
  106. justify-content: center;
  107. .content-left{
  108. display: flex;
  109. flex-direction: row;
  110. height: 100%;
  111. align-items: center;
  112. }
  113. .content-right{
  114. display: flex;
  115. flex-direction: column;
  116. height: 100%;
  117. justify-content: center;
  118. }
  119. .content-right-first{
  120. display: flex;
  121. flex-direction: row;
  122. align-items: center;
  123. padding-bottom: 5px;
  124. }
  125. .content-right-second{
  126. display: flex;
  127. flex-direction: row;
  128. align-items: center;
  129. }
  130. }
  131. </style>