From b3a53f9a64aa55ef2a43c2edd7fa8d3eaaeabcde Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 25 Mar 2021 11:34:46 +0800 Subject: [PATCH 1/9] =?UTF-8?q?feat(=E8=A7=86=E5=9B=BE):=201.=E5=88=9D?= =?UTF-8?q?=E6=AD=A5=E5=A2=9E=E5=8A=A0=E7=BB=93=E6=9E=9C=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=EF=BC=8C=E6=9D=A1=E4=BB=B6=E4=B9=8B=E9=97=B4=E6=9A=82=E6=97=B6?= =?UTF-8?q?=E5=8F=AA=E6=94=AF=E6=8C=81'=E4=B8=94'=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=9B2.fix=E8=AE=BE=E7=BD=AE=E6=98=BE=E7=A4=BA=E5=90=8Dbug?= =?UTF-8?q?=EF=BC=9B3.=E4=B8=80=E4=BA=9B=E6=A0=B7=E5=BC=8F=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/dto/chart/ChartViewFieldDTO.java | 4 + .../dto/chart/ChartViewFieldFilterDTO.java | 15 ++ .../service/chart/ChartViewService.java | 37 ++++- frontend/src/lang/zh.js | 14 +- .../BackgroundColorSelector.vue | 2 +- .../components/drag-item/DimensionItem.vue | 40 +----- .../chart/components/drag-item/QuotaItem.vue | 50 ++----- .../components/filter/QuotaFilterEditor.vue | 129 ++++++++++++++++++ frontend/src/views/chart/group/Group.vue | 2 +- frontend/src/views/chart/view/ChartEdit.vue | 93 ++++++++++++- 10 files changed, 303 insertions(+), 83 deletions(-) create mode 100644 backend/src/main/java/io/dataease/dto/chart/ChartViewFieldFilterDTO.java create mode 100644 frontend/src/views/chart/components/filter/QuotaFilterEditor.vue diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java index 5b93d472d3..9eae0f4a58 100644 --- a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java +++ b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldDTO.java @@ -2,6 +2,8 @@ package io.dataease.dto.chart; import lombok.Data; +import java.util.List; + /** * @Author gin * @Date 2021/3/11 1:18 下午 @@ -29,4 +31,6 @@ public class ChartViewFieldDTO { private String summary; private String sort; + + private List filter; } diff --git a/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldFilterDTO.java b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldFilterDTO.java new file mode 100644 index 0000000000..b5303899a3 --- /dev/null +++ b/backend/src/main/java/io/dataease/dto/chart/ChartViewFieldFilterDTO.java @@ -0,0 +1,15 @@ +package io.dataease.dto.chart; + +import lombok.Getter; +import lombok.Setter; + +/** + * @Author gin + * @Date 2021/3/25 10:31 上午 + */ +@Getter +@Setter +public class ChartViewFieldFilterDTO { + private String term; + private String value; +} diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 2f3341a1b1..2c93998a96 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -174,6 +174,41 @@ public class ChartViewService { sql = sql.substring(0, sql.length() - 1); } // 如果是对结果字段过滤,则再包裹一层sql - return sql; + String[] resultFilter = yAxis.stream().filter(y -> CollectionUtils.isNotEmpty(y.getFilter()) && y.getFilter().size() > 0) + .map(y -> { + String[] s = y.getFilter().stream().map(f -> "AND _" + y.getSummary() + "_" + y.getOriginName() + transMysqlFilterTerm(f.getTerm()) + f.getValue()).toArray(String[]::new); + return StringUtils.join(s, " "); + }).toArray(String[]::new); + if (resultFilter.length == 0) { + return sql; + } else { + String filterSql = MessageFormat.format("SELECT * FROM {0} WHERE 1=1 {1}", + "(" + sql + ") AS tmp", + StringUtils.join(resultFilter, " ")); + return filterSql; + } + } + + public String transMysqlFilterTerm(String term) { + switch (term) { + case "eq": + return "="; + case "not_eq": + return "<>"; + case "lt": + return "<"; + case "le": + return "<="; + case "gt": + return ">"; + case "ge": + return ">="; + case "null": + return "IS NULL"; + case "not_null": + return "IS NOT NULL"; + default: + return ""; + } } } diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index c5b4bfb8ed..6b2b57cb4c 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -681,7 +681,19 @@ export default { filter: '过滤', none: '无', background: '背景', - alpha: '透明度' + alpha: '透明度', + add_filter: '添加过滤', + no_limit: '无限制', + filter_eq: '等于', + filter_not_eq: '不等于', + filter_lt: '小于', + filter_le: '小于等于', + filter_gt: '大于', + filter_ge: '大于等于', + filter_null: '为空', + filter_not_null: '不为空', + filter_include: '包含', + filter_not_include: '不包含' }, dataset: { datalist: '数据集', diff --git a/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue b/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue index 7ec8fc943a..e77eb30e75 100644 --- a/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue +++ b/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue @@ -11,7 +11,7 @@ - + diff --git a/frontend/src/views/chart/components/drag-item/DimensionItem.vue b/frontend/src/views/chart/components/drag-item/DimensionItem.vue index 192b7454c5..78665a05c5 100644 --- a/frontend/src/views/chart/components/drag-item/DimensionItem.vue +++ b/frontend/src/views/chart/components/drag-item/DimensionItem.vue @@ -15,18 +15,6 @@ - - - - - - - - - @@ -45,15 +33,6 @@ export default { }, data() { return { - renameItem: false, - itemForm: { - name: '' - }, - itemFormRules: { - name: [ - { required: true, message: this.$t('commons.input_content'), trigger: 'change' } - ] - } } }, mounted() { @@ -80,22 +59,9 @@ export default { } }, showRename() { - this.itemForm.name = this.item.name - this.renameItem = true - }, - closeRename() { - this.renameItem = false - this.resetRename() - }, - saveRename(param) { - this.item.name = param.name - this.$emit('onDimensionItemChange', this.item) - this.closeRename() - }, - resetRename() { - this.itemForm = { - name: '' - } + this.item.index = this.index + this.item.renameType = 'dimension' + this.$emit('onNameEdit', this.item) }, removeItem() { this.item.index = this.index diff --git a/frontend/src/views/chart/components/drag-item/QuotaItem.vue b/frontend/src/views/chart/components/drag-item/QuotaItem.vue index ad7d985411..ae5a1f5738 100644 --- a/frontend/src/views/chart/components/drag-item/QuotaItem.vue +++ b/frontend/src/views/chart/components/drag-item/QuotaItem.vue @@ -59,7 +59,7 @@ - + {{ $t('chart.filter') }}... @@ -71,18 +71,6 @@ - - - - - - - - - @@ -101,15 +89,6 @@ export default { }, data() { return { - renameItem: false, - itemForm: { - name: '' - }, - itemFormRules: { - name: [ - { required: true, message: this.$t('commons.input_content'), trigger: 'change' } - ] - } } }, mounted() { @@ -127,6 +106,9 @@ export default { case 'remove': this.removeItem() break + case 'filter': + this.editFilter() + break default: break } @@ -167,28 +149,18 @@ export default { type: type } }, - showRename() { - this.itemForm.name = this.item.name - this.renameItem = true - }, - closeRename() { - this.renameItem = false - this.resetRename() - }, - saveRename(param) { - this.item.name = param.name - this.$emit('onQuotaItemChange', this.item) - this.closeRename() - }, - resetRename() { - this.itemForm = { - name: '' - } + this.item.index = this.index + this.item.renameType = 'quota' + this.$emit('onNameEdit', this.item) }, removeItem() { this.item.index = this.index this.$emit('onQuotaItemRemove', this.item) + }, + editFilter() { + this.item.index = this.index + this.$emit('editItemFilter', this.item) } } } diff --git a/frontend/src/views/chart/components/filter/QuotaFilterEditor.vue b/frontend/src/views/chart/components/filter/QuotaFilterEditor.vue new file mode 100644 index 0000000000..cd74405567 --- /dev/null +++ b/frontend/src/views/chart/components/filter/QuotaFilterEditor.vue @@ -0,0 +1,129 @@ + + + + + diff --git a/frontend/src/views/chart/group/Group.vue b/frontend/src/views/chart/group/Group.vue index 2b62b520f4..0836c30843 100644 --- a/frontend/src/views/chart/group/Group.vue +++ b/frontend/src/views/chart/group/Group.vue @@ -528,7 +528,7 @@ export default { yAxis: DEFAULT_YAXIS_STYLE, background: DEFAULT_BACKGROUND_COLOR }) - view.customFilter = JSON.stringify({}) + view.customFilter = JSON.stringify([]) post('/chart/view/save', view).then(response => { this.selectTableFlag = false this.$store.dispatch('chart/setTableId', null) diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 238cb6bfe6..6d51067de9 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -151,7 +151,7 @@ @end="end2" > - + @@ -166,7 +166,7 @@ @end="end2" > - + @@ -176,6 +176,34 @@ + + + + + + + + + + + + + + + + @@ -207,10 +235,11 @@ import TooltipSelector from '../components/shape-attr/TooltipSelector' import XAxisSelector from '../components/component-style/XAxisSelector' import YAxisSelector from '../components/component-style/YAxisSelector' import BackgroundColorSelector from '../components/component-style/BackgroundColorSelector' +import QuotaFilterEditor from '../components/filter/QuotaFilterEditor' export default { name: 'ChartEdit', - components: { BackgroundColorSelector, FilterItem, XAxisSelector, YAxisSelector, TooltipSelector, LabelSelector, LegendSelector, TitleSelector, SizeSelector, ColorSelector, ChartComponent, QuotaItem, DimensionItem, draggable }, + components: { QuotaFilterEditor, BackgroundColorSelector, FilterItem, XAxisSelector, YAxisSelector, TooltipSelector, LabelSelector, LegendSelector, TitleSelector, SizeSelector, ColorSelector, ChartComponent, QuotaItem, DimensionItem, draggable }, data() { return { table: {}, @@ -240,6 +269,17 @@ export default { moveId: -1, chart: { id: 'echart' + }, + filterEdit: false, + quotaItem: {}, + renameItem: false, + itemForm: { + name: '' + }, + itemFormRules: { + name: [ + { required: true, message: this.$t('commons.input_content'), trigger: 'change' } + ] } } }, @@ -305,6 +345,9 @@ export default { if (!ele.sort || ele.sort === '') { ele.sort = 'none' } + if (!ele.filter) { + ele.filter = [] + } }) if (view.type.startsWith('pie') || view.type.startsWith('funnel')) { if (view.yaxis.length > 1) { @@ -490,6 +533,40 @@ export default { onChangeBackgroundForm(val) { this.view.customStyle.background = val this.save() + }, + + showEditFilter(item) { + this.quotaItem = JSON.parse(JSON.stringify(item)) + this.filterEdit = true + }, + closeQuotaFilter() { + this.filterEdit = false + }, + saveQuotaFilter() { + this.view.yaxis[this.quotaItem.index].filter = this.quotaItem.filter + this.save() + this.closeQuotaFilter() + }, + + showRename(val) { + this.itemForm = JSON.parse(JSON.stringify(val)) + this.renameItem = true + }, + saveRename() { + if (this.itemForm.renameType === 'quota') { + this.view.yaxis[this.itemForm.index].name = this.itemForm.name + } else if (this.itemForm.renameType === 'dimension') { + this.view.xaxis[this.itemForm.index].name = this.itemForm.name + } + this.save() + this.closeRename() + }, + closeRename() { + this.renameItem = false + this.resetRename() + }, + resetRename() { + this.itemForm = {} } } } @@ -623,4 +700,14 @@ export default { .chart-class{ height: calc(100% - 124px); } + + .dialog-css>>>.el-dialog__title { + font-size: 14px; + } + .dialog-css >>> .el-dialog__header { + padding: 20px 20px 0; + } + .dialog-css >>> .el-dialog__body { + padding: 10px 20px 20px; + } From 586b3ef24f08e11c9b87c6b45d0d80afb5e3bbcb Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 25 Mar 2021 11:58:13 +0800 Subject: [PATCH 2/9] =?UTF-8?q?feat(=E8=A7=86=E5=9B=BE):=20fix=20sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/service/chart/ChartViewService.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java index 2c93998a96..3c282d3dce 100644 --- a/backend/src/main/java/io/dataease/service/chart/ChartViewService.java +++ b/backend/src/main/java/io/dataease/service/chart/ChartViewService.java @@ -192,21 +192,21 @@ public class ChartViewService { public String transMysqlFilterTerm(String term) { switch (term) { case "eq": - return "="; + return " = "; case "not_eq": - return "<>"; + return " <> "; case "lt": - return "<"; + return " < "; case "le": - return "<="; + return " <= "; case "gt": - return ">"; + return " > "; case "ge": - return ">="; + return " >= "; case "null": - return "IS NULL"; + return " IS NULL "; case "not_null": - return "IS NOT NULL"; + return " IS NOT NULL "; default: return ""; } From d321be221a73720c9c9bf7b1af1066b51bf9a236 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 25 Mar 2021 12:43:19 +0800 Subject: [PATCH 3/9] =?UTF-8?q?style(=E8=A7=86=E5=9B=BE):=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/chart/view/ChartEdit.vue | 31 ++++++++++++++------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 6d51067de9..ddbb0ef56a 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -15,18 +15,18 @@ - + -
+
{{ $t('chart.dimension') }} @@ -35,14 +35,14 @@
-
+
{{ $t('chart.quota') }} @@ -54,7 +54,7 @@
@@ -73,7 +73,7 @@
-
+
{{ $t('chart.chart_type') }}
@@ -172,7 +172,7 @@ - + @@ -566,7 +566,7 @@ export default { this.resetRename() }, resetRename() { - this.itemForm = {} + // this.itemForm = {} } } } @@ -595,6 +595,16 @@ export default { margin-left: 10px; } + .view-panel { + display: flex; + height: calc(100% - 40px); + } + + .drag-list { + height: calc(100% - 26px); + overflow:auto; + } + .item { padding: 2px 10px; margin: 2px 2px 0 2px; @@ -698,7 +708,8 @@ export default { } .chart-class{ - height: calc(100% - 124px); + height: calc(100% - 84px); + padding: 10px; } .dialog-css>>>.el-dialog__title { From c7351ac742cb804eb4a594366520ae795e7298c8 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 25 Mar 2021 15:48:20 +0800 Subject: [PATCH 4/9] =?UTF-8?q?style(=E8=A7=86=E5=9B=BE):=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/components/dataease/DeAsideContainer.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/dataease/DeAsideContainer.vue b/frontend/src/components/dataease/DeAsideContainer.vue index b4542868cc..f9bb956c24 100644 --- a/frontend/src/components/dataease/DeAsideContainer.vue +++ b/frontend/src/components/dataease/DeAsideContainer.vue @@ -21,7 +21,7 @@ export default { props: { width: { type: String, - default: '300px' + default: '260px' }, enableAsideHidden: { type: Boolean, From 92766de9f9a8de1c0a1c09a5f05de0a3d62b37f8 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 25 Mar 2021 16:41:03 +0800 Subject: [PATCH 5/9] =?UTF-8?q?style(=E8=A7=86=E5=9B=BE):=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/component-style/BackgroundColorSelector.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue b/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue index e77eb30e75..038e201afa 100644 --- a/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue +++ b/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue @@ -9,7 +9,7 @@ - + From 68df03d70806e3309cc0193cb67935308d498e41 Mon Sep 17 00:00:00 2001 From: junjie Date: Thu, 25 Mar 2021 17:09:44 +0800 Subject: [PATCH 6/9] =?UTF-8?q?style(=E6=95=B0=E6=8D=AE=E9=9B=86):=20css?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/dataset/data/UpdateInfo.vue | 27 ++++++++++++++----- frontend/src/views/dataset/data/ViewTable.vue | 15 ++++++++++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/frontend/src/views/dataset/data/UpdateInfo.vue b/frontend/src/views/dataset/data/UpdateInfo.vue index e7274a794e..49324e36d0 100644 --- a/frontend/src/views/dataset/data/UpdateInfo.vue +++ b/frontend/src/views/dataset/data/UpdateInfo.vue @@ -195,9 +195,9 @@ -
{{ $t('dataset.incremental_update_type') }}:
+ {{ $t('dataset.incremental_update_type') }}: - + {{ $t('dataset.incremental_add') }} {{ $t('dataset.incremental_delete') }} @@ -207,10 +207,10 @@ -
{{ $t('dataset.param') }}:
+ {{ $t('dataset.param') }}: - {{ $t('dataset.last_update_time') }} - {{ $t('dataset.current_update_time') }} + {{ $t('dataset.last_update_time') }} + {{ $t('dataset.current_update_time') }}
@@ -504,7 +504,18 @@ export default { } - diff --git a/frontend/src/views/dataset/data/ViewTable.vue b/frontend/src/views/dataset/data/ViewTable.vue index ae0b3df02e..14b729adf0 100644 --- a/frontend/src/views/dataset/data/ViewTable.vue +++ b/frontend/src/views/dataset/data/ViewTable.vue @@ -29,7 +29,7 @@ - +