Commit 5f4259ca5dc0587c276b2c6fe7981c1b97ebfa22
1 parent
8e2f3e8c
feat(src/views/chart): 修改重写ChartsOptionContent组件路径,修改不需要的隐藏
Showing
4 changed files
with
242 additions
and
6 deletions
| 1 | +/** | |
| 2 | + * 需要隐藏的组件配置 | |
| 3 | + * 加重写的都是覆盖原组件的 | |
| 4 | + * 没加重写的是原来就有的 | |
| 5 | + */ | |
| 6 | + | |
| 7 | +export const hideAsideComponentsObj = { | |
| 8 | + Bars: [ | |
| 9 | + 'VBarCommon' //柱状图 | |
| 10 | + ], | |
| 11 | + Lines: [ | |
| 12 | + 'VLineCommon', //折线图 | |
| 13 | + 'VLineGradients', //双折线渐变面积图 | |
| 14 | + 'ExternalVCOverrideLineGradients' //重写双折线渐变面积图 | |
| 15 | + ], | |
| 16 | + Pies: [ | |
| 17 | + 'VPieCircle' //饼图-环形 | |
| 18 | + ], | |
| 19 | + Maps: [ | |
| 20 | + 'VMapBase' //地图(可选省份) | |
| 21 | + ], | |
| 22 | + Mores: [ | |
| 23 | + 'VProcess', //NaiveUI-进度 | |
| 24 | + 'VImage', //图片 | |
| 25 | + 'VImageCarousel' //轮播图 | |
| 26 | + ], | |
| 27 | + Texts: [ | |
| 28 | + 'VTextGradient', //渐变文字 | |
| 29 | + 'VTextBarrage', //弹幕文字 | |
| 30 | + 'VTextCommon' //文字 | |
| 31 | + ], | |
| 32 | + all: [ | |
| 33 | + 'VBarCommon', //柱状图 | |
| 34 | + 'VLineCommon', //折线图 | |
| 35 | + 'VLineLinearSingle', //单折线渐变图 | |
| 36 | + 'VLineGradientSingle', //单折线渐变面积图 | |
| 37 | + 'VLineGradients', //双折线渐变面积图 | |
| 38 | + 'ExternalVCOverrideLineGradients', //重写双折线渐变面积图 | |
| 39 | + 'VPieCircle', //饼图-环形 | |
| 40 | + 'VMapBase', //地图(可选省份) | |
| 41 | + 'VProcess', //NaiveUI-进度 | |
| 42 | + 'VTextGradient', //渐变文字 | |
| 43 | + 'VTextBarrage', //弹幕文字 | |
| 44 | + 'VTextCommon', //文字 | |
| 45 | + 'VVideo', //视频 | |
| 46 | + 'VIframe' //远程网页 | |
| 47 | + ] | |
| 48 | +} | ... | ... |
| 1 | +<template> | |
| 2 | + <!-- 侧边栏和数据分发处理 --> | |
| 3 | + <div class="go-chart-common"> | |
| 4 | + <n-menu | |
| 5 | + v-show="hidePackageOneCategory" | |
| 6 | + class="chart-menu-width" | |
| 7 | + v-model:value="selectValue" | |
| 8 | + :options="packages.menuOptions" | |
| 9 | + :icon-size="16" | |
| 10 | + :indent="18" | |
| 11 | + @update:value="clickItemHandle" | |
| 12 | + ></n-menu> | |
| 13 | + <div class="chart-content-list"> | |
| 14 | + <n-scrollbar trigger="none"> | |
| 15 | + <charts-item-box :menuOptions="packages.selectOptions" @deletePhoto="deleteHandle"></charts-item-box> | |
| 16 | + </n-scrollbar> | |
| 17 | + </div> | |
| 18 | + </div> | |
| 19 | +</template> | |
| 20 | +<script setup lang="ts"> | |
| 21 | +import { ref, watch, computed, reactive } from 'vue' | |
| 22 | +import { ConfigType } from '@/packages/index.d' | |
| 23 | +import { useSettingStore } from '@/store/modules/settingStore/settingStore' | |
| 24 | +import { loadAsyncComponent } from '@/utils' | |
| 25 | +import { usePackagesStore } from '@/store/modules/packagesStore/packagesStore' | |
| 26 | +import { PackagesCategoryEnum } from '@/packages/index.d' | |
| 27 | +import { hideAsideComponentsObj } from './config' | |
| 28 | +import { remove } from 'lodash' | |
| 29 | + | |
| 30 | +const ChartsItemBox = loadAsyncComponent(() => import('../../../components/ChartsItemBox/index.vue')) | |
| 31 | +const packagesStore = usePackagesStore() | |
| 32 | + | |
| 33 | +const props = defineProps({ | |
| 34 | + selectOptions: { | |
| 35 | + type: Object, | |
| 36 | + default: () => {} | |
| 37 | + } | |
| 38 | +}) | |
| 39 | + | |
| 40 | +// 隐藏设置 | |
| 41 | +const settingStore = useSettingStore() | |
| 42 | + | |
| 43 | +const hidePackageOneCategory = computed(() => { | |
| 44 | + if (packages.categorysNum > 2) return true | |
| 45 | + return !settingStore.getHidePackageOneCategory | |
| 46 | +}) | |
| 47 | + | |
| 48 | +let packages = reactive<{ | |
| 49 | + [T: string]: any | |
| 50 | +}>({ | |
| 51 | + // 侧边栏 | |
| 52 | + menuOptions: [], | |
| 53 | + // 当前选择 | |
| 54 | + selectOptions: {}, | |
| 55 | + // 分类归档 | |
| 56 | + categorys: { | |
| 57 | + all: [] | |
| 58 | + }, | |
| 59 | + categoryNames: { | |
| 60 | + all: '所有' | |
| 61 | + }, | |
| 62 | + // 分类归档数量 | |
| 63 | + categorysNum: 0, | |
| 64 | + // 存储不同类别组件进来的选中值 | |
| 65 | + saveSelectOptions: {} | |
| 66 | +}) | |
| 67 | + | |
| 68 | +const selectValue = ref<string>('all') | |
| 69 | + | |
| 70 | +// 设置初始列表 | |
| 71 | +const setSelectOptions = (categorys: any) => { | |
| 72 | + for (const val in categorys) { | |
| 73 | + packages.selectOptions = categorys[val] | |
| 74 | + break | |
| 75 | + } | |
| 76 | +} | |
| 77 | + | |
| 78 | +// THINGS_KIT修改左侧边栏隐藏部分组件(比如重写的,有问题的等需要隐藏) | |
| 79 | +const byKeyhideAside = (hideAsideComponentsObj: Record<string, string[]>, categorys: Record<string, any>) => { | |
| 80 | + for (const key in categorys) { | |
| 81 | + const categoryKey = key | |
| 82 | + const categoryValue = categorys[key] | |
| 83 | + for (const hideKey in hideAsideComponentsObj) { | |
| 84 | + const needHideKey = hideKey | |
| 85 | + const needCategoryValue = hideAsideComponentsObj[key] | |
| 86 | + if (categoryKey === needHideKey) { | |
| 87 | + remove(categoryValue, item => { | |
| 88 | + const { chartKey } = item as any | |
| 89 | + return needCategoryValue.includes(chartKey) | |
| 90 | + }) | |
| 91 | + } | |
| 92 | + } | |
| 93 | + } | |
| 94 | + return categorys | |
| 95 | +} | |
| 96 | + | |
| 97 | +watch( | |
| 98 | + // @ts-ignore | |
| 99 | + () => props.selectOptions, | |
| 100 | + (newData: { list: ConfigType[] }) => { | |
| 101 | + packages.categorysNum = 0 | |
| 102 | + if (!newData) return | |
| 103 | + newData.list.forEach((e: ConfigType) => { | |
| 104 | + const value: ConfigType[] = (packages.categorys as any)[e.category] | |
| 105 | + packages.categorys[e.category] = value && value.length ? [...value, e] : [e] | |
| 106 | + packages.categoryNames[e.category] = e.categoryName | |
| 107 | + packages.categorys['all'].push(e) | |
| 108 | + }) | |
| 109 | + for (const val in packages.categorys) { | |
| 110 | + packages.categorysNum += 1 | |
| 111 | + packages.menuOptions.push({ | |
| 112 | + key: val, | |
| 113 | + label: packages.categoryNames[val] | |
| 114 | + }) | |
| 115 | + } | |
| 116 | + setSelectOptions(packages.categorys) | |
| 117 | + byKeyhideAside(hideAsideComponentsObj, packages.categorys) | |
| 118 | + console.log(packages.categorys) | |
| 119 | + // 默认选中处理 | |
| 120 | + selectValue.value = packages.menuOptions[0]['key'] | |
| 121 | + }, | |
| 122 | + { | |
| 123 | + immediate: true | |
| 124 | + } | |
| 125 | +) | |
| 126 | + | |
| 127 | +watch( | |
| 128 | + () => packagesStore.newPhoto, | |
| 129 | + newPhoto => { | |
| 130 | + if (!newPhoto) return | |
| 131 | + const newPhotoCategory = newPhoto.category | |
| 132 | + packages.categorys[newPhotoCategory].splice(1, 0, newPhoto) | |
| 133 | + packages.categorys['all'].splice(1, 0, newPhoto) | |
| 134 | + } | |
| 135 | +) | |
| 136 | + | |
| 137 | +// 删除图片 | |
| 138 | +const deleteHandle = (item: ConfigType, index: number) => { | |
| 139 | + packages.categorys[item.category].splice(index, 1) | |
| 140 | + packages.categorys['all'].splice(index, 1) | |
| 141 | +} | |
| 142 | + | |
| 143 | +// 处理点击事件 | |
| 144 | +const clickItemHandle = (key: string) => { | |
| 145 | + packages.selectOptions = packages.categorys[key] | |
| 146 | +} | |
| 147 | +</script> | |
| 148 | + | |
| 149 | +<style lang="scss" scoped> | |
| 150 | +/* 此高度与 ContentBox 组件关联*/ | |
| 151 | +$topHeight: 40px; | |
| 152 | +$menuWidth: 65px; | |
| 153 | +@include go('chart-common') { | |
| 154 | + display: flex; | |
| 155 | + height: calc(100vh - #{$--header-height} - #{$topHeight}); | |
| 156 | + .chart-menu-width { | |
| 157 | + width: $menuWidth; | |
| 158 | + flex-shrink: 0; | |
| 159 | + @include fetch-bg-color('background-color2-shallow'); | |
| 160 | + } | |
| 161 | + .chart-content-list { | |
| 162 | + width: 200px; | |
| 163 | + flex: 1; | |
| 164 | + display: flex; | |
| 165 | + flex-direction: column; | |
| 166 | + align-items: center; | |
| 167 | + } | |
| 168 | + @include deep() { | |
| 169 | + .n-menu-item { | |
| 170 | + height: 30px; | |
| 171 | + &.n-menu-item--selected { | |
| 172 | + &::before { | |
| 173 | + background-color: rgba(0, 0, 0, 0); | |
| 174 | + } | |
| 175 | + } | |
| 176 | + .n-menu-item-content { | |
| 177 | + text-align: center; | |
| 178 | + padding: 0px 14px !important; | |
| 179 | + font-size: 12px !important; | |
| 180 | + } | |
| 181 | + } | |
| 182 | + } | |
| 183 | +} | |
| 184 | +</style> | ... | ... |
| 1 | 1 | <template> |
| 2 | 2 | <!-- 左侧所有组件的展示列表 --> |
| 3 | - <content-box class="go-content-charts" :class="{ scoped: !getCharts }" title="组件" :depth="1" :backIcon="false"> | |
| 3 | + <content-box class="go-content-charts" :class="{ scoped: !getCharts }" title="组件" :depth="1" :backIcon="false"> | |
| 4 | 4 | <template #icon> |
| 5 | 5 | <n-icon size="14" :depth="2"> |
| 6 | 6 | <bar-chart-icon></bar-chart-icon> |
| ... | ... | @@ -22,7 +22,7 @@ |
| 22 | 22 | @update:value="clickItemHandle" |
| 23 | 23 | ></n-menu> |
| 24 | 24 | <div class="menu-component-box"> |
| 25 | - <go-skeleton :load="!selectOptions" round text :repeat="2" style="width: 90%"></go-skeleton> | |
| 25 | + <go-skeleton :load="!selectOptions" round text :repeat="2" style="width: 90%"></go-skeleton> | |
| 26 | 26 | <charts-option-content |
| 27 | 27 | v-if="selectOptions" |
| 28 | 28 | :selectOptions="selectOptions" |
| ... | ... | @@ -36,11 +36,12 @@ |
| 36 | 36 | |
| 37 | 37 | <script setup lang="ts"> |
| 38 | 38 | import { ContentBox } from '../ContentBox/index' |
| 39 | -import { ChartsOptionContent } from './components/ChartsOptionContent' | |
| 39 | +// THINGS_KIT 重写ChartsOptionContent组件路径 | |
| 40 | +import { ChartsOptionContent } from './external/components/ChartsOptionContent' | |
| 40 | 41 | import { ChartsSearch } from './components/ChartsSearch' |
| 41 | -import { useAsideHook } from './hooks/useAside.hook' | |
| 42 | - | |
| 43 | -const { getCharts, BarChartIcon, themeColor, selectOptions, selectValue, clickItemHandle, menuOptions } = useAsideHook() | |
| 42 | +import { useAsideHook } from './hooks/useAside.hook' | |
| 43 | + | |
| 44 | +const { getCharts, BarChartIcon, themeColor, selectOptions, selectValue, clickItemHandle, menuOptions } = useAsideHook() | |
| 44 | 45 | </script> |
| 45 | 46 | |
| 46 | 47 | <style lang="scss" scoped> | ... | ... |