index.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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-family': config.customize.fontFamily,
  37. 'font-size': customize.secondSize + 'px',
  38. color:customize.secondColor,
  39. 'font-weight':customize.secondWeight,
  40. }">
  41. {{ optionData }}
  42. </span>
  43. <span
  44. :style="{
  45. 'margin-left':'10px',
  46. 'font-size': customize.unitSize + 'px',
  47. 'line-height':customize.unitSize + 'px',
  48. color:customize.unitColor,
  49. }">
  50. {{unit}}
  51. </span>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  58. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  59. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  60. export default {
  61. name: 'Card',
  62. components: {},
  63. mixins: [paramsMixins, commonMixins, linkageMixins],
  64. props: {
  65. // 卡片的属性
  66. config: {
  67. type: Object,
  68. default: () => ({})
  69. }
  70. },
  71. data () {
  72. return {
  73. customClass: {}
  74. }
  75. },
  76. watch: {},
  77. mounted () {
  78. // this.chartInit()
  79. },
  80. computed: {
  81. gradientColor0 () {
  82. return this.config.customize.gradientColor0 || this.config.customize.gradientColor1 || 'transparent'
  83. },
  84. gradientColor1 () {
  85. return this.config.customize.gradientColor1 || this.config.customize.gradientColor0 || 'transparent'
  86. },
  87. unit(){
  88. return this.config?.customize.unit || ''
  89. },
  90. option () {
  91. return this.config?.option
  92. },
  93. optionData () {
  94. return this.option?.data || 80
  95. },
  96. customize () {
  97. return this.config?.customize
  98. },
  99. // tableData () {
  100. // let dataList = ''
  101. // if (this.optionData instanceof Array && this.optionData.length > 0) {
  102. // dataList = this.option?.yField
  103. // ? this.optionData[0][this.option.yField]
  104. // : this.optionData[0]?.value
  105. // } else {
  106. // dataList = this.optionData ? this.optionData[this.option.yField] : ''
  107. // }
  108. // return dataList
  109. // }
  110. },
  111. methods: {
  112. dataFormatting (config, data) {
  113. let dataList = ''
  114. if(data.success){
  115. if (data.data instanceof Array) {
  116. dataList = config.dataSource.dimensionField
  117. ? data.data[0][config.dataSource.dimensionField]
  118. : data.data[0].value
  119. } else {
  120. dataList = data.data[config.dataSource.dimensionField]
  121. }
  122. }else{
  123. dataList=0
  124. }
  125. config.option = {
  126. ...config.option,
  127. data: dataList
  128. }
  129. return config
  130. }
  131. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. @import "../../assets/fonts/numberFont/stylesheet.css";
  136. .content{
  137. display: flex;
  138. flex-direction: column;
  139. height: 100%;
  140. width: 100%;
  141. text-align: center;
  142. justify-content: center;
  143. .content-right-first{
  144. width: 100%;
  145. text-align: center;
  146. padding-bottom: 5px;
  147. }
  148. .content-right-second{
  149. display: flex;
  150. justify-content: center;
  151. align-items: center;
  152. }
  153. }
  154. </style>