index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <n-layout has-sider sider-placement="right">
  3. <n-layout-content>
  4. <!-- 图表拖拽区域 -->
  5. <ContentEdit />
  6. </n-layout-content>
  7. <n-layout-sider
  8. collapse-mode="transform"
  9. :collapsed-width="0"
  10. :width="350"
  11. :collapsed="collapsed"
  12. :native-scrollbar="false"
  13. show-trigger="bar"
  14. @collapse="collapsedHindle"
  15. @expand="expandHindle"
  16. >
  17. <ContentBox
  18. class="go-content-layers go-boderbox"
  19. :showTop="false"
  20. :depth="2"
  21. >
  22. <!-- 画布 -->
  23. <n-tabs
  24. v-show="!selectTarget"
  25. class="tabs-box"
  26. size="small"
  27. type="segment"
  28. >
  29. <n-tab-pane size="small" display-directive="show:lazy">
  30. <template #tab>
  31. <n-space>
  32. <span> 页面设置 </span>
  33. <n-icon size="16" class="icon-position">
  34. <BrowsersOutlineIcon />
  35. </n-icon>
  36. </n-space>
  37. </template>
  38. <CanvasPage name="canvas" />
  39. </n-tab-pane>
  40. </n-tabs>
  41. <!-- 编辑 -->
  42. <n-tabs
  43. v-show="selectTarget"
  44. class="tabs-box"
  45. size="small"
  46. type="segment"
  47. >
  48. <n-tab-pane
  49. v-for="item in tabList"
  50. :key="item.key"
  51. :name="item.key"
  52. size="small"
  53. display-directive="show:lazy"
  54. >
  55. <template #tab>
  56. <n-space>
  57. <span>{{ item.title }}</span>
  58. <n-icon size="16" class="icon-position">
  59. <component :is="item.icon"></component>
  60. </n-icon>
  61. </n-space>
  62. </template>
  63. <component :is="item.render"></component>
  64. </n-tab-pane>
  65. </n-tabs>
  66. </ContentBox>
  67. </n-layout-sider>
  68. </n-layout>
  69. </template>
  70. <script setup lang="ts">
  71. import { shallowRef, ref, toRefs, watch, computed, reactive } from 'vue'
  72. import { icon } from '@/plugins'
  73. import { loadAsyncComponent } from '@/utils'
  74. import { ContentBox } from '../ContentBox/index'
  75. import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore'
  76. import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d'
  77. import { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
  78. const { getDetails } = toRefs(useChartLayoutStore())
  79. const { setItem } = useChartLayoutStore()
  80. const chartEditStoreStore = useChartEditStoreStore()
  81. const { ConstructIcon, FlashIcon, BrowsersOutlineIcon } = icon.ionicons5
  82. const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'))
  83. const CanvasPage = loadAsyncComponent(() =>
  84. import('./components/CanvasPage/index.vue')
  85. )
  86. const Setting = loadAsyncComponent(() =>
  87. import('./components/Setting/index.vue')
  88. )
  89. const Behind = loadAsyncComponent(() => import('./components/Behind/index.vue'))
  90. const collapsed = ref<boolean>(getDetails.value)
  91. const collapsedHindle = () => {
  92. collapsed.value = true
  93. setItem(ChartLayoutStoreEnum.DETAILS, true)
  94. }
  95. const expandHindle = () => {
  96. collapsed.value = false
  97. setItem(ChartLayoutStoreEnum.DETAILS, false)
  98. }
  99. const selectTarget = computed(() => {
  100. const selectId = chartEditStoreStore.getTargetChart.selectId
  101. if (!selectId) return undefined
  102. return chartEditStoreStore.componentList[
  103. chartEditStoreStore.fetchTargetIndex()
  104. ]
  105. })
  106. watch(getDetails, newData => {
  107. if (newData) {
  108. collapsedHindle()
  109. } else {
  110. expandHindle()
  111. }
  112. })
  113. // 页面设置
  114. const pageSetting = reactive({
  115. key: 'pageSetting',
  116. title: '页面设置',
  117. render: CanvasPage
  118. })
  119. const tabList = shallowRef([
  120. {
  121. key: 'setting',
  122. title: '设置',
  123. icon: ConstructIcon,
  124. render: Setting
  125. },
  126. {
  127. key: 'behind',
  128. title: '数据',
  129. icon: FlashIcon,
  130. render: Behind
  131. }
  132. ])
  133. </script>
  134. <style lang="scss" scoped>
  135. @include go(content-layers) {
  136. padding: 10px;
  137. overflow: hidden;
  138. .icon-position {
  139. padding-top: 2px;
  140. }
  141. }
  142. </style>