RenderCard.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 RemoteComponent from 'data-room-ui/RemoteComponents/index.vue'
  27. import cloneDeep from 'lodash/cloneDeep'
  28. const components = {}
  29. for (const key in pcComponent) {
  30. if (Object.hasOwnProperty.call(pcComponent, key)) {
  31. components[key] = pcComponent[key]
  32. }
  33. }
  34. export default {
  35. name: 'RenderCard',
  36. // mixins: [commonMixins],
  37. components: {
  38. ...components,
  39. CustomComponent,
  40. Svgs,
  41. RemoteComponent
  42. },
  43. props: {
  44. // 卡片的属性
  45. config: {
  46. type: Object,
  47. default: () => ({})
  48. },
  49. ruleKey: {
  50. type: Number,
  51. default: 0
  52. }
  53. },
  54. data () {
  55. return {}
  56. },
  57. computed: {},
  58. mounted () {
  59. // 调用初始化方法
  60. dataInit(this)
  61. },
  62. beforeDestroy () {
  63. destroyedEvent()
  64. },
  65. methods: {
  66. ...mapMutations('bigScreen', [
  67. 'changeChartConfig'
  68. ]),
  69. resolveComponentType,
  70. // 切换主题时针对远程组件触发样式修改的方法
  71. styleHandler (config) {
  72. this.$emit('styleHandler', config)
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .render-item-wrap {
  79. width: 100%;
  80. height: 100%;
  81. display: flex;
  82. overflow: hidden;
  83. box-sizing: border-box;
  84. }
  85. </style>