mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-20 06:34:55 +00:00
[improvement][headless-fe] Restructured the data for the dimension value settings interface. (#760)
* [improvement][semantic-fe] Add model alias setting & Add view permission restrictions to the model permission management tab. [improvement][semantic-fe] Add permission control to the action buttons for the main domain; apply high sensitivity filtering to the authorization of metrics/dimensions. [improvement][semantic-fe] Optimize the editing mode in the dimension/metric/datasource components to use the modelId stored in the database for data, instead of relying on the data from the state manager. * [improvement][semantic-fe] Add time granularity setting in the data source configuration. * [improvement][semantic-fe] Dictionary import for dimension values supported in Q&A visibility * [improvement][semantic-fe] Modification of data source creation prompt wording" * [improvement][semantic-fe] metric market experience optimization * [improvement][semantic-fe] enhance the analysis of metric trends * [improvement][semantic-fe] optimize the presentation of metric trend permissions * [improvement][semantic-fe] add metric trend download functionality * [improvement][semantic-fe] fix the dimension initialization issue in metric correlation * [improvement][semantic-fe] Fix the issue of database changes not taking effect when creating based on an SQL data source. * [improvement][semantic-fe] Optimizing pagination logic and some CSS styles * [improvement][semantic-fe] Fixing the API for the indicator list by changing "current" to "pageNum" * [improvement][semantic-fe] Fixing the default value setting for the indicator list * [improvement][semantic-fe] Adding batch operations for indicators/dimensions/models * [improvement][semantic-fe] Replacing the single status update API for indicators/dimensions with a batch update API * [improvement][semantic-fe] Redesigning the indicator homepage to incorporate trend charts and table functionality for indicators * [improvement][semantic-fe] Optimizing the logic for setting dimension values and editing data sources, and adding system settings functionality * [improvement][semantic-fe] Upgrading antd version to 5.x, extracting the batch operation button component, optimizing the interaction for system settings, and expanding the configuration generation types for list-to-select component. * [improvement][semantic-fe] Adding the ability to filter dimensions based on whether they are tags or not. * [improvement][semantic-fe] Adding the ability to edit relationships between models in the canvas. * [improvement][semantic-fe] Updating the datePicker component to use dayjs instead. * [improvement][semantic-fe] Fixing the issue with passing the model ID for dimensions in the indicator market. * [improvement][semantic-fe] Fixing the abnormal state of the popup when creating a model. * [improvement][semantic-fe] Adding permission logic for bulk operations in the indicator market. * [improvement][semantic-fe] Adding the ability to download and transpose data. * [improvement][semantic-fe] Fixing the initialization issue with the date selection component in the indicator details page when switching time granularity. * [improvement][semantic-fe] Fixing the logic error in the dimension value setting. * [improvement][semantic-fe] Fixing the synchronization issue with the question and answer settings information. * [improvement][semantic-fe] Optimizing the canvas functionality for better performance and user experience. * [improvement][semantic-fe] Optimizing the update process for drawing model relationship edges in the canvas. * [improvement][semantic-fe] Changing the line type for canvas connections. * [improvement][semantic-fe] Replacing the initialization variable from "semantic" to "headless". * [improvement][semantic-fe] Fixing the missing migration issue for default drill-down dimension configuration in model editing. Additionally, optimizing the data retrieval method for initializing fields in the model. * [improvement][semantic-fe] Updating the logic for the fieldName. * [improvement][semantic-fe] Adjusting the position of the metrics tab. * [improvement][semantic-fe] Changing the 字段名称 to 英文名称. * [improvement][semantic-fe] Fix metric measurement deletion. * [improvement][semantic-fe] UI optimization for metric details page. * [improvement][semantic-fe] UI optimization for metric details page. * [improvement][semantic-fe] UI adjustment for metric details page. * [improvement][semantic-fe] The granularity field in the time type of model editing now supports setting it as empty. * [improvement][semantic-fe] Added field type and metric type to the metric creation options. * [improvement][semantic-fe] The organization structure selection feature has been added to the permission management. * [improvement][semantic-fe] Improved user experience for the metric list. * [improvement][semantic-fe] fix update the metric list. * [improvement][headless-fe] Added view management functionality. * [improvement][headless-fe] The view management functionality has been added. This feature allows users to create, edit, and manage different views within the system. * [improvement][headless-fe] Added model editing side effect detection. * [improvement][headless-fe] Fixed the logic error in view editing. * [improvement][headless-fe] Fixed the issue with initializing dimension associations in metric settings. * [improvement][headless-fe] Added the ability to hide the Q&A settings entry point. * [improvement][headless-fe] Fixed the issue with selecting search results in metric field creation. * [improvement][headless-fe] Added search functionality to the field list in model editing. * [improvement][headless-fe] fix the field list in model editing * [improvement][headless-fe] Restructured the data for the dimension value settings interface.
This commit is contained in:
@@ -184,7 +184,7 @@ const DimensionValueSettingModal: React.FC<CreateFormProps> = ({
|
||||
{
|
||||
label: '维度值设置',
|
||||
key: 'setting',
|
||||
children: <DimensionValueSettingForm modelId={modelId} dimensionItem={dimensionItem} />,
|
||||
children: <DimensionValueSettingForm dimensionItem={dimensionItem} />,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -1,244 +0,0 @@
|
||||
import { useEffect, useState, forwardRef, useImperativeHandle } from 'react';
|
||||
import type { ForwardRefRenderFunction } from 'react';
|
||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||
import { formLayout } from '@/components/FormHelper/utils';
|
||||
import { message, Form, Input, Select, Button, InputNumber } from 'antd';
|
||||
import { addDomainExtend, editDomainExtend } from '../../service';
|
||||
import {
|
||||
formatRichEntityDataListToIds,
|
||||
wrapperTransTypeAndId,
|
||||
splitListToTransTypeId,
|
||||
} from './utils';
|
||||
import styles from '../style.less';
|
||||
import { ISemantic } from '../../data';
|
||||
import { ChatConfigType, TransType, SemanticNodeType } from '../../enum';
|
||||
import TransTypeTag from '../TransTypeTag';
|
||||
|
||||
type Props = {
|
||||
entityData: any;
|
||||
chatConfigKey: string;
|
||||
chatConfigType: ChatConfigType.TAG | ChatConfigType.METRIC;
|
||||
metricList: ISemantic.IMetricItem[];
|
||||
dimensionList: ISemantic.IDimensionItem[];
|
||||
domainId: number;
|
||||
onSubmit: (params?: any) => void;
|
||||
};
|
||||
|
||||
const FormItem = Form.Item;
|
||||
const Option = Select.Option;
|
||||
|
||||
const formDefaultValue = {
|
||||
unit: 7,
|
||||
period: 'DAY',
|
||||
timeMode: 'LAST',
|
||||
};
|
||||
|
||||
const DefaultSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
{ metricList, dimensionList, entityData, chatConfigKey, chatConfigType, onSubmit },
|
||||
ref,
|
||||
) => {
|
||||
const [form] = Form.useForm();
|
||||
const [dataItemListOptions, setDataItemListOptions] = useState<any>([]);
|
||||
const formatEntityData = formatRichEntityDataListToIds(entityData);
|
||||
const getFormValidateFields = async () => {
|
||||
return await form.validateFields();
|
||||
};
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
getFormValidateFields,
|
||||
}));
|
||||
|
||||
useEffect(() => {
|
||||
form.resetFields();
|
||||
if (!(entityData?.id && entityData?.chatDefaultConfig)) {
|
||||
return;
|
||||
}
|
||||
const { chatDefaultConfig, id } = formatEntityData;
|
||||
form.setFieldsValue({
|
||||
...formDefaultValue,
|
||||
...chatDefaultConfig,
|
||||
id,
|
||||
});
|
||||
if (chatConfigType === ChatConfigType.TAG) {
|
||||
initDataItemValue(chatDefaultConfig);
|
||||
}
|
||||
}, [entityData, dataItemListOptions]);
|
||||
|
||||
const initDataItemValue = (chatDefaultConfig: {
|
||||
dimensionIds: number[];
|
||||
metricIds: number[];
|
||||
}) => {
|
||||
const { dimensionIds, metricIds } = chatDefaultConfig;
|
||||
const dimensionIdString = dimensionIds.map((dimensionId: number) => {
|
||||
return wrapperTransTypeAndId(TransType.DIMENSION, dimensionId);
|
||||
});
|
||||
const metricIdString = metricIds.map((metricId: number) => {
|
||||
return wrapperTransTypeAndId(TransType.METRIC, metricId);
|
||||
});
|
||||
form.setFieldsValue({
|
||||
dataItemIds: [...dimensionIdString, ...metricIdString],
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (Array.isArray(dimensionList) && Array.isArray(metricList)) {
|
||||
const dimensionEnum = dimensionList.map((item: ISemantic.IDimensionItem) => {
|
||||
const { name, id, bizName } = item;
|
||||
return {
|
||||
name,
|
||||
label: (
|
||||
<>
|
||||
<TransTypeTag type={SemanticNodeType.DIMENSION} />
|
||||
{name}
|
||||
</>
|
||||
),
|
||||
value: wrapperTransTypeAndId(TransType.DIMENSION, id),
|
||||
bizName,
|
||||
id,
|
||||
transType: TransType.DIMENSION,
|
||||
};
|
||||
});
|
||||
const metricEnum = metricList.map((item: ISemantic.IMetricItem) => {
|
||||
const { name, id, bizName } = item;
|
||||
return {
|
||||
name,
|
||||
label: (
|
||||
<>
|
||||
<TransTypeTag type={SemanticNodeType.METRIC} />
|
||||
{name}
|
||||
</>
|
||||
),
|
||||
value: wrapperTransTypeAndId(TransType.METRIC, id),
|
||||
bizName,
|
||||
id,
|
||||
transType: TransType.METRIC,
|
||||
};
|
||||
});
|
||||
setDataItemListOptions([...dimensionEnum, ...metricEnum]);
|
||||
}
|
||||
}, [dimensionList, metricList]);
|
||||
|
||||
const saveEntity = async () => {
|
||||
const values = await form.validateFields();
|
||||
const { id, dataItemIds } = values;
|
||||
let dimensionConfig = {};
|
||||
if (dataItemIds) {
|
||||
const { dimensionIds, metricIds } = splitListToTransTypeId(dataItemIds);
|
||||
dimensionConfig = {
|
||||
dimensionIds,
|
||||
metricIds,
|
||||
};
|
||||
}
|
||||
let saveDomainExtendQuery = addDomainExtend;
|
||||
if (id) {
|
||||
saveDomainExtendQuery = editDomainExtend;
|
||||
}
|
||||
const params = {
|
||||
...formatEntityData,
|
||||
chatDefaultConfig: { ...values, ...dimensionConfig },
|
||||
};
|
||||
const { modelId } = entityData;
|
||||
const { code, msg, data } = await saveDomainExtendQuery({
|
||||
[chatConfigKey]: params,
|
||||
modelId,
|
||||
id,
|
||||
});
|
||||
if (code === 200) {
|
||||
form.setFieldValue('id', data);
|
||||
onSubmit?.();
|
||||
message.success('保存成功');
|
||||
return;
|
||||
}
|
||||
message.error(msg);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Form
|
||||
{...formLayout}
|
||||
form={form}
|
||||
layout="vertical"
|
||||
className={styles.form}
|
||||
initialValues={formDefaultValue}
|
||||
>
|
||||
<FormItem hidden={true} name="id" label="ID">
|
||||
<Input placeholder="id" />
|
||||
</FormItem>
|
||||
|
||||
{chatConfigType === ChatConfigType.TAG && (
|
||||
<FormItem name="dataItemIds" label="圈选结果展示字段">
|
||||
<Select
|
||||
mode="multiple"
|
||||
allowClear
|
||||
style={{ width: '100%' }}
|
||||
optionLabelProp="name"
|
||||
filterOption={(inputValue: string, item: any) => {
|
||||
const { name } = item;
|
||||
if (name.includes(inputValue)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}}
|
||||
placeholder="请选择圈选结果展示字段"
|
||||
options={dataItemListOptions}
|
||||
/>
|
||||
</FormItem>
|
||||
)}
|
||||
<FormItem
|
||||
label={
|
||||
<FormItemTitle
|
||||
title={'时间范围'}
|
||||
subTitle={'问答搜索结果选择中,如果没有指定时间范围,将会采用默认时间范围'}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<Input.Group compact>
|
||||
{chatConfigType === ChatConfigType.TAG ? (
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
lineHeight: '32px',
|
||||
marginRight: '8px',
|
||||
}}
|
||||
>
|
||||
前
|
||||
</span>
|
||||
) : (
|
||||
<>
|
||||
<FormItem name={'timeMode'} noStyle>
|
||||
<Select style={{ width: '90px' }}>
|
||||
<Option value="LAST">前</Option>
|
||||
<Option value="RECENT">最近</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
</>
|
||||
)}
|
||||
<FormItem name={'unit'} noStyle>
|
||||
<InputNumber style={{ width: '120px' }} />
|
||||
</FormItem>
|
||||
<FormItem name={'period'} noStyle>
|
||||
<Select style={{ width: '90px' }}>
|
||||
<Option value="DAY">天</Option>
|
||||
<Option value="WEEK">周</Option>
|
||||
<Option value="MONTH">月</Option>
|
||||
<Option value="YEAR">年</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
</Input.Group>
|
||||
</FormItem>
|
||||
<FormItem>
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
saveEntity();
|
||||
}}
|
||||
>
|
||||
保 存
|
||||
</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default forwardRef(DefaultSettingForm);
|
||||
@@ -1,107 +1,118 @@
|
||||
import { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
||||
import type { ForwardRefRenderFunction } from 'react';
|
||||
import { Form, Input, Switch, Space, Button, Divider, Tooltip, message } from 'antd';
|
||||
import { Form, Switch, Space, Button, Tooltip, message, Select } from 'antd';
|
||||
import FormItemTitle from '@/components/FormHelper/FormItemTitle';
|
||||
import { RedoOutlined, InfoCircleOutlined } from '@ant-design/icons';
|
||||
import { formLayout } from '@/components/FormHelper/utils';
|
||||
import { DictTaskState, TransType } from '../../enum';
|
||||
import { DictTaskState, KnowledgeConfigTypeEnum, KnowledgeConfigStatusEnum } from '../../enum';
|
||||
import {
|
||||
getDomainExtendDetailConfig,
|
||||
addDomainExtend,
|
||||
editDomainExtend,
|
||||
searchKnowledgeConfigQuery,
|
||||
searchDictLatestTaskList,
|
||||
createDictTask,
|
||||
editDictConfig,
|
||||
createDictConfig,
|
||||
deleteDictTask,
|
||||
} from '../../service';
|
||||
import type { IChatConfig, ISemantic } from '../../data';
|
||||
import type { ISemantic } from '../../data';
|
||||
import { isString } from 'lodash';
|
||||
import styles from '../style.less';
|
||||
import CommonEditList from '../../components/CommonEditList';
|
||||
|
||||
type Props = {
|
||||
modelId: number;
|
||||
dimensionItem: ISemantic.IDimensionItem;
|
||||
onSubmit?: () => void;
|
||||
};
|
||||
|
||||
type TaskStateMap = Record<string, DictTaskState>;
|
||||
|
||||
const FormItem = Form.Item;
|
||||
|
||||
const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
{ modelId, dimensionItem },
|
||||
{ dimensionItem },
|
||||
ref,
|
||||
) => {
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const exchangeFields = ['blackList', 'whiteList'];
|
||||
const [modelRichConfigData, setModelRichConfigData] = useState<IChatConfig.IConfig>();
|
||||
const [dimensionVisible, setDimensionVisible] = useState<boolean>(false);
|
||||
const [taskStateMap, setTaskStateMap] = useState<TaskStateMap>({});
|
||||
const [taskItemState, setTaskItemState] = useState<ISemantic.IDictKnowledgeTaskItem>();
|
||||
const [saveLoading, setSaveLoading] = useState<boolean>(false);
|
||||
const [refreshLoading, setRefreshLoading] = useState<boolean>(false);
|
||||
const [knowledgeConfig, setKnowledgeConfig] = useState<ISemantic.IDictKnowledgeConfigItem>();
|
||||
|
||||
const queryThemeListData: any = async () => {
|
||||
const { code, data } = await getDomainExtendDetailConfig({
|
||||
modelId,
|
||||
});
|
||||
const [deleteLoading, setDeleteLoading] = useState<boolean>(false);
|
||||
const [importDictState, setImportDictState] = useState<boolean>(false);
|
||||
|
||||
if (code === 200) {
|
||||
setModelRichConfigData(data);
|
||||
const targetKnowledgeInfos = data?.chatAggRichConfig?.knowledgeInfos || [];
|
||||
const targetConfig = targetKnowledgeInfos.find(
|
||||
(item: IChatConfig.IKnowledgeInfosItem) => item.itemId === dimensionItem.id,
|
||||
);
|
||||
if (targetConfig) {
|
||||
const { knowledgeAdvancedConfig, searchEnable } = targetConfig;
|
||||
setDimensionVisible(searchEnable);
|
||||
const { blackList, whiteList, ruleList } = knowledgeAdvancedConfig;
|
||||
form.setFieldsValue({
|
||||
blackList: blackList.join(','),
|
||||
whiteList: whiteList.join(','),
|
||||
ruleList: ruleList || [],
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
message.error('获取问答设置信息失败');
|
||||
const defaultKnowledgeConfig: ISemantic.IDictKnowledgeConfigItemConfig = {
|
||||
blackList: [],
|
||||
whiteList: [],
|
||||
ruleList: [],
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
queryThemeListData();
|
||||
searchKnowledgeConfig();
|
||||
queryDictLatestTaskList();
|
||||
}, []);
|
||||
|
||||
const taskRender = (dimension: ISemantic.IDimensionItem) => {
|
||||
const { id, type } = dimension;
|
||||
const target = taskStateMap[id];
|
||||
if (type === TransType.DIMENSION && target) {
|
||||
return DictTaskState[target] || '未知状态';
|
||||
const taskRender = () => {
|
||||
if (taskItemState?.taskStatus) {
|
||||
return (
|
||||
<span style={{ color: '#5493ff', fontWeight: 'bold' }}>
|
||||
{DictTaskState[taskItemState.taskStatus] || '未知状态'}
|
||||
</span>
|
||||
);
|
||||
}
|
||||
return '--';
|
||||
};
|
||||
|
||||
const searchKnowledgeConfig = async () => {
|
||||
setRefreshLoading(true);
|
||||
const { code, data } = await searchKnowledgeConfigQuery({
|
||||
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||
itemId: dimensionItem.id,
|
||||
});
|
||||
|
||||
setRefreshLoading(false);
|
||||
if (code !== 200) {
|
||||
message.error('获取字典导入配置失败!');
|
||||
return;
|
||||
}
|
||||
const configItem = data[0];
|
||||
if (configItem) {
|
||||
const { status, config } = configItem;
|
||||
if (status === KnowledgeConfigStatusEnum.ONLINE) {
|
||||
setDimensionVisible(true);
|
||||
} else {
|
||||
setDimensionVisible(false);
|
||||
}
|
||||
form.setFieldsValue({
|
||||
...config,
|
||||
});
|
||||
setKnowledgeConfig(configItem);
|
||||
} else {
|
||||
form.setFieldsValue({
|
||||
...defaultKnowledgeConfig,
|
||||
});
|
||||
createDictConfigQuery(dimensionItem, defaultKnowledgeConfig);
|
||||
}
|
||||
};
|
||||
|
||||
const queryDictLatestTaskList = async () => {
|
||||
setRefreshLoading(true);
|
||||
searchKnowledgeConfigQuery({ itemId: dimensionItem.id });
|
||||
const { code, data } = await searchDictLatestTaskList({
|
||||
modelId,
|
||||
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||
itemId: dimensionItem.id,
|
||||
});
|
||||
setRefreshLoading(false);
|
||||
if (code !== 200) {
|
||||
message.error('获取字典导入任务失败!');
|
||||
return;
|
||||
}
|
||||
const tastMap = data.reduce(
|
||||
(stateMap: TaskStateMap, item: { dimId: number; status: DictTaskState }) => {
|
||||
const { dimId, status } = item;
|
||||
stateMap[dimId] = status;
|
||||
return stateMap;
|
||||
},
|
||||
{},
|
||||
);
|
||||
setTaskStateMap(tastMap);
|
||||
|
||||
if (data?.id) {
|
||||
if (data.taskStatus !== 'running') {
|
||||
setImportDictState(false);
|
||||
}
|
||||
setTaskItemState(data);
|
||||
}
|
||||
};
|
||||
|
||||
const getFormValidateFields = async () => {
|
||||
@@ -128,12 +139,29 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
getFormValidateFields,
|
||||
}));
|
||||
|
||||
const createDictConfigQuery = async (
|
||||
dimension: ISemantic.IDimensionItem,
|
||||
config: ISemantic.IDictKnowledgeConfigItemConfig,
|
||||
) => {
|
||||
const { code, data } = await createDictConfig({
|
||||
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||
itemId: dimension.id,
|
||||
config,
|
||||
status: 1,
|
||||
});
|
||||
|
||||
if (code !== 200) {
|
||||
message.error('字典导入配置创建失败!');
|
||||
return;
|
||||
}
|
||||
setKnowledgeConfig(data);
|
||||
};
|
||||
|
||||
const createDictTaskQuery = async (dimension: ISemantic.IDimensionItem) => {
|
||||
setImportDictState(true);
|
||||
const { code } = await createDictTask({
|
||||
updateMode: 'REALTIME_ADD',
|
||||
modelAndDimPair: {
|
||||
[modelId]: [dimension.id],
|
||||
},
|
||||
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||
itemId: dimension.id,
|
||||
});
|
||||
|
||||
if (code !== 200) {
|
||||
@@ -145,73 +173,40 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
}, 2000);
|
||||
};
|
||||
|
||||
const saveEntity = async (searchEnable = dimensionVisible) => {
|
||||
setSaveLoading(true);
|
||||
const globalKnowledgeConfigFormFields: any = await getFormValidateFields();
|
||||
|
||||
const tempData = { ...modelRichConfigData };
|
||||
const targetKnowledgeInfos = modelRichConfigData?.chatAggRichConfig?.knowledgeInfos || [];
|
||||
|
||||
const hasHistoryConfig = targetKnowledgeInfos.find((item) => item.itemId === dimensionItem.id);
|
||||
let knowledgeInfos: IChatConfig.IKnowledgeInfosItem[] = targetKnowledgeInfos;
|
||||
|
||||
if (hasHistoryConfig) {
|
||||
knowledgeInfos = targetKnowledgeInfos.reduce(
|
||||
(
|
||||
knowledgeInfosList: IChatConfig.IKnowledgeInfosItem[],
|
||||
item: IChatConfig.IKnowledgeInfosItem,
|
||||
) => {
|
||||
if (item.itemId === dimensionItem.id) {
|
||||
knowledgeInfosList.push({
|
||||
...item,
|
||||
knowledgeAdvancedConfig: {
|
||||
...item.knowledgeAdvancedConfig,
|
||||
...globalKnowledgeConfigFormFields,
|
||||
},
|
||||
searchEnable,
|
||||
});
|
||||
} else {
|
||||
knowledgeInfosList.push({
|
||||
...item,
|
||||
});
|
||||
}
|
||||
return knowledgeInfosList;
|
||||
},
|
||||
[],
|
||||
);
|
||||
} else {
|
||||
knowledgeInfos.push({
|
||||
itemId: dimensionItem.id,
|
||||
bizName: dimensionItem.bizName,
|
||||
knowledgeAdvancedConfig: {
|
||||
...globalKnowledgeConfigFormFields,
|
||||
},
|
||||
searchEnable,
|
||||
});
|
||||
}
|
||||
|
||||
const { id, modelId, chatAggRichConfig } = tempData;
|
||||
const saveParams = {
|
||||
id,
|
||||
modelId,
|
||||
chatAggConfig: {
|
||||
...chatAggRichConfig,
|
||||
knowledgeInfos,
|
||||
},
|
||||
};
|
||||
let saveDomainExtendQuery = addDomainExtend;
|
||||
if (id) {
|
||||
saveDomainExtendQuery = editDomainExtend;
|
||||
}
|
||||
|
||||
const { code, msg } = await saveDomainExtendQuery({
|
||||
...saveParams,
|
||||
});
|
||||
setSaveLoading(false);
|
||||
if (code === 200) {
|
||||
const editDictTaskQuery = async (
|
||||
status: KnowledgeConfigStatusEnum = KnowledgeConfigStatusEnum.ONLINE,
|
||||
) => {
|
||||
if (!knowledgeConfig?.id) {
|
||||
return;
|
||||
}
|
||||
const config = await form.validateFields();
|
||||
setSaveLoading(true);
|
||||
const { code } = await editDictConfig({
|
||||
...knowledgeConfig,
|
||||
config: {
|
||||
...knowledgeConfig.config,
|
||||
...config,
|
||||
},
|
||||
status,
|
||||
});
|
||||
setSaveLoading(false);
|
||||
if (code !== 200) {
|
||||
message.error('字典导入配置保存失败!');
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const deleteDictTaskQuery = async (dimension: ISemantic.IDimensionItem) => {
|
||||
setDeleteLoading(true);
|
||||
const { code } = await deleteDictTask({
|
||||
type: KnowledgeConfigTypeEnum.DIMENSION,
|
||||
itemId: dimension.id,
|
||||
});
|
||||
setDeleteLoading(false);
|
||||
if (code !== 200) {
|
||||
message.error('字典清除失败!');
|
||||
return;
|
||||
}
|
||||
message.error(msg);
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -236,7 +231,11 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
size="small"
|
||||
checked={dimensionVisible}
|
||||
onChange={(value) => {
|
||||
saveEntity(value);
|
||||
editDictTaskQuery(
|
||||
value
|
||||
? KnowledgeConfigStatusEnum.ONLINE
|
||||
: KnowledgeConfigStatusEnum.OFFLINE,
|
||||
);
|
||||
setDimensionVisible(value);
|
||||
}}
|
||||
/>
|
||||
@@ -249,21 +248,27 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
>
|
||||
{dimensionVisible && (
|
||||
<Space size={20} style={{ marginBottom: 20 }}>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
style={{ padding: 0 }}
|
||||
onClick={(event) => {
|
||||
createDictTaskQuery(dimensionItem);
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<Tooltip title="立即将维度值导入字典">
|
||||
<Tooltip title="立即将维度值导入字典">
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
style={{ padding: 0 }}
|
||||
disabled={importDictState}
|
||||
onClick={(event) => {
|
||||
createDictTaskQuery(dimensionItem);
|
||||
setTaskItemState({
|
||||
...(taskItemState || ({} as ISemantic.IDictKnowledgeTaskItem)),
|
||||
taskStatus: 'running',
|
||||
});
|
||||
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<Space>
|
||||
立即导入字典 <InfoCircleOutlined />
|
||||
</Space>
|
||||
</Tooltip>
|
||||
</Button>
|
||||
</Button>
|
||||
</Tooltip>
|
||||
|
||||
<Tooltip title="刷新字典任务状态">
|
||||
<Space>
|
||||
@@ -276,12 +281,34 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
}}
|
||||
>
|
||||
导入状态
|
||||
<RedoOutlined />:
|
||||
<Space>
|
||||
<RedoOutlined />: <span>{taskRender(dimensionItem)}</span>
|
||||
</Space>
|
||||
</Button>
|
||||
</Space>
|
||||
</Tooltip>
|
||||
|
||||
<span>{taskRender(dimensionItem)}</span>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
style={{ padding: 0 }}
|
||||
disabled={taskItemState?.taskStatus === 'running'}
|
||||
loading={deleteLoading}
|
||||
onClick={(event) => {
|
||||
deleteDictTaskQuery(dimensionItem);
|
||||
setTaskItemState({
|
||||
...(taskItemState || ({} as ISemantic.IDictKnowledgeTaskItem)),
|
||||
taskStatus: '',
|
||||
});
|
||||
event.stopPropagation();
|
||||
}}
|
||||
>
|
||||
<Tooltip title="清除当前配置的字典">
|
||||
<Space>
|
||||
清除字典 <InfoCircleOutlined />
|
||||
</Space>
|
||||
</Tooltip>
|
||||
</Button>
|
||||
</Space>
|
||||
)}
|
||||
</FormItem>
|
||||
@@ -306,7 +333,7 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
<Button
|
||||
type="primary"
|
||||
onClick={() => {
|
||||
saveEntity();
|
||||
editDictTaskQuery();
|
||||
}}
|
||||
loading={saveLoading}
|
||||
>
|
||||
@@ -316,11 +343,21 @@ const DimensionValueSettingForm: ForwardRefRenderFunction<any, Props> = (
|
||||
</div>
|
||||
|
||||
<FormItem name="blackList" label="黑名单">
|
||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
||||
<Select
|
||||
mode="tags"
|
||||
placeholder="输入维度值后回车确认,多别名输入、复制粘贴支持英文逗号自动分隔"
|
||||
tokenSeparators={[',']}
|
||||
maxTagCount={9}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem name="whiteList" label="白名单">
|
||||
<Input placeholder="多个维度值用英文逗号隔开" />
|
||||
<Select
|
||||
mode="tags"
|
||||
placeholder="输入维度值后回车确认,多别名输入、复制粘贴支持英文逗号自动分隔"
|
||||
tokenSeparators={[',']}
|
||||
maxTagCount={9}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
<FormItem name="ruleList">
|
||||
|
||||
@@ -1,103 +0,0 @@
|
||||
import { message, Space } from 'antd';
|
||||
import { useEffect, useState, forwardRef, useImperativeHandle, Ref } from 'react';
|
||||
import type { Dispatch } from 'umi';
|
||||
import { connect } from 'umi';
|
||||
import type { StateType } from '../../model';
|
||||
import { getDomainExtendDetailConfig } from '../../service';
|
||||
import ProCard from '@ant-design/pro-card';
|
||||
|
||||
import DefaultSettingForm from './DefaultSettingForm';
|
||||
import type { IChatConfig } from '../../data';
|
||||
import { ChatConfigType } from '../../enum';
|
||||
|
||||
type Props = {
|
||||
chatConfigType: ChatConfigType.TAG | ChatConfigType.METRIC;
|
||||
onConfigSave?: () => void;
|
||||
dispatch: Dispatch;
|
||||
domainManger: StateType;
|
||||
};
|
||||
|
||||
const EntitySection: React.FC<Props> = forwardRef(
|
||||
({ domainManger, chatConfigType = ChatConfigType.TAG, onConfigSave }, ref: Ref<any>) => {
|
||||
const { selectDomainId, selectModelId: modelId, dimensionList, metricList } = domainManger;
|
||||
|
||||
const [entityData, setEntityData] = useState<IChatConfig.IChatRichConfig>();
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
refreshConfigData: queryThemeListData,
|
||||
}));
|
||||
|
||||
const queryThemeListData: any = async () => {
|
||||
const { code, data } = await getDomainExtendDetailConfig({
|
||||
modelId,
|
||||
});
|
||||
|
||||
if (code === 200) {
|
||||
const { chatAggRichConfig, chatDetailRichConfig, id, domainId, modelId } = data;
|
||||
if (chatConfigType === ChatConfigType.TAG) {
|
||||
setEntityData({ ...chatDetailRichConfig, id, domainId, modelId });
|
||||
}
|
||||
if (chatConfigType === ChatConfigType.METRIC) {
|
||||
setEntityData({ ...chatAggRichConfig, id, domainId, modelId });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
message.error('获取问答设置信息失败');
|
||||
};
|
||||
|
||||
const initPage = async () => {
|
||||
queryThemeListData();
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!modelId) {
|
||||
return;
|
||||
}
|
||||
initPage();
|
||||
}, [modelId]);
|
||||
|
||||
return (
|
||||
<div style={{ width: 800, margin: '0 auto' }}>
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={20}>
|
||||
<ProCard bordered title="默认设置">
|
||||
<DefaultSettingForm
|
||||
domainId={Number(selectDomainId)}
|
||||
entityData={entityData || {}}
|
||||
chatConfigType={chatConfigType}
|
||||
chatConfigKey={
|
||||
chatConfigType === ChatConfigType.TAG ? 'chatDetailConfig' : 'chatAggConfig'
|
||||
}
|
||||
dimensionList={dimensionList.filter((item) => {
|
||||
const blackDimensionList = entityData?.visibility?.blackDimIdList;
|
||||
if (Array.isArray(blackDimensionList)) {
|
||||
return !blackDimensionList.includes(item.id);
|
||||
}
|
||||
return false;
|
||||
})}
|
||||
metricList={metricList.filter((item) => {
|
||||
const blackMetricIdList = entityData?.visibility?.blackMetricIdList;
|
||||
if (Array.isArray(blackMetricIdList)) {
|
||||
return !blackMetricIdList.includes(item.id);
|
||||
}
|
||||
return false;
|
||||
})}
|
||||
onSubmit={() => {
|
||||
queryThemeListData();
|
||||
onConfigSave?.();
|
||||
}}
|
||||
/>
|
||||
</ProCard>
|
||||
</Space>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
);
|
||||
export default connect(
|
||||
({ domainManger }: { domainManger: StateType }) => ({
|
||||
domainManger,
|
||||
}),
|
||||
() => {},
|
||||
null,
|
||||
{ forwardRef: true },
|
||||
)(EntitySection);
|
||||
Reference in New Issue
Block a user