测试修改问题,国际化
This commit is contained in:
@ -1,29 +1,18 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { history } from 'umi';
|
||||
import { Button, Card, Descriptions, Divider, Spin, message, Typography, Empty, Space } from 'antd';
|
||||
import { history, useIntl } from 'umi';
|
||||
import { Button, Card, Descriptions, Divider, Spin, message, Typography, Empty } from 'antd';
|
||||
import { ArrowLeftOutlined } from '@ant-design/icons';
|
||||
import { getTemplateDetail } from '@/servers/api/supplierEvaluate';
|
||||
import {
|
||||
TaskType,
|
||||
TaskTypeText,
|
||||
TemplateStatus,
|
||||
TemplateStatusText,
|
||||
TemplateStatusColor,
|
||||
CategoryLimitationType,
|
||||
CategoryLimitationTypeText,
|
||||
StarLevel,
|
||||
} from '@/dicts/supplierTemplateDict';
|
||||
import ScoreEvaluationTable from '@/components/ScoreEvaluationTable';
|
||||
import { TemplateStatusText, CategoryLimitationTypeText } from '@/dicts/supplierTemplateDict';
|
||||
import EvaluateTemplateTable from '@/components/EvaluateTemplateTable';
|
||||
import type { TemplateDimension } from '@/servers/dao/supplierEvaluateTask';
|
||||
|
||||
const { Title } = Typography;
|
||||
|
||||
const SupplierTemplateManageDetail: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [templateDetail, setTemplateDetail] = useState<TemplateDimension | null>(
|
||||
null,
|
||||
);
|
||||
const [templateDetail, setTemplateDetail] = useState<TemplateDimension | null>(null);
|
||||
const [templateData, setTemplateData] = useState<any[]>([]);
|
||||
|
||||
// 从路由获取ID
|
||||
@ -42,11 +31,14 @@ const SupplierTemplateManageDetail: React.FC = () => {
|
||||
setTemplateData(res.data.indicatorStList);
|
||||
}
|
||||
} else {
|
||||
message.error(res.message || '获取模板详情失败');
|
||||
message.error(
|
||||
intl.formatMessage({ id: 'supplierTemplateManage.message.getDetailFailed' }) ||
|
||||
res.message,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取模板详情失败:', error);
|
||||
message.error('获取模板详情失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.message.getDetailFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -57,7 +49,7 @@ const SupplierTemplateManageDetail: React.FC = () => {
|
||||
if (id) {
|
||||
fetchTemplateDetail(id);
|
||||
} else {
|
||||
message.error('模板ID不存在,无法获取详情');
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.detail.idNotExist' }));
|
||||
history.goBack();
|
||||
}
|
||||
}, [id]);
|
||||
@ -69,8 +61,11 @@ const SupplierTemplateManageDetail: React.FC = () => {
|
||||
|
||||
// 获取状态标签
|
||||
const getStatusText = (status: string | undefined) => {
|
||||
if (!status) return '未知状态';
|
||||
return TemplateStatusText[status as keyof typeof TemplateStatusText] || '未知状态';
|
||||
if (!status) return intl.formatMessage({ id: 'supplierTemplateManage.detail.unknown' });
|
||||
return (
|
||||
TemplateStatusText[status as keyof typeof TemplateStatusText] ||
|
||||
intl.formatMessage({ id: 'supplierTemplateManage.detail.unknown' })
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
@ -78,34 +73,62 @@ const SupplierTemplateManageDetail: React.FC = () => {
|
||||
<Card>
|
||||
<div className="page-header">
|
||||
<Title level={4} style={{ margin: 0 }}>
|
||||
模板详情
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.detail.title' })}
|
||||
</Title>
|
||||
<Button type="link" icon={<ArrowLeftOutlined />} onClick={handleBack}>
|
||||
返回
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.back' })}
|
||||
</Button>
|
||||
</div>
|
||||
<Spin spinning={loading}>
|
||||
{templateDetail ? (
|
||||
<>
|
||||
<Card title="基本信息" bordered={false}>
|
||||
<Card
|
||||
title={intl.formatMessage({ id: 'supplierTemplateManage.detail.card.basicInfo' })}
|
||||
bordered={false}
|
||||
>
|
||||
<Descriptions column={2} bordered>
|
||||
<Descriptions.Item label="模板名称">
|
||||
<Descriptions.Item
|
||||
label={intl.formatMessage({
|
||||
id: 'supplierTemplateManage.detail.label.templateName',
|
||||
})}
|
||||
>
|
||||
{templateDetail.templateName}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="品类限制">
|
||||
{CategoryLimitationTypeText[templateDetail.categoryLimitation as keyof typeof CategoryLimitationTypeText] || '未知'}
|
||||
<Descriptions.Item
|
||||
label={intl.formatMessage({
|
||||
id: 'supplierTemplateManage.detail.label.categoryLimitation',
|
||||
})}
|
||||
>
|
||||
{CategoryLimitationTypeText[
|
||||
templateDetail.categoryLimitation as keyof typeof CategoryLimitationTypeText
|
||||
] || intl.formatMessage({ id: 'supplierTemplateManage.detail.unknown' })}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="品类">
|
||||
{templateDetail.categoryName || '未知品类'}
|
||||
<Descriptions.Item
|
||||
label={intl.formatMessage({
|
||||
id: 'supplierTemplateManage.detail.label.category',
|
||||
})}
|
||||
>
|
||||
{templateDetail.categoryName ||
|
||||
intl.formatMessage({ id: 'supplierTemplateManage.detail.unknownCategory' })}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">
|
||||
<Descriptions.Item
|
||||
label={intl.formatMessage({ id: 'supplierTemplateManage.detail.label.status' })}
|
||||
>
|
||||
{getStatusText(templateDetail.status)}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">
|
||||
<Descriptions.Item
|
||||
label={intl.formatMessage({
|
||||
id: 'supplierTemplateManage.detail.label.createTime',
|
||||
})}
|
||||
>
|
||||
{templateDetail.createTime}
|
||||
</Descriptions.Item>
|
||||
{templateDetail.updateTime && (
|
||||
<Descriptions.Item label="更新时间">
|
||||
<Descriptions.Item
|
||||
label={intl.formatMessage({
|
||||
id: 'supplierTemplateManage.detail.label.updateTime',
|
||||
})}
|
||||
>
|
||||
{templateDetail.updateTime}
|
||||
</Descriptions.Item>
|
||||
)}
|
||||
@ -114,19 +137,27 @@ const SupplierTemplateManageDetail: React.FC = () => {
|
||||
|
||||
<Divider />
|
||||
|
||||
<Card title="评价指标" bordered={false}>
|
||||
<Card
|
||||
title={intl.formatMessage({ id: 'supplierTemplateManage.detail.card.indicators' })}
|
||||
bordered={false}
|
||||
>
|
||||
{templateData.length > 0 ? (
|
||||
<EvaluateTemplateTable
|
||||
value={templateData}
|
||||
isDetail={true}
|
||||
/>
|
||||
<EvaluateTemplateTable value={templateData} isDetail={true} />
|
||||
) : (
|
||||
<Empty description="暂无指标数据" />
|
||||
<Empty
|
||||
description={intl.formatMessage({
|
||||
id: 'supplierTemplateManage.detail.noIndicators',
|
||||
})}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
</>
|
||||
) : (
|
||||
!loading && <Empty description="暂无模板详情数据" />
|
||||
!loading && (
|
||||
<Empty
|
||||
description={intl.formatMessage({ id: 'supplierTemplateManage.detail.noDetail' })}
|
||||
/>
|
||||
)
|
||||
)}
|
||||
</Spin>
|
||||
</Card>
|
||||
|
Reference in New Issue
Block a user