index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <div
  3. class="go-chart-edit-tools"
  4. :class="[settingStore.getChartToolsStatus, isMiniComputed ? 'isMini' : 'unMini']"
  5. @click="isMini && (isMini = false)"
  6. @mouseenter="toolsMouseoverHandle"
  7. @mouseleave="toolsMouseoutHandle"
  8. >
  9. <!-- PawIcon -->
  10. <n-icon v-show="isHide && settingStore.getChartToolsStatus === ToolsStatusEnum.ASIDE" class="asideLogo" size="22">
  11. <PawIcon></PawIcon>
  12. </n-icon>
  13. <n-tooltip
  14. v-for="(item, index) in btnListComputed"
  15. :key="item.key"
  16. :disabled="!isAside || (isHide && asideTootipDis)"
  17. trigger="hover"
  18. placement="left"
  19. >
  20. <template #trigger>
  21. <div class="btn-item" :class="[btnList.length - 1 === index && 'go-mt-0']">
  22. <n-button v-if="item.type === TypeEnum.BUTTON" :circle="isAside" secondary @click="item.handle">
  23. <template #icon>
  24. <n-icon size="22" v-if="isAside">
  25. <component :is="item.icon"></component>
  26. </n-icon>
  27. <component v-else :is="item.icon"></component>
  28. </template>
  29. <n-text depth="3" v-show="!isAside">{{ item.name }}</n-text>
  30. </n-button>
  31. <!-- 下载 -->
  32. <n-upload
  33. v-else-if="item.type === TypeEnum.IMPORTUPLOAD"
  34. v-model:file-list="importUploadFileListRef"
  35. :show-file-list="false"
  36. :customRequest="importCustomRequest"
  37. @before-upload="importBeforeUpload"
  38. >
  39. <n-button :circle="isAside" secondary>
  40. <template #icon>
  41. <n-icon size="22" v-if="isAside">
  42. <component :is="item.icon"></component>
  43. </n-icon>
  44. <component v-else :is="item.icon"></component>
  45. </template>
  46. <n-text depth="3" v-show="!isAside">{{ item.name }}</n-text>
  47. </n-button>
  48. </n-upload>
  49. </div>
  50. </template>
  51. <!-- 提示 -->
  52. <span>{{ item.name }}</span>
  53. </n-tooltip>
  54. </div>
  55. <!-- 系统设置 model -->
  56. <go-system-set v-model:modelShow="globalSettingModel"></go-system-set>
  57. </template>
  58. <script setup lang="ts">
  59. import { ref, computed, h } from 'vue'
  60. import { useSettingStore } from '@/store/modules/settingStore/settingStore'
  61. import { ToolsStatusEnum } from '@/store/modules/settingStore/settingStore.d'
  62. import { GoSystemSet } from '@/components/GoSystemSet/index'
  63. import { exportHandle } from './utils'
  64. import { useFile } from './hooks/useFile.hooks'
  65. import { BtnListType, TypeEnum } from './index.d'
  66. import { icon } from '@/plugins'
  67. const { DownloadIcon, ShareIcon, PawIcon, SettingsSharpIcon } = icon.ionicons5
  68. const settingStore = useSettingStore()
  69. // 鼠标悬停定时器
  70. let mouseTime: any = null
  71. // 系统设置 model
  72. const globalSettingModel = ref(false)
  73. // 最小化
  74. const isMini = ref<boolean>(true)
  75. // 控制 tootip 提示时机
  76. const asideTootipDis = ref(true)
  77. // 文件上传
  78. const { importUploadFileListRef, importCustomRequest, importBeforeUpload } = useFile()
  79. // 配置列表
  80. const btnList: BtnListType[] = [
  81. {
  82. key: 'export',
  83. type: TypeEnum.BUTTON,
  84. name: '导出',
  85. icon: ShareIcon,
  86. handle: exportHandle
  87. },
  88. {
  89. key: 'import',
  90. type: TypeEnum.IMPORTUPLOAD,
  91. name: '导入',
  92. icon: DownloadIcon
  93. },
  94. {
  95. key: 'setting',
  96. type: TypeEnum.BUTTON,
  97. name: '设置',
  98. icon: SettingsSharpIcon,
  99. handle: () => {
  100. globalSettingModel.value = true
  101. }
  102. }
  103. ]
  104. // 是否是侧边栏
  105. const isAside = computed(() => settingStore.getChartToolsStatus === ToolsStatusEnum.ASIDE)
  106. // 是否隐藏(悬浮展示)
  107. const isHide = computed(() => settingStore.getChartToolsStatusHide)
  108. // 是否展示最小化(与全局配置相关)
  109. const isMiniComputed = computed(() => isMini.value && isHide.value)
  110. // 页面渲染配置
  111. const btnListComputed = computed(() => {
  112. if (!isAside.value) return btnList
  113. const reverseArr: BtnListType[] = []
  114. btnList.map(item => {
  115. reverseArr.unshift(item)
  116. })
  117. return reverseArr
  118. })
  119. // 鼠标移入
  120. const toolsMouseoverHandle = () => {
  121. mouseTime = setTimeout(() => {
  122. if (isMini.value) {
  123. isMini.value = false
  124. asideTootipDis.value = true
  125. }
  126. }, 200)
  127. setTimeout(() => {
  128. asideTootipDis.value = false
  129. }, 400)
  130. }
  131. // 鼠标移出
  132. const toolsMouseoutHandle = () => {
  133. clearTimeout(mouseTime)
  134. if (!isMini.value) {
  135. isMini.value = true
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. /* 底部区域的高度 */
  141. $dockHeight: 30px;
  142. $dockBottom: 60px;
  143. $dockMiniWidth: 200px;
  144. $dockMiniBottom: 53px;
  145. $asideHeight: 130px;
  146. $asideMiniHeight: 22px;
  147. $asideBottom: 70px;
  148. @include go('chart-edit-tools') {
  149. @extend .go-background-filter;
  150. position: absolute;
  151. display: flex;
  152. justify-content: space-around;
  153. align-items: center;
  154. border-radius: 25px;
  155. border: 1px solid;
  156. mix-blend-mode: luminosity;
  157. @include fetch-border-color('hover-border-color-shallow');
  158. &.aside {
  159. flex-direction: column-reverse;
  160. height: auto;
  161. right: 20px;
  162. padding: 20px 8px;
  163. bottom: $asideBottom;
  164. overflow: hidden;
  165. transition: height ease 0.4s;
  166. .btn-item {
  167. margin-bottom: 10px;
  168. @include deep() {
  169. .n-button__icon {
  170. margin-right: 4px;
  171. margin-bottom: 12px;
  172. }
  173. }
  174. }
  175. &.unMini {
  176. animation: aside-in 0.4s ease forwards;
  177. @keyframes aside-in {
  178. 0% {
  179. opacity: 0.5;
  180. height: $asideMiniHeight;
  181. }
  182. 100% {
  183. height: $asideHeight;
  184. opacity: 1;
  185. }
  186. }
  187. .btn-item {
  188. position: relative;
  189. display: block;
  190. }
  191. .asideLogo {
  192. opacity: 0.4;
  193. }
  194. }
  195. &.isMini {
  196. cursor: pointer;
  197. padding: 13px 13px;
  198. background-color: var(--n-toggle-bar-color);
  199. animation: aside-mini-in 0.4s ease forwards;
  200. @keyframes aside-mini-in {
  201. 0% {
  202. opacity: 0.5;
  203. height: $asideHeight;
  204. }
  205. 100% {
  206. opacity: 1;
  207. height: $asideMiniHeight;
  208. }
  209. }
  210. .btn-item {
  211. position: relative;
  212. display: none;
  213. }
  214. .asideLogo {
  215. opacity: 1;
  216. }
  217. }
  218. }
  219. &.dock {
  220. width: auto;
  221. left: 50%;
  222. transform: translateX(-50%);
  223. .btn-item {
  224. margin-right: 20px;
  225. &:last-child {
  226. margin-right: 0;
  227. }
  228. }
  229. &.unMini {
  230. animation: dock-in 0.4s ease forwards;
  231. @keyframes dock-in {
  232. 0% {
  233. opacity: 0;
  234. height: 0;
  235. padding: 5px;
  236. bottom: $dockMiniBottom;
  237. mix-blend-mode: screen;
  238. }
  239. 100% {
  240. height: $dockHeight;
  241. padding: 8px 30px;
  242. bottom: $dockBottom;
  243. border-radius: 25px;
  244. mix-blend-mode: none;
  245. }
  246. }
  247. }
  248. /* 最小化 */
  249. &.isMini {
  250. height: 0;
  251. width: $dockMiniWidth;
  252. bottom: $dockMiniBottom;
  253. padding: 5px;
  254. border-radius: 8px;
  255. cursor: pointer;
  256. border: 0px;
  257. mix-blend-mode: screen;
  258. animation: dock-mini-in 1s ease forwards;
  259. @keyframes dock-mini-in {
  260. 0% {
  261. opacity: 1;
  262. height: $dockHeight;
  263. padding: 8px 30px;
  264. bottom: $dockBottom;
  265. border-radius: 25px;
  266. }
  267. 20% {
  268. height: 0;
  269. border-radius: 8px;
  270. }
  271. 50% {
  272. opacity: 0;
  273. bottom: calc(#{$dockMiniBottom} - 10px);
  274. }
  275. 100% {
  276. opacity: 1;
  277. height: 0;
  278. padding: 5px;
  279. bottom: $dockMiniBottom;
  280. mix-blend-mode: screen;
  281. }
  282. }
  283. .btn-item {
  284. position: relative;
  285. bottom: -50px;
  286. display: none;
  287. }
  288. }
  289. &::after {
  290. content: '';
  291. position: absolute;
  292. left: 0;
  293. width: 100%;
  294. height: 20px;
  295. bottom: -20px;
  296. cursor: pointer;
  297. }
  298. }
  299. }
  300. </style>