diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index a72074f27a..8f35fa2549 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -596,6 +596,7 @@ export default { summary: '汇总方式', fast_calc: '快速计算', sum: '求和', + count: '计数', avg: '平均', max: '最大值', min: '最小值', diff --git a/frontend/src/views/chart/components/DimensionItem.vue b/frontend/src/views/chart/components/DimensionItem.vue index 8eea1a7926..192b7454c5 100644 --- a/frontend/src/views/chart/components/DimensionItem.vue +++ b/frontend/src/views/chart/components/DimensionItem.vue @@ -1,20 +1,32 @@ @@ -25,14 +37,71 @@ export default { item: { type: Object, required: true + }, + index: { + type: Number, + required: true } }, data() { - return {} + return { + renameItem: false, + itemForm: { + name: '' + }, + itemFormRules: { + name: [ + { required: true, message: this.$t('commons.input_content'), trigger: 'change' } + ] + } + } }, mounted() { }, - methods: {} + methods: { + clickItem(param) { + if (!param) { + return + } + switch (param.type) { + case 'rename': + this.showRename() + break + case 'remove': + this.removeItem() + break + default: + break + } + }, + beforeClickItem(type) { + return { + 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('onDimensionItemChange', this.item) + this.closeRename() + }, + resetRename() { + this.itemForm = { + name: '' + } + }, + removeItem() { + this.item.index = this.index + this.$emit('onDimensionItemRemove', this.item) + } + } } diff --git a/frontend/src/views/chart/components/QuotaItem.vue b/frontend/src/views/chart/components/QuotaItem.vue index 76c07c82ce..08af376fc3 100644 --- a/frontend/src/views/chart/components/QuotaItem.vue +++ b/frontend/src/views/chart/components/QuotaItem.vue @@ -13,6 +13,7 @@ {{ $t('chart.sum') }} + {{ $t('chart.count') }} {{ $t('chart.avg') }} {{ $t('chart.max') }} {{ $t('chart.min') }} @@ -34,6 +35,9 @@ {{ $t('chart.show_name_set') }} + + {{ $t('chart.delete') }} + @@ -59,6 +63,10 @@ export default { item: { type: Object, required: true + }, + index: { + type: Number, + required: true } }, data() { @@ -104,6 +112,9 @@ export default { case 'rename': this.showRename() break + case 'remove': + this.removeItem() + break default: break } @@ -130,6 +141,10 @@ export default { this.itemForm = { name: '' } + }, + removeItem() { + this.item.index = this.index + this.$emit('onQuotaItemRemove', this.item) } } } diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index a2de6850cd..28da54ba29 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -101,7 +101,7 @@ -
+
@@ -117,7 +117,7 @@
-
+
{{ $t('chart.result_filter') }}
TODO
@@ -137,7 +137,7 @@ @end="end2" > - + @@ -152,7 +152,7 @@ @end="end2" > - + @@ -406,6 +406,15 @@ export default { return true }, + dimensionItemChange(item) { + this.save() + }, + + dimensionItemRemove(item) { + this.view.xaxis.splice(item.index, 1) + this.save() + }, + quotaItemChange(item) { // 更新item // this.view.yaxis.forEach(function(ele) { @@ -416,6 +425,11 @@ export default { this.save() }, + quotaItemRemove(item) { + this.view.yaxis.splice(item.index, 1) + this.save() + }, + onColorChange(val) { this.view.customAttr.color = val this.save()