封装选择供应商组件; 丰富选择品类库 说明文档
This commit is contained in:
@ -22,7 +22,6 @@ interface TemplateItem {
|
||||
const BasicInfoStep = forwardRef<any, BasicInfoStepProps>(({ formData, onFormDataChange }, ref) => {
|
||||
const [form] = Form.useForm();
|
||||
const [templates, setTemplates] = useState<TemplateItem[]>([]);
|
||||
const [selectedCategoryId, setSelectedCategoryId] = useState<string | undefined>(undefined);
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
|
||||
// 暴露表单方法给父组件
|
||||
@ -64,11 +63,6 @@ const BasicInfoStep = forwardRef<any, BasicInfoStepProps>(({ formData, onFormDat
|
||||
// 初始化表单数据
|
||||
if (formData) {
|
||||
form.setFieldsValue(formData);
|
||||
|
||||
// 设置已选品类
|
||||
if (formData.categoryId) {
|
||||
setSelectedCategoryId(formData.categoryId);
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
|
||||
@ -78,6 +72,7 @@ const BasicInfoStep = forwardRef<any, BasicInfoStepProps>(({ formData, onFormDat
|
||||
if (changedValues.templateId) {
|
||||
const template = templates.find((t) => t.id === changedValues.templateId);
|
||||
if (template) {
|
||||
// 更新品类限制类型
|
||||
form.setFieldsValue({
|
||||
categoryLimitation: template.categoryLimitation || '0',
|
||||
});
|
||||
@ -87,16 +82,10 @@ const BasicInfoStep = forwardRef<any, BasicInfoStepProps>(({ formData, onFormDat
|
||||
form.setFieldsValue({
|
||||
categoryId: undefined,
|
||||
});
|
||||
setSelectedCategoryId(undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理品类变更
|
||||
if (changedValues.categoryId) {
|
||||
setSelectedCategoryId(changedValues.categoryId?.[0]);
|
||||
}
|
||||
|
||||
// 默认设置weightStatus为0
|
||||
const formattedValues = {
|
||||
...allValues,
|
||||
@ -122,11 +111,6 @@ const BasicInfoStep = forwardRef<any, BasicInfoStepProps>(({ formData, onFormDat
|
||||
return categoryLimitation === CategoryLimitationType.LIMITED;
|
||||
}, [form]);
|
||||
|
||||
// 处理品类选择变化
|
||||
const handleCategoryChange = useCallback((value: string | string[]) => {
|
||||
const categoryId = Array.isArray(value) ? value[0] : value;
|
||||
setSelectedCategoryId(categoryId);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className={styles.basicInfoStep}>
|
||||
@ -212,7 +196,7 @@ const BasicInfoStep = forwardRef<any, BasicInfoStepProps>(({ formData, onFormDat
|
||||
name="categoryId"
|
||||
rules={[{ required: true, message: '请选择品类' }]}
|
||||
>
|
||||
<CategorySelector onChange={handleCategoryChange} />
|
||||
<CategorySelector multiple={false} />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
)}
|
||||
|
Reference in New Issue
Block a user