index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <template>
  2. <div
  3. class="chart-item"
  4. v-for="(item, index) in localStorageInfo.componentList"
  5. :class="animationsClass(item.styles.animations)"
  6. :key="item.id"
  7. :style="{
  8. ...getComponentAttrStyle(item.attr, index),
  9. ...getFilterStyle(item.styles),
  10. ...getTransformStyle(item.styles),
  11. ...getStatusStyle(item.status),
  12. ...getBlendModeStyle(item.styles) as any
  13. }"
  14. >
  15. <!-- 分组 -->
  16. <preview-render-group
  17. v-if="item.isGroup"
  18. :groupData="(item as CreateComponentGroupType)"
  19. :groupIndex="index"
  20. :themeSetting="themeSetting"
  21. :themeColor="themeColor"
  22. ></preview-render-group>
  23. <!-- 单组件 -->
  24. <component
  25. v-else
  26. :is="item.chartConfig.chartKey"
  27. :id="item.id"
  28. :chartConfig="item"
  29. :themeSetting="themeSetting"
  30. :themeColor="themeColor"
  31. :style="{ ...getSizeStyle(item.attr) }"
  32. v-on="useLifeHandler(item)"
  33. ></component>
  34. </div>
  35. </template>
  36. <script setup lang="ts">
  37. import { PropType, computed, onMounted } from 'vue'
  38. import { useChartDataPondFetch } from '@/hooks'
  39. import { ChartEditStorageType } from '../../index.d'
  40. import { PreviewRenderGroup } from '../PreviewRenderGroup/index'
  41. import { CreateComponentGroupType } from '@/packages/index.d'
  42. import { chartColors } from '@/settings/chartThemes/index'
  43. import { animationsClass, getFilterStyle, getTransformStyle, getBlendModeStyle } from '@/utils'
  44. import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
  45. import { useLifeHandler } from '@/hooks'
  46. // 初始化数据池
  47. const { initDataPond } = useChartDataPondFetch()
  48. const props = defineProps({
  49. localStorageInfo: {
  50. type: Object as PropType<ChartEditStorageType>,
  51. required: true
  52. }
  53. })
  54. // 主题色
  55. const themeSetting = computed(() => {
  56. const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
  57. return chartThemeSetting
  58. })
  59. // 配置项
  60. const themeColor = computed(() => {
  61. const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
  62. return chartColors[chartThemeColor]
  63. })
  64. // 组件渲染结束初始化数据池
  65. onMounted(() => {
  66. initDataPond(props.localStorageInfo.requestGlobalConfig)
  67. })
  68. </script>
  69. <style lang="scss" scoped>
  70. .chart-item {
  71. position: absolute;
  72. }
  73. </style>