提交 e1ed4470 authored 作者: fit2cloud-chenyw's avatar fit2cloud-chenyw

refactor: 仪表板兼容插件视图

上级 09188e9d
package io.dataease.base.domain; package io.dataease.base.domain;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@Data @Data
public class ChartView implements Serializable { public class ChartView implements Serializable {
@ApiModelProperty("ID")
private String id; private String id;
@ApiModelProperty("名称")
private String name; private String name;
@ApiModelProperty("分组ID")
private String title;
private String sceneId; private String sceneId;
@ApiModelProperty("数据集ID")
private String tableId; private String tableId;
@ApiModelProperty("图表类型")
private String type; private String type;
@ApiModelProperty("chart渲染方式")
private String render; private String render;
@ApiModelProperty("展示结果")
private Integer resultCount; private Integer resultCount;
@ApiModelProperty("展示模式")
private String resultMode; private String resultMode;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("创建人")
private String createBy; private String createBy;
@ApiModelProperty("创建时间")
private Long createTime; private Long createTime;
@ApiModelProperty("更新时间")
private Long updateTime; private Long updateTime;
@ApiModelProperty("样式优先级")
private String stylePriority; private String stylePriority;
private String chartType;
private Boolean isPlugin;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }
\ No newline at end of file
...@@ -244,6 +244,76 @@ public class ChartViewExample { ...@@ -244,6 +244,76 @@ public class ChartViewExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTitleIsNull() {
addCriterion("title is null");
return (Criteria) this;
}
public Criteria andTitleIsNotNull() {
addCriterion("title is not null");
return (Criteria) this;
}
public Criteria andTitleEqualTo(String value) {
addCriterion("title =", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotEqualTo(String value) {
addCriterion("title <>", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThan(String value) {
addCriterion("title >", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThanOrEqualTo(String value) {
addCriterion("title >=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThan(String value) {
addCriterion("title <", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThanOrEqualTo(String value) {
addCriterion("title <=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLike(String value) {
addCriterion("title like", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotLike(String value) {
addCriterion("title not like", value, "title");
return (Criteria) this;
}
public Criteria andTitleIn(List<String> values) {
addCriterion("title in", values, "title");
return (Criteria) this;
}
public Criteria andTitleNotIn(List<String> values) {
addCriterion("title not in", values, "title");
return (Criteria) this;
}
public Criteria andTitleBetween(String value1, String value2) {
addCriterion("title between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andTitleNotBetween(String value1, String value2) {
addCriterion("title not between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andSceneIdIsNull() { public Criteria andSceneIdIsNull() {
addCriterion("scene_id is null"); addCriterion("scene_id is null");
return (Criteria) this; return (Criteria) this;
...@@ -654,76 +724,6 @@ public class ChartViewExample { ...@@ -654,76 +724,6 @@ public class ChartViewExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andTitleIsNull() {
addCriterion("title is null");
return (Criteria) this;
}
public Criteria andTitleIsNotNull() {
addCriterion("title is not null");
return (Criteria) this;
}
public Criteria andTitleEqualTo(String value) {
addCriterion("title =", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotEqualTo(String value) {
addCriterion("title <>", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThan(String value) {
addCriterion("title >", value, "title");
return (Criteria) this;
}
public Criteria andTitleGreaterThanOrEqualTo(String value) {
addCriterion("title >=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThan(String value) {
addCriterion("title <", value, "title");
return (Criteria) this;
}
public Criteria andTitleLessThanOrEqualTo(String value) {
addCriterion("title <=", value, "title");
return (Criteria) this;
}
public Criteria andTitleLike(String value) {
addCriterion("title like", value, "title");
return (Criteria) this;
}
public Criteria andTitleNotLike(String value) {
addCriterion("title not like", value, "title");
return (Criteria) this;
}
public Criteria andTitleIn(List<String> values) {
addCriterion("title in", values, "title");
return (Criteria) this;
}
public Criteria andTitleNotIn(List<String> values) {
addCriterion("title not in", values, "title");
return (Criteria) this;
}
public Criteria andTitleBetween(String value1, String value2) {
addCriterion("title between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andTitleNotBetween(String value1, String value2) {
addCriterion("title not between", value1, value2, "title");
return (Criteria) this;
}
public Criteria andCreateByIsNull() { public Criteria andCreateByIsNull() {
addCriterion("create_by is null"); addCriterion("create_by is null");
return (Criteria) this; return (Criteria) this;
...@@ -983,6 +983,136 @@ public class ChartViewExample { ...@@ -983,6 +983,136 @@ public class ChartViewExample {
addCriterion("style_priority not between", value1, value2, "stylePriority"); addCriterion("style_priority not between", value1, value2, "stylePriority");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andChartTypeIsNull() {
addCriterion("chart_type is null");
return (Criteria) this;
}
public Criteria andChartTypeIsNotNull() {
addCriterion("chart_type is not null");
return (Criteria) this;
}
public Criteria andChartTypeEqualTo(String value) {
addCriterion("chart_type =", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeNotEqualTo(String value) {
addCriterion("chart_type <>", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeGreaterThan(String value) {
addCriterion("chart_type >", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeGreaterThanOrEqualTo(String value) {
addCriterion("chart_type >=", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeLessThan(String value) {
addCriterion("chart_type <", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeLessThanOrEqualTo(String value) {
addCriterion("chart_type <=", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeLike(String value) {
addCriterion("chart_type like", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeNotLike(String value) {
addCriterion("chart_type not like", value, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeIn(List<String> values) {
addCriterion("chart_type in", values, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeNotIn(List<String> values) {
addCriterion("chart_type not in", values, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeBetween(String value1, String value2) {
addCriterion("chart_type between", value1, value2, "chartType");
return (Criteria) this;
}
public Criteria andChartTypeNotBetween(String value1, String value2) {
addCriterion("chart_type not between", value1, value2, "chartType");
return (Criteria) this;
}
public Criteria andIsPluginIsNull() {
addCriterion("is_plugin is null");
return (Criteria) this;
}
public Criteria andIsPluginIsNotNull() {
addCriterion("is_plugin is not null");
return (Criteria) this;
}
public Criteria andIsPluginEqualTo(Boolean value) {
addCriterion("is_plugin =", value, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginNotEqualTo(Boolean value) {
addCriterion("is_plugin <>", value, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginGreaterThan(Boolean value) {
addCriterion("is_plugin >", value, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginGreaterThanOrEqualTo(Boolean value) {
addCriterion("is_plugin >=", value, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginLessThan(Boolean value) {
addCriterion("is_plugin <", value, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginLessThanOrEqualTo(Boolean value) {
addCriterion("is_plugin <=", value, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginIn(List<Boolean> values) {
addCriterion("is_plugin in", values, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginNotIn(List<Boolean> values) {
addCriterion("is_plugin not in", values, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginBetween(Boolean value1, Boolean value2) {
addCriterion("is_plugin between", value1, value2, "isPlugin");
return (Criteria) this;
}
public Criteria andIsPluginNotBetween(Boolean value1, Boolean value2) {
addCriterion("is_plugin not between", value1, value2, "isPlugin");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {
......
package io.dataease.base.domain; package io.dataease.base.domain;
import java.io.Serializable; import java.io.Serializable;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString; import lombok.ToString;
...@@ -11,27 +9,26 @@ import lombok.ToString; ...@@ -11,27 +9,26 @@ import lombok.ToString;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true) @ToString(callSuper = true)
public class ChartViewWithBLOBs extends ChartView implements Serializable { public class ChartViewWithBLOBs extends ChartView implements Serializable {
@ApiModelProperty("x轴")
private String xAxis; private String xAxis;
@ApiModelProperty("x轴(Row)")
private String xAxisExt; private String xAxisExt;
@ApiModelProperty("y轴")
private String yAxis; private String yAxis;
@ApiModelProperty("副y轴")
private String yAxisExt; private String yAxisExt;
@ApiModelProperty("堆叠")
private String extStack; private String extStack;
@ApiModelProperty("气泡")
private String extBubble; private String extBubble;
@ApiModelProperty("图形属性")
private String customAttr; private String customAttr;
@ApiModelProperty("组件样式")
private String customStyle; private String customStyle;
@ApiModelProperty("过滤条件")
private String customFilter; private String customFilter;
@ApiModelProperty("下钻字段")
private String drillFields; private String drillFields;
@ApiModelProperty("快照")
private String snapshot; private String snapshot;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
......
...@@ -310,3 +310,6 @@ delete from chart_group where id in ( ...@@ -310,3 +310,6 @@ delete from chart_group where id in (
ALTER TABLE `panel_link_mapping` ALTER TABLE `panel_link_mapping`
ADD COLUMN `uuid` varchar(8) NULL COMMENT 'uuid' AFTER `user_id`; ADD COLUMN `uuid` varchar(8) NULL COMMENT 'uuid' AFTER `user_id`;
ALTER TABLE `chart_view`
ADD COLUMN `is_plugin` bit(1) NULL COMMENT '是否插件' AFTER `chart_type`;
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</div> </div>
</div> </div>
<plugin-com <plugin-com
v-if="isPlugin" v-if="chart.isPlugin"
:ref="element.propValue.id" :ref="element.propValue.id"
:component-name="chart.type + '-view'" :component-name="chart.type + '-view'"
:obj="{chart, trackMenu, searchCount, terminalType: scaleCoefficientType}" :obj="{chart, trackMenu, searchCount, terminalType: scaleCoefficientType}"
...@@ -89,7 +89,6 @@ import ChartComponentG2 from '@/views/chart/components/ChartComponentG2' ...@@ -89,7 +89,6 @@ import ChartComponentG2 from '@/views/chart/components/ChartComponentG2'
import EditBarView from '@/components/canvas/components/Editor/EditBarView' import EditBarView from '@/components/canvas/components/Editor/EditBarView'
import { customAttrTrans, customStyleTrans, recursionTransObj } from '@/components/canvas/utils/style' import { customAttrTrans, customStyleTrans, recursionTransObj } from '@/components/canvas/utils/style'
import ChartComponentS2 from '@/views/chart/components/ChartComponentS2' import ChartComponentS2 from '@/views/chart/components/ChartComponentS2'
import { pluginTypes } from '@/api/chart/chart'
import PluginCom from '@/views/system/plugin/PluginCom' import PluginCom from '@/views/system/plugin/PluginCom'
export default { export default {
name: 'UserView', name: 'UserView',
...@@ -162,9 +161,7 @@ export default { ...@@ -162,9 +161,7 @@ export default {
pre: null, pre: null,
preCanvasPanel: null, preCanvasPanel: null,
sourceCustomAttrStr: null, sourceCustomAttrStr: null,
sourceCustomStyleStr: null, sourceCustomStyleStr: null
isPlugin: false,
plugins: []
} }
}, },
computed: { computed: {
...@@ -332,7 +329,7 @@ export default { ...@@ -332,7 +329,7 @@ export default {
} }
}, },
'chartType': function(newVal, oldVal) { 'chartType': function(newVal, oldVal) {
this.isPlugin = this.plugins.some(plugin => plugin.value === this.chart.type) // this.isPlugin = this.plugins.some(plugin => plugin.value === this.chart.type)
if (newVal === 'map' && newVal !== oldVal) { if (newVal === 'map' && newVal !== oldVal) {
this.initAreas() this.initAreas()
} }
...@@ -347,12 +344,7 @@ export default { ...@@ -347,12 +344,7 @@ export default {
deep: true deep: true
} }
}, },
beforeCreate() {
pluginTypes().then(res => {
this.plugins = res.data
this.isPlugin = this.plugins.some(plugin => plugin.value === this.chart.type)
})
},
created() { created() {
this.refId = uuid.v1 this.refId = uuid.v1
if (this.element && this.element.propValue && this.element.propValue.viewId) { if (this.element && this.element.propValue && this.element.propValue.viewId) {
......
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
v-model="view.type" v-model="view.type"
style="width: 100%" style="width: 100%"
> >
<chart-type :chart="view" style="height: 350px;" /> <chart-type ref="cu-chart-type" :chart="view" style="height: 350px;" />
</el-radio-group> </el-radio-group>
</div> </div>
</el-row> </el-row>
...@@ -420,6 +420,11 @@ export default { ...@@ -420,6 +420,11 @@ export default {
currentKey: null currentKey: null
} }
}, },
computed: {
chartType() {
return this.view.type
}
},
watch: { watch: {
saveStatus() { saveStatus() {
}, },
...@@ -436,6 +441,9 @@ export default { ...@@ -436,6 +441,9 @@ export default {
searchType(val) { searchType(val) {
this.searchPids = [] this.searchPids = []
this.$refs.chartTreeRef.filter(this.filterText) this.$refs.chartTreeRef.filter(this.filterText)
},
chartType(val) {
this.view.isPlugin = val && this.$refs['cu-chart-type'] && this.$refs['cu-chart-type'].currentIsPlugin(val)
} }
}, },
...@@ -733,6 +741,7 @@ export default { ...@@ -733,6 +741,7 @@ export default {
view.sceneId = this.currGroup.id view.sceneId = this.currGroup.id
view.tableId = this.table.id view.tableId = this.table.id
view.type = this.view.type view.type = this.view.type
view.isPlugin = this.view.isPlugin
view.render = this.view.render view.render = this.view.render
view.resultMode = 'custom' view.resultMode = 'custom'
view.resultCount = 1000 view.resultCount = 1000
......
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
:disabled="!hasDataPermission('manage',param.privileges)" :disabled="!hasDataPermission('manage',param.privileges)"
@change="changeChartType()" @change="changeChartType()"
> >
<chart-type :chart="view" style="height: 480px" /> <chart-type ref="cu-chart-type" :chart="view" style="height: 480px" />
</el-radio-group> </el-radio-group>
</div> </div>
</el-row> </el-row>
...@@ -220,7 +220,7 @@ ...@@ -220,7 +220,7 @@
</el-row> </el-row>
</el-row> </el-row>
<plugin-com v-if="isPlugin" :component-name="view.type + '-data'" :obj="{view, param, chart}" /> <plugin-com v-if="view.isPlugin" :component-name="view.type + '-data'" :obj="{view, param, chart}" />
<div v-else> <div v-else>
<el-row v-if="view.type ==='map'" class="padding-lr"> <el-row v-if="view.type ==='map'" class="padding-lr">
...@@ -820,7 +820,7 @@ ...@@ -820,7 +820,7 @@
<el-row style="width: 100%;height: 100%;" class="padding-lr"> <el-row style="width: 100%;height: 100%;" class="padding-lr">
<div ref="imageWrapper" style="height: 100%"> <div ref="imageWrapper" style="height: 100%">
<plugin-com <plugin-com
v-if="httpRequest.status && chart.type && isPlugin" v-if="httpRequest.status && chart.type && view.isPlugin"
:component-name="chart.type + '-view'" :component-name="chart.type + '-view'"
:obj="{chart}" :obj="{chart}"
class="chart-class" class="chart-class"
...@@ -1055,7 +1055,6 @@ import { compareItem } from '@/views/chart/chart/compare' ...@@ -1055,7 +1055,6 @@ import { compareItem } from '@/views/chart/chart/compare'
import ChartComponentS2 from '@/views/chart/components/ChartComponentS2' import ChartComponentS2 from '@/views/chart/components/ChartComponentS2'
import DimensionExtItem from '@/views/chart/components/drag-item/DimensionExtItem' import DimensionExtItem from '@/views/chart/components/drag-item/DimensionExtItem'
import PluginCom from '@/views/system/plugin/PluginCom' import PluginCom from '@/views/system/plugin/PluginCom'
import { pluginTypes } from '@/api/chart/chart'
export default { export default {
name: 'ChartEdit', name: 'ChartEdit',
components: { components: {
...@@ -1143,7 +1142,8 @@ export default { ...@@ -1143,7 +1142,8 @@ export default {
split: DEFAULT_SPLIT split: DEFAULT_SPLIT
}, },
customFilter: [], customFilter: [],
render: 'antv' render: 'antv',
isPlugin: false
}, },
moveId: -1, moveId: -1,
chart: { chart: {
...@@ -1190,9 +1190,8 @@ export default { ...@@ -1190,9 +1190,8 @@ export default {
drill: false, drill: false,
hasEdit: false, hasEdit: false,
quotaItemCompare: {}, quotaItemCompare: {},
showEditQuotaCompare: false, showEditQuotaCompare: false
plugins: [],
isPlugin: false
} }
}, },
computed: { computed: {
...@@ -1213,7 +1212,7 @@ export default { ...@@ -1213,7 +1212,7 @@ export default {
this.fieldFilter(val) this.fieldFilter(val)
}, },
'chartType': function(newVal, oldVal) { 'chartType': function(newVal, oldVal) {
this.isPlugin = this.plugins.some(plugin => plugin.value === this.chart.type) this.view.isPlugin = this.$refs['cu-chart-type'] && this.$refs['cu-chart-type'].currentIsPlugin(newVal)
if (newVal === 'map' && newVal !== oldVal) { if (newVal === 'map' && newVal !== oldVal) {
this.initAreas() this.initAreas()
} }
...@@ -1232,12 +1231,7 @@ export default { ...@@ -1232,12 +1231,7 @@ export default {
}, },
activated() { activated() {
}, },
beforeCreate() {
pluginTypes().then(res => {
this.plugins = res.data
this.isPlugin = this.plugins.some(plugin => plugin.value === this.chart.type)
})
},
methods: { methods: {
bindPluginEvent() { bindPluginEvent() {
bus.$on('show-dimension-edit-filter', this.showDimensionEditFilter) bus.$on('show-dimension-edit-filter', this.showDimensionEditFilter)
......
<template> <template>
<div class="chart-type"> <div v-if="loadFinish" class="chart-type">
<div v-for="(renderItem, category) in renderMap[chart.render]" :key="category"> <div v-for="(renderItem, category) in renderMap[chart.render]" :key="category">
<el-divider class="chart-type-divider">{{ $t(category) }}</el-divider> <el-divider class="chart-type-divider">{{ $t(category) }}</el-divider>
...@@ -38,21 +38,38 @@ export default { ...@@ -38,21 +38,38 @@ export default {
data() { data() {
return { return {
defaultTypes: TYPE_CONFIGS, defaultTypes: TYPE_CONFIGS,
allTypes: [], renderMap: {},
renderMap: {} loadFinish: false
} }
}, },
beforeCreate() { created() {
pluginTypes().then(res => { const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views'))
const plugins = res.data if (plugins) {
this.initTypes(plugins)
} else {
pluginTypes().then(res => {
const plugins = res.data
localStorage.setItem('plugin-views', JSON.stringify(plugins))
this.initTypes(plugins)
}).catch(e => {
localStorage.setItem('plugin-views', null)
this.initTypes([])
})
}
},
methods: {
currentIsPlugin(type) {
const plugins = localStorage.getItem('plugin-views') && JSON.parse(localStorage.getItem('plugin-views')) || []
return plugins.some(plugin => plugin.value === type)
},
initTypes(plugins) {
plugins.forEach(plugin => { plugins.forEach(plugin => {
plugin.isPlugin = true plugin.isPlugin = true
}) })
this.pluginTypes = [...this.defaultTypes, ...plugins] this.pluginTypes = [...this.defaultTypes, ...plugins]
this.formatTypes() this.formatTypes()
}) this.loadFinish = true
}, },
methods: {
formatTypes() { formatTypes() {
this.pluginTypes.forEach(item => { this.pluginTypes.forEach(item => {
const { render, category } = item const { render, category } = item
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论