index.vue 4.4 KB

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