Files
AIclinicalresearch/frontend/src/components/knowledge/CreateKBDialog.tsx
AI Clinical Dev Team 239c7ea85e feat: Day 21-22 - knowledge base frontend completed, fix CORS and file upload issues
- Complete knowledge base list and detail pages
- Complete document upload component
- Fix CORS config (add PUT/DELETE method support)
- Fix file upload issues (disabled state and beforeUpload return value)
- Add detailed debug logs (cleaned up)
- Create Day 21-22 completion summary document
2025-10-11 15:40:12 +08:00

117 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import React, { useState } from 'react';
import { Modal, Form, Input, message } from 'antd';
const { TextArea } = Input;
interface CreateKBDialogProps {
open: boolean;
onCancel: () => void;
onCreate: (name: string, description?: string) => Promise<void>;
}
const CreateKBDialog: React.FC<CreateKBDialogProps> = ({
open,
onCancel,
onCreate,
}) => {
const [form] = Form.useForm();
const [loading, setLoading] = useState(false);
const handleOk = async () => {
try {
const values = await form.validateFields();
setLoading(true);
await onCreate(values.name, values.description);
message.success('知识库创建成功!');
form.resetFields();
onCancel();
} catch (error: any) {
if (error.errorFields) {
// 表单验证错误
return;
}
message.error(error.message || '创建失败');
} finally {
setLoading(false);
}
};
const handleCancel = () => {
form.resetFields();
onCancel();
};
return (
<Modal
title="创建知识库"
open={open}
onOk={handleOk}
onCancel={handleCancel}
okText="创建"
cancelText="取消"
confirmLoading={loading}
destroyOnClose
>
<Form
form={form}
layout="vertical"
autoComplete="off"
>
<Form.Item
name="name"
label="知识库名称"
rules={[
{ required: true, message: '请输入知识库名称' },
{ max: 50, message: '名称不能超过50个字符' },
]}
>
<Input
placeholder="例如:文献综述资料"
maxLength={50}
showCount
/>
</Form.Item>
<Form.Item
name="description"
label="描述(选填)"
rules={[
{ max: 200, message: '描述不能超过200个字符' },
]}
>
<TextArea
placeholder="简要描述该知识库的用途..."
rows={4}
maxLength={200}
showCount
/>
</Form.Item>
<div style={{
padding: 12,
background: '#f0f5ff',
borderRadius: 4,
fontSize: 13,
color: '#595959'
}}>
<p style={{ margin: 0, marginBottom: 8 }}>
📌 <strong></strong>
</p>
<ul style={{ margin: 0, paddingLeft: 20 }}>
<li> 3 </li>
<li> 50 </li>
<li>PDFDOCDOCXTXTMD</li>
<li>10MB</li>
</ul>
</div>
</Form>
</Modal>
);
};
export default CreateKBDialog;