diff --git a/nezha-fronted/src/assets/css/components/common/filterSearch/filterSearch.scss b/nezha-fronted/src/assets/css/components/common/filterSearch/filterSearch.scss new file mode 100644 index 000000000..88e74bad7 --- /dev/null +++ b/nezha-fronted/src/assets/css/components/common/filterSearch/filterSearch.scss @@ -0,0 +1,103 @@ +.tag-search { + display: flex; + align-items: center; + height: 30px; + overflow: auto hidden; + border: 1px solid #CECECE; + border-radius: 2px; + padding-left: 10px; + padding-right: 80px; + background-color: white; + .cursor-pointer{ + cursor: pointer !important; + } + .el-input__inner{ + height: 20px !important; + line-height: 20px !important; + width: 166px !important; + } + &::-webkit-scrollbar { + width: 8px; + height: 8px; + } + + .tag-search__meta, .tag-search__add { + margin-right: 10px; + flex-shrink: 0; + } + + .tag-search__add { + display: flex; + align-items: center; + height: 22px; + padding: 0 4px; + font-size: 12px; + color: #333; + background-color: #F5F6F7; + border: 1px solid #D7D7D7; + border-radius: 1px; + cursor: pointer; + transition: all linear .1s; + + &:hover { + background-color: white; + color: #111; + } + } + + .tag-search__meta { + display: flex; + height: 22px; + padding: 0 6px; + font-size: 12px; + background-color: #F5F6F7; + + &>div:not(:last-of-type) { + margin-right: 6px; + } + + &.tag-search__meta--condition { + .condition__delete { + display: flex; + align-items: center; + color: #bcbdbd; + font-size: 16px; + margin-right: 6px; + cursor: pointer; + transition: all linear .1s; + + &:hover { + color: #999; + } + } + .condition__column, .condition__operator, .condition__value { + display: flex; + align-items: center; + color: #333; + font-weight: bold; + cursor: text; + } + .condition__operator { + color: #3976CB; + } + .condition__operation-select { + display: flex; + align-items: center; + + .condition__operation { + margin: 0 5px; + color: #3976CB; + } + } + } + &.tag-search__meta--connection { + .connection__value { + display: flex; + align-items: center; + color: #3976CB; + font-weight: bold; + cursor: text; + } + } + } +} diff --git a/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss b/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss index be12cf7ae..7585a5d86 100644 --- a/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss +++ b/nezha-fronted/src/assets/css/components/common/rightBox/chartRightBox/chartRightBox.scss @@ -209,6 +209,7 @@ flex: 1; margin-left: 10px; height: 100%; + width: calc(60% - 10px); } //.el-select__tags > span { // display: flex; diff --git a/nezha-fronted/src/assets/css/components/index.scss b/nezha-fronted/src/assets/css/components/index.scss index 326dca1cd..14d2fbab5 100644 --- a/nezha-fronted/src/assets/css/components/index.scss +++ b/nezha-fronted/src/assets/css/components/index.scss @@ -66,6 +66,7 @@ @import './common/pagination.scss'; @import './common/searchInput.scss'; @import './common/timePicker.scss'; +@import './common/filterSearch/filterSearch.scss'; @import './layout/container.scss'; @import './layout/header.scss'; diff --git a/nezha-fronted/src/components/common/filterSearch/filterSearch.js b/nezha-fronted/src/components/common/filterSearch/filterSearch.js new file mode 100644 index 000000000..7eb4b2070 --- /dev/null +++ b/nezha-fronted/src/components/common/filterSearch/filterSearch.js @@ -0,0 +1,76 @@ +import _ from 'lodash' +export const connection = 'connection' +export const condition = 'condition' +export const columnType = { + fullText: 'fullText', + string: 'string', + long: 'long', + number: 'number', + array: 'array' +} +export default class Meta { + // meta元数据有两种,一是condition,表示字段、操作符、值的组合,二是connection,是condition之间的连接符,AND | OR + constructor (type) { + switch (type) { + case connection: { + this.newConnection() + break + } + default: { + this.newCondition() + break + } + } + } + + newConnection () { + this.meta = connection + this.value = 'AND' + this.isEditing = false + } + + newCondition () { + this.meta = condition + this.name = '' + this.nameIsEditing = false + this.oper = '' + this.operIsEditing = false + this.value = '' + this.valueIsEditing = false + } + + isEmpty () { + if (this.meta === condition) { + return _.isEmpty(this.name) + } else { + return true + } + } + + // 取消editing状态 + cancelEditing () { + if (this.meta === condition) { + this.nameIsEditing = false + this.operIsEditing = false + this.valueIsEditing = false + } + if (this.meta === connection) { + this.isEditing = false + } + } + + // 是否是完整的condition + isCompleteCondition () { + return this.name && this.oper && this.value + } + + resetOperator () { + this.oper = '' + this.operIsEditing = false + } + + resetValue () { + this.value = '' + this.valueIsEditing = false + } +} diff --git a/nezha-fronted/src/components/common/filterSearch/filterSearch.vue b/nezha-fronted/src/components/common/filterSearch/filterSearch.vue index 0740f0f82..239e0ae47 100644 --- a/nezha-fronted/src/components/common/filterSearch/filterSearch.vue +++ b/nezha-fronted/src/components/common/filterSearch/filterSearch.vue @@ -1,12 +1,200 @@ diff --git a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue index abbc6c8ca..96e2f8006 100644 --- a/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue +++ b/nezha-fronted/src/components/common/rightBox/chart/systemChartConfig.vue @@ -100,9 +100,9 @@ prop="param.filter" > @@ -662,6 +662,9 @@ export default { isGauge, init () { this.chartConfig = JSON.parse(JSON.stringify(this.params)) + if (!this.chartConfig.param.datasource[0].filter) { + this.chartConfig.param.datasource[0].filter = [] + } this.oldType = this.chartConfig.type }, getSystemData () { @@ -675,11 +678,13 @@ export default { this.chartConfig.param.datasource[0].type = this.systemData[0].name this.groupList = this.systemData[0].group this.selectList = this.systemData[0].select + this.keyList = this.systemData[0].filter } else { const system = this.systemData.find(item => item.name === this.chartConfig.param.datasource[0].type) this.chartConfig.param.system = system.name this.groupList = system.group this.selectList = system.select + this.keyList = system.filter } this.$refs.chartForm && this.$refs.chartForm.clearValidate() } @@ -764,8 +769,10 @@ export default { this.chartConfig.param.datasource[0].systemSelect = '' this.chartConfig.param.datasource[0].group = '' this.chartConfig.param.datasource[0].select = '' + this.chartConfig.param.datasource[0].filter = [] this.groupList = item.group this.selectList = JSON.parse(JSON.stringify(item.select)) + this.keyList = JSON.parse(JSON.stringify(item.filter)) }, systemGroupChange (index) { this.chartConfig.param.datasource[index].group = this.chartConfig.param.datasource[index].systemGroup.map(item => {