index.vue 4.1 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-family': config.customize.fontFamily,
  36. 'font-size': customize.firstSize + 'px',
  37. 'height':customize.firstSize + 'px',
  38. color:customize.firstColor,
  39. 'font-weight':customize.firstWeight,
  40. 'margin-bottom':customize.lineDistance +'px'
  41. }"
  42. >
  43. {{ optionData}}
  44. <span
  45. :style="{
  46. 'margin-left':'10px',
  47. 'font-size': customize.unitSize + 'px',
  48. color:customize.unitColor,
  49. }">
  50. {{unit}}
  51. </span>
  52. </span>
  53. <span
  54. :style="{
  55. 'font-size': customize.secondSize + 'px',
  56. 'height':customize.secondSize + 'px',
  57. color:customize.secondColor,
  58. 'font-weight':customize.secondWeight,
  59. }"
  60. class="content-right-second"
  61. >
  62. {{ customize.secondLine }}
  63. </span>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  70. import paramsMixins from 'data-room-ui/js/mixins/paramsMixins'
  71. import linkageMixins from 'data-room-ui/js/mixins/linkageMixins'
  72. export default {
  73. name: 'Card',
  74. components: {},
  75. mixins: [paramsMixins, commonMixins, linkageMixins],
  76. props: {
  77. // 卡片的属性
  78. config: {
  79. type: Object,
  80. default: () => ({})
  81. }
  82. },
  83. data () {
  84. return {
  85. imgUrl:require('data-room-ui/assets/images/cardImg/cardicon.png'),
  86. customClass: {}
  87. }
  88. },
  89. watch: {},
  90. mounted () {
  91. },
  92. computed: {
  93. gradientColor0 () {
  94. return this.config.customize.gradientColor0 || this.config.customize.gradientColor1 || 'transparent'
  95. },
  96. gradientColor1 () {
  97. return this.config.customize.gradientColor1 || this.config.customize.gradientColor0 || 'transparent'
  98. },
  99. unit(){
  100. return this.config?.customize.unit || ''
  101. },
  102. option () {
  103. return this.config?.option
  104. },
  105. optionData () {
  106. return this.option?.data || 80
  107. },
  108. customize () {
  109. return this.config?.customize
  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. .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>