index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. :style="{
  18. 'margin-right':customize.distance + 'px'
  19. }"
  20. class="content-left"
  21. >
  22. <el-image
  23. :style="{
  24. width: customize.imgSize + 'px',
  25. height: customize.imgSize + 'px',
  26. }"
  27. :src="customize.src?customize.src:imgUrl"
  28. fit="contain"
  29. />
  30. </div>
  31. <div class="content-right">
  32. <span
  33. class="content-right-first"
  34. :style="{
  35. 'font-size': customize.firstSize + 'px',
  36. 'height':customize.firstSize + 'px',
  37. color:customize.firstColor,
  38. 'font-weight':customize.firstWeight,
  39. 'margin-bottom':customize.lineDistance +'px'
  40. }"
  41. >{{ customize.secondLine }}</span>
  42. <span
  43. :style="{
  44. 'font-family': config.customize.fontFamily,
  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. {{ optionData}}
  53. <span
  54. :style="{
  55. 'margin-left':'10px',
  56. 'font-size': customize.unitSize + 'px',
  57. color:customize.unitColor,
  58. }">
  59. {{unit}}
  60. </span>
  61. </span>
  62. </div>
  63. </div>
  64. </div>
  65. </template>
  66. <script>
  67. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  68. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  69. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  70. export default {
  71. name: 'Card',
  72. components: {},
  73. mixins: [paramsMixins, commonMixins, linkageMixins],
  74. props: {
  75. // 卡片的属性
  76. config: {
  77. type: Object,
  78. default: () => ({})
  79. }
  80. },
  81. data () {
  82. return {
  83. imgUrl:require('data-room-ui/assets/images/cardImg/cardicon.png'),
  84. customClass: {}
  85. }
  86. },
  87. watch: {},
  88. mounted () {
  89. },
  90. computed: {
  91. gradientColor0 () {
  92. return this.config.customize.gradientColor0 || this.config.customize.gradientColor1 || 'transparent'
  93. },
  94. gradientColor1 () {
  95. return this.config.customize.gradientColor1 || this.config.customize.gradientColor0 || 'transparent'
  96. },
  97. unit(){
  98. return this.config?.customize.unit || ''
  99. },
  100. option () {
  101. return this.config?.option
  102. },
  103. optionData () {
  104. return this.option?.data || 80
  105. },
  106. customize () {
  107. return this.config?.customize
  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=80
  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. @import "../../assets/fonts/numberFont/stylesheet.css";
  135. .content{
  136. display: flex;
  137. flex-direction: row;
  138. height: 100%;
  139. width: 100%;
  140. // background-color: aliceblue;
  141. justify-content: center;
  142. .content-left{
  143. display: flex;
  144. flex-direction: row;
  145. height: 100%;
  146. align-items: center;
  147. }
  148. .content-right{
  149. display: flex;
  150. flex-direction: column;
  151. height: 100%;
  152. justify-content: center;
  153. }
  154. .content-right-first{
  155. display: flex;
  156. flex-direction: row;
  157. align-items: center;
  158. padding-bottom: 5px;
  159. }
  160. .content-right-second{
  161. display: flex;
  162. flex-direction: row;
  163. align-items: center;
  164. }
  165. }
  166. </style>