index.vue 4.4 KB

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