index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. class="content-right-first"
  16. :style="{
  17. 'font-size': customize.firstSize + 'px',
  18. 'height':customize.firstSize + 'px',
  19. color:customize.firstColor,
  20. 'font-weight':customize.firstWeight,
  21. 'margin-bottom':customize.lineDistance +'px'
  22. }"
  23. >
  24. {{ customize.secondLine }}
  25. </div>
  26. <div
  27. :style="{
  28. 'height': customize.secondSize + 'px',
  29. }"
  30. class="content-right-second"
  31. >
  32. <span
  33. :style="{
  34. 'font-size': customize.secondSize + 'px',
  35. color:customize.secondColor,
  36. 'font-weight':customize.secondWeight,
  37. }">
  38. {{ optionData }}
  39. </span>
  40. <span
  41. :style="{
  42. 'margin-left':'10px',
  43. 'font-size': customize.unitSize + 'px',
  44. 'line-height':customize.unitSize + 'px',
  45. color:customize.unitColor,
  46. }">
  47. {{unit}}
  48. </span>
  49. </div>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  55. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  56. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  57. export default {
  58. name: 'Card',
  59. components: {},
  60. mixins: [paramsMixins, commonMixins, linkageMixins],
  61. props: {
  62. // 卡片的属性
  63. config: {
  64. type: Object,
  65. default: () => ({})
  66. }
  67. },
  68. data () {
  69. return {
  70. customClass: {}
  71. }
  72. },
  73. watch: {},
  74. mounted () {
  75. // this.chartInit()
  76. },
  77. computed: {
  78. unit(){
  79. return this.config?.customize.unit || ''
  80. },
  81. option () {
  82. return this.config?.option
  83. },
  84. optionData () {
  85. return this.option?.data || 80
  86. },
  87. customize () {
  88. return this.config?.customize
  89. },
  90. // tableData () {
  91. // let dataList = ''
  92. // if (this.optionData instanceof Array && this.optionData.length > 0) {
  93. // dataList = this.option?.yField
  94. // ? this.optionData[0][this.option.yField]
  95. // : this.optionData[0]?.value
  96. // } else {
  97. // dataList = this.optionData ? this.optionData[this.option.yField] : ''
  98. // }
  99. // return dataList
  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=0
  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: column;
  129. height: 100%;
  130. width: 100%;
  131. text-align: center;
  132. justify-content: center;
  133. .content-right-first{
  134. width: 100%;
  135. text-align: center;
  136. padding-bottom: 5px;
  137. }
  138. .content-right-second{
  139. display: flex;
  140. justify-content: center;
  141. align-items: center;
  142. }
  143. }
  144. </style>