index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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>
  16. <!-- 右键 -->
  17. <n-dropdown
  18. placement="bottom-start"
  19. trigger="manual"
  20. size="small"
  21. :x="mousePosition.x"
  22. :y="mousePosition.y"
  23. :options="menuOptions"
  24. :show="showDropdownRef"
  25. :on-clickoutside="onClickoutside"
  26. @select="handleMenuSelect"
  27. />
  28. <!-- 图表 -->
  29. <ShapeBox
  30. v-for="(item, index) in chartEditStore.getComponentList"
  31. :key="item.id"
  32. :data-id="item.id"
  33. :index="index"
  34. :style="useComponentStyle(item.attr, index)"
  35. :item="item"
  36. @contextmenu="handleContextMenu($event, index)"
  37. @mousedown="mousedownHandle($event, item)"
  38. @mouseenter="mouseenterHandle($event, item)"
  39. @mouseleave="mouseleaveHandle($event, item)"
  40. >
  41. <component
  42. class="edit-content-chart"
  43. :is="item.key"
  44. :chartData="item"
  45. :style="useSizeStyle(item.attr)"
  46. />
  47. </ShapeBox>
  48. </EditRange>
  49. </div>
  50. <!-- 底部控制 -->
  51. <template #bottom>
  52. <EditBottom />
  53. </template>
  54. </ContentBox>
  55. </template>
  56. <script lang="ts" setup>
  57. import { onUnmounted, onMounted, toRefs } from 'vue'
  58. import { ContentBox } from '../ContentBox/index'
  59. import { EditRange } from './components/EditRange'
  60. import { EditBottom } from './components/EditBottom'
  61. import { ShapeBox } from './components/ShapeBox/index'
  62. import {
  63. useLayout,
  64. mousedownHandle,
  65. mouseenterHandle,
  66. mouseleaveHandle
  67. } from './hooks/useLayout.hook'
  68. import { handleDrop, handleDragOver } from './hooks/useDrop.hook'
  69. import { useContextMenu } from './hooks/useContextMenu.hook'
  70. import { getChartEditStore } from './hooks/useStore.hook'
  71. import { useComponentStyle, useSizeStyle } from './hooks/useStyle.hook'
  72. const chartEditStore = getChartEditStore()
  73. const {
  74. showDropdownRef,
  75. menuOptions,
  76. onClickoutside,
  77. mousePosition,
  78. handleContextMenu,
  79. handleMenuSelect
  80. } = useContextMenu()
  81. // 布局处理
  82. useLayout()
  83. </script>
  84. <style lang="scss" scoped>
  85. @include goId(chart-edit-layout) {
  86. position: relative;
  87. width: 100%;
  88. overflow: hidden;
  89. @include background-image('background-point');
  90. @extend .go-point-bg;
  91. @include goId(chart-edit-content) {
  92. margin: 20px;
  93. overflow: hidden;
  94. transform-origin: left top;
  95. border: 1px solid rgba(0, 0, 0, 0);
  96. @extend .go-transition;
  97. &.content-resize {
  98. border-radius: 15px;
  99. @include hover-border-color('hover-border-color');
  100. }
  101. .edit-content-chart {
  102. position: absolute;
  103. }
  104. }
  105. }
  106. </style>