You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

36 lines
1.3 KiB

import { jsx as _jsx } from "react/jsx-runtime";
import Main from './main';
import { Modal, Form } from 'antd';
import { useRef } from "react";
export default function ({ when = false }) {
const form = Form.useFormInstance();
const aRef = useRef(true);
return (_jsx(Main, Object.assign({ when: when }, { children: ({ isActive, onConfirm, onCancel }) => {
console.log(isActive);
if (!form.isFieldsTouched()) {
// @ts-ignore
onConfirm();
return null;
}
if (form.isFieldsTouched() && isActive) {
if (!aRef.current) {
aRef.current = true;
return;
}
Modal.confirm({
title: '请确认当前页面信息是否提交?\n' +
'未提交的信息不进行保存,避免失误操作请再次确认是否离开',
onOk: (e) => {
aRef.current = false;
onConfirm(e);
Modal.destroyAll();
},
onCancel: (e) => {
onCancel(e);
Modal.destroyAll();
},
});
}
return null;
} })));
}