feat(视图):视图指标增加数量字段

This commit is contained in:
junjie 2021-04-25 15:10:49 +08:00
parent 9302d0f092
commit e3099e9cb2
5 changed files with 34 additions and 14 deletions

View File

@ -256,7 +256,7 @@ public class ChartViewService {
public String transMysqlSQL(String table, List<ChartViewFieldDTO> xAxis, List<ChartViewFieldDTO> yAxis, List<ChartExtFilterRequest> extFilterRequestList) {
// 字段汇总 排序等
String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getOriginName() + ") AS DECIMAL(20,2)) AS _" + y.getSummary() + "_" + y.getOriginName()).toArray(String[]::new);
String[] field = yAxis.stream().map(y -> "CAST(" + y.getSummary() + "(" + y.getOriginName() + ") AS DECIMAL(20,2)) AS _" + y.getSummary() + "_" + (StringUtils.equalsIgnoreCase(y.getOriginName(), "*") ? "" : y.getOriginName())).toArray(String[]::new);
String[] group = xAxis.stream().map(ChartViewFieldDTO::getOriginName).toArray(String[]::new);
String[] order = yAxis.stream().filter(y -> StringUtils.isNotEmpty(y.getSort()) && !StringUtils.equalsIgnoreCase(y.getSort(), "none"))
.map(y -> "_" + y.getSummary() + "_" + y.getOriginName() + " " + y.getSort()).toArray(String[]::new);

View File

@ -135,6 +135,19 @@ public class DataSetTableService {
dimension.add(field);
}
});
// quota add count
DatasetTableField count = DatasetTableField.builder()
.id("count")
.tableId(dataSetTableRequest.getId())
.originName("*")
.name("记录数*")
.type("INT")
.checked(true)
.columnIndex(999)
.deType(2)
.build();
quota.add(count);
Map<String, List<DatasetTableField>> map = new HashMap<>();
map.put("dimension", dimension);
map.put("quota", quota);

View File

@ -699,7 +699,8 @@ export default {
area_mode: '面积',
rose_radius: '圆角',
view_name: '视图名称',
name_can_not_empty: '名称不能为空'
name_can_not_empty: '名称不能为空',
custom_count: '记录数'
},
dataset: {
datalist: '数据集',

View File

@ -3,7 +3,9 @@
<el-dropdown trigger="click" size="mini" @command="clickItem">
<span class="el-dropdown-link">
<el-tag size="small" class="item-axis">
{{ item.name }}<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span><i class="el-icon-arrow-down el-icon--right" />
<span>{{ item.name }}</span>
<span v-if="item.summary" class="summary-span">{{ $t('chart.'+item.summary) }}</span>
<i class="el-icon-arrow-down el-icon--right" />
</el-tag>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item>
@ -17,17 +19,17 @@
<i class="el-icon-arrow-right el-icon--right" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeSummary('sum')">{{ $t('chart.sum') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('count')">{{ $t('chart.count') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('avg')">{{ $t('chart.avg') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('max')">{{ $t('chart.max') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('min')">{{ $t('chart.min') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('stddev_pop')">{{ $t('chart.stddev_pop') }}</el-dropdown-item>
<el-dropdown-item :command="beforeSummary('var_pop')">{{ $t('chart.var_pop') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id === 'count'" :command="beforeSummary('count')">{{ $t('chart.count') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('sum')">{{ $t('chart.sum') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('avg')">{{ $t('chart.avg') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('max')">{{ $t('chart.max') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('min')">{{ $t('chart.min') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('stddev_pop')">{{ $t('chart.stddev_pop') }}</el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'" :command="beforeSummary('var_pop')">{{ $t('chart.var_pop') }}</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-dropdown-item>
<el-dropdown-item>
<el-dropdown-item v-if="item.id !== 'count'">
<el-dropdown placement="right-start" size="mini" style="width: 100%" @command="quickCalc">
<span class="el-dropdown-link inner-dropdown-menu">
<span>

View File

@ -1,6 +1,6 @@
<template>
<el-row style="height: 100%;overflow-y: hidden;width: 100%;">
<!-- <span v-show="false">{{ vId }}</span>-->
<!-- <span v-show="false">{{ vId }}</span>-->
<el-row style="height: 40px;background-color: white" class="padding-lr">
<el-popover
placement="right-start"
@ -62,7 +62,7 @@
<svg-icon v-if="item.deType === 0" icon-class="field_text" class="field-icon-text" />
<svg-icon v-if="item.deType === 1" icon-class="field_time" class="field-icon-time" />
<svg-icon v-if="item.deType === 2 || item.deType === 3" icon-class="field_value" class="field-icon-value" />
{{ item.name }}
<span>{{ item.name }}</span>
</span>
</transition-group>
</draggable>
@ -368,7 +368,11 @@ export default {
// })
view.yaxis.forEach(function(ele) {
if (!ele.summary || ele.summary === '') {
ele.summary = 'sum'
if (ele.id === 'count') {
ele.summary = 'count'
} else {
ele.summary = 'sum'
}
}
if (!ele.sort || ele.sort === '') {
ele.sort = 'none'