index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. {{ optionData }}
  25. </div>
  26. <div
  27. :style="{
  28. 'font-size': customize.secondSize + 'px',
  29. 'height':customize.secondSize + 'px',
  30. color:customize.secondColor,
  31. 'font-weight':customize.secondWeight,
  32. }"
  33. class="content-right-second"
  34. >
  35. {{ customize.secondLine }}
  36. </div>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  42. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  43. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  44. export default {
  45. name: 'Card',
  46. components: {},
  47. mixins: [paramsMixins, commonMixins, linkageMixins],
  48. props: {
  49. // 卡片的属性
  50. config: {
  51. type: Object,
  52. default: () => ({})
  53. }
  54. },
  55. data () {
  56. return {
  57. customClass: {}
  58. }
  59. },
  60. watch: {},
  61. mounted () {
  62. // this.chartInit()
  63. },
  64. computed: {
  65. option () {
  66. return this.config?.option
  67. },
  68. optionData () {
  69. return this.option?.data || 0
  70. },
  71. customize () {
  72. return this.config?.customize
  73. },
  74. // tableData () {
  75. // let dataList = ''
  76. // if (this.optionData instanceof Array && this.optionData.length > 0) {
  77. // dataList = this.option?.yField
  78. // ? this.optionData[0][this.option.yField]
  79. // : this.optionData[0]?.value
  80. // } else {
  81. // dataList = this.optionData ? this.optionData[this.option.yField] : ''
  82. // }
  83. // return dataList
  84. // }
  85. },
  86. methods: {
  87. dataFormatting (config, data) {
  88. let dataList = ''
  89. if(data.success){
  90. if (data.data instanceof Array) {
  91. dataList = config.dataSource.dimensionField
  92. ? data.data[0][config.dataSource.dimensionField]
  93. : data.data[0].value
  94. } else {
  95. dataList = data.data[config.dataSource.dimensionField]
  96. }
  97. }else{
  98. dataList=0
  99. }
  100. config.option = {
  101. ...config.option,
  102. data: dataList
  103. }
  104. return config
  105. }
  106. }
  107. }
  108. </script>
  109. <style lang="scss" scoped>
  110. .content{
  111. display: flex;
  112. flex-direction: column;
  113. height: 100%;
  114. width: 100%;
  115. text-align: center;
  116. justify-content: center;
  117. .content-right-first{
  118. width: 100%;
  119. text-align: center;
  120. padding-bottom: 5px;
  121. }
  122. .content-right-second{
  123. width: 100%;
  124. text-align: center;
  125. }
  126. }
  127. </style>