index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <ContentBox
  3. id="go-chart-edit-layout"
  4. :flex="true"
  5. :showTop="false"
  6. :showBottom="true"
  7. :depth="1"
  8. :xScroll="true"
  9. @drop="handleDrag"
  10. @dragover="handleDragOver"
  11. >
  12. <div id="go-chart-edit-content">
  13. <!-- 展示 -->
  14. <EditRange ref="editRangeRef">
  15. <!-- 图表 -->
  16. <EditShapeBox
  17. v-for="(item, index) in chartEditStore.getComponentList"
  18. :key="item.id"
  19. :data-id="item.id"
  20. :index="index"
  21. :style="useComponentStyle(item.attr, index)"
  22. :item="item"
  23. @mousedown="mousedownHandle($event, item)"
  24. @mouseenter="mouseenterHandle($event, item)"
  25. @mouseleave="mouseleaveHandle($event, item)"
  26. @contextmenu="handleContextMenu($event, item)"
  27. >
  28. <component
  29. class="edit-content-chart"
  30. :is="item.chartConfig.chartKey"
  31. :chartConfig="item"
  32. :themeSetting="themeSetting"
  33. :themeColor="themeColor"
  34. :style="useSizeStyle(item.attr)"
  35. />
  36. </EditShapeBox>
  37. </EditRange>
  38. </div>
  39. <!-- 底部控制 -->
  40. <template #bottom>
  41. <EditBottom />
  42. </template>
  43. </ContentBox>
  44. </template>
  45. <script lang="ts" setup>
  46. import { ref, onMounted, computed } from 'vue'
  47. import { ContentBox } from '../contentBox/index'
  48. import { EditRange } from './components/EditRange'
  49. import { EditBottom } from './components/EditBottom'
  50. import { EditShapeBox } from './components/EditShapeBox/index'
  51. import { useLayout } from './hooks/useLayout.hook'
  52. import { useAddKeyboard } from '../hooks/useKeyboard.hook'
  53. import { handleDrag, handleDragOver, useMouseHandle } from './hooks/useDrag.hook'
  54. import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
  55. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  56. import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook'
  57. import { chartColors } from '@/settings/chartThemes/index'
  58. const chartEditStore = useChartEditStore()
  59. const { handleContextMenu } = useContextMenu()
  60. // 布局处理
  61. useLayout()
  62. // 点击事件
  63. const editRangeRef = ref<HTMLElement | null>(null)
  64. const { mouseenterHandle, mouseleaveHandle, mousedownHandle } = useMouseHandle()
  65. // 主题色
  66. const themeSetting = computed(() => {
  67. const chartThemeSetting = chartEditStore.getEditCanvasConfig.chartThemeSetting
  68. return chartThemeSetting
  69. })
  70. // 配置项
  71. const themeColor = computed(() => {
  72. const chartThemeColor = chartEditStore.getEditCanvasConfig.chartThemeColor
  73. return chartColors[chartThemeColor]
  74. })
  75. // 键盘事件
  76. onMounted(() => {
  77. useAddKeyboard()
  78. })
  79. </script>
  80. <style lang="scss" scoped>
  81. @include goId(chart-edit-layout) {
  82. position: relative;
  83. width: 100%;
  84. overflow: hidden;
  85. @include background-image('background-point');
  86. @extend .go-point-bg;
  87. @include goId(chart-edit-content) {
  88. margin: 20px;
  89. border: 1px solid rgba(0, 0, 0, 0);
  90. @extend .go-transition;
  91. &.content-resize {
  92. border-radius: 15px;
  93. @include hover-border-color('hover-border-color');
  94. }
  95. .edit-content-chart {
  96. position: absolute;
  97. }
  98. }
  99. }
  100. </style>