feat: 合并重复样式数据

This commit is contained in:
wangjiahao 2021-06-22 14:14:31 +08:00
parent d9d1b3a21e
commit aa38a4be51
4 changed files with 65 additions and 150 deletions

View File

@ -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
}

View File

@ -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: []
}

View File

@ -48,9 +48,6 @@
<span class="header-title">
{{ $t('panel.panel_list') }}
<el-button style="float: right;padding-right: 7px;margin-top: -8px" icon="el-icon-plus" type="text" @click="showEditPanel(newFolder)" />
<!-- <el-button style="float: right;" type="primary" size="mini" @click="showEditPanel(newFolder)">-->
<!-- {{ $t('panel.groupAdd') }}-->
<!-- </el-button>-->
</span>
</el-row>
<el-col class="custom-tree-container">
@ -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: '[]'
}
},

View File

@ -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) {