index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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. >{{ optionData}}</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. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  57. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  58. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  59. export default {
  60. name: 'Card',
  61. components: {},
  62. mixins: [paramsMixins, commonMixins, linkageMixins],
  63. props: {
  64. // 卡片的属性
  65. config: {
  66. type: Object,
  67. default: () => ({})
  68. }
  69. },
  70. data () {
  71. return {
  72. customClass: {}
  73. }
  74. },
  75. watch: {},
  76. mounted () {
  77. },
  78. computed: {
  79. option () {
  80. return this.config?.option
  81. },
  82. optionData () {
  83. return this.option?.data || 80
  84. },
  85. customize () {
  86. return this.config?.customize
  87. },
  88. },
  89. methods: {
  90. dataFormatting (config, data) {
  91. let dataList = ''
  92. if(data.success){
  93. if (data.data instanceof Array) {
  94. dataList = config.dataSource.dimensionField
  95. ? data.data[0][config.dataSource.dimensionField]
  96. : data.data[0].value
  97. } else {
  98. dataList = data.data[config.dataSource.dimensionField]
  99. }
  100. }else{
  101. dataList=80
  102. }
  103. config.option = {
  104. ...config.option,
  105. data: dataList
  106. }
  107. return config
  108. }
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .content{
  114. display: flex;
  115. flex-direction: row;
  116. height: 100%;
  117. width: 100%;
  118. // background-color: aliceblue;
  119. justify-content: center;
  120. .content-left{
  121. display: flex;
  122. flex-direction: row;
  123. height: 100%;
  124. align-items: center;
  125. }
  126. .content-right{
  127. display: flex;
  128. flex-direction: column;
  129. height: 100%;
  130. justify-content: center;
  131. }
  132. .content-right-first{
  133. display: flex;
  134. flex-direction: row;
  135. align-items: center;
  136. padding-bottom: 5px;
  137. }
  138. .content-right-second{
  139. display: flex;
  140. flex-direction: row;
  141. align-items: center;
  142. }
  143. }
  144. </style>