mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-11 12:07:42 +00:00
fix: 新建模型,存在多个度量的情况下,度量的扩展配置均会显示成第1个度量中的值; (#1909)
* fix(semantic-model): 新建模型,存在多个度量的情况下,度量的扩展配置均会显示成第1个度量中的值 * refactor(semantic-model): 新建模型,扩展配置的取值方式,find重构成解构 --------- Co-authored-by: tristanliu <37809633+sevenliu1896@users.noreply.github.com>
This commit is contained in:
@@ -1,19 +1,19 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Table, Select, Checkbox, Input, Space, Tooltip, Form, Switch, Row, Col } from 'antd';
|
import { Checkbox, Form, Input, Select, Space, Switch, Table, Tooltip } from 'antd';
|
||||||
import TableTitleTooltips from '../../components/TableTitleTooltips';
|
import TableTitleTooltips from '../../components/TableTitleTooltips';
|
||||||
import { isUndefined } from 'lodash';
|
import { isUndefined } from 'lodash';
|
||||||
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
||||||
import SqlEditor from '@/components/SqlEditor';
|
import SqlEditor from '@/components/SqlEditor';
|
||||||
import { ISemantic } from '../../data';
|
import { ISemantic } from '../../data';
|
||||||
import {
|
import {
|
||||||
TYPE_OPTIONS,
|
|
||||||
DATE_FORMATTER,
|
|
||||||
AGG_OPTIONS,
|
AGG_OPTIONS,
|
||||||
EnumDataSourceType,
|
DATE_FORMATTER,
|
||||||
DATE_OPTIONS,
|
DATE_OPTIONS,
|
||||||
DIM_OPTIONS,
|
DIM_OPTIONS,
|
||||||
|
EnumDataSourceType,
|
||||||
EnumModelDataType,
|
EnumModelDataType,
|
||||||
PARTITION_TIME_FORMATTER,
|
PARTITION_TIME_FORMATTER,
|
||||||
|
TYPE_OPTIONS,
|
||||||
} from '../constants';
|
} from '../constants';
|
||||||
import styles from '../style.less';
|
import styles from '../style.less';
|
||||||
|
|
||||||
@@ -90,8 +90,7 @@ const ModelFieldForm: React.FC<Props> = ({
|
|||||||
dataIndex: 'type',
|
dataIndex: 'type',
|
||||||
width: 250,
|
width: 250,
|
||||||
render: (_: any, record: FieldItem) => {
|
render: (_: any, record: FieldItem) => {
|
||||||
const type = fields.find((field) => field.bizName === record.bizName)?.type;
|
const { type, classType } = record;
|
||||||
const classType = fields.find((field) => field.bizName === record.bizName)?.classType;
|
|
||||||
const selectTypeValue = [EnumModelDataType.DIMENSION].includes(classType)
|
const selectTypeValue = [EnumModelDataType.DIMENSION].includes(classType)
|
||||||
? classType
|
? classType
|
||||||
: type;
|
: type;
|
||||||
@@ -229,13 +228,10 @@ const ModelFieldForm: React.FC<Props> = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (type === EnumDataSourceType.MEASURES) {
|
if (type === EnumDataSourceType.MEASURES) {
|
||||||
const agg = record.expr
|
|
||||||
? fields.find((field) => field.expr === record.expr)?.agg
|
|
||||||
: undefined;
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
placeholder="度量算子"
|
placeholder="度量算子"
|
||||||
value={agg}
|
value={record.agg}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
handleFieldChange(record, 'agg', value);
|
handleFieldChange(record, 'agg', value);
|
||||||
}}
|
}}
|
||||||
@@ -251,7 +247,6 @@ const ModelFieldForm: React.FC<Props> = ({
|
|||||||
</Select>
|
</Select>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.SHOW_TAG) {
|
if (process.env.SHOW_TAG) {
|
||||||
if (type === EnumDataSourceType.CATEGORICAL) {
|
if (type === EnumDataSourceType.CATEGORICAL) {
|
||||||
const isTag = fields.find((field) => field.bizName === record.bizName)?.isTag;
|
const isTag = fields.find((field) => field.bizName === record.bizName)?.isTag;
|
||||||
@@ -299,10 +294,7 @@ const ModelFieldForm: React.FC<Props> = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ([EnumDataSourceType.TIME, EnumDataSourceType.PARTITION_TIME].includes(type)) {
|
if ([EnumDataSourceType.TIME, EnumDataSourceType.PARTITION_TIME].includes(type)) {
|
||||||
const dateFormat = fields.find((field) => field.bizName === record.bizName)?.dateFormat;
|
const { dateFormat, timeGranularity } = record;
|
||||||
const timeGranularity = fields.find(
|
|
||||||
(field) => field.bizName === record.bizName,
|
|
||||||
)?.timeGranularity;
|
|
||||||
const dateFormatterOptions =
|
const dateFormatterOptions =
|
||||||
type === EnumDataSourceType.PARTITION_TIME ? PARTITION_TIME_FORMATTER : DATE_FORMATTER;
|
type === EnumDataSourceType.PARTITION_TIME ? PARTITION_TIME_FORMATTER : DATE_FORMATTER;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user