[Core] [DataSet] Add filter grouping

This commit is contained in:
qianmoQ 2024-02-25 16:16:50 +08:00
parent 15b5bcd679
commit 40db677b34
3 changed files with 37 additions and 6 deletions

View File

@ -24,6 +24,7 @@ export default {
columnModeMetric: 'Metric',
columnModeDimension: 'Dimension',
columnModeGroup: 'Group',
columnModeFilter: 'Filter',
columnSortNone: 'None',
columnOrderAsc: 'Ascending',
columnOrderDesc: 'Descending',
@ -75,5 +76,5 @@ export default {
columnExpressionAvg: 'Average',
columnExpressionCount: 'Count',
validatorSamplingTip: 'The order by key must contain a sampling key',
customFunction: 'Custom Function'
customFunction: 'Custom Function',
}

View File

@ -24,6 +24,7 @@ export default {
columnModeMetric: '指标',
columnModeDimension: '维度',
columnModeGroup: '分组',
columnModeFilter: '筛选器',
columnSortNone: '无',
columnOrderAsc: '升序',
columnOrderDesc: '降序',
@ -75,5 +76,5 @@ export default {
columnExpressionAvg: '平均值',
columnExpressionCount: '计数',
validatorSamplingTip: '排序键中必须包含抽样键',
customFunction: '自定义函数'
customFunction: '自定义函数',
}

View File

@ -118,7 +118,27 @@
:content="$t('common.remove')">
<FontAwesomeIcon icon="trash"
class="point"
@click="handlerRemove(element.id, index, groups, true)">
@click="handlerRemove(element.id, index, groups, 'group')">
</FontAwesomeIcon>
</Tooltip>
</Tag>
</template>
</Draggable>
</ListItem>
<ListItem>
{{ $t('dataset.columnModeFilter') }}: &nbsp;
<Draggable group="dimensions"
item-key="id"
:list="filters">
<template #item="{ element, index}">
<Tag size="medium"
class="point">
{{ element.aliasName ? element.aliasName : element.name }} &nbsp;
<Tooltip transfer
:content="$t('common.remove')">
<FontAwesomeIcon icon="trash"
class="point"
@click="handlerRemove(element.id, index, filters, 'filter')">
</FontAwesomeIcon>
</Tooltip>
</Tag>
@ -365,9 +385,11 @@ export default {
metrics: [],
dimensions: [],
groups: [],
filters: [],
configure: {
columns: [],
groups: [],
filters: [],
limit: 1000
},
configuration: null as Configuration,
@ -402,6 +424,10 @@ export default {
groups: {
handler: 'handlerApplyAdhoc',
deep: true
},
filters: {
handler: 'handlerApplyAdhoc',
deep: true
}
},
created()
@ -505,13 +531,16 @@ export default {
{
return value
},
handlerRemove(id: number, index: number, array: [], isGroup?: boolean)
handlerRemove(id: number, index: number, array: [], type?: string)
{
array.splice(index, 1)
this.configure.columns = this.configure.columns.filter((item: { id: number; }) => item.id !== id)
if (isGroup) {
if (type === 'group') {
this.configure.groups = this.configure.groups.filter((item: { id: number; }) => item.id !== id)
}
else if (type === 'filter') {
this.configure.filters = this.configure.filters.filter((item: { id: number; }) => item.id !== id)
}
this.handlerAdhoc()
},
handlerCommit(value: any)
@ -543,7 +572,7 @@ export default {
if (foundIndex !== -1) {
this.configure.columns.splice(foundIndex, 1, value)
if (value.mode === ColumnType.METRIC) {
this.metrics.find((item: { id: any; }) => item.id === value.id).expression = value.expression
this.metrics.find((item: { id: number; }) => item.id === value.id).expression = value.expression
}
this.handlerAdhoc()
}