Commit 7fa2cf99 authored by XieZhiXiong's avatar XieZhiXiong

fix: 修复删除、确认没有触发页面返回提示的问题

parent 21178661
......@@ -2,7 +2,21 @@ import { FormPath } from '@formily/antd';
import { Space } from 'antd';
import React from 'react';
interface OperationProps {
/**
* 删除之后触发事件
*/
onDeleteAfter?: () => void,
/**
* 保存之后触发事件
*/
onSaveAfter?: () => void,
}
const Operation = (props) => {
const xComponentProps: OperationProps = props.props['x-component-props'] || {};
const { onDeleteAfter, onSaveAfter } = xComponentProps;
/** 这里用index 做值貌似有点问题 */
const [, index] = props.name.split(".")
const id = props.form.getFieldValue(`datas.${index}.id`);
......@@ -42,6 +56,7 @@ const Operation = (props) => {
props.form.setFieldValue(`datas`, newDataSource.filter((_item) => _item.status === 1))
props.form.setFieldValue(`cacheData`, newDataSource)
onDeleteAfter?.();
}
const handleSave = () => {
......@@ -74,6 +89,7 @@ const Operation = (props) => {
});
props.form.setFieldValue(`cacheData`, newDataSource)
onSaveAfter?.();
}
if (editable) {
......
......@@ -142,7 +142,10 @@ export const schema: ISchema = {
operations: {
title: '操作',
'x-component': 'Operation',
editable: false
editable: false,
'x-component-props': {
onDeleteAfter: '{{handleActionsAfter}}',
},
}
}
}
......
......@@ -198,6 +198,13 @@ const SourceList = () => {
}
}
/**
* 处理删除操作、确认操作没有触发 onFormInputChange 的问题
*/
const handleActionsAfter = () => {
setUnsaved(true)
};
return (
<AnchorPage
title={intl.formatMessage({ id: 'material.sourceList', defaultMessage: '货源清单' })}
......@@ -218,6 +225,7 @@ const SourceList = () => {
previewPlaceholder=' '
expressionScope={{
renderAddition: renderAddition(),
handleActionsAfter: handleActionsAfter,
}}
initialValues={initialValue}
onSubmit={handleSubmit}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment