index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <div
  3. :class="`bs-indexCard`"
  4. style="width: 100%;height: 100%;position: relative;"
  5. >
  6. <div
  7. :style="{
  8. 'background-image': `linear-gradient(${customize.gradientDirection}, ${
  9. gradientColor0 ? gradientColor0 : gradientColor1
  10. } , ${gradientColor1 ? gradientColor1 : gradientColor0})`,
  11. 'border-radius':customize.borderRadius + 'px',
  12. border:`${customize.borderWidth}px solid ${customize.borderColor}`,
  13. }"
  14. class="content"
  15. >
  16. <div
  17. class="content-right-first"
  18. :style="{
  19. 'font-size': customize.firstSize + 'px',
  20. 'height':customize.firstSize + 'px',
  21. color:customize.firstColor,
  22. 'font-weight':customize.firstWeight,
  23. 'margin-bottom':customize.lineDistance +'px'
  24. }"
  25. >
  26. {{ customize.secondLine }}
  27. </div>
  28. <div
  29. :style="{
  30. 'height': customize.secondSize + 'px',
  31. }"
  32. class="content-right-second"
  33. >
  34. <span
  35. :style="{
  36. 'font-size': customize.secondSize + 'px',
  37. color:customize.secondColor,
  38. 'font-weight':customize.secondWeight,
  39. }">
  40. {{ optionData }}
  41. </span>
  42. <span
  43. :style="{
  44. 'margin-left':'10px',
  45. 'font-size': customize.unitSize + 'px',
  46. 'line-height':customize.unitSize + 'px',
  47. color:customize.unitColor,
  48. }">
  49. {{unit}}
  50. </span>
  51. </div>
  52. </div>
  53. </div>
  54. </template>
  55. <script>
  56. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  57. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  58. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  59. export default {
  60. name: 'Card',
  61. components: {},
  62. mixins: [paramsMixins, commonMixins, linkageMixins],
  63. props: {
  64. // 卡片的属性
  65. config: {
  66. type: Object,
  67. default: () => ({})
  68. }
  69. },
  70. data () {
  71. return {
  72. customClass: {}
  73. }
  74. },
  75. watch: {},
  76. mounted () {
  77. // this.chartInit()
  78. },
  79. computed: {
  80. gradientColor0 () {
  81. return this.config.customize.gradientColor0 || this.config.customize.gradientColor1 || 'transparent'
  82. },
  83. gradientColor1 () {
  84. return this.config.customize.gradientColor1 || this.config.customize.gradientColor0 || 'transparent'
  85. },
  86. unit(){
  87. return this.config?.customize.unit || ''
  88. },
  89. option () {
  90. return this.config?.option
  91. },
  92. optionData () {
  93. return this.option?.data || 80
  94. },
  95. customize () {
  96. return this.config?.customize
  97. },
  98. // tableData () {
  99. // let dataList = ''
  100. // if (this.optionData instanceof Array && this.optionData.length > 0) {
  101. // dataList = this.option?.yField
  102. // ? this.optionData[0][this.option.yField]
  103. // : this.optionData[0]?.value
  104. // } else {
  105. // dataList = this.optionData ? this.optionData[this.option.yField] : ''
  106. // }
  107. // return dataList
  108. // }
  109. },
  110. methods: {
  111. dataFormatting (config, data) {
  112. let dataList = ''
  113. if(data.success){
  114. if (data.data instanceof Array) {
  115. dataList = config.dataSource.dimensionField
  116. ? data.data[0][config.dataSource.dimensionField]
  117. : data.data[0].value
  118. } else {
  119. dataList = data.data[config.dataSource.dimensionField]
  120. }
  121. }else{
  122. dataList=0
  123. }
  124. config.option = {
  125. ...config.option,
  126. data: dataList
  127. }
  128. return config
  129. }
  130. }
  131. }
  132. </script>
  133. <style lang="scss" scoped>
  134. .content{
  135. display: flex;
  136. flex-direction: column;
  137. height: 100%;
  138. width: 100%;
  139. text-align: center;
  140. justify-content: center;
  141. .content-right-first{
  142. width: 100%;
  143. text-align: center;
  144. padding-bottom: 5px;
  145. }
  146. .content-right-second{
  147. display: flex;
  148. justify-content: center;
  149. align-items: center;
  150. }
  151. }
  152. </style>