diff --git a/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts b/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts index b1155ea5..abcef916 100644 --- a/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts +++ b/src/store/modules/chartLayoutStore/chartLayoutStore.d.ts @@ -1,5 +1,5 @@ export enum ChartModeEnum { - SINGLE= 'single', + SINGLE = 'single', DOUBLE = 'double' } @@ -13,7 +13,8 @@ export enum ChartLayoutStoreEnum { CHARTS = 'charts', DETAILS = 'details', Chart_TYPE = 'chartType', - LAYER_TYPE = 'layerType' + LAYER_TYPE = 'layerType', + PERCENTAGE = 'percentage' } export interface ChartLayoutType { @@ -27,4 +28,6 @@ export interface ChartLayoutType { [ChartLayoutStoreEnum.Chart_TYPE]: ChartModeEnum // 层级展示方式 [ChartLayoutStoreEnum.LAYER_TYPE]: LayerModeEnum + // 当前正在加载的数量 + [ChartLayoutStoreEnum.PERCENTAGE]: number } diff --git a/src/store/modules/chartLayoutStore/chartLayoutStore.ts b/src/store/modules/chartLayoutStore/chartLayoutStore.ts index c50bd520..5aa5704e 100644 --- a/src/store/modules/chartLayoutStore/chartLayoutStore.ts +++ b/src/store/modules/chartLayoutStore/chartLayoutStore.ts @@ -24,6 +24,8 @@ export const useChartLayoutStore = defineStore({ chartType: ChartModeEnum.SINGLE, // 图层类型(默认图片) layerType: LayerModeEnum.THUMBNAIL, + // 当前加载数量 + percentage: 0, // 防止值不存在 ...storageChartLayout }), @@ -42,6 +44,9 @@ export const useChartLayoutStore = defineStore({ }, getLayerType(): LayerModeEnum { return this.layerType + }, + getPercentage(): number { + return this.percentage } }, actions: { @@ -54,6 +59,11 @@ export const useChartLayoutStore = defineStore({ setTimeout(() => { chartEditStore.computedScale() }, 500) + }, + setItemUnHandle(key: T, value: K): void { + this.$patch(state => { + state[key] = value + }) } } }) diff --git a/src/views/chart/ContentLoad/index.ts b/src/views/chart/ContentLoad/index.ts new file mode 100644 index 00000000..7e41ed39 --- /dev/null +++ b/src/views/chart/ContentLoad/index.ts @@ -0,0 +1,3 @@ +import ContentLoad from './index.vue' + +export { ContentLoad } diff --git a/src/views/chart/ContentLoad/index.vue b/src/views/chart/ContentLoad/index.vue new file mode 100644 index 00000000..6b7905a5 --- /dev/null +++ b/src/views/chart/ContentLoad/index.vue @@ -0,0 +1,33 @@ + + + diff --git a/src/views/chart/hooks/useSync.hook.ts b/src/views/chart/hooks/useSync.hook.ts index 3d551f00..ac006245 100644 --- a/src/views/chart/hooks/useSync.hook.ts +++ b/src/views/chart/hooks/useSync.hook.ts @@ -2,6 +2,8 @@ import { getUUID } from '@/utils' import { useChartEditStore } from '@/store/modules/chartEditStore/chartEditStore' import { ChartEditStoreEnum, ChartEditStorage } from '@/store/modules/chartEditStore/chartEditStore.d' import { useChartHistoryStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' +import { useChartLayoutStore } from '@/store/modules/chartLayoutStore/chartLayoutStore' +import { ChartLayoutStoreEnum } from '@/store/modules/chartLayoutStore/chartLayoutStore.d' import { fetchChartComponent, fetchConfigComponent, createComponent } from '@/packages/index' import { BaseEvent, EventLife, CreateComponentType, CreateComponentGroupType } from '@/packages/index.d' import { PublicGroupConfigClass } from '@/packages/public/publicConfig' @@ -85,7 +87,7 @@ const componentMerge = (newObject: any, sources: any, notComponent = false) => { export const useSync = () => { const chartEditStore = useChartEditStore() const chartHistoryStore = useChartHistoryStore() - + const chartLayoutStore = useChartLayoutStore() /** * * 组件动态注册 * @param projectData 项目数据 @@ -151,7 +153,14 @@ export const useSync = () => { for (const key in projectData) { // 组件 if (key === ChartEditStoreEnum.COMPONENT_LIST) { + let loadIndex = 0 + const listLength = projectData[key].length; + console.log(listLength) for (const comItem of projectData[key]) { + // 设置加载数量 + let percentage = parseInt((parseFloat(`${++loadIndex / listLength}`) * 100).toString()) + chartLayoutStore.setItemUnHandle(ChartLayoutStoreEnum.PERCENTAGE, percentage) + // 判断类型 if (comItem.isGroup) { // 创建分组 let groupClass = new PublicGroupConfigClass() @@ -182,6 +191,9 @@ export const useSync = () => { componentMerge(chartEditStore[key], projectData[key], true) } } + + // 清除数量 + chartLayoutStore.setItemUnHandle(ChartLayoutStoreEnum.PERCENTAGE, 0) } return { diff --git a/src/views/chart/index.vue b/src/views/chart/index.vue index 46cbfe3e..89c60d95 100644 --- a/src/views/chart/index.vue +++ b/src/views/chart/index.vue @@ -32,6 +32,8 @@ :on-clickoutside="onClickOutSide" @select="handleMenuSelect" > + +