index.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <content-box
  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"></component>
  12. </n-icon>
  13. </template>
  14. <!-- 图层内容 -->
  15. <layers-list-item
  16. v-for="item in reverseList"
  17. :key="item.id"
  18. :componentData="item"
  19. @mousedown="mousedownHandle(item)"
  20. @mouseenter="mouseenterHandle(item)"
  21. @mouseleave="mouseleaveHandle(item)"
  22. @contextmenu="handleContextMenu($event)"
  23. ></layers-list-item>
  24. </content-box>
  25. </template>
  26. <script setup lang="ts">
  27. import { computed } from 'vue'
  28. import { ContentBox } from '../contentBox/index'
  29. import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
  30. import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
  31. import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore'
  32. import { CreateComponentType } from '@/packages/index.d'
  33. import cloneDeep from 'lodash/cloneDeep'
  34. import {
  35. useContextMenu,
  36. MenuEnum
  37. } from '@/views/chart/hooks/useContextMenu.hook'
  38. import { LayersListItem } from './components/LayersListItem/index'
  39. import { icon } from '@/plugins'
  40. const { LayersIcon } = icon.ionicons5
  41. const chartLayoutStore = useChartLayoutStore()
  42. const chartEditStore = useChartEditStore()
  43. const { handleContextMenu } = useContextMenu({
  44. hideOptionsList: [MenuEnum.CLEAR, MenuEnum.PARSE]
  45. })
  46. // 逆序输出
  47. const reverseList = computed(() => {
  48. const list: CreateComponentType[] = cloneDeep(chartEditStore.getComponentList)
  49. return list.reverse()
  50. })
  51. const backHandle = () => {
  52. chartLayoutStore.setItem(ChartLayoutStoreEnum.LAYERS, false)
  53. }
  54. // 点击事件
  55. const mousedownHandle = (item: CreateComponentType) => {
  56. chartEditStore.setTargetSelectChart(item.id)
  57. }
  58. // 进入事件
  59. const mouseenterHandle = (item: CreateComponentType) => {
  60. chartEditStore.setTargetHoverChart(item.id)
  61. }
  62. // 移出事件
  63. const mouseleaveHandle = (item: CreateComponentType) => {
  64. chartEditStore.setTargetHoverChart(undefined)
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. $wight: 170px;
  69. @include go(content-layers) {
  70. width: $wight;
  71. flex-shrink: 0;
  72. overflow: hidden;
  73. @extend .go-transition;
  74. &.scoped {
  75. width: 0;
  76. }
  77. }
  78. </style>