index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div
  3. :class="`bs-indexCard-${customTheme}`"
  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. {{ customize.secondLine }}
  49. </span>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import commonMixins from '../../../js/mixins/commonMixins'
  56. import paramsMixins from '../../../js/mixins/paramsMixins'
  57. export default {
  58. name: 'Card',
  59. components: {},
  60. mixins: [paramsMixins, commonMixins],
  61. props: {
  62. // 卡片的属性
  63. config: {
  64. type: Object,
  65. default: () => ({})
  66. }
  67. },
  68. data() {
  69. return {
  70. customClass: {}
  71. }
  72. },
  73. watch: {},
  74. mounted () {
  75. this.chartInit()
  76. },
  77. computed: {
  78. option () {
  79. return this.config?.option
  80. },
  81. optionData () {
  82. return this.option?.data || []
  83. },
  84. customize () {
  85. return this.option?.customize
  86. },
  87. tableData () {
  88. let dataList = ''
  89. if (this.optionData instanceof Array && this.optionData.length > 0) {
  90. dataList = this.option?.yField
  91. ? this.optionData[0][this.option.yField]
  92. : this.optionData[0]?.value
  93. } else {
  94. dataList = this.optionData ? this.optionData[this.option.yField] : ''
  95. }
  96. return dataList
  97. }
  98. },
  99. methods: {
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped>
  104. .content{
  105. display: flex;
  106. flex-direction: row;
  107. height: 100%;
  108. width: 100%;
  109. // background-color: aliceblue;
  110. justify-content: center;
  111. .content-left{
  112. display: flex;
  113. flex-direction: row;
  114. height: 100%;
  115. align-items: center;
  116. }
  117. .content-right{
  118. display: flex;
  119. flex-direction: column;
  120. height: 100%;
  121. justify-content: center;
  122. }
  123. .content-right-first{
  124. display: flex;
  125. flex-direction: row;
  126. align-items: center;
  127. padding-bottom: 5px;
  128. }
  129. .content-right-second{
  130. display: flex;
  131. flex-direction: row;
  132. align-items: center;
  133. }
  134. }
  135. </style>