import React, { useEffect, useState } from "react";
import { Form, Input, message, Modal as AntdModal, Spin } from "antd";
import { save替换nameApi } from "../api";
import { useStore } from "../index";
export default function Modal() {
const { pagination, current, setCurrent, open, setOpen } = useStore();
const [form] = Form.useForm();
const [confirmLoading, setConfirmLoading] = useState(false);
useEffect(() => {
if (open && current) {
form.setFieldsValue(current);
} else {
form.resetFields();
}
}, [open, current]);
function onOk(val: any) {
const hide = message.loading('提交中,请稍后...', 0);
setConfirmLoading(true);
const params: 替换name.ListVO = {
...val,
id: current?.id,
};
save替换nameApi(params)
.then((res) => {
hide();
setConfirmLoading(false);
message.success(res.result);
onCancel();
pagination.setLoading(true);
})
.catch((error) => {
hide();
setConfirmLoading(false);
message.error(error.message);
});
}
function onCancel() {
setCurrent(undefined);
setOpen(false);
}
return (
替换name`}
open={open}
maskClosable={false}
onOk={form.submit}
confirmLoading={confirmLoading}
onCancel={onCancel}
>
);
}