index.vue 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 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. />
  24. </ContentBox>
  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. ChartEditStoreEnum,
  36. TargetChartType
  37. } from '@/store/modules/chartEditStore/chartEditStore.d'
  38. import {
  39. useContextMenu,
  40. MenuOptionsItemType,
  41. MenuEnum
  42. } from '@/views/chart/hooks/useContextMenu.hook'
  43. import { ListItem } from './components/ListItem/index'
  44. import { icon } from '@/plugins'
  45. const { LayersIcon } = icon.ionicons5
  46. const chartLayoutStore = useChartLayoutStore()
  47. const chartEditStore = useChartEditStore()
  48. const { handleContextMenu } = useContextMenu({
  49. hideOptionsList: [MenuEnum.CLEAR, MenuEnum.PARSE]
  50. })
  51. // 逆序输出
  52. const reverseList = computed(()=>{
  53. const list: CreateComponentType[] = cloneDeep(chartEditStore.getComponentList)
  54. return list.reverse()
  55. })
  56. const backHandle = () => {
  57. chartLayoutStore.setItem(ChartLayoutStoreEnum.LAYERS, false)
  58. }
  59. // 点击事件
  60. const mousedownHandle = (item: CreateComponentType) => {
  61. chartEditStore.setTargetSelectChart(item.id)
  62. }
  63. // 进入事件
  64. const mouseenterHandle = (item: CreateComponentType) => {
  65. chartEditStore.setTargetHoverChart(item.id)
  66. }
  67. // 移出事件
  68. const mouseleaveHandle = (item: CreateComponentType) => {
  69. chartEditStore.setTargetHoverChart(undefined)
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. $wight: 170px;
  74. @include go(content-layers) {
  75. width: $wight;
  76. flex-shrink: 0;
  77. overflow: hidden;
  78. @extend .go-transition;
  79. &.scoped {
  80. width: 0;
  81. }
  82. }
  83. </style>