提交一下 换git仓库了
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import React, { useState, useEffect, forwardRef, useImperativeHandle } from 'react';
|
||||
import { Card, Row, Col, Input, Select, Radio, Table, Button, Space, Pagination, Form } from 'antd';
|
||||
import { SearchOutlined, ArrowRightOutlined } from '@ant-design/icons';
|
||||
import styles from '../supplierTaskManageAdd.less';
|
||||
@ -17,7 +17,7 @@ interface SupplierItem {
|
||||
category: string;
|
||||
}
|
||||
|
||||
const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFormDataChange }) => {
|
||||
const SupplierSelectStep = forwardRef<any, SupplierSelectStepProps>(({ formData, onFormDataChange }, ref) => {
|
||||
const [filterForm] = Form.useForm();
|
||||
const [categoryKeyword, setCategoryKeyword] = useState<string>('');
|
||||
const [selectedCategory, setSelectedCategory] = useState<string | undefined>(undefined);
|
||||
@ -33,6 +33,25 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
const [pendingSelectedRowKeys, setPendingSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
const [selectedSelectedRowKeys, setSelectedSelectedRowKeys] = useState<React.Key[]>([]);
|
||||
|
||||
// 暴露表单方法给父组件
|
||||
useImperativeHandle(ref, () => ({
|
||||
validateFields: () => {
|
||||
// 这里可以添加自定义验证逻辑
|
||||
return Promise.resolve();
|
||||
},
|
||||
getFieldsValue: () => {
|
||||
return {
|
||||
selectedSuppliers,
|
||||
supplierIds: selectedSuppliers.map(supplier => ({ id: supplier.key }))
|
||||
};
|
||||
},
|
||||
setFieldsValue: (values: any) => {
|
||||
if (values.selectedSuppliers) {
|
||||
setSelectedSuppliers(values.selectedSuppliers);
|
||||
}
|
||||
},
|
||||
}));
|
||||
|
||||
// 初始化数据
|
||||
useEffect(() => {
|
||||
// 从formData中恢复已选供应商
|
||||
@ -87,7 +106,10 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
|
||||
// 更新表单数据
|
||||
const updateFormData = (suppliers: SupplierItem[]) => {
|
||||
onFormDataChange({ selectedSuppliers: suppliers });
|
||||
onFormDataChange({
|
||||
selectedSuppliers: suppliers,
|
||||
supplierIds: suppliers.map(supplier => ({ id: supplier.key }))
|
||||
});
|
||||
};
|
||||
|
||||
// 处理筛选条件变化
|
||||
@ -242,7 +264,7 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
onValuesChange={handleFilterChange}
|
||||
>
|
||||
<Row gutter={24}>
|
||||
<Col span={12}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="选择类别" name="category">
|
||||
<Select
|
||||
placeholder="请选择"
|
||||
@ -254,19 +276,17 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="品类关键字" name="categoryKeyword">
|
||||
<Input placeholder="请输入" allowClear />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={24}>
|
||||
<Col span={12}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="品类范围" name="categoryRange">
|
||||
<Input placeholder="请输入" allowClear />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="近一年有付款" name="hasPaymentLastYear" initialValue="是">
|
||||
<Radio.Group>
|
||||
<Radio value="是">是</Radio>
|
||||
@ -274,9 +294,7 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
</Radio.Group>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
<Row gutter={24}>
|
||||
<Col span={12}>
|
||||
<Col span={8}>
|
||||
<Form.Item label="准入部门" name="department">
|
||||
<Select
|
||||
placeholder="请选择"
|
||||
@ -288,7 +306,7 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Col span={8}>
|
||||
<Form.Item wrapperCol={{ offset: 6, span: 18 }}>
|
||||
<Button type="primary" onClick={() => filterForm.submit()}>
|
||||
查询
|
||||
@ -391,6 +409,6 @@ const SupplierSelectStep: React.FC<SupplierSelectStepProps> = ({ formData, onFor
|
||||
</Row>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
export default SupplierSelectStep;
|
||||
|
Reference in New Issue
Block a user