fix: doctor report list shows all patient reports, upload area supports file selection, start-dev.bat starts frontends
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react';
|
||||
import { useState, useRef } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Button } from '@/components/common/Button';
|
||||
import { Input } from '@/components/common/Input';
|
||||
@@ -9,18 +9,38 @@ import styles from './ReportUploadPage.module.css';
|
||||
|
||||
export function ReportUploadPage() {
|
||||
const navigate = useNavigate();
|
||||
const fileRef = useRef<HTMLInputElement>(null);
|
||||
const [title, setTitle] = useState('');
|
||||
const [category, setCategory] = useState('血液检查');
|
||||
const [files, setFiles] = useState<File[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
const categories = ['血液检查', '心电图', '影像学', '尿液检查', '其他'];
|
||||
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files) {
|
||||
setFiles((prev) => [...prev, ...Array.from(e.target.files!)]);
|
||||
}
|
||||
// Reset so the same file can be selected again
|
||||
if (fileRef.current) fileRef.current.value = '';
|
||||
};
|
||||
|
||||
const removeFile = (index: number) => {
|
||||
setFiles((prev) => prev.filter((_, i) => i !== index));
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!title.trim()) { toast('请输入报告名称', 'error'); return; }
|
||||
setLoading(true);
|
||||
await reportService.uploadReport({ title, category });
|
||||
toast('上传成功,正在解读中...');
|
||||
setTimeout(() => navigate(-1), 800);
|
||||
try {
|
||||
await reportService.uploadReport({ title, category });
|
||||
toast('上传成功');
|
||||
setTimeout(() => navigate('/services/reports'), 800);
|
||||
} catch {
|
||||
toast('上传失败,请检查后端是否运行', 'error');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -36,11 +56,30 @@ export function ReportUploadPage() {
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className={styles.uploadArea}>
|
||||
<span style={{ fontSize: 40 }}>📸</span>
|
||||
<span style={{ fontSize: '14px', color: '#6B7280' }}>点击拍照或选择图片上传</span>
|
||||
<span style={{ fontSize: '11px', color: '#9CA3AF' }}>模拟上传,直接保存即可</span>
|
||||
<div className={styles.uploadArea} onClick={() => fileRef.current?.click()}>
|
||||
<span style={{ fontSize: 36 }}>📷</span>
|
||||
<span style={{ fontSize: 14, color: '#6B7280' }}>点击选择报告图片</span>
|
||||
<span style={{ fontSize: 11, color: '#9CA3AF' }}>支持 jpg、png,可多选</span>
|
||||
</div>
|
||||
<input
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
multiple
|
||||
style={{ display: 'none' }}
|
||||
onChange={handleFileChange}
|
||||
/>
|
||||
|
||||
{files.length > 0 && (
|
||||
<div className={styles.fileList}>
|
||||
{files.map((file, i) => (
|
||||
<div key={i} className={styles.fileItem}>
|
||||
<span className={styles.fileName}>📎 {file.name}</span>
|
||||
<button className={styles.fileRemove} onClick={() => removeFile(i)}>✕</button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Button variant="primary" size="lg" fullWidth loading={loading} onClick={handleSubmit}>
|
||||
提交上传
|
||||
|
||||
Reference in New Issue
Block a user