From aa38a4be51b7c863570af118ff75c3a6f52fb3e7 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 22 Jun 2021 14:14:31 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=90=88=E5=B9=B6=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/custom-component/UserView.vue | 36 +------- frontend/src/views/chart/chart/chart.js | 47 +++++++++++ frontend/src/views/panel/list/PanelList.vue | 84 +------------------ frontend/src/views/panel/panel.js | 48 +++-------- 4 files changed, 65 insertions(+), 150 deletions(-) diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index b4bc2cc4bb..4d39a51293 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -23,17 +23,7 @@ import { uuid } from 'vue-uuid' import { mapState } from 'vuex' import { isChange } from '@/utils/conditionUtil' -import { - DEFAULT_COLOR_CASE, - DEFAULT_SIZE, - DEFAULT_TITLE_STYLE, - DEFAULT_LEGEND_STYLE, - DEFAULT_LABEL, - DEFAULT_TOOLTIP, - DEFAULT_XAXIS_STYLE, - DEFAULT_YAXIS_STYLE, - DEFAULT_BACKGROUND_COLOR -} from '@/views/chart/chart/chart' +import { BASE_CHART_STRING } from '@/views/chart/chart/chart' export default { name: 'UserView', @@ -64,29 +54,7 @@ export default { data() { return { refId: null, - chart: { - stylePriority: 'panel', - xaxis: '[]', - yaxis: '[]', - show: true, - type: 'panel', - title: '', - customAttr: JSON.stringify({ - color: DEFAULT_COLOR_CASE, - tableColor: DEFAULT_COLOR_CASE, - size: DEFAULT_SIZE, - label: DEFAULT_LABEL, - tooltip: DEFAULT_TOOLTIP - }), - customStyle: JSON.stringify({ - text: DEFAULT_TITLE_STYLE, - legend: DEFAULT_LEGEND_STYLE, - xAxis: DEFAULT_XAXIS_STYLE, - yAxis: DEFAULT_YAXIS_STYLE, - background: DEFAULT_BACKGROUND_COLOR - }), - customFilter: '[]' - }, + chart: BASE_CHART_STRING, requestStatus: 'waiting', message: null } diff --git a/frontend/src/views/chart/chart/chart.js b/frontend/src/views/chart/chart/chart.js index f4a9a12c7f..c8a9313261 100644 --- a/frontend/src/views/chart/chart/chart.js +++ b/frontend/src/views/chart/chart/chart.js @@ -367,3 +367,50 @@ export const BASE_GAUGE = { } ] } + +export const BASE_CHART_STRING = { + stylePriority: 'panel', + xaxis: '[]', + yaxis: '[]', + show: true, + type: 'panel', + title: '', + customAttr: JSON.stringify({ + color: DEFAULT_COLOR_CASE, + tableColor: DEFAULT_COLOR_CASE, + size: DEFAULT_SIZE, + label: DEFAULT_LABEL, + tooltip: DEFAULT_TOOLTIP + }), + customStyle: JSON.stringify({ + text: DEFAULT_TITLE_STYLE, + legend: DEFAULT_LEGEND_STYLE, + xAxis: DEFAULT_XAXIS_STYLE, + yAxis: DEFAULT_YAXIS_STYLE, + background: DEFAULT_BACKGROUND_COLOR + }), + customFilter: '[]' +} + +export const BASE_CHART = { + xaxis: [], + yaxis: [], + show: true, + type: 'panel', + title: '', + customAttr: { + color: DEFAULT_COLOR_CASE, + tableColor: DEFAULT_COLOR_CASE, + size: DEFAULT_SIZE, + label: DEFAULT_LABEL, + tooltip: DEFAULT_TOOLTIP + }, + customStyle: { + text: DEFAULT_TITLE_STYLE, + legend: DEFAULT_LEGEND_STYLE, + xAxis: DEFAULT_XAXIS_STYLE, + yAxis: DEFAULT_YAXIS_STYLE, + background: DEFAULT_BACKGROUND_COLOR + }, + customFilter: [] +} diff --git a/frontend/src/views/panel/list/PanelList.vue b/frontend/src/views/panel/list/PanelList.vue index df96a9f6e4..de073f1b1c 100644 --- a/frontend/src/views/panel/list/PanelList.vue +++ b/frontend/src/views/panel/list/PanelList.vue @@ -48,9 +48,6 @@ {{ $t('panel.panel_list') }} - - - @@ -181,22 +178,9 @@ import bus from '@/utils/bus' import EditPanel from './EditPanel' import { addGroup, delGroup, groupTree, defaultTree, findOne } from '@/api/panel/panel' import { - DEFAULT_COLOR_CASE, - DEFAULT_SIZE, - DEFAULT_TITLE_STYLE, - DEFAULT_LEGEND_STYLE, - DEFAULT_LABEL, - DEFAULT_TOOLTIP, - DEFAULT_XAXIS_STYLE, - DEFAULT_YAXIS_STYLE, - DEFAULT_BACKGROUND_COLOR -} from '@/views/chart/chart/chart' -import { - DEFAULT_COMMON_CANVAS_STYLE + DEFAULT_COMMON_CANVAS_STYLE, DEFAULT_COMMON_CANVAS_STYLE_STRING } from '@/views/panel/panel' -import { DEFAULT_PANEL_STYLE } from '@/views/panel/panel' - export default { name: 'PanelList', components: { GrantAuth, LinkGenerate, EditPanel }, @@ -216,38 +200,7 @@ export default { level: null, nodeType: null, panelType: null, - panelStyle: JSON.stringify({ - width: 1600, - height: 900, - scale: 100, - scaleWidth: 100, - scaleHeight: 100, - selfAdaption: true, - auxiliaryMatrix: true, - openCommonStyle: true, - panel: DEFAULT_PANEL_STYLE, - chart: { - xaxis: '[]', - yaxis: '[]', - show: true, - type: 'panel', - title: '', - customAttr: JSON.stringify({ - color: DEFAULT_COLOR_CASE, - tableColor: DEFAULT_COLOR_CASE, - size: DEFAULT_SIZE, - label: DEFAULT_LABEL, - tooltip: DEFAULT_TOOLTIP - }), - customStyle: JSON.stringify({ - text: DEFAULT_TITLE_STYLE, - legend: DEFAULT_LEGEND_STYLE, - xAxis: DEFAULT_XAXIS_STYLE, - yAxis: DEFAULT_YAXIS_STYLE, - background: DEFAULT_BACKGROUND_COLOR - }), - customFilter: '[]' - }}), + panelStyle: JSON.stringify(DEFAULT_COMMON_CANVAS_STYLE_STRING), panelData: '[]' } }, @@ -262,38 +215,7 @@ export default { level: null, nodeType: null, panelType: null, - panelStyle: JSON.stringify({ - width: 1600, - height: 900, - scale: 100, - scaleWidth: 100, - scaleHeight: 100, - selfAdaption: true, - auxiliaryMatrix: true, - openCommonStyle: true, - panel: DEFAULT_PANEL_STYLE, - chart: { - xaxis: '[]', - yaxis: '[]', - show: true, - type: 'panel', - title: '', - customAttr: JSON.stringify({ - color: DEFAULT_COLOR_CASE, - tableColor: DEFAULT_COLOR_CASE, - size: DEFAULT_SIZE, - label: DEFAULT_LABEL, - tooltip: DEFAULT_TOOLTIP - }), - customStyle: JSON.stringify({ - text: DEFAULT_TITLE_STYLE, - legend: DEFAULT_LEGEND_STYLE, - xAxis: DEFAULT_XAXIS_STYLE, - yAxis: DEFAULT_YAXIS_STYLE, - background: DEFAULT_BACKGROUND_COLOR - }), - customFilter: '[]' - }}), + panelStyle: JSON.stringify(DEFAULT_COMMON_CANVAS_STYLE_STRING), panelData: '[]' } }, diff --git a/frontend/src/views/panel/panel.js b/frontend/src/views/panel/panel.js index c6fee9533c..92d1aec6ed 100644 --- a/frontend/src/views/panel/panel.js +++ b/frontend/src/views/panel/panel.js @@ -1,14 +1,4 @@ -import { - DEFAULT_COLOR_CASE, - DEFAULT_SIZE, - DEFAULT_TITLE_STYLE, - DEFAULT_LEGEND_STYLE, - DEFAULT_LABEL, - DEFAULT_TOOLTIP, - DEFAULT_XAXIS_STYLE, - DEFAULT_YAXIS_STYLE, - DEFAULT_BACKGROUND_COLOR -} from '@/views/chart/chart/chart' +import { BASE_CHART, BASE_CHART_STRING } from '@/views/chart/chart/chart' import { deepCopy } from '@/components/canvas/utils/utils' export const DEFAULT_PANEL_STYLE = { @@ -18,7 +8,7 @@ export const DEFAULT_PANEL_STYLE = { gap: 'no' } -export const DEFAULT_COMMON_CANVAS_STYLE = { +export const CANVAS_STYLE = { width: 1600, height: 900, scale: 100, @@ -27,29 +17,17 @@ export const DEFAULT_COMMON_CANVAS_STYLE = { selfAdaption: true, auxiliaryMatrix: true, openCommonStyle: true, - panel: DEFAULT_PANEL_STYLE, - chart: { - xaxis: [], - yaxis: [], - show: true, - type: 'panel', - title: '', - customAttr: { - color: DEFAULT_COLOR_CASE, - tableColor: DEFAULT_COLOR_CASE, - size: DEFAULT_SIZE, - label: DEFAULT_LABEL, - tooltip: DEFAULT_TOOLTIP - }, - customStyle: { - text: DEFAULT_TITLE_STYLE, - legend: DEFAULT_LEGEND_STYLE, - xAxis: DEFAULT_XAXIS_STYLE, - yAxis: DEFAULT_YAXIS_STYLE, - background: DEFAULT_BACKGROUND_COLOR - }, - customFilter: [] - } + panel: DEFAULT_PANEL_STYLE +} + +export const DEFAULT_COMMON_CANVAS_STYLE = { + ...CANVAS_STYLE, + chart: BASE_CHART +} + +export const DEFAULT_COMMON_CANVAS_STYLE_STRING = { + ...CANVAS_STYLE, + chart: BASE_CHART_STRING } export function chartTransStr2Object(targetIn, copy) {