fix: doctor report list shows all patient reports, upload area supports file selection, start-dev.bat starts frontends
This commit is contained in:
@@ -3,4 +3,9 @@
|
||||
.catGrid { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.catChip { padding: 6px 14px; border-radius: var(--radius-full); font-size: var(--font-size-sm); background: var(--color-bg-secondary); color: var(--color-text-secondary); }
|
||||
.catActive { background: var(--color-primary-bg); color: var(--color-primary); }
|
||||
.uploadArea { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px; background: var(--color-bg); border: 2px dashed var(--color-border); border-radius: var(--radius-lg); cursor: pointer; }
|
||||
.uploadArea { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 32px; background: var(--color-bg); border: 2px dashed var(--color-border); border-radius: var(--radius-lg); cursor: pointer; transition: border-color 0.15s; }
|
||||
.uploadArea:hover { border-color: var(--color-primary); background: var(--color-primary-bg); }
|
||||
.fileList { display: flex; flex-direction: column; gap: 6px; }
|
||||
.fileItem { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; background: var(--color-bg); border-radius: var(--radius-sm); font-size: var(--font-size-sm); }
|
||||
.fileName { color: var(--color-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.fileRemove { background: none; border: none; color: var(--color-danger); cursor: pointer; font-size: 14px; padding: 4px; }
|
||||
|
||||
@@ -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