备份:PWA配置前的完整版本
包含所有最新开发的功能和修复,作为PWA正确配置前的备份点。
This commit is contained in:
@@ -3,6 +3,7 @@ import { Card, Button, Progress, Tag, List, Spin, message, Empty, Space, Typogra
|
||||
import { ArrowLeftOutlined, RightOutlined } from '@ant-design/icons';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import apiClient from '../../utils/request';
|
||||
import { useLanguageStore } from '../../store/languageStore';
|
||||
|
||||
const { Title, Text } = Typography;
|
||||
|
||||
@@ -28,6 +29,7 @@ const ConstructionOverview: React.FC = () => {
|
||||
const [projects, setProjects] = useState<Project[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const navigate = useNavigate();
|
||||
const { t, currentLanguage } = useLanguageStore();
|
||||
|
||||
useEffect(() => { fetchProjects(); }, []);
|
||||
|
||||
@@ -45,7 +47,7 @@ const ConstructionOverview: React.FC = () => {
|
||||
}));
|
||||
setProjects(enriched);
|
||||
}
|
||||
} catch (e) { message.error('获取项目列表失败'); }
|
||||
} catch (e) { message.error(t('construction.getListFailed')); }
|
||||
finally { setLoading(false); }
|
||||
};
|
||||
|
||||
@@ -55,7 +57,7 @@ const ConstructionOverview: React.FC = () => {
|
||||
};
|
||||
|
||||
const getStatusText = (status: string) => {
|
||||
const map: Record<string, string> = { active: '施工中', in_progress: '施工中', planning: '待开工', completed: '已完工', suspended: '暂停' };
|
||||
const map: Record<string, string> = { active: t('construction.underConstruction'), in_progress: t('construction.underConstruction'), planning: t('construction.pendingStart'), completed: t('construction.completed'), suspended: t('construction.paused') };
|
||||
return map[status] || status;
|
||||
};
|
||||
|
||||
@@ -64,28 +66,28 @@ const ConstructionOverview: React.FC = () => {
|
||||
|
||||
return (
|
||||
<div style={{ padding: 24 }}>
|
||||
<Card title={<Title level={4} style={{ margin: 0 }}>施工总览</Title>}>
|
||||
<Card title={<Title level={4} style={{ margin: 0 }}>{t('construction.overview')}</Title>}>
|
||||
<Spin spinning={loading}>
|
||||
{activeProjects.length === 0 && completedProjects.length === 0 ? (
|
||||
<Empty description="暂无施工项目" />
|
||||
<Empty description={t('construction.noProjects')} />
|
||||
) : (
|
||||
<>
|
||||
{activeProjects.length > 0 && (
|
||||
<>
|
||||
<Text strong style={{ fontSize: 16 }}>施工中项目:{activeProjects.length}个</Text>
|
||||
<Text strong style={{ fontSize: 16 }}>{t('construction.underConstruction')}{activeProjects.length}{t('common.unit')}</Text>
|
||||
<List
|
||||
style={{ marginTop: 16 }}
|
||||
dataSource={activeProjects}
|
||||
renderItem={(project) => (
|
||||
<List.Item
|
||||
actions={[<Button type="primary" icon={<RightOutlined />} onClick={() => navigate(`/construction/progress/${project.id}`)}>进入</Button>]}
|
||||
actions={[<Button type="primary" icon={<RightOutlined />} onClick={() => navigate(`/construction/progress/${project.id}`)}>{t('construction.enter')}</Button>]}
|
||||
>
|
||||
<List.Item.Meta
|
||||
title={<Space><Text strong>{project.name}</Text><Tag color={getStatusColor(project.status)}>{getStatusText(project.status)}</Tag></Space>}
|
||||
description={
|
||||
<div style={{ marginTop: 8 }}>
|
||||
<div style={{ marginBottom: 4 }}>
|
||||
<Text type="secondary">当前阶段:{project.current_phase || '未设置'}</Text>
|
||||
<Text type="secondary">{t('construction.currentPhase')}{project.current_phase || t('common.notSet')}</Text>
|
||||
{project.phases.length > 0 && <Text type="secondary" style={{ marginLeft: 16 }}>({project.phases.filter(p => p.status === 'completed').length}/{project.phases.length})</Text>}
|
||||
</div>
|
||||
<Progress percent={project.phase_progress || 0} size="small" strokeColor="#1890ff" />
|
||||
@@ -99,16 +101,16 @@ const ConstructionOverview: React.FC = () => {
|
||||
)}
|
||||
{completedProjects.length > 0 && (
|
||||
<>
|
||||
<Text strong style={{ fontSize: 16, marginTop: 24, display: 'block' }}>已完工项目:{completedProjects.length}个</Text>
|
||||
<Text strong style={{ fontSize: 16, marginTop: 24, display: 'block' }}>{t('construction.completedProjects')}{completedProjects.length}{t('common.unit')}</Text>
|
||||
<List
|
||||
style={{ marginTop: 16 }}
|
||||
dataSource={completedProjects}
|
||||
renderItem={(project) => (
|
||||
<List.Item
|
||||
actions={[<Button icon={<RightOutlined />} onClick={() => navigate(`/construction/progress/${project.id}`)}>查看</Button>]}
|
||||
actions={[<Button icon={<RightOutlined />} onClick={() => navigate(`/construction/progress/${project.id}`)}>{t('common.view')}</Button>]}
|
||||
>
|
||||
<List.Item.Meta
|
||||
title={<Space><Text>{project.name}</Text><Tag>已完工</Tag></Space>}
|
||||
title={<Space><Text>{project.name}</Text><Tag>{t('construction.completed')}</Tag></Space>}
|
||||
description={<Progress percent={100} size="small" />}
|
||||
/>
|
||||
</List.Item>
|
||||
@@ -124,4 +126,4 @@ const ConstructionOverview: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ConstructionOverview;
|
||||
export default ConstructionOverview;
|
||||
Reference in New Issue
Block a user