From b0a20db908e4a6545e95283c31927f9d7aa9616c Mon Sep 17 00:00:00 2001
From: linxd <544554903@qq.com>
Date: Fri, 8 Aug 2025 16:32:02 +0800
Subject: [PATCH] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E5=92=8C=E5=B9=B4=E5=AE=A1?=
=?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=96=B0=E5=A2=9E=E9=80=89=E6=8B=A9=E6=A8=A1?=
=?UTF-8?q?=E6=9D=BF=E6=97=B6,=E5=B0=86=E5=93=81=E7=B1=BB=E9=99=90?=
=?UTF-8?q?=E5=88=B6=E5=92=8C=E5=93=81=E7=B1=BB=E5=9B=9E=E5=A1=AB?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../components/BasicInfoStep.tsx | 113 +++++++++++----
.../components/BasicInfoStep.tsx | 131 ++++++++++++++----
2 files changed, 193 insertions(+), 51 deletions(-)
diff --git a/src/pages/supplierAnnualManage/supplierAnnualTaskManage/components/BasicInfoStep.tsx b/src/pages/supplierAnnualManage/supplierAnnualTaskManage/components/BasicInfoStep.tsx
index bf12296..3bddf08 100644
--- a/src/pages/supplierAnnualManage/supplierAnnualTaskManage/components/BasicInfoStep.tsx
+++ b/src/pages/supplierAnnualManage/supplierAnnualTaskManage/components/BasicInfoStep.tsx
@@ -1,8 +1,8 @@
import React, { useState, useEffect, useCallback, forwardRef, useImperativeHandle } from 'react';
-import { Form, Input, Select, DatePicker, Row, Col, Card, Radio } from 'antd';
+import { Form, Input, Select, DatePicker, Row, Col, Card, Radio, message } from 'antd';
import moment from 'moment';
import { useIntl, FormattedMessage } from 'umi';
-import { getAllAnnualTemplates } from '@/servers/api/supplierAnnual';
+import { getAllAnnualTemplates,getAnnualTemplateDetail } from '@/servers/api/supplierAnnual';
import CategorySelector from '@/components/CategorySelector';
import styles from '../supplierAnnualTaskManageAdd.less';
import { CategoryLimitationType } from '@/dicts/supplierTemplateDict';
@@ -83,17 +83,35 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
});
};
+ // 监听表单里 categoryLimitation 的当前值 判断是否显示品类选择器
+ const categoryLimitation = Form.useWatch('categoryLimitation', form);
+ const showCategorySelector = categoryLimitation === CategoryLimitationType.LIMITED;
- // 判断是否显示品类选择器
- const shouldShowCategorySelector = useCallback(() => {
- const categoryLimitation = taskFormData.categoryLimitation;
- return categoryLimitation === CategoryLimitationType.LIMITED;
- }, [taskFormData]);
-
+ // 处理模板选择 将模板的是否限制品类,和品类id赋值
+ const handleTemplateSelect = async (templateId: string) => {
+ const res = await getAnnualTemplateDetail(templateId);
+ if (res.success && res.data) {
+ // 更新表单数据
+ const formValues = {
+ ...taskFormData,
+ categoryLimitation: res.data.categoryLimitation || CategoryLimitationType.UNIVERSAL,
+ categoryId: res.data.categoryId,
+ };
+ form.setFieldsValue(formValues);
+ } else {
+ message.error(
+ intl.formatMessage({ id: 'supplierTemplateManage.message.getDetailFailed' }) || res.message,
+ );
+ }
+ };
return (
-
+
-
+
@@ -121,11 +144,13 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
value: value ? moment(value) : undefined,
})}
normalize={(value) => value && value.format('YYYY')}
- rules={[{ required: true, message: "请选择年审年份" }]}
+ rules={[{ required: true, message: '请选择年审年份' }]}
>
-
@@ -137,7 +162,7 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
({
value: value ? moment(value) : undefined,
})}
@@ -146,7 +171,9 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
@@ -154,7 +181,7 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
({
value: value ? moment(value) : undefined,
})}
@@ -163,7 +190,9 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
@@ -172,9 +201,18 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
@@ -186,12 +224,21 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {
- {shouldShowCategorySelector() && (
+ {showCategorySelector && (
@@ -202,15 +249,27 @@ const BasicInfoStepComponent = (props: BasicInfoStepProps) => {