供应商评价模板,禁用逻辑

This commit is contained in:
linxd
2025-07-04 13:14:27 +08:00
parent 359559f61b
commit ba28c1ff51
5 changed files with 157 additions and 68 deletions

View File

@ -92,7 +92,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
// 获取所有模板列表
const fetchTemplateList = async () => {
try {
const res = await getAllTemplates();
const res = await getAllTemplates({ status: '1' });
if (res.success && res.data) {
// 如果是修改,需要过滤掉自己
if (location.state?.editData) {
@ -234,6 +234,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
if (isEdit && templateDetail) {
dataToSubmit.id = templateDetail.id;
}
debugger
setLoading(true);
try {
// 调用API接口
@ -337,6 +338,11 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
// setTemplateData(copiedIndicatorStList);
setTemplateData(res.data.indicatorStList);
// 赋值表单,因为需要传递到组件中判断状态
form.setFieldsValue({
indicatorStMore: res.data.indicatorStMore,
indicatorTypeMore: res.data.indicatorTypeMore,
})
}
} else {
message.error(
@ -502,6 +508,10 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
id: 'supplierTemplateManage.form.selectTemplate',
})}
loading={templateList.length === 0}
showSearch={true}
filterOption={(input, option) => {
return (option?.children ?? '').toLowerCase().includes(input.toLowerCase())
}}
onSelect={handleTemplateSelect}
>
{templateList.map((template) =>
@ -534,11 +544,16 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
</Form.Item>
</Col>
</Row>
{getUserRole() === 'admin' && (
<Row gutter={24}>
<Col span={8}>
<Form.Item label="是否可追加一级指标" name="indicatorStMore">
<Radio.Group>
<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>
@ -555,7 +570,7 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
{({ getFieldValue }) =>
getFieldValue('indicatorStMore') === IndicatorAddOption.CANNOT_ADD ? (
<Col span={8}>
<Form.Item label="禁用指标类型" name="indicatorTypeMore">
<Form.Item label="禁用指标类型" name="indicatorTypeMore" hidden={getUserRole() !== 'admin'}>
<Select
placeholder="请选择禁用指标类型"
options={indicatorTypes}
@ -580,7 +595,6 @@ const SupplierTemplateManageAdd: React.FC<PageProps> = ({ breadcrumb, dispatch }
</Form.Item>
</Col> */}
</Row>
)}
</Card>
<Divider />