RenderCard.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. const components = {}
  48. for (const key in pcComponent) {
  49. if (Object.hasOwnProperty.call(pcComponent, key)) {
  50. components[key] = pcComponent[key]
  51. }
  52. }
  53. export default {
  54. name: 'RenderCard',
  55. // mixins: [commonMixins],
  56. components: {
  57. ...components,
  58. CustomComponent,
  59. Svgs,
  60. RemoteComponent,
  61. EchartsComponent
  62. },
  63. props: {
  64. // 卡片的属性
  65. config: {
  66. type: Object,
  67. default: () => ({})
  68. },
  69. ruleKey: {
  70. type: Number,
  71. default: 0
  72. }
  73. },
  74. data () {
  75. return {
  76. height: 0
  77. }
  78. },
  79. computed: {
  80. },
  81. mounted () {
  82. // 调用初始化方法
  83. dataInit(this)
  84. },
  85. beforeDestroy () {
  86. destroyedEvent()
  87. },
  88. methods: {
  89. ...mapMutations('bigScreen', [
  90. 'changeChartConfig'
  91. ]),
  92. resolveComponentType,
  93. // 切换主题时针对远程组件触发样式修改的方法
  94. styleHandler (config) {
  95. this.$emit('styleHandler', config)
  96. }
  97. // // 打开右侧面板
  98. // openRightPanel () {
  99. // this.$emit('openRightPanel', this.currentChart)
  100. // }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .content{
  106. position: relative;
  107. width: 100%;
  108. height: 100%;
  109. display: flex;
  110. align-items: flex-end;
  111. }
  112. .render-item-wrap {
  113. width: 100%;
  114. height: 100%;
  115. display: flex;
  116. position: relative;
  117. overflow: hidden;
  118. box-sizing: border-box;
  119. padding-bottom: 15px;
  120. }
  121. </style>