维护国际化
This commit is contained in:
@ -11,7 +11,7 @@ import type { ColumnsType } from 'antd/es/table';
|
||||
import EvaluateTemplateTable from '@/components/EvaluateTemplateTable';
|
||||
import { getTemplateDetail } from '@/servers/api/supplierEvaluate';
|
||||
import type { Dispatch } from 'umi';
|
||||
import { connect } from 'umi';
|
||||
import { connect, useIntl } from 'umi';
|
||||
import type { SupplierTaskModelState } from '@/models/supplierTaskManage';
|
||||
|
||||
// 组件接收的Props定义
|
||||
@ -31,6 +31,7 @@ enum EvaluateType {
|
||||
|
||||
// 定义组件,使用 innerRef 代替直接的 ref
|
||||
const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
const intl = useIntl();
|
||||
const { supplierTaskManage, dispatch, innerRef } = props;
|
||||
|
||||
// 从 model 获取表单数据,避免通过 props 层层传递
|
||||
@ -134,11 +135,11 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
setIndicators(newIndicators);
|
||||
}
|
||||
} else {
|
||||
message.error(res.message || '获取模板详情失败');
|
||||
message.error(res.message || intl.formatMessage({ id: 'supplierTaskManage.message.fetchTemplatesFailed' }));
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取模板详情失败:', error);
|
||||
message.error('获取模板详情失败');
|
||||
console.error(intl.formatMessage({ id: 'supplierTaskManage.message.fetchTemplatesFailed' }), error);
|
||||
message.error(intl.formatMessage({ id: 'supplierTaskManage.message.fetchTemplatesFailed' }));
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@ -170,7 +171,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
// 打开指标分工弹窗
|
||||
const handleOpenDivisionModal = () => {
|
||||
if (selectedRowKeys.length === 0) {
|
||||
message.warning('请先选择评价人员');
|
||||
message.warning(intl.formatMessage({ id: 'supplierTaskManage.message.noSelectedEvaluators' }));
|
||||
return;
|
||||
}
|
||||
// 直接显示批量模板选择弹窗
|
||||
@ -230,14 +231,14 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
// 保存指标分配
|
||||
const handleSaveIndicatorAssignment = () => {
|
||||
if (!currentUserId) {
|
||||
message.warning('未选择评价人员');
|
||||
message.warning(intl.formatMessage({ id: 'supplierTaskManage.message.noSelectedEvaluators' }));
|
||||
return;
|
||||
}
|
||||
// 将选择回来的指标提取二级指标id
|
||||
const indicatorNdListIds = getIndicatorNdListIds(selectedTemplateItems);
|
||||
handleIndicatorAssignment(indicatorNdListIds, [currentUserId]);
|
||||
setTemplateViewModalVisible(false);
|
||||
message.success('已设置评价人员指标分工');
|
||||
message.success(intl.formatMessage({ id: 'supplierTaskManage.message.evaluatorDivisionSet' }));
|
||||
};
|
||||
|
||||
// 批量设置指标分工
|
||||
@ -247,7 +248,10 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
const userIds = selectedRowKeys.map((key) => key.toString());
|
||||
handleIndicatorAssignment(indicatorNdListIds, userIds);
|
||||
setBatchTemplateModalVisible(false);
|
||||
message.success(`已为${selectedRowKeys.length}名评价人员设置分工`);
|
||||
message.success(intl.formatMessage(
|
||||
{ id: 'supplierTaskManage.message.batchDivisionSet' },
|
||||
{ count: selectedRowKeys.length }
|
||||
));
|
||||
};
|
||||
|
||||
// 处理单个评价人员的指标分工
|
||||
@ -274,7 +278,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
const handleViewAssignment = (person: SupplierTaskManage.PersonnelItem) => {
|
||||
const assignment = person.indicatorIds;
|
||||
if (!assignment) {
|
||||
message.info('该评价人员尚未设置分工');
|
||||
message.info(intl.formatMessage({ id: 'supplierTaskManage.message.noEvaluatorDivision' }));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -300,10 +304,10 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
// 删除评价人员
|
||||
const handleRemoveEvaluator = (userId: string) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '确定要删除该评价人员吗?',
|
||||
okText: '确定',
|
||||
cancelText: '取消',
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.modal.delete.title' }),
|
||||
content: intl.formatMessage({ id: 'supplierTaskManage.modal.delete.content' }),
|
||||
okText: intl.formatMessage({ id: 'supplierTaskManage.button.confirm' }),
|
||||
cancelText: intl.formatMessage({ id: 'supplierTaskManage.button.cancel' }),
|
||||
onOk: () => {
|
||||
// 更新评价人员列表
|
||||
setEvaluators((prev) => prev.filter((e) => e.id !== userId));
|
||||
@ -316,7 +320,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
},
|
||||
});
|
||||
|
||||
message.success('已删除评价人员');
|
||||
message.success(intl.formatMessage({ id: 'supplierTaskManage.message.deleteSuccess' }));
|
||||
},
|
||||
});
|
||||
};
|
||||
@ -333,7 +337,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
if (evaluators.length === 0) {
|
||||
return {
|
||||
valid: false,
|
||||
message: '请先分配评价人员',
|
||||
message: intl.formatMessage({ id: 'supplierTaskManage.message.noEvaluatorAssigned' }),
|
||||
};
|
||||
}
|
||||
return { valid: true };
|
||||
@ -350,46 +354,46 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
// 表格列定义
|
||||
const columns: ColumnsType<SupplierTaskManage.PersonnelItem> = [
|
||||
{
|
||||
title: '姓名',
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.column.name' }),
|
||||
dataIndex: 'name',
|
||||
key: 'name',
|
||||
},
|
||||
{
|
||||
title: '所属部门',
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.column.userDept' }),
|
||||
dataIndex: 'userDept',
|
||||
key: 'userDept',
|
||||
},
|
||||
{
|
||||
title: '员工编号',
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.column.id' }),
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
},
|
||||
{
|
||||
title: '是否设置分工',
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.column.hasDivision' }),
|
||||
key: 'hasDivision',
|
||||
render: (_: any, record: SupplierTaskManage.PersonnelItem) => {
|
||||
if (!record.indicatorIds || record.indicatorIds.length === 0)
|
||||
return <Tag color="red">未设置</Tag>;
|
||||
return <Tag color="green">已设置</Tag>;
|
||||
return <Tag color="red">{intl.formatMessage({ id: 'supplierTaskManage.status.notSet' })}</Tag>;
|
||||
return <Tag color="green">{intl.formatMessage({ id: 'supplierTaskManage.status.set' })}</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
title: intl.formatMessage({ id: 'supplierTaskManage.column.action' }),
|
||||
key: 'action',
|
||||
render: (_: any, record: SupplierTaskManage.PersonnelItem) => (
|
||||
<Space size="middle">
|
||||
{!record.isSelected && (
|
||||
<>
|
||||
<Button type="link" onClick={() => handleAssignIndicators(record.id)}>
|
||||
评价指标分工
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.evaluatorDivision' })}
|
||||
</Button>
|
||||
<Button type="link" onClick={() => handleRemoveEvaluator(record.id)}>
|
||||
删除
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.delete' })}
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
<Button type="link" onClick={() => handleViewAssignment(record)}>
|
||||
查看
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.view' })}
|
||||
</Button>
|
||||
</Space>
|
||||
),
|
||||
@ -409,7 +413,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
onClick={handleOpenDivisionModal}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
>
|
||||
设置评价指标分工
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.setEvaluationDivision' })}
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
@ -424,16 +428,19 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
|
||||
{/* 批量选择指标模板弹窗 */}
|
||||
<Modal
|
||||
title={`批量设置评价指标分工 (已选择 ${selectedRowKeys.length} 名评价人员)`}
|
||||
title={intl.formatMessage(
|
||||
{ id: 'supplierTaskManage.modal.batchDivision.title' },
|
||||
{ count: selectedRowKeys.length }
|
||||
)}
|
||||
visible={batchTemplateModalVisible}
|
||||
onCancel={handleCloseBatchTemplateModal}
|
||||
width={1200}
|
||||
footer={[
|
||||
<Button key="cancel" onClick={handleCloseBatchTemplateModal}>
|
||||
取消
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.cancel' })}
|
||||
</Button>,
|
||||
<Button key="save" type="primary" onClick={handleBatchSetDivision}>
|
||||
确定并保存
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.saveAndConfirm' })}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
@ -447,7 +454,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
/>
|
||||
) : (
|
||||
<div style={{ textAlign: 'center', padding: '20px 0' }}>
|
||||
{loading ? '加载中...' : '暂无模板数据'}
|
||||
{loading ? intl.formatMessage({ id: 'supplierTaskManage.text.loading' }) : intl.formatMessage({ id: 'supplierTaskManage.text.noTemplateData' })}
|
||||
</div>
|
||||
)}
|
||||
</Spin>
|
||||
@ -455,16 +462,16 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
|
||||
{/* 设置评价指标分工 */}
|
||||
<Modal
|
||||
title="设置评价指标分工"
|
||||
title={intl.formatMessage({ id: 'supplierTaskManage.modal.division.title' })}
|
||||
visible={templateViewModalVisible}
|
||||
onCancel={handleCloseTemplateViewModal}
|
||||
width={1200}
|
||||
footer={[
|
||||
<Button key="cancel" onClick={handleCloseTemplateViewModal}>
|
||||
取消
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.cancel' })}
|
||||
</Button>,
|
||||
<Button key="save" type="primary" onClick={handleSaveIndicatorAssignment}>
|
||||
保存
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.save' })}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
@ -480,7 +487,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
/>
|
||||
) : (
|
||||
<div style={{ textAlign: 'center', padding: '20px 0' }}>
|
||||
{loading ? '加载中...' : '暂无模板数据'}
|
||||
{loading ? intl.formatMessage({ id: 'supplierTaskManage.text.loading' }) : intl.formatMessage({ id: 'supplierTaskManage.text.noTemplateData' })}
|
||||
</div>
|
||||
)}
|
||||
</Spin>
|
||||
@ -488,13 +495,16 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
|
||||
{/* 查看评价人员指标分工弹窗 */}
|
||||
<Modal
|
||||
title={`评价人员 ${getCurrentEvaluatorName()} 的指标分工`}
|
||||
title={intl.formatMessage(
|
||||
{ id: 'supplierTaskManage.modal.viewDivision.title' },
|
||||
{ name: getCurrentEvaluatorName() }
|
||||
)}
|
||||
visible={viewModalVisible}
|
||||
onCancel={handleCloseViewModal}
|
||||
width={1200}
|
||||
footer={[
|
||||
<Button key="close" onClick={handleCloseViewModal}>
|
||||
关闭
|
||||
{intl.formatMessage({ id: 'supplierTaskManage.button.close' })}
|
||||
</Button>,
|
||||
]}
|
||||
>
|
||||
@ -503,7 +513,7 @@ const DivisionStepComponent = (props: DivisionStepProps) => {
|
||||
<EvaluateTemplateTable value={filteredIndicators} isDetail={true} />
|
||||
) : (
|
||||
<div style={{ textAlign: 'center', padding: '20px 0' }}>
|
||||
{loading ? '加载中...' : '暂无指标分工数据'}
|
||||
{loading ? intl.formatMessage({ id: 'supplierTaskManage.text.loading' }) : intl.formatMessage({ id: 'supplierTaskManage.text.noDivisionData' })}
|
||||
</div>
|
||||
)}
|
||||
</Spin>
|
||||
|
Reference in New Issue
Block a user