index.vue 3.5 KB

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