测试修改问题,国际化
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { history } from 'umi';
|
||||
import { history, useIntl } from 'umi';
|
||||
import {
|
||||
Button,
|
||||
Table,
|
||||
@ -30,6 +30,7 @@ import CategorySelector from '@/components/CategorySelector/CategorySelector';
|
||||
const { Option } = Select;
|
||||
|
||||
const SupplierTemplateManage: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
@ -40,7 +41,10 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
total: 0,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total) => `共 ${total} 条记录`,
|
||||
showTotal: (total) => intl.formatMessage(
|
||||
{ id: 'supplierTemplateManage.pagination.total' },
|
||||
{ total }
|
||||
),
|
||||
});
|
||||
const [searchParams, setSearchParams] = useState<SupplierEvaluate.TemplateSearchParams>({});
|
||||
|
||||
@ -87,11 +91,11 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
total: res.data.total,
|
||||
});
|
||||
} else {
|
||||
message.error(res.message || '获取模板列表失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.message.fetchFailed' }) || res.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取模板列表失败:', error);
|
||||
message.error('获取模板列表失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.message.fetchFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -127,9 +131,9 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
|
||||
// 获取状态标签
|
||||
const getStatusTag = (status: string | undefined) => {
|
||||
if (!status) return <Tag>未知状态</Tag>;
|
||||
if (!status) return <Tag>{intl.formatMessage({ id: 'supplierTemplateManage.status.unknown' })}</Tag>;
|
||||
const color = TemplateStatusColor[status as keyof typeof TemplateStatusColor] || 'default';
|
||||
const text = TemplateStatusText[status as keyof typeof TemplateStatusText] || '未知状态';
|
||||
const text = TemplateStatusText[status as keyof typeof TemplateStatusText] || intl.formatMessage({ id: 'supplierTemplateManage.status.unknown' });
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
};
|
||||
|
||||
@ -140,13 +144,13 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '序号',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.index' }),
|
||||
render: (_: any, __: SupplierEvaluate.TemplateRecord, index: number) =>
|
||||
(pagination.current! - 1) * pagination.pageSize! + index + 1,
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '模板名称',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.templateName' }),
|
||||
dataIndex: 'templateName',
|
||||
key: 'templateName',
|
||||
width: 200,
|
||||
@ -160,13 +164,13 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '品类',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.category' }),
|
||||
dataIndex: 'categoryName',
|
||||
key: 'categoryName',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '创建单位',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.tenantName' }),
|
||||
dataIndex: 'tenantName',
|
||||
key: 'tenantName',
|
||||
width: 180,
|
||||
@ -180,36 +184,36 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '创建部门',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.deptName' }),
|
||||
dataIndex: 'deptName',
|
||||
key: 'deptName',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.createTime' }),
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.status' }),
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (status: string) => getStatusTag(status),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: intl.formatMessage({ id: 'supplierTemplateManage.column.action' }),
|
||||
key: 'action',
|
||||
width: 150,
|
||||
align: 'center' as const,
|
||||
render: (_: unknown, record: SupplierEvaluate.TemplateRecord) => (
|
||||
<Space size="middle">
|
||||
<Button type="link" onClick={() => handleEdit(record)}>
|
||||
编辑
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.edit' })}
|
||||
</Button>
|
||||
<Button type="link" onClick={() => handleView(record)}>
|
||||
查看
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.view' })}
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
@ -244,22 +248,22 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
layout="inline"
|
||||
className="filter-form"
|
||||
>
|
||||
<Form.Item name="templateName" label="模板名称">
|
||||
<Input placeholder="请输入模板名称" allowClear />
|
||||
<Form.Item name="templateName" label={intl.formatMessage({ id: 'supplierTemplateManage.column.templateName' })}>
|
||||
<Input placeholder={intl.formatMessage({ id: 'supplierTemplateManage.placeholder.templateName' })} allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="tenantName" label="创建单位">
|
||||
<Select placeholder="请选择创建单位" allowClear style={{ width: 200 }}>
|
||||
<Form.Item name="tenantName" label={intl.formatMessage({ id: 'supplierTemplateManage.column.tenantName' })}>
|
||||
<Select placeholder={intl.formatMessage({ id: 'supplierTemplateManage.placeholder.tenantName' })} allowClear style={{ width: 200 }}>
|
||||
{companyOptions.map(option => (
|
||||
<Option key={option.value} value={option.value}>{option.label}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Form.Item name="categoryId" label="品类">
|
||||
<Form.Item name="categoryId" label={intl.formatMessage({ id: 'supplierTemplateManage.column.category' })}>
|
||||
<CategorySelector multiple={false} style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
<Form.Item className="filter-btns">
|
||||
<Button type="primary" htmlType="submit" icon={<SearchOutlined />}>
|
||||
搜索
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.search' })}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
@ -270,13 +274,13 @@ const SupplierTemplateManage: React.FC = () => {
|
||||
fetchTemplateList(1, pagination.pageSize, {});
|
||||
}}
|
||||
>
|
||||
重置
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.reset' })}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<div className="right-buttons">
|
||||
<Button type="primary" ghost icon={<PlusOutlined />} onClick={handleAdd}>
|
||||
新增
|
||||
{intl.formatMessage({ id: 'supplierTemplateManage.button.add' })}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
Reference in New Issue
Block a user