index.vue 4.2 KB

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