index.vue 4.1 KB

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