index.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <template>
  2. <ContentBox
  3. id="go-chart-edit-layout"
  4. ref="editDomRef"
  5. :flex="true"
  6. :showTop="false"
  7. :showBottom="true"
  8. :depth="1"
  9. :xScroll="true"
  10. @drop="handleDrop"
  11. @dragover="handleDragOver"
  12. >
  13. <div id="go-chart-edit-content">
  14. <!-- 展示 -->
  15. <EditRange ref="editRangeRef">
  16. <!-- 图表 -->
  17. <ShapeBox
  18. v-for="(item, index) in chartEditStore.getComponentList"
  19. :key="item.id"
  20. :data-id="item.id"
  21. :index="index"
  22. :style="useComponentStyle(item.attr, index)"
  23. :item="item"
  24. @contextmenu="handleContextMenu($event, index)"
  25. @mousedown="mousedownHandle($event, item)"
  26. @mouseenter="mouseenterHandle($event, item)"
  27. @mouseleave="mouseleaveHandle($event, item)"
  28. >
  29. <component
  30. class="edit-content-chart"
  31. :is="item.key"
  32. :chartData="item"
  33. :style="useSizeStyle(item.attr)"
  34. />
  35. </ShapeBox>
  36. </EditRange>
  37. </div>
  38. <!-- 底部控制 -->
  39. <template #bottom>
  40. <EditBottom />
  41. </template>
  42. </ContentBox>
  43. </template>
  44. <script lang="ts" setup>
  45. import { ref, onMounted } from 'vue'
  46. import { ContentBox } from '../ContentBox/index'
  47. import { EditRange } from './components/EditRange'
  48. import { EditBottom } from './components/EditBottom'
  49. import { ShapeBox } from './components/ShapeBox/index'
  50. import { useLayout } from './hooks/useLayout.hook'
  51. import { handleDrop, handleDragOver, useMouseHandle } from './hooks/useDrop.hook'
  52. import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
  53. import { getChartEditStore } from './hooks/useStore.hook'
  54. import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook'
  55. import { CreateComponentType } from '@/packages/index.d'
  56. const chartEditStore = getChartEditStore()
  57. const { handleContextMenu } = useContextMenu()
  58. // 布局处理
  59. useLayout()
  60. // 点击事件
  61. const editRangeRef = ref<HTMLElement | null>(null)
  62. const { mouseenterHandle, mouseleaveHandle, mousedownHandle } = useMouseHandle()
  63. </script>
  64. <style lang="scss" scoped>
  65. @include goId(chart-edit-layout) {
  66. position: relative;
  67. width: 100%;
  68. overflow: hidden;
  69. @include background-image('background-point');
  70. @extend .go-point-bg;
  71. @include goId(chart-edit-content) {
  72. margin: 20px;
  73. overflow: hidden;
  74. transform-origin: left top;
  75. border: 1px solid rgba(0, 0, 0, 0);
  76. @extend .go-transition;
  77. &.content-resize {
  78. border-radius: 15px;
  79. @include hover-border-color('hover-border-color');
  80. }
  81. .edit-content-chart {
  82. position: absolute;
  83. }
  84. }
  85. }
  86. </style>