index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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
  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. </ContentBox>
  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 { useChartEditStoreStore } from '@/store/modules/chartEditStore/chartEditStore'
  84. const { getDetails } = toRefs(useChartLayoutStore())
  85. const { setItem } = useChartLayoutStore()
  86. const chartEditStoreStore = useChartEditStoreStore()
  87. const { ConstructIcon, FlashIcon, DesktopOutlineIcon, RocketIcon } = icon.ionicons5
  88. const ContentEdit = loadAsyncComponent(() => import('../ContentEdit/index.vue'))
  89. const CanvasPage = loadAsyncComponent(() =>
  90. import('./components/CanvasPage/index.vue')
  91. )
  92. const ChartSetting = loadAsyncComponent(() =>
  93. import('./components/ChartSetting/index.vue')
  94. )
  95. const ChartData = loadAsyncComponent(() =>
  96. import('./components/ChartData/index.vue')
  97. )
  98. const ChartEvent = loadAsyncComponent(() =>
  99. import('./components/ChartEvent/index.vue')
  100. )
  101. const collapsed = ref<boolean>(getDetails.value)
  102. const collapsedHindle = () => {
  103. collapsed.value = true
  104. setItem(ChartLayoutStoreEnum.DETAILS, true)
  105. }
  106. const expandHindle = () => {
  107. collapsed.value = false
  108. setItem(ChartLayoutStoreEnum.DETAILS, false)
  109. }
  110. const selectTarget = computed(() => {
  111. const selectId = chartEditStoreStore.getTargetChart.selectId
  112. if (!selectId) return undefined
  113. return chartEditStoreStore.componentList[
  114. chartEditStoreStore.fetchTargetIndex()
  115. ]
  116. })
  117. watch(getDetails, newData => {
  118. if (newData) {
  119. collapsedHindle()
  120. } else {
  121. expandHindle()
  122. }
  123. })
  124. // 页面设置
  125. const globalTabList = [
  126. {
  127. key: 'pageSetting',
  128. title: '页面配置',
  129. icon: DesktopOutlineIcon,
  130. render: CanvasPage
  131. }
  132. ]
  133. const canvasTabList = [
  134. {
  135. key: 'ChartSetting',
  136. title: '定制',
  137. icon: ConstructIcon,
  138. render: ChartSetting
  139. },
  140. {
  141. key: 'ChartData',
  142. title: '数据',
  143. icon: FlashIcon,
  144. render: ChartData
  145. },
  146. {
  147. key: 'ChartEvent',
  148. title: '事件',
  149. icon: RocketIcon,
  150. render: ChartEvent
  151. },
  152. ]
  153. </script>
  154. <style lang="scss" scoped>
  155. @include go(content-layers) {
  156. overflow: hidden;
  157. .tabs-box {
  158. padding: 10px;
  159. .icon-position {
  160. padding-top: 2px;
  161. }
  162. }
  163. }
  164. </style>