FEAT => 本次更新项目为:

内容选择构建完成
This commit is contained in:
超级老白兔
2025-08-07 18:27:37 +08:00
parent bb06d3e4f8
commit b06a0e16b0

View File

@@ -38,32 +38,13 @@ const ContentSelector = forwardRef<ContentSelectorRef, ContentSelectorProps>(
}));
// 处理选择变化
const handleLibrariesChange = (contentGroups: string[]) => {
const newSelectedLibraries = contentGroups.map(id => ({
id,
name: `内容库 ${id}`, // 这里应该从API获取完整信息
targets: [], // 这里应该从API获取完整信息
}));
const handleLibrariesChange = (contentGroupsOptions: ContentItem[]) => {
const contentGroups = contentGroupsOptions.map(c => c.id.toString());
onNext({
contentGroups: libraryIds,
contentGroupsOptions: newSelectedLibraries,
contentGroups,
contentGroupsOptions,
});
form.setFieldValue("contentLibraries", libraryIds);
};
// 处理选择详情变化
const handleSelectDetail = (libraries: any[]) => {
// 将API返回的数据转换为ContentLibrary格式
const convertedLibraries = libraries.map(lib => ({
id: lib.id,
name: lib.name,
targets: [], // 这里需要根据实际情况获取targets数据
}));
onNext(convertedLibraries);
form.setFieldValue(
"contentLibraries",
libraries.map(lib => lib.id),
);
form.setFieldValue("contentGroups", contentGroups);
};
return (
@@ -72,7 +53,7 @@ const ContentSelector = forwardRef<ContentSelectorRef, ContentSelectorProps>(
<Form
form={form}
layout="vertical"
initialValues={{ contentLibraries: selectedLibraryIds }}
initialValues={{ contentGroups: selectedContent.map(c => c.id) }}
>
<div style={{ marginBottom: 16 }}>
<h2 style={{ margin: 0, fontSize: 18, fontWeight: 600 }}>
@@ -84,7 +65,7 @@ const ContentSelector = forwardRef<ContentSelectorRef, ContentSelectorProps>(
</div>
<Form.Item
name="contentLibraries"
name="contentGroups"
rules={[
{ required: true, message: "请选择至少一个内容库" },
{ type: "array", min: 1, message: "请选择至少一个内容库" },
@@ -92,13 +73,12 @@ const ContentSelector = forwardRef<ContentSelectorRef, ContentSelectorProps>(
]}
>
<ContentSelection
selectedLibraries={selectedContent}
selectedContent={selectedContent}
onSelect={handleLibrariesChange}
onSelectDetail={handleSelectDetail}
placeholder="选择内容库"
showInput={true}
showSelectedList={true}
readonly={loading}
readonly={false}
selectedListMaxHeight={320}
/>
</Form.Item>