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 io.dataease.extensions.view.util.FieldUtil;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -39,6 +40,25 @@ public class IndicatorHandler extends NumericalChartHandler {
|
|||||||
var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis);
|
var xAxis = formatResult.getAxisMap().get(ChartAxis.xAxis);
|
||||||
var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis);
|
var yAxis = formatResult.getAxisMap().get(ChartAxis.yAxis);
|
||||||
var allFields = (List<ChartViewFieldDTO>) filterResult.getContext().get("allFields");
|
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());
|
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());
|
Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, FieldUtil.transFields(allFields), crossDs, dsMap, Utils.getParams(FieldUtil.transFields(allFields)), view.getCalParams());
|
||||||
String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view);
|
String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view);
|
||||||
|
@ -91,6 +91,11 @@ const showValueFormatter = computed<boolean>(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const isEnableCompare = () => {
|
const isEnableCompare = () => {
|
||||||
|
// 指标卡开放同环比配置
|
||||||
|
if (chart.value.type === 'indicator') {
|
||||||
|
state.disableEditCompare = false
|
||||||
|
return
|
||||||
|
}
|
||||||
let xAxis = null
|
let xAxis = null
|
||||||
if (Object.prototype.toString.call(chart.value.xAxis) === '[object Array]') {
|
if (Object.prototype.toString.call(chart.value.xAxis) === '[object Array]') {
|
||||||
xAxis = JSON.parse(JSON.stringify(chart.value.xAxis))
|
xAxis = JSON.parse(JSON.stringify(chart.value.xAxis))
|
||||||
|
@ -17,6 +17,14 @@ const props = defineProps({
|
|||||||
chart: {
|
chart: {
|
||||||
type: Object,
|
type: Object,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
dimensionData: {
|
||||||
|
type: Array,
|
||||||
|
required: false
|
||||||
|
},
|
||||||
|
quotaData: {
|
||||||
|
type: Array,
|
||||||
|
required: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -36,6 +44,10 @@ watch(
|
|||||||
{ deep: true }
|
{ deep: true }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const isIndicator = () => {
|
||||||
|
return chart.value.type === 'indicator'
|
||||||
|
}
|
||||||
|
|
||||||
// 过滤xaxis,extStack所有日期字段
|
// 过滤xaxis,extStack所有日期字段
|
||||||
const initFieldList = () => {
|
const initFieldList = () => {
|
||||||
let xAxis = null
|
let xAxis = null
|
||||||
@ -61,6 +73,11 @@ const initFieldList = () => {
|
|||||||
|
|
||||||
t1.push(...t2)
|
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
|
state.fieldList = t1
|
||||||
// 如果没有选中字段,则默认选中第一个
|
// 如果没有选中字段,则默认选中第一个
|
||||||
@ -92,6 +109,15 @@ const initCompareType = () => {
|
|||||||
} else {
|
} else {
|
||||||
state.compareList = []
|
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 (
|
if (
|
||||||
(!compareItem.value.compareCalc.type ||
|
(!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()
|
initFieldList()
|
||||||
initCompareType()
|
initCompareType()
|
||||||
</script>
|
</script>
|
||||||
@ -119,7 +153,7 @@ initCompareType()
|
|||||||
<el-option
|
<el-option
|
||||||
v-for="field in state.fieldList"
|
v-for="field in state.fieldList"
|
||||||
:key="field.id"
|
:key="field.id"
|
||||||
:label="field.name + '(' + t('chart.' + field.dateStyle) + ')'"
|
:label="fieldFormatter(field)"
|
||||||
:value="field.id"
|
:value="field.id"
|
||||||
/>
|
/>
|
||||||
</el-select>
|
</el-select>
|
||||||
@ -150,7 +184,7 @@ initCompareType()
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item :label="t('chart.tip')">
|
<el-form-item :label="t('chart.tip')">
|
||||||
<span class="exp-style">
|
<span class="exp-style" style="padding-top: 2px">
|
||||||
当对比日期需要过滤时,请使用过滤组件实现过滤;使用视图过滤器,仪表板下钻和联动等功能,会导致结果不一致
|
当对比日期需要过滤时,请使用过滤组件实现过滤;使用视图过滤器,仪表板下钻和联动等功能,会导致结果不一致
|
||||||
</span>
|
</span>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -159,14 +193,15 @@ initCompareType()
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.el-form-item {
|
.ed-form-item {
|
||||||
margin-bottom: 10px !important;
|
margin-bottom: 10px !important;
|
||||||
}
|
}
|
||||||
.compare-form :deep(.el-form-item__label) {
|
.compare-form :deep(.ed-form-item__label) {
|
||||||
font-size: 12px !important;
|
font-size: 12px !important;
|
||||||
font-weight: 400 !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-size: 12px !important;
|
||||||
font-weight: 400 !important;
|
font-weight: 400 !important;
|
||||||
}
|
}
|
||||||
|
@ -3351,7 +3351,12 @@ const deleteChartFieldItem = id => {
|
|||||||
width="600px"
|
width="600px"
|
||||||
class="dialog-css"
|
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>
|
<template #footer>
|
||||||
<div class="dialog-footer">
|
<div class="dialog-footer">
|
||||||
<el-button @click="closeQuotaEditCompare">{{ t('chart.cancel') }} </el-button>
|
<el-button @click="closeQuotaEditCompare">{{ t('chart.cancel') }} </el-button>
|
||||||
|
@ -53,13 +53,8 @@ export class IndicatorChartView extends AbstractChartView {
|
|||||||
],
|
],
|
||||||
'function-cfg': ['emptyDataStrategy']
|
'function-cfg': ['emptyDataStrategy']
|
||||||
}
|
}
|
||||||
axis: AxisType[] = ['xAxis', 'yAxis', 'filter']
|
axis: AxisType[] = ['yAxis', 'filter']
|
||||||
axisConfig: AxisConfig = {
|
axisConfig: AxisConfig = {
|
||||||
xAxis: {
|
|
||||||
name: `日期 / ${t('chart.dimension')}`,
|
|
||||||
limit: 1,
|
|
||||||
type: 'd'
|
|
||||||
},
|
|
||||||
yAxis: {
|
yAxis: {
|
||||||
name: `${t('chart.quota')}`,
|
name: `${t('chart.quota')}`,
|
||||||
limit: 1
|
limit: 1
|
||||||
|
Loading…
Reference in New Issue
Block a user