Skip to content

Commit 56c0327

Browse files
author
昔梦
committed
fix:DrawerList点击确定增加表单校验
1 parent 6ff699a commit 56c0327

File tree

1 file changed

+14
-3
lines changed
  • packages/form-render/src/widgets/listDrawer

1 file changed

+14
-3
lines changed

packages/form-render/src/widgets/listDrawer/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,26 @@ const TableList: React.FC<Props> = (props: any) => {
9696
} else {
9797
form.setFieldValue([...rootPath, indexRef.current], itemData);
9898
}
99-
hanldeConfirm();
99+
handleCloseDrawer();
100100
};
101101

102-
const hanldeConfirm = () => {
102+
const handleCloseDrawer = () => {
103103
setItemData(null);
104104
setVisible(false);
105105
indexRef.current = null;
106106
};
107107

108+
const hanldeConfirm = () => {
109+
form
110+
.validateFields()
111+
.then(res => {
112+
handleCloseDrawer();
113+
})
114+
.catch(error => {
115+
console.log('表单校验错误', error);
116+
});
117+
};
118+
108119
const columns: any = sortProperties(Object.entries(columnSchema))
109120
.map(([dataIndex, item]) => {
110121
const { required, title, tooltip, width, columnHidden } = item;
@@ -259,7 +270,7 @@ const TableList: React.FC<Props> = (props: any) => {
259270
)}
260271
{visible && (
261272
<FormDrawer
262-
{...drawerProps}
273+
{...drawerProps}
263274
schema={schema}
264275
data={itemData}
265276
widgets={widgets}

0 commit comments

Comments
 (0)