From be8ace3455c9e647a1181b2f4ed7c18cac31af3b Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 21 Feb 2022 18:03:21 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-1577=20feat=EF=BC=9Achart=20=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=A1=B5=E9=9D=A2=20system=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=BA=90=E5=A2=9E=E5=8A=A0filter=EF=BC=8880%=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chart/panelChart.vue | 3 ++- .../common/filterSearch/filterSearch.vue | 20 ++++++++++++------- .../common/rightBox/chart/chartRightBox.vue | 3 +++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index 832e9350c..8ad1370ba 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -290,7 +290,8 @@ export default { group: this.chartInfo.param.datasource[0].group, select: [this.chartInfo.param.datasource[0].select], limit: this.chartInfo.param.datasource[0].limit, - sort: this.chartInfo.param.datasource[0].sort + sort: this.chartInfo.param.datasource[0].sort, + filter: this.chartInfo.param.datasource[0].filter ? this.chartInfo.param.datasource[0].filter.filter(item => item.value) : [] } const chartData = [] const params = { diff --git a/nezha-fronted/src/components/common/filterSearch/filterSearch.vue b/nezha-fronted/src/components/common/filterSearch/filterSearch.vue index 239e0ae47..01420d51d 100644 --- a/nezha-fronted/src/components/common/filterSearch/filterSearch.vue +++ b/nezha-fronted/src/components/common/filterSearch/filterSearch.vue @@ -87,10 +87,8 @@ export default { }, mounted () { this.metaList = this.valueList.map(item => { - return { - ...new Meta(), - ...item - } + const obj = Object.assign(new Meta(condition), item) + return obj }) }, methods: { @@ -118,7 +116,6 @@ export default { this.$emit('update:valueList', this.metaList) this.$emit('change') this.$nextTick(() => { - console.log(this.$refs.columnSelect) this.$refs.columnSelect[0].focus() }) } @@ -131,9 +128,9 @@ export default { columnBlur (meta, index, type) { setTimeout(() => { meta.name = meta.name.replace(/"/g, '') - // meta.nameIsEditing = false + meta.nameIsEditing = false if (!meta.name) { - // this.metaList.splice(index, 1) + this.metaList.splice(index, 1) this.$emit('update:valueList', this.metaList) this.$emit('change') } @@ -185,6 +182,15 @@ export default { }, valueBlur (meta, index, type) { meta.valueIsEditing = false + for (let i = 0; i < this.rule.length; i++) { + const item = this.rule[i] + const reg = new RegExp(item.regex) + if (!reg.test(meta.value)) { + meta.value = '' + this.$message.error(this.$t(item.tip)) + break + } + } this.$emit('update:valueList', this.metaList) this.$emit('change') }, diff --git a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue index d57b3cb79..dac428d55 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/chartRightBox.vue @@ -238,6 +238,9 @@ export default { if (params.type === 'table') { delete params.param.tags } + if (params.datasource === 'system' && params.param.datasource[0].filter) { + params.param.datasource[0].filter = params.param.datasource[0].filter.filter(item => item.value) + } if (params.id) { // 修改 this.$put('visual/panel/chart', params).then(response => { if (response.code === 200) {