From c42e9ad0fb0d62117661b60ba2122555219619fc Mon Sep 17 00:00:00 2001 From: MTrun <1262327911@qq.com> Date: Tue, 22 Mar 2022 15:46:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9data=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E8=B0=83=E7=94=A8=E5=92=8C=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=AE=BE=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/settings/designSetting.ts | 5 ++- .../chartEditStore/chartEditStore.d.ts | 18 ++++++--- .../modules/chartEditStore/chartEditStore.ts | 19 ++++------ .../components/ChartDataSetting/index.vue | 11 ++---- .../components/ChartDataAjax/index.vue | 38 +++++++++---------- .../ChartDataMatchingAndShow/index.vue | 12 +++--- .../components/ChartDataStatic/index.vue | 4 +- .../ChartData/hooks/useFile.hooks.ts | 2 +- .../components/ChartData/index.vue | 3 +- 9 files changed, 54 insertions(+), 58 deletions(-) diff --git a/src/settings/designSetting.ts b/src/settings/designSetting.ts index 962fc485..de39ad50 100644 --- a/src/settings/designSetting.ts +++ b/src/settings/designSetting.ts @@ -32,4 +32,7 @@ export const borderRadius = '6px' export const carouselInterval = 4000 // 工作台大屏背景图片大小限制(5M) -export const backgroundImageSize = 5 \ No newline at end of file +export const backgroundImageSize = 5 + +// 数据请求间隔 +export const requestInterval = 30 \ No newline at end of file diff --git a/src/store/modules/chartEditStore/chartEditStore.d.ts b/src/store/modules/chartEditStore/chartEditStore.d.ts index 78353276..7bbc2155 100644 --- a/src/store/modules/chartEditStore/chartEditStore.d.ts +++ b/src/store/modules/chartEditStore/chartEditStore.d.ts @@ -118,7 +118,7 @@ export enum ChartEditStoreEnum { RECORD_CHART = 'recordChart', // 以下需要存储 EDIT_CANVAS_CONFIG = 'editCanvasConfig', - REQUEST_CONFIG = 'requestConfig', + REQUEST_GLOBAL_CONFIG = 'requestGlobalConfig', COMPONENT_LIST = 'componentList', } @@ -130,15 +130,21 @@ export enum RequestDataTypeEnum { AJAX = 1, } -// 数据配置 +// 全局的图表请求配置 +export type RequestGlobalConfigType = { + // 请求源地址 + requestOriginUrl?: string + // 轮询时间 + requestInterval?: number +} +// 单个图表请求配置 export type RequestConfigType = { // 获取数据的方式 requestDataType: RequestDataTypeEnum // 请求方式 get/post/del/put/patch requestHttpType: RequestHttpEnum - // 请求源地址 + // 去除源的 url requestUrl?: string - requestInterval?: number } // Store 类型 @@ -149,12 +155,12 @@ export interface ChartEditStoreType { [ChartEditStoreEnum.MOUSE_POSITION]: MousePositionType [ChartEditStoreEnum.TARGET_CHART]: TargetChartType [ChartEditStoreEnum.RECORD_CHART]?: RecordChartType - [ChartEditStoreEnum.REQUEST_CONFIG]: RequestConfigType + [ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: RequestGlobalConfigType [ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[] } export interface ChartEditStorage { [ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: EditCanvasConfigType - [ChartEditStoreEnum.REQUEST_CONFIG]: RequestConfigType + [ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: RequestGlobalConfigType [ChartEditStoreEnum.COMPONENT_LIST]: CreateComponentType[] } diff --git a/src/store/modules/chartEditStore/chartEditStore.ts b/src/store/modules/chartEditStore/chartEditStore.ts index bda5db74..48c690aa 100644 --- a/src/store/modules/chartEditStore/chartEditStore.ts +++ b/src/store/modules/chartEditStore/chartEditStore.ts @@ -4,7 +4,7 @@ import { CreateComponentType } from '@/packages/index.d' import debounce from 'lodash/debounce' import cloneDeep from 'lodash/cloneDeep' import { defaultTheme, globalThemeJson } from '@/settings/chartThemes/index' -import { RequestHttpEnum } from '@/enums/httpEnum' +import { requestInterval } from '@/settings/designSetting' // 记录记录 import { useChartHistoryStoreStore } from '@/store/modules/chartHistoryStore/chartHistoryStore' import { HistoryActionTypeEnum, HistoryItemType, HistoryTargetTypeEnum } from '@/store/modules/chartHistoryStore/chartHistoryStore.d' @@ -16,8 +16,7 @@ import { MousePositionType, TargetChartType, RecordChartType, - RequestConfigType, - RequestDataTypeEnum, + RequestGlobalConfigType, EditCanvasConfigType } from './chartEditStore.d' @@ -86,11 +85,9 @@ export const useChartEditStore = defineStore({ chartThemeSetting: globalThemeJson }, // 数据请求处理(需存储给后端) - requestConfig: { - requestDataType: RequestDataTypeEnum.STATIC, - requestHttpType: RequestHttpEnum.GET, - requestUrl: undefined, - requestInterval: 10 + requestGlobalConfig: { + requestOriginUrl: '', + requestInterval: requestInterval }, // 图表数组(需存储给后端) componentList: [] @@ -114,8 +111,8 @@ export const useChartEditStore = defineStore({ getRecordChart(): RecordChartType | undefined { return this.recordChart }, - getRequestConfig(): RequestConfigType { - return this.requestConfig + getRequestGlobalConfig(): RequestGlobalConfigType { + return this.requestGlobalConfig }, getComponentList(): CreateComponentType[] { return this.componentList @@ -125,7 +122,7 @@ export const useChartEditStore = defineStore({ return { [ChartEditStoreEnum.EDIT_CANVAS_CONFIG]: this.getEditCanvasConfig, [ChartEditStoreEnum.COMPONENT_LIST]: this.getComponentList, - [ChartEditStoreEnum.REQUEST_CONFIG]: this.getRequestConfig + [ChartEditStoreEnum.REQUEST_GLOBAL_CONFIG]: this.getRequestGlobalConfig } } }, diff --git a/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue b/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue index 0154d3c5..94b82f01 100644 --- a/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue +++ b/src/views/chart/ContentConfigurations/components/CanvasPage/components/ChartDataSetting/index.vue @@ -2,14 +2,14 @@