index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }"
  13. >
  14. <!-- 分组 -->
  15. <preview-render-group
  16. v-if="item.isGroup"
  17. :groupData="(item as CreateComponentGroupType)"
  18. :groupIndex="index"
  19. :themeSetting="themeSetting"
  20. :themeColor="themeColor"
  21. ></preview-render-group>
  22. <!-- 单组件 -->
  23. <component
  24. v-else
  25. :is="item.chartConfig.chartKey"
  26. :chartConfig="item"
  27. :themeSetting="themeSetting"
  28. :themeColor="themeColor"
  29. :style="{ ...getSizeStyle(item.attr) }"
  30. ></component>
  31. </div>
  32. </template>
  33. <script setup lang="ts">
  34. import { PropType, computed } from 'vue'
  35. import { ChartEditStorageType } from '../../index.d'
  36. import { PreviewRenderGroup } from '../PreviewRenderGroup/index'
  37. import { CreateComponentGroupType } from '@/packages/index.d'
  38. import { chartColors } from '@/settings/chartThemes/index'
  39. import { animationsClass, getFilterStyle, getTransformStyle } from '@/utils'
  40. import { getSizeStyle, getComponentAttrStyle, getStatusStyle } from '../../utils'
  41. const props = defineProps({
  42. localStorageInfo: {
  43. type: Object as PropType<ChartEditStorageType>,
  44. required: true
  45. }
  46. })
  47. // 主题色
  48. const themeSetting = computed(() => {
  49. const chartThemeSetting = props.localStorageInfo.editCanvasConfig.chartThemeSetting
  50. return chartThemeSetting
  51. })
  52. // 配置项
  53. const themeColor = computed(() => {
  54. const chartThemeColor = props.localStorageInfo.editCanvasConfig.chartThemeColor
  55. return chartColors[chartThemeColor]
  56. })
  57. </script>
  58. <style lang="scss" scoped>
  59. .chart-item {
  60. position: absolute;
  61. }
  62. </style>