维护国际化
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,
|
||||
@ -34,6 +34,7 @@ interface AnnualTemplateSearchParams {
|
||||
}
|
||||
|
||||
const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
@ -44,7 +45,7 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
total: 0,
|
||||
showSizeChanger: true,
|
||||
showQuickJumper: true,
|
||||
showTotal: (total) => `共 ${total} 条记录`,
|
||||
showTotal: (total) => intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.total' }, { total }),
|
||||
});
|
||||
const [searchParams, setSearchParams] = useState<AnnualTemplateSearchParams>({});
|
||||
|
||||
@ -100,11 +101,11 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
total,
|
||||
});
|
||||
} else {
|
||||
message.error(response.message || '获取模板列表失败');
|
||||
message.error(response.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.getListFailed' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取模板列表失败:', error);
|
||||
message.error('获取模板列表失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.getListFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -128,23 +129,23 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
// 处理启用模板
|
||||
const handleEnableTemplate = (id: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认启用',
|
||||
content: '确定要启用此模板吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableConfirmTitle' }),
|
||||
content: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableConfirmContent' }),
|
||||
okText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' }),
|
||||
cancelText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' }),
|
||||
onOk: async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await enableAnnualTemplate(id);
|
||||
if (res.success) {
|
||||
message.success('模板启用成功');
|
||||
message.success(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableSuccess' }));
|
||||
fetchTemplateList(pagination.current, pagination.pageSize, searchParams);
|
||||
} else {
|
||||
message.error(res.message || '启用模板失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableFailed' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('启用模板失败:', error);
|
||||
message.error('启用模板失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -155,23 +156,23 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
// 处理禁用模板
|
||||
const handleDisableTemplate = (id: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认禁用',
|
||||
content: '确定要禁用此模板吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableConfirmTitle' }),
|
||||
content: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableConfirmContent' }),
|
||||
okText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' }),
|
||||
cancelText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' }),
|
||||
onOk: async () => {
|
||||
try {
|
||||
setLoading(true);
|
||||
const res = await disableAnnualTemplate(id);
|
||||
if (res.success) {
|
||||
message.success('模板禁用成功');
|
||||
message.success(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableSuccess' }));
|
||||
fetchTemplateList(pagination.current, pagination.pageSize, searchParams);
|
||||
} else {
|
||||
message.error(res.message || '禁用模板失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableFailed' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('禁用模板失败:', error);
|
||||
message.error('禁用模板失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -192,9 +193,9 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
|
||||
// 获取状态标签
|
||||
const getStatusTag = (status: string | undefined) => {
|
||||
if (!status) return <Tag>未知状态</Tag>;
|
||||
if (!status) return <Tag>{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.unknownStatus' })}</Tag>;
|
||||
const color = AnnualTemplateStatusColor[status as keyof typeof AnnualTemplateStatusColor] || 'default';
|
||||
const text = AnnualTemplateStatusText[status as keyof typeof AnnualTemplateStatusText] || '未知状态';
|
||||
const text = AnnualTemplateStatusText[status as keyof typeof AnnualTemplateStatusText] || intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.unknownStatus' });
|
||||
return <Tag color={color}>{text}</Tag>;
|
||||
};
|
||||
|
||||
@ -205,13 +206,13 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '序号',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.serialNumber' }),
|
||||
render: (_: any, __: supplierAnnualTemplateManage.TemplateRecord, index: number) =>
|
||||
(pagination.current! - 1) * pagination.pageSize! + index + 1,
|
||||
width: 80,
|
||||
},
|
||||
{
|
||||
title: '模板名称',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' }),
|
||||
dataIndex: 'templateName',
|
||||
key: 'templateName',
|
||||
width: 200,
|
||||
@ -225,13 +226,13 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '品类',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.category' }),
|
||||
dataIndex: 'categoryName',
|
||||
key: 'categoryName',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '创建单位',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.createUnit' }),
|
||||
dataIndex: 'tenantName',
|
||||
key: 'tenantName',
|
||||
width: 180,
|
||||
@ -245,26 +246,26 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '创建部门',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.createDept' }),
|
||||
dataIndex: 'deptName',
|
||||
key: 'deptName',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.createTime' }),
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.status' }),
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (status: string) => getStatusTag(status),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.operation' }),
|
||||
key: 'action',
|
||||
width: 200,
|
||||
align: 'center' as const,
|
||||
@ -273,40 +274,40 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
{/* 草稿状态可以编辑,其他状态不可编辑 */}
|
||||
{record.status === AnnualTemplateStatus.DRAFT && (
|
||||
<Button type="link" onClick={() => handleEdit(record)} size="small">
|
||||
编辑
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.edit' })}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* 所有状态都可以查看 */}
|
||||
<Button type="link" onClick={() => handleView(record)} size="small">
|
||||
查看
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.view' })}
|
||||
</Button>
|
||||
|
||||
{/* 草稿状态显示启用按钮 */}
|
||||
{record.status === AnnualTemplateStatus.DRAFT && (
|
||||
<Button type="link" onClick={() => handleEnableTemplate(record.id)} size="small">
|
||||
启用
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.enable' })}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* 草稿状态显示禁用按钮 */}
|
||||
{record.status === AnnualTemplateStatus.DRAFT && (
|
||||
<Button type="link" danger onClick={() => handleDisableTemplate(record.id)} size="small">
|
||||
禁用
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.disable' })}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* 禁用状态显示启用按钮 */}
|
||||
{record.status === AnnualTemplateStatus.DISABLED && (
|
||||
<Button type="link" onClick={() => handleEnableTemplate(record.id)} size="small">
|
||||
启用
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.enable' })}
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* 启用状态显示禁用按钮 */}
|
||||
{record.status === AnnualTemplateStatus.ENABLED && (
|
||||
<Button type="link" danger onClick={() => handleDisableTemplate(record.id)} size="small">
|
||||
禁用
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.disable' })}
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
@ -316,8 +317,6 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
|
||||
// 处理添加
|
||||
const handleAdd = () => {
|
||||
// message.info('新增功能尚未开发');
|
||||
// 将来实现新增功能时使用:
|
||||
history.push('supplierAnnualTemplateManageAdd');
|
||||
};
|
||||
|
||||
@ -349,22 +348,22 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
layout="inline"
|
||||
className="filter-form"
|
||||
>
|
||||
<Form.Item name="templateName" label="模板名称">
|
||||
<Input placeholder="请输入模板名称" allowClear />
|
||||
<Form.Item name="templateName" label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' })}>
|
||||
<Input placeholder={`${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseInput' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' })}`} allowClear />
|
||||
</Form.Item>
|
||||
<Form.Item name="deptId" label="创建单位">
|
||||
<Select placeholder="请选择创建单位" allowClear style={{ width: 200 }}>
|
||||
<Form.Item name="deptId" label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.createUnit' })}>
|
||||
<Select placeholder={`${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseSelect' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.createUnit' })}`} 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: 'supplierAnnualTemplateManage.list.category' })}>
|
||||
<CategorySelector multiple={false} style={{ width: 200 }} />
|
||||
</Form.Item>
|
||||
<Form.Item className="filter-btns">
|
||||
<Button type="primary" htmlType="submit" icon={<SearchOutlined />}>
|
||||
搜索
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.search' })}
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
@ -372,13 +371,13 @@ const SupplierAnnualTemplateManage: React.FC = () => {
|
||||
icon={<DeleteOutlined />}
|
||||
onClick={handleReset}
|
||||
>
|
||||
重置
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.reset' })}
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<div className="right-buttons">
|
||||
<Button type="primary" ghost icon={<PlusOutlined />} onClick={handleAdd}>
|
||||
新增
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.add' })}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -17,7 +17,7 @@ import {
|
||||
Popconfirm,
|
||||
Modal,
|
||||
} from 'antd';
|
||||
import { history, useLocation } from 'umi';
|
||||
import { history, useLocation, useIntl } from 'umi';
|
||||
import {
|
||||
ArrowLeftOutlined,
|
||||
SaveOutlined,
|
||||
@ -73,6 +73,7 @@ const StarOptionsText = {
|
||||
};
|
||||
|
||||
const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [form] = Form.useForm();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [isEdit, setIsEdit] = useState<boolean>(false);
|
||||
@ -91,12 +92,12 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
if (res.success && res.data) {
|
||||
setTemplateList(res.data);
|
||||
} else {
|
||||
message.error(res.message || '获取模板列表失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.getListFailed' }));
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
console.error('获取模板列表失败:', error);
|
||||
message.error('获取模板列表失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.getListFailed' }));
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
@ -123,12 +124,12 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
setIndicatorList(res.data.indicatorList);
|
||||
}
|
||||
} else {
|
||||
message.error(res.message || '获取模板详情失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.getDetailFailed' }));
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
console.error('获取模板详情失败:', error);
|
||||
message.error('获取模板详情失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.getDetailFailed' }));
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
@ -162,7 +163,7 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
history.goBack();
|
||||
};
|
||||
|
||||
// 实际提交数据的函数
|
||||
// 实际提交数据的函数
|
||||
const submitFormData = async (submitData: supplierAnnualTemplateManage.AddTemplateRequest) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@ -175,14 +176,20 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
}
|
||||
|
||||
if (res && res.success) {
|
||||
message.success(isEdit ? '模板更新成功' : '模板保存成功');
|
||||
message.success(isEdit
|
||||
? intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.submitSuccess' })
|
||||
: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.saveSuccess' }));
|
||||
history.goBack();
|
||||
} else {
|
||||
message.error(res?.message || (isEdit ? '模板更新失败' : '模板保存失败'));
|
||||
message.error(res?.message || (isEdit
|
||||
? intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.submitFailed' })
|
||||
: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.saveFailed' })));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交失败:', error);
|
||||
message.error('提交失败');
|
||||
message.error(isEdit
|
||||
? intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.submitFailed' })
|
||||
: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.saveFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -192,14 +199,17 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
const handleSubmit = async (values: any) => {
|
||||
// 检查指标列表
|
||||
if (!indicatorList || indicatorList.length === 0) {
|
||||
message.error('至少需要添加一项指标');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.atLeastOneIndicator' }));
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查指标名称不能为空
|
||||
const emptyNameIndex = indicatorList.findIndex(item => !item.itemName);
|
||||
if (emptyNameIndex !== -1) {
|
||||
message.error(`第 ${emptyNameIndex + 1} 项指标名称不能为空`);
|
||||
message.error(intl.formatMessage(
|
||||
{ id: 'supplierAnnualTemplateManage.add.indicatorNameRequired' },
|
||||
{ index: emptyNameIndex + 1 }
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -217,10 +227,12 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
|
||||
// 显示确认弹框
|
||||
Modal.confirm({
|
||||
title: '确认提交',
|
||||
content: isEdit ? '确定要更新此模板吗?' : '确定要保存此模板吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' }),
|
||||
content: isEdit
|
||||
? intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.enableConfirmContent' })
|
||||
: intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.disableConfirmContent' }),
|
||||
okText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' }),
|
||||
cancelText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' }),
|
||||
onOk: async () => {
|
||||
await submitFormData(submitData);
|
||||
}
|
||||
@ -251,12 +263,12 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
setIndicatorList(copiedList);
|
||||
}
|
||||
} else {
|
||||
message.error(res.message || '获取模板详情失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.getDetailFailed' }));
|
||||
}
|
||||
setLoading(false);
|
||||
} catch (error) {
|
||||
console.error('获取模板详情失败:', error);
|
||||
message.error('获取模板详情失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.getDetailFailed' }));
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
@ -294,26 +306,26 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
// 指标表格列定义
|
||||
const columns = [
|
||||
{
|
||||
title: '序号',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.serialNumber' }),
|
||||
dataIndex: 'orderBy',
|
||||
key: 'orderBy',
|
||||
width: 80,
|
||||
render: (_: string, __: any, index: number) => index + 1,
|
||||
},
|
||||
{
|
||||
title: '检查项目',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.checkItem' }),
|
||||
dataIndex: 'itemName',
|
||||
key: 'itemName',
|
||||
render: (text: string, record: supplierAnnualTemplateManage.IndicatorItem, index: number) => (
|
||||
<Input
|
||||
value={text}
|
||||
onChange={(e) => handleIndicatorChange(index, 'itemName', e.target.value)}
|
||||
placeholder="请输入检查项目名称"
|
||||
placeholder={`${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseInput' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.checkItem' })}`}
|
||||
/>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '星号项',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.starItem' }),
|
||||
dataIndex: 'isStar',
|
||||
key: 'isStar',
|
||||
width: 120,
|
||||
@ -323,13 +335,13 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
onChange={(value) => handleIndicatorChange(index, 'isStar', value)}
|
||||
className={styles.starSelector}
|
||||
>
|
||||
<Option value={StarOptions.YES}>{StarOptionsText[StarOptions.YES]}</Option>
|
||||
<Option value={StarOptions.NO}>{StarOptionsText[StarOptions.NO]}</Option>
|
||||
<Option value={StarOptions.YES}>{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.yes' })}</Option>
|
||||
<Option value={StarOptions.NO}>{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.no' })}</Option>
|
||||
</Select>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.operation' }),
|
||||
key: 'action',
|
||||
width: 120,
|
||||
render: (_: any, __: supplierAnnualTemplateManage.IndicatorItem, index: number) => (
|
||||
@ -339,16 +351,16 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
type="link"
|
||||
icon={<PlusOutlined />}
|
||||
onClick={handleAddIndicator}
|
||||
title="添加指标"
|
||||
title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.addIndicator' })}
|
||||
/>
|
||||
)}
|
||||
<Popconfirm
|
||||
title="确定要删除此指标吗?"
|
||||
title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.modal.deleteConfirmContent' })}
|
||||
onConfirm={() => handleDeleteIndicator(index)}
|
||||
okText="确定"
|
||||
cancelText="取消"
|
||||
okText={intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.confirm' })}
|
||||
cancelText={intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' })}
|
||||
>
|
||||
<Button type="link" danger icon={<DeleteOutlined />} title="删除指标" />
|
||||
<Button type="link" danger icon={<DeleteOutlined />} title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.deleteIndicator' })} />
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
@ -359,10 +371,13 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
<div className="common-container">
|
||||
<div className={styles.pageHeader}>
|
||||
<Title level={4} style={{ margin: 0 }}>
|
||||
{isEdit ? '编辑年度模板' : '新增年度模板'}
|
||||
{isEdit
|
||||
? intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.edit' })
|
||||
: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.title' })
|
||||
}
|
||||
</Title>
|
||||
<Button type="link" icon={<ArrowLeftOutlined />} onClick={handleBack}>
|
||||
返回
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.back' })}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -377,26 +392,30 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
wrapperCol={{ span: 17 }}
|
||||
>
|
||||
<Spin spinning={loading}>
|
||||
<Card title="基础信息" bordered={false} className={styles.innerCard}>
|
||||
<Card title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.basicInfo' })} bordered={false} className={styles.innerCard}>
|
||||
<Row gutter={24}>
|
||||
<Col span={8}>
|
||||
<Form.Item
|
||||
label="模板名称"
|
||||
label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' })}
|
||||
name="templateName"
|
||||
rules={[{ required: true, message: '请输入模板名称' }]}
|
||||
rules={[{ required: true, message: `${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseInput' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' })}` }]}
|
||||
>
|
||||
<Input placeholder="请输入模板名称" maxLength={50} />
|
||||
<Input placeholder={`${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseInput' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' })}`} maxLength={50} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Form.Item
|
||||
label="是否限品类"
|
||||
label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.categoryLimitation' })}
|
||||
name="categoryLimitation"
|
||||
rules={[{ required: true, message: '请选择是否限品类' }]}
|
||||
rules={[{ required: true, message: `${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseSelect' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.categoryLimitation' })}` }]}
|
||||
>
|
||||
<Radio.Group>
|
||||
<Radio value={CategoryLimitationType.UNIVERSAL}>{CategoryLimitationTypeText[CategoryLimitationType.UNIVERSAL]}</Radio>
|
||||
<Radio value={CategoryLimitationType.LIMITED}>{CategoryLimitationTypeText[CategoryLimitationType.LIMITED]}</Radio>
|
||||
<Radio value={CategoryLimitationType.UNIVERSAL}>
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.categoryLimitationUniversal' })}
|
||||
</Radio>
|
||||
<Radio value={CategoryLimitationType.LIMITED}>
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.categoryLimitationLimited' })}
|
||||
</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
@ -411,9 +430,9 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
const categoryLimitation = getFieldValue('categoryLimitation');
|
||||
return categoryLimitation === CategoryLimitationType.LIMITED ? (
|
||||
<Form.Item
|
||||
label="选择品类"
|
||||
label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.selectCategory' })}
|
||||
name="categoryId"
|
||||
rules={[{ required: true, message: '请选择品类' }]}
|
||||
rules={[{ required: true, message: `${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseSelect' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.category' })}` }]}
|
||||
>
|
||||
<CategorySelector multiple={false} />
|
||||
</Form.Item>
|
||||
@ -426,11 +445,11 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
<Row gutter={24}>
|
||||
<Col span={8}>
|
||||
<Form.Item
|
||||
label="选择模版"
|
||||
label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.selectTemplate' })}
|
||||
name="copyTemplateId"
|
||||
>
|
||||
<Select
|
||||
placeholder="选择模版"
|
||||
placeholder={intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseSelect' })}
|
||||
loading={templateList.length === 0}
|
||||
onSelect={handleTemplateSelect}
|
||||
>
|
||||
@ -446,9 +465,9 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Form.Item
|
||||
label="模板状态"
|
||||
label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.status' })}
|
||||
name="status"
|
||||
rules={[{ required: true, message: '请选择模板状态' }]}
|
||||
rules={[{ required: true, message: `${intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.pleaseSelect' })}${intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.status' })}` }]}
|
||||
>
|
||||
<Radio.Group>
|
||||
<Radio value={AnnualTemplateStatus.DRAFT}>{AnnualTemplateStatusText[AnnualTemplateStatus.DRAFT]}</Radio>
|
||||
@ -462,7 +481,7 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
|
||||
<Divider />
|
||||
|
||||
<Card title="指标信息" bordered={false} className={styles.innerCard}>
|
||||
<Card title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.indicatorInfo' })} bordered={false} className={styles.innerCard}>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={indicatorList}
|
||||
@ -470,7 +489,7 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
rowKey="orderBy"
|
||||
size="middle"
|
||||
pagination={false}
|
||||
locale={{ emptyText: '暂无指标数据' }}
|
||||
locale={{ emptyText: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.noIndicatorData' }) }}
|
||||
className={styles.indicatorTable}
|
||||
/>
|
||||
</Card>
|
||||
@ -478,9 +497,9 @@ const SupplierAnnualTemplateManageAdd: React.FC = () => {
|
||||
|
||||
<div className={styles.formActions}>
|
||||
<Space>
|
||||
<Button onClick={handleBack}>取消</Button>
|
||||
<Button onClick={handleBack}>{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.cancel' })}</Button>
|
||||
<Button type="primary" htmlType="submit" loading={loading} icon={<SaveOutlined />}>
|
||||
{isEdit ? '更新' : '保存'}
|
||||
{isEdit ? intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.update' }) : intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.save' })}
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { history } from 'umi';
|
||||
import { history, useIntl } from 'umi';
|
||||
import { Button, Card, Descriptions, Divider, Spin, message, Typography, Empty, Space, Table, Tag } from 'antd';
|
||||
import { ArrowLeftOutlined } from '@ant-design/icons';
|
||||
import { getAnnualTemplateDetail } from '@/servers/api/supplierAnnual';
|
||||
@ -37,6 +37,7 @@ const StarOptionsText = {
|
||||
};
|
||||
|
||||
const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [templateDetail, setTemplateDetail] = useState<supplierAnnualTemplateManage.TemplateDetailData | null>(null);
|
||||
const [indicatorList, setIndicatorList] = useState<supplierAnnualTemplateManage.IndicatorItem[]>([]);
|
||||
@ -57,11 +58,11 @@ const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
setIndicatorList(res.data.indicatorList);
|
||||
}
|
||||
} else {
|
||||
message.error(res.message || '获取模板详情失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.getDetailFailed' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取模板详情失败:', error);
|
||||
message.error('获取模板详情失败');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.getDetailFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -72,7 +73,7 @@ const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
if (id) {
|
||||
fetchTemplateDetail(id);
|
||||
} else {
|
||||
message.error('模板ID不存在,无法获取详情');
|
||||
message.error(intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.idNotExist' }));
|
||||
history.goBack();
|
||||
}
|
||||
}, [id]);
|
||||
@ -84,34 +85,34 @@ const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
|
||||
// 获取状态标签
|
||||
const getStatusText = (status: string | undefined) => {
|
||||
if (!status) return '未知状态';
|
||||
return AnnualTemplateStatusText[status as keyof typeof AnnualTemplateStatusText] || '未知状态';
|
||||
if (!status) return intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.unknownStatus' });
|
||||
return AnnualTemplateStatusText[status as keyof typeof AnnualTemplateStatusText] || intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.unknownStatus' });
|
||||
};
|
||||
|
||||
// 指标表格列定义
|
||||
const columns = [
|
||||
{
|
||||
title: '序号',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.serialNumber' }),
|
||||
dataIndex: 'orderBy',
|
||||
key: 'orderBy',
|
||||
width: 80,
|
||||
render: (_: string, __: any, index: number) => index + 1,
|
||||
},
|
||||
{
|
||||
title: '检查项目',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.checkItem' }),
|
||||
dataIndex: 'itemName',
|
||||
key: 'itemName',
|
||||
},
|
||||
{
|
||||
title: '星号项',
|
||||
title: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.starItem' }),
|
||||
dataIndex: 'isStar',
|
||||
key: 'isStar',
|
||||
width: 100,
|
||||
render: (isStar: string) => {
|
||||
return isStar === StarOptions.YES ? (
|
||||
<Tag color="warning">是</Tag>
|
||||
<Tag color="warning">{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.yes' })}</Tag>
|
||||
) : (
|
||||
<Tag>否</Tag>
|
||||
<Tag>{intl.formatMessage({ id: 'supplierAnnualTemplateManage.common.no' })}</Tag>
|
||||
);
|
||||
},
|
||||
},
|
||||
@ -122,29 +123,31 @@ const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
<Card>
|
||||
<div className={styles['page-header']}>
|
||||
<Title level={4} style={{ margin: 0 }}>
|
||||
年度模板详情
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.title' })}
|
||||
</Title>
|
||||
<Button type="link" icon={<ArrowLeftOutlined />} onClick={handleBack}>
|
||||
返回
|
||||
{intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.back' })}
|
||||
</Button>
|
||||
</div>
|
||||
<Spin spinning={loading}>
|
||||
{templateDetail ? (
|
||||
<>
|
||||
<Card title="基本信息" bordered={false} className={styles['detail-card']}>
|
||||
<Card title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.basicInfo' })} bordered={false} className={styles['detail-card']}>
|
||||
<Descriptions column={2} bordered>
|
||||
<Descriptions.Item label="模板名称">
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.templateName' })}>
|
||||
{templateDetail.templateName}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="品类限制">
|
||||
{CategoryLimitationTypeText[templateDetail.categoryLimitation as keyof typeof CategoryLimitationTypeText] || '未知'}
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.categoryLimitation' })}>
|
||||
{templateDetail.categoryLimitation === CategoryLimitationType.UNIVERSAL
|
||||
? intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.categoryLimitationUniversal' })
|
||||
: intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.categoryLimitationLimited' })}
|
||||
</Descriptions.Item>
|
||||
{templateDetail.categoryLimitation === CategoryLimitationType.LIMITED && (
|
||||
<Descriptions.Item label="品类">
|
||||
{templateDetail.categoryName || '未知品类'}
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.category' })}>
|
||||
{templateDetail.categoryName || intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.unknownCategory' })}
|
||||
</Descriptions.Item>
|
||||
)}
|
||||
<Descriptions.Item label="状态">
|
||||
<Descriptions.Item label={intl.formatMessage({ id: 'supplierAnnualTemplateManage.list.status' })}>
|
||||
<Tag color={AnnualTemplateStatusColor[templateDetail.status as keyof typeof AnnualTemplateStatusColor]} className={styles['status-tag']}>
|
||||
{getStatusText(templateDetail.status)}
|
||||
</Tag>
|
||||
@ -154,7 +157,7 @@ const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
|
||||
<Divider />
|
||||
|
||||
<Card title="指标信息" bordered={false} className={styles['detail-card']}>
|
||||
<Card title={intl.formatMessage({ id: 'supplierAnnualTemplateManage.add.indicatorInfo' })} bordered={false} className={styles['detail-card']}>
|
||||
{indicatorList.length > 0 ? (
|
||||
<Table
|
||||
columns={columns}
|
||||
@ -165,12 +168,12 @@ const SupplierAnnualTemplateManageDetail: React.FC = () => {
|
||||
className={styles['indicator-table']}
|
||||
/>
|
||||
) : (
|
||||
<Empty description="暂无指标数据" />
|
||||
<Empty description={intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.noIndicatorData' })} />
|
||||
)}
|
||||
</Card>
|
||||
</>
|
||||
) : (
|
||||
!loading && <Empty description="暂无模板详情数据" />
|
||||
!loading && <Empty description={intl.formatMessage({ id: 'supplierAnnualTemplateManage.detail.noTemplateData' })} />
|
||||
)}
|
||||
</Spin>
|
||||
</Card>
|
||||
|
Reference in New Issue
Block a user