RenderCard2.vue 2.2 KB

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