index.vue 4.0 KB

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