打分时增加校验:一级指标分值必须大于等于下级所有二级指标分值总和
This commit is contained in:
@ -276,6 +276,19 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.message.addIndicator' }));
|
||||
return;
|
||||
}
|
||||
// 校验每一个一级指标所属的所有二级指标分值是否超过一级指标的分值
|
||||
const hasInvalidScore = templateData.some((stItem) => {
|
||||
const totalScore = stItem.indicatorNdList.reduce(
|
||||
(acc, ndItem) => acc + parseFloat(ndItem.score || '0'),
|
||||
0,
|
||||
);
|
||||
return totalScore > parseFloat(stItem.score || '0');
|
||||
});
|
||||
|
||||
if (hasInvalidScore) {
|
||||
message.error('一级指标分值不能小于二级指标分值之和');
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示确认对话框
|
||||
confirm({
|
||||
@ -341,7 +354,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
form.setFieldsValue({
|
||||
indicatorStMore: res.data.indicatorStMore,
|
||||
indicatorTypeMore: res.data.indicatorTypeMore,
|
||||
})
|
||||
});
|
||||
}
|
||||
} else {
|
||||
message.error(
|
||||
@ -509,7 +522,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
loading={templateList.length === 0}
|
||||
showSearch={true}
|
||||
filterOption={(input, option) => {
|
||||
return (option?.children ?? '').toLowerCase().includes(input.toLowerCase())
|
||||
return (option?.children ?? '').toLowerCase().includes(input.toLowerCase());
|
||||
}}
|
||||
onSelect={handleTemplateSelect}
|
||||
>
|
||||
@ -543,44 +556,54 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={24}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="是否可追加一级指标" name="indicatorStMore" hidden={getUserRole() !== 'admin'}>
|
||||
<Radio.Group onChange={(e) => {
|
||||
<Row gutter={24}>
|
||||
<Col span={8}>
|
||||
<Form.Item
|
||||
label="是否可追加一级指标"
|
||||
name="indicatorStMore"
|
||||
hidden={getUserRole() !== 'admin'}
|
||||
>
|
||||
<Radio.Group
|
||||
onChange={(e) => {
|
||||
if (e.target.value === IndicatorAddOption.CAN_ADD) {
|
||||
form.setFieldsValue({
|
||||
indicatorTypeMore: '',
|
||||
});
|
||||
}
|
||||
}}>
|
||||
<Radio value={IndicatorAddOption.CAN_ADD}>
|
||||
{IndicatorAddOptionText[IndicatorAddOption.CAN_ADD]}
|
||||
</Radio>
|
||||
<Radio value={IndicatorAddOption.CANNOT_ADD}>
|
||||
{IndicatorAddOptionText[IndicatorAddOption.CANNOT_ADD]}
|
||||
</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Form.Item // 这里必须放在Row下
|
||||
shouldUpdate={(prev, curr) => prev.indicatorStMore !== curr.indicatorStMore}
|
||||
noStyle
|
||||
>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue('indicatorStMore') === IndicatorAddOption.CANNOT_ADD ? (
|
||||
<Col span={8}>
|
||||
<Form.Item label="禁用指标类型" name="indicatorTypeMore" hidden={getUserRole() !== 'admin'}>
|
||||
<Select
|
||||
placeholder="请选择禁用指标类型"
|
||||
options={indicatorTypes}
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
) : null
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Radio value={IndicatorAddOption.CAN_ADD}>
|
||||
{IndicatorAddOptionText[IndicatorAddOption.CAN_ADD]}
|
||||
</Radio>
|
||||
<Radio value={IndicatorAddOption.CANNOT_ADD}>
|
||||
{IndicatorAddOptionText[IndicatorAddOption.CANNOT_ADD]}
|
||||
</Radio>
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
{/* <Col span={8}>
|
||||
</Col>
|
||||
<Form.Item // 这里必须放在Row下
|
||||
shouldUpdate={(prev, curr) => prev.indicatorStMore !== curr.indicatorStMore}
|
||||
noStyle
|
||||
>
|
||||
{({ getFieldValue }) =>
|
||||
getFieldValue('indicatorStMore') === IndicatorAddOption.CANNOT_ADD ? (
|
||||
<Col span={8}>
|
||||
<Form.Item
|
||||
label="禁用指标类型"
|
||||
name="indicatorTypeMore"
|
||||
hidden={getUserRole() !== 'admin'}
|
||||
>
|
||||
<Select
|
||||
placeholder="请选择禁用指标类型"
|
||||
options={indicatorTypes}
|
||||
allowClear
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
) : null
|
||||
}
|
||||
</Form.Item>
|
||||
{/* <Col span={8}>
|
||||
<Form.Item
|
||||
label={intl.formatMessage({ id: 'supplierTemplateManage.form.indicatorNdMore' })}
|
||||
name="indicatorNdMore"
|
||||
@ -593,7 +616,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
|
||||
/>
|
||||
</Form.Item>
|
||||
</Col> */}
|
||||
</Row>
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
<Divider />
|
||||
|
Reference in New Issue
Block a user