index.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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?customize.src:imgUrl"
  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. imgUrl:require('data-room-ui/assets/images/cardImg/cardicon.png'),
  81. customClass: {}
  82. }
  83. },
  84. watch: {},
  85. mounted () {
  86. },
  87. computed: {
  88. unit(){
  89. return this.config?.customize.unit || ''
  90. },
  91. option () {
  92. return this.config?.option
  93. },
  94. optionData () {
  95. return this.option?.data || 80
  96. },
  97. customize () {
  98. return this.config?.customize
  99. },
  100. },
  101. methods: {
  102. dataFormatting (config, data) {
  103. let dataList = ''
  104. if(data.success){
  105. if (data.data instanceof Array) {
  106. dataList = config.dataSource.dimensionField
  107. ? data.data[0][config.dataSource.dimensionField]
  108. : data.data[0].value
  109. } else {
  110. dataList = data.data[config.dataSource.dimensionField]
  111. }
  112. }else{
  113. dataList=80
  114. }
  115. config.option = {
  116. ...config.option,
  117. data: dataList
  118. }
  119. return config
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss" scoped>
  125. .content{
  126. display: flex;
  127. flex-direction: row;
  128. height: 100%;
  129. width: 100%;
  130. // background-color: aliceblue;
  131. justify-content: center;
  132. .content-left{
  133. display: flex;
  134. flex-direction: row;
  135. height: 100%;
  136. align-items: center;
  137. }
  138. .content-right{
  139. display: flex;
  140. flex-direction: column;
  141. height: 100%;
  142. justify-content: center;
  143. }
  144. .content-right-first{
  145. display: flex;
  146. flex-direction: row;
  147. align-items: center;
  148. padding-bottom: 5px;
  149. }
  150. .content-right-second{
  151. display: flex;
  152. flex-direction: row;
  153. align-items: center;
  154. }
  155. }
  156. </style>