防抖
This commit is contained in:
@ -38,7 +38,8 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||
const [suppliers, setSuppliers] = useState<Supplier[]>([]);
|
||||
const [timelimitOption, setTimelimitOption] = useState<any[]>([]);
|
||||
const supplierDetailModal = useSupplierDetailModal();
|
||||
|
||||
//提交防抖
|
||||
const [submitting, setSubmitting] = useState(false);
|
||||
const removeSupplier = (id: string) => {
|
||||
setSuppliers(suppliers.filter((s) => s.id !== id));
|
||||
};
|
||||
@ -49,6 +50,8 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (submitting) return; // 防重复提交
|
||||
setSubmitting(true);
|
||||
try {
|
||||
const values = await form.validateFields();
|
||||
if (suppliers.length === 0) {
|
||||
@ -75,6 +78,8 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||
}
|
||||
} catch (err) {
|
||||
// 校验失败
|
||||
} finally {
|
||||
setSubmitting(false); // 无论成功失败都解锁
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
@ -114,7 +119,7 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||
return (
|
||||
<>
|
||||
<Modal
|
||||
title="供应商退出"
|
||||
title="供应商黑名单"
|
||||
visible={visible}
|
||||
onCancel={onCancel}
|
||||
width={900}
|
||||
@ -143,19 +148,7 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||
wrapperCol={{ flex: 1 }} // 输入框区域自适应剩余空间
|
||||
layout="horizontal"
|
||||
>
|
||||
|
||||
{/* <Form.Item
|
||||
label="黑名单类型"
|
||||
name="backlistType"
|
||||
rules={[{ required: true, message: '请选择黑名单类型' }]}
|
||||
>
|
||||
<Select placeholder="请选择黑名单类型">
|
||||
{DEPT_OPTIONS.map((opt) => (
|
||||
<Option key={opt.value} value={opt.value}>{opt.label}</Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item> */}
|
||||
|
||||
|
||||
<Form.Item
|
||||
label="时限类型"
|
||||
name="timelimitType"
|
||||
@ -181,7 +174,7 @@ const CreateBlacklistModal: React.FC<CreateBlacklistModalProps> = ({
|
||||
</div>
|
||||
|
||||
<div style={{ marginTop: 28, textAlign: "center" }}>
|
||||
<Button type="primary" style={{ marginRight: 24 }} onClick={handleSubmit}>提交审批</Button>
|
||||
<Button type="primary" style={{ marginRight: 24 }} onClick={handleSubmit} disabled={submitting}>提交审批</Button>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
Reference in New Issue
Block a user