index.vue 3.6 KB

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