RenderCard.vue 2.7 KB

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