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