forked from github/dataease
fix(图表-指标卡): 去除日期维度配置,同环比配置优化
This commit is contained in:
parent
0b5c026a07
commit
075d0f6859
@ -13,6 +13,7 @@ import io.dataease.extensions.view.dto.*;
|
||||
import io.dataease.extensions.view.util.FieldUtil;
|
||||
import lombok.Getter;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -39,6 +40,25 @@ public class IndicatorHandler extends NumericalChartHandler {
|
||||
var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis);
|
||||
var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis);
|
||||
var allFields = (List<ChartViewFieldDTO>) filterResult.getContext().get("allFields");
|
||||
ChartViewFieldDTO chartViewFieldDTO = yAxis.get(0);
|
||||
ChartFieldCompareDTO compareCalc = chartViewFieldDTO.getCompareCalc();
|
||||
boolean isYoy = org.apache.commons.lang3.StringUtils.isNotEmpty(compareCalc.getType())
|
||||
&& !org.apache.commons.lang3.StringUtils.equalsIgnoreCase(compareCalc.getType(), "none");
|
||||
if (isYoy) {
|
||||
xAxis.clear();
|
||||
// 设置维度字段,从同环比中获取用户选择的字段
|
||||
xAxis.addAll(allFields.stream().filter(i-> StringUtils.endsWithIgnoreCase(i.getId().toString(),yAxis.get(0).getCompareCalc().getField().toString())).toList());
|
||||
xAxis.get(0).setSort("desc");
|
||||
if(StringUtils.endsWithIgnoreCase("month_mom",compareCalc.getType())){
|
||||
xAxis.get(0).setDateStyle("y_M");
|
||||
}
|
||||
if(StringUtils.endsWithIgnoreCase("day_mom",compareCalc.getType())){
|
||||
xAxis.get(0).setDateStyle("y_M_d");
|
||||
}
|
||||
if(StringUtils.endsWithIgnoreCase("year_mom",compareCalc.getType())){
|
||||
xAxis.get(0).setDateStyle("y");
|
||||
}
|
||||
}
|
||||
Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, FieldUtil.transFields(allFields), crossDs, dsMap, Utils.getParams(FieldUtil.transFields(allFields)), view.getCalParams());
|
||||
Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, FieldUtil.transFields(allFields), crossDs, dsMap, Utils.getParams(FieldUtil.transFields(allFields)), view.getCalParams());
|
||||
String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view);
|
||||
|
@ -91,6 +91,11 @@ const showValueFormatter = computed<boolean>(() => {
|
||||
})
|
||||
|
||||
const isEnableCompare = () => {
|
||||
// 指标卡开放同环比配置
|
||||
if (chart.value.type === 'indicator') {
|
||||
state.disableEditCompare = false
|
||||
return
|
||||
}
|
||||
let xAxis = null
|
||||
if (Object.prototype.toString.call(chart.value.xAxis) === '[object Array]') {
|
||||
xAxis = JSON.parse(JSON.stringify(chart.value.xAxis))
|
||||
|
@ -17,6 +17,14 @@ const props = defineProps({
|
||||
chart: {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
dimensionData: {
|
||||
type: Array,
|
||||
required: false
|
||||
},
|
||||
quotaData: {
|
||||
type: Array,
|
||||
required: false
|
||||
}
|
||||
})
|
||||
|
||||
@ -36,6 +44,10 @@ watch(
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
const isIndicator = () => {
|
||||
return chart.value.type === 'indicator'
|
||||
}
|
||||
|
||||
// 过滤xaxis,extStack所有日期字段
|
||||
const initFieldList = () => {
|
||||
let xAxis = null
|
||||
@ -61,6 +73,11 @@ const initFieldList = () => {
|
||||
|
||||
t1.push(...t2)
|
||||
}
|
||||
if (isIndicator) {
|
||||
t1.length = 0
|
||||
t1.push(...props.dimensionData.filter(ele => ele.deType === 1))
|
||||
t1.push(...props.quotaData.filter(ele => ele.deType === 1))
|
||||
}
|
||||
|
||||
state.fieldList = t1
|
||||
// 如果没有选中字段,则默认选中第一个
|
||||
@ -92,6 +109,15 @@ const initCompareType = () => {
|
||||
} else {
|
||||
state.compareList = []
|
||||
}
|
||||
if (isIndicator) {
|
||||
state.compareList = [
|
||||
{ name: 'day_mom', value: 'day_mom' },
|
||||
{ name: 'month_mom', value: 'month_mom' },
|
||||
{ name: 'year_mom', value: 'year_mom' },
|
||||
{ name: 'month_yoy', value: 'month_yoy' },
|
||||
{ name: 'year_yoy', value: 'year_yoy' }
|
||||
]
|
||||
}
|
||||
// 如果没有选中一个同环比类型,则默认选中第一个
|
||||
if (
|
||||
(!compareItem.value.compareCalc.type ||
|
||||
@ -103,6 +129,14 @@ const initCompareType = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const fieldFormatter = field => {
|
||||
if (isIndicator) {
|
||||
return field.name
|
||||
} else {
|
||||
return field.name + '(' + t('chart.' + field.dateStyle) + ')'
|
||||
}
|
||||
}
|
||||
|
||||
initFieldList()
|
||||
initCompareType()
|
||||
</script>
|
||||
@ -119,7 +153,7 @@ initCompareType()
|
||||
<el-option
|
||||
v-for="field in state.fieldList"
|
||||
:key="field.id"
|
||||
:label="field.name + '(' + t('chart.' + field.dateStyle) + ')'"
|
||||
:label="fieldFormatter(field)"
|
||||
:value="field.id"
|
||||
/>
|
||||
</el-select>
|
||||
@ -150,7 +184,7 @@ initCompareType()
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="t('chart.tip')">
|
||||
<span class="exp-style">
|
||||
<span class="exp-style" style="padding-top: 2px">
|
||||
当对比日期需要过滤时,请使用过滤组件实现过滤;使用视图过滤器,仪表板下钻和联动等功能,会导致结果不一致
|
||||
</span>
|
||||
</el-form-item>
|
||||
@ -159,14 +193,15 @@ initCompareType()
|
||||
</template>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.el-form-item {
|
||||
.ed-form-item {
|
||||
margin-bottom: 10px !important;
|
||||
}
|
||||
.compare-form :deep(.el-form-item__label) {
|
||||
.compare-form :deep(.ed-form-item__label) {
|
||||
font-size: 12px !important;
|
||||
font-weight: 400 !important;
|
||||
padding-top: 8px !important;
|
||||
}
|
||||
.compare-form :deep(.el-radio__label) {
|
||||
.compare-form :deep(.ed-radio__label) {
|
||||
font-size: 12px !important;
|
||||
font-weight: 400 !important;
|
||||
}
|
||||
|
@ -3351,7 +3351,12 @@ const deleteChartFieldItem = id => {
|
||||
width="600px"
|
||||
class="dialog-css"
|
||||
>
|
||||
<compare-edit :compare-item="state.quotaItemCompare" :chart="view" />
|
||||
<compare-edit
|
||||
:compare-item="state.quotaItemCompare"
|
||||
:chart="view"
|
||||
:dimension-data="dimensionData"
|
||||
:quota-data="quotaData"
|
||||
/>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="closeQuotaEditCompare">{{ t('chart.cancel') }} </el-button>
|
||||
|
@ -53,13 +53,8 @@ export class IndicatorChartView extends AbstractChartView {
|
||||
],
|
||||
'function-cfg': ['emptyDataStrategy']
|
||||
}
|
||||
axis: AxisType[] = ['xAxis', 'yAxis', 'filter']
|
||||
axis: AxisType[] = ['yAxis', 'filter']
|
||||
axisConfig: AxisConfig = {
|
||||
xAxis: {
|
||||
name: `日期 / ${t('chart.dimension')}`,
|
||||
limit: 1,
|
||||
type: 'd'
|
||||
},
|
||||
yAxis: {
|
||||
name: `${t('chart.quota')}`,
|
||||
limit: 1
|
||||
|
Loading…
Reference in New Issue
Block a user