RenderCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!--
  2. * @description: 渲染组件
  3. * @Date: 2022-08-18 09:42:45
  4. * @Author: xingheng
  5. -->
  6. <template>
  7. <div class="content">
  8. <component
  9. :is="resolveComponentType(config.border.type)"
  10. v-if="config.border&&config.border.type"
  11. :id="`border${config.code}`"
  12. :ref="`border${config.code}`"
  13. :key="`border${config.key}`"
  14. :config="config"
  15. />
  16. <div
  17. class="render-item-wrap"
  18. :style="
  19. `height:calc(100% - ${(config.border&&config.title&&config.border.type&&config.border.type!='GcBorder11'&&config.border.isTitle)?config.border.titleHeight:0}px);
  20. padding-top:${config.border?config.border.padding[0]:0}px;
  21. padding-right:${config.border?config.border.padding[1]:0}px;
  22. padding-bottom:${config.border?config.border.padding[2]:0}px;
  23. padding-left:${config.border?config.border.padding[3]:0}px
  24. `"
  25. >
  26. <component
  27. :is="resolveComponentType(config.type)"
  28. :id="`${config.code}`"
  29. :ref="config.code"
  30. :key="config.key"
  31. :config="config"
  32. @styleHandler="styleHandler"
  33. />
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. // import commonMixins from 'data-room-ui/js/mixins/commonMixins'
  39. import { mapMutations } from 'vuex'
  40. import { resolveComponentType } from 'data-room-ui/js/utils'
  41. import pcComponent from 'data-room-ui/js/utils/componentImport'
  42. import { dataInit, destroyedEvent } from 'data-room-ui/js/utils/eventBus'
  43. import CustomComponent from '../PlotRender/index.vue'
  44. import EchartsComponent from '../EchartsRender/index.vue'
  45. import Svgs from '../Svgs/index.vue'
  46. import RemoteComponent from 'data-room-ui/RemoteComponents/index.vue'
  47. import cloneDeep from 'lodash/cloneDeep'
  48. const components = {}
  49. for (const key in pcComponent) {
  50. if (Object.hasOwnProperty.call(pcComponent, key)) {
  51. components[key] = pcComponent[key]
  52. }
  53. }
  54. export default {
  55. name: 'RenderCard',
  56. // mixins: [commonMixins],
  57. components: {
  58. ...components,
  59. CustomComponent,
  60. Svgs,
  61. RemoteComponent,
  62. EchartsComponent
  63. },
  64. props: {
  65. // 卡片的属性
  66. config: {
  67. type: Object,
  68. default: () => ({})
  69. },
  70. ruleKey: {
  71. type: Number,
  72. default: 0
  73. }
  74. },
  75. data () {
  76. return {
  77. height: 0
  78. }
  79. },
  80. computed: {
  81. },
  82. mounted () {
  83. // 调用初始化方法
  84. dataInit(this)
  85. },
  86. beforeDestroy () {
  87. destroyedEvent()
  88. },
  89. methods: {
  90. ...mapMutations('bigScreen', [
  91. 'changeChartConfig'
  92. ]),
  93. resolveComponentType,
  94. // 切换主题时针对远程组件触发样式修改的方法
  95. styleHandler (config) {
  96. this.$emit('styleHandler', config)
  97. }
  98. // // 打开右侧面板
  99. // openRightPanel () {
  100. // this.$emit('openRightPanel', this.currentChart)
  101. // }
  102. }
  103. }
  104. </script>
  105. <style lang="scss" scoped>
  106. .content{
  107. position: relative;
  108. width: 100%;
  109. height: 100%;
  110. display: flex;
  111. align-items: flex-end;
  112. }
  113. .render-item-wrap {
  114. width: 100%;
  115. height: 100%;
  116. display: flex;
  117. position: relative;
  118. overflow: hidden;
  119. box-sizing: border-box;
  120. padding-bottom: 15px;
  121. }
  122. </style>