index.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <ContentBox
  3. class="go-content-layers"
  4. :class="{ scoped: !chartLayoutStore.getLayers }"
  5. title="图层"
  6. :depth="2"
  7. @back="backHandle"
  8. >
  9. <template #icon>
  10. <n-icon size="16" :depth="2">
  11. <component :is="LayersIcon" />
  12. </n-icon>
  13. </template>
  14. <!-- 图层内容 -->
  15. <ListItem
  16. v-for="(item) in chartEditStore.getComponentList"
  17. :key="item.id"
  18. :componentData="item"
  19. @mousedown="mousedownHandle(item)"
  20. @mouseenter="mouseenterHandle(item)"
  21. @mouseleave="mouseleaveHandle(item)"
  22. @contextmenu="handleContextMenu($event, item)"
  23. />
  24. </ContentBox>
  25. </template>
  26. <script setup lang="ts">
  27. import { ContentBox } from '../ContentBox/index'
  28. import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
  29. import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
  30. import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
  31. import { ChartEditStoreEnum, TargetChartType } from '@/store/modules/chartEditStore/chartEditStore.d'
  32. import { CreateComponentType } from '@/packages/index.d'
  33. import { useContextMenu } from '@/views/chart/hooks/useContextMenu.hook'
  34. import { ListItem } from './components/ListItem/index'
  35. import { icon } from '@/plugins'
  36. const { LayersIcon } = icon.ionicons5
  37. const chartLayoutStore = useChartLayoutStore()
  38. const chartEditStore = useChartEditStoreStore()
  39. const { handleContextMenu } = useContextMenu()
  40. const backHandle = () => {
  41. chartLayoutStore.setItem(ChartLayoutStoreEnum.LAYERS, false)
  42. }
  43. // 点击事件
  44. const mousedownHandle = (item: CreateComponentType) => {
  45. chartEditStore.setTargetSelectChart(item.id)
  46. }
  47. // 进入事件
  48. const mouseenterHandle = (item: CreateComponentType) => {
  49. chartEditStore.setTargetHoverChart(item.id)
  50. }
  51. // 移出事件
  52. const mouseleaveHandle = (item: CreateComponentType) => {
  53. chartEditStore.setTargetHoverChart(undefined)
  54. }
  55. </script>
  56. <style lang="scss" scoped>
  57. $wight: 170px;
  58. @include go(content-layers) {
  59. width: $wight;
  60. flex-shrink: 0;
  61. overflow: hidden;
  62. @extend .go-transition;
  63. &.scoped {
  64. width: 0;
  65. }
  66. }
  67. </style>