index.vue 3.7 KB

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