index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. >
  60. {{ unit }}
  61. </span>
  62. </span>
  63. </div>
  64. </div>
  65. </div>
  66. </template>
  67. <script>
  68. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  69. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  70. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  71. export default {
  72. name: 'Card',
  73. components: {},
  74. mixins: [paramsMixins, commonMixins, linkageMixins],
  75. props: {
  76. // 卡片的属性
  77. config: {
  78. type: Object,
  79. default: () => ({})
  80. }
  81. },
  82. data () {
  83. return {
  84. imgUrl: require('data-room-ui/assets/images/cardImg/cardicon.png'),
  85. customClass: {}
  86. }
  87. },
  88. watch: {},
  89. mounted () {
  90. },
  91. computed: {
  92. gradientColor0 () {
  93. return this.config.customize.gradientColor0 || this.config.customize.gradientColor1 || 'transparent'
  94. },
  95. gradientColor1 () {
  96. return this.config.customize.gradientColor1 || this.config.customize.gradientColor0 || 'transparent'
  97. },
  98. unit () {
  99. return this.config?.customize.unit || ''
  100. },
  101. option () {
  102. return this.config?.option
  103. },
  104. optionData () {
  105. return this.option?.data ?? 80
  106. },
  107. customize () {
  108. return this.config?.customize
  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 = 80
  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: row;
  139. height: 100%;
  140. width: 100%;
  141. // background-color: aliceblue;
  142. justify-content: center;
  143. .content-left{
  144. display: flex;
  145. flex-direction: row;
  146. height: 100%;
  147. align-items: center;
  148. }
  149. .content-right{
  150. display: flex;
  151. flex-direction: column;
  152. height: 100%;
  153. justify-content: center;
  154. }
  155. .content-right-first{
  156. display: flex;
  157. flex-direction: row;
  158. align-items: center;
  159. padding-bottom: 5px;
  160. }
  161. .content-right-second{
  162. display: flex;
  163. flex-direction: row;
  164. align-items: center;
  165. }
  166. }
  167. </style>