年审模块
This commit is contained in:
@ -108,7 +108,7 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
if (taskFormData.selectedSuppliers && taskFormData.selectedSuppliers.length > 0) {
|
||||
// 转换上一步的供应商数据,添加评价人员数量字段
|
||||
const suppliersWithEvaluators = taskFormData.selectedSuppliers.map(
|
||||
(supplier) => {
|
||||
(supplier: SupplierItem) => {
|
||||
// 确保evaluators字段存在且为数组
|
||||
const evaluators = supplier.evaluators || [];
|
||||
return {
|
||||
@ -129,52 +129,6 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
|
||||
}, [taskFormData]); // 依赖于 taskFormData,当 model 数据变化时重新计算
|
||||
|
||||
/**
|
||||
* 当选择的人员变化时,更新权重单位列表
|
||||
* 根据所有评价人员的部门信息,动态生成权重单位列表
|
||||
*/
|
||||
useEffect(() => {
|
||||
// 从所有供应商的评价人员中提取部门信息
|
||||
const allDepartments: PersonnelItem[] = [];
|
||||
|
||||
suppliers.forEach((supplier) => {
|
||||
if (supplier.evaluators && supplier.evaluators.length > 0) {
|
||||
supplier.evaluators.forEach((evaluator) => {
|
||||
if (evaluator.userDept) {
|
||||
allDepartments.push(evaluator);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// 去重部门列表 - 根据部门ID去重
|
||||
const departmentMap = new Map<string, PersonnelItem>();
|
||||
allDepartments.forEach((dept) => {
|
||||
if (dept.userDeptId && !departmentMap.has(dept.userDeptId)) {
|
||||
departmentMap.set(dept.userDeptId, dept);
|
||||
}
|
||||
});
|
||||
const uniqueDepartments = Array.from(departmentMap.values());
|
||||
|
||||
// 如果有部门数据,生成权重单位列表
|
||||
if (uniqueDepartments.length > 0) {
|
||||
const newTaskDeptWeightList: DeptWeightItem[] = uniqueDepartments.map((dept) => ({
|
||||
weightDept: dept.userDeptId || '',
|
||||
weightValue: '0', // 默认权重为0
|
||||
weightDeptName: dept.userDept || '',
|
||||
}));
|
||||
|
||||
// 更新权重单位列表,保留原有权重值
|
||||
setTaskDeptWeightList((prevList) => {
|
||||
const prevValuesMap = new Map(prevList.map((item) => [item.weightDept, item.weightValue]));
|
||||
|
||||
return newTaskDeptWeightList.map((item) => ({
|
||||
...item,
|
||||
weightValue: prevValuesMap.get(item.weightDept) || '0', // 如果有原来的权重值则保留
|
||||
}));
|
||||
});
|
||||
}
|
||||
}, [suppliers]); // 依赖于suppliers,当选择的供应商或其评价人员变化时重新计算
|
||||
|
||||
/**
|
||||
* 更新表单数据
|
||||
@ -186,7 +140,7 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
const { suppliersWithEvaluators }: { suppliersWithEvaluators: SupplierItem[] } = updatedData;
|
||||
// 构建供应商ID列表
|
||||
const supplierIds = suppliersWithEvaluators.map((supplier) => ({
|
||||
id: supplier.id,
|
||||
suppliedId: supplier.id,
|
||||
userIds: supplier.evaluators?.map((e: PersonnelItem) => e.id) || [],
|
||||
}));
|
||||
|
||||
@ -223,48 +177,6 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
if (selectedRowKeys.length === 0) return;
|
||||
setBatchSelectModalVisible(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理设置评分单位权重按钮点击事件
|
||||
* 打开权重设置模态框
|
||||
*/
|
||||
const handleWeightSetting = () => {
|
||||
// 将权重数据转换为表单初始值
|
||||
form.setFieldsValue({
|
||||
taskDeptWeightList: taskDeptWeightList.reduce((acc, item) => {
|
||||
acc[item.weightDept] = parseInt(item.weightValue, 10) || 0;
|
||||
return acc;
|
||||
}, {} as Record<string, number>),
|
||||
});
|
||||
|
||||
setWeightSettingModalVisible(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存权重设置
|
||||
* 更新本地权重数据并同步到 Dva model
|
||||
*/
|
||||
const handleSaveWeights = () => {
|
||||
form.validateFields().then((values) => {
|
||||
// 将表单值转换回权重列表格式
|
||||
const updatedTaskDeptWeightList = taskDeptWeightList.map((item) => ({
|
||||
...item,
|
||||
weightValue: values.taskDeptWeightList[item.weightDept].toString(),
|
||||
}));
|
||||
|
||||
// 更新本地状态
|
||||
setTaskDeptWeightList(updatedTaskDeptWeightList);
|
||||
|
||||
// 同步到Dva model
|
||||
updateFormData({
|
||||
suppliersWithEvaluators: suppliers,
|
||||
taskDeptWeightList: updatedTaskDeptWeightList,
|
||||
});
|
||||
|
||||
setWeightSettingModalVisible(false);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 处理选择评价人员按钮点击事件
|
||||
* 打开评价人员选择模态框
|
||||
@ -376,7 +288,7 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
// 渲染组件
|
||||
return (
|
||||
<div className={styles.evaluatorSelectStep}>
|
||||
<Card title="选择评价人员" bordered={false} className="inner-card">
|
||||
<Card title="选择年审人员" bordered={false} className="inner-card">
|
||||
{/* 工具栏区域 */}
|
||||
{mode !== 'division' && (
|
||||
<div className={styles.toolbar}>
|
||||
@ -386,10 +298,7 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
onClick={handleBatchSelect}
|
||||
disabled={selectedRowKeys.length === 0}
|
||||
>
|
||||
批量选择评价人员
|
||||
</Button>
|
||||
<Button onClick={handleWeightSetting} disabled={taskDeptWeightList.length === 0}>
|
||||
设置评分单位权重
|
||||
批量选择年审人员
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
@ -412,7 +321,7 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* 批量选择评价人员弹窗 */}
|
||||
{/* 批量选择年审人员弹窗 */}
|
||||
<BatchEvaluatorModal
|
||||
visible={batchSelectModalVisible}
|
||||
onCancel={() => setBatchSelectModalVisible(false)}
|
||||
@ -421,7 +330,7 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
onSelect={handleBatchEvaluatorSelect}
|
||||
/>
|
||||
|
||||
{/* 单个供应商评价人员弹窗 */}
|
||||
{/* 单个供应商年审人员弹窗 */}
|
||||
<SupplierEvaluatorModal
|
||||
visible={evaluatorModalVisible}
|
||||
onCancel={() => setEvaluatorModalVisible(false)}
|
||||
@ -432,14 +341,6 @@ const EvaluatorSelectStepComponent = (props: EvaluatorSelectStepProps) => {
|
||||
mode={modalMode}
|
||||
/>
|
||||
|
||||
{/* 权重设置弹窗 */}
|
||||
<WeightSettingModal
|
||||
visible={weightSettingModalVisible}
|
||||
onCancel={() => setWeightSettingModalVisible(false)}
|
||||
onOk={handleSaveWeights}
|
||||
taskDeptWeightList={taskDeptWeightList}
|
||||
form={form}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
|
Reference in New Issue
Block a user