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