From 84c9d78fa7feffe3430b7c85dc97383cd7193ba1 Mon Sep 17 00:00:00 2001 From: vben Date: Fri, 30 Oct 2020 22:06:14 +0800 Subject: [PATCH] refactor(form): code optimization and reconstruction --- CHANGELOG.zh_CN.md | 13 + src/components/Form/src/BasicForm.vue | 413 +++--------------- src/components/Form/src/FormAction.tsx | 82 ++-- src/components/Form/src/FormItem.tsx | 20 +- src/components/Form/src/helper.ts | 5 +- src/components/Form/src/hooks/useAdvanced.ts | 179 ++++++++ .../Form/src/hooks/useComponentRegister.ts | 3 +- src/components/Form/src/hooks/useForm.ts | 3 +- .../Form/src/hooks/useFormAction.ts | 233 ++++++++++ .../Form/src/hooks/useFormValues.ts | 38 +- src/components/Form/src/props.ts | 4 + src/components/Form/src/types/form.ts | 2 + src/components/Form/src/types/hooks.ts | 6 + src/components/Modal/src/ModalWrapper.tsx | 30 +- src/components/Modal/src/useModal.ts | 12 +- src/views/demo/comp/modal/Modal4.vue | 60 ++- src/views/demo/comp/modal/index.vue | 6 + 17 files changed, 676 insertions(+), 433 deletions(-) create mode 100644 src/components/Form/src/hooks/useAdvanced.ts create mode 100644 src/components/Form/src/hooks/useFormAction.ts create mode 100644 src/components/Form/src/types/hooks.ts diff --git a/CHANGELOG.zh_CN.md b/CHANGELOG.zh_CN.md index 84d4187a9bd..2698357d7f0 100644 --- a/CHANGELOG.zh_CN.md +++ b/CHANGELOG.zh_CN.md @@ -1,5 +1,17 @@ ## Wip +### ✨ Features + +- 表单组件现在支持直接传入 model 直接进行 set 操作,参考**组件->弹窗扩展->打开弹窗并传递数据** + +- modal 的 useModalInner 现在支持传入回调函数,用于接收外部`transferModalData`传进来的值, + - 用于处理打开弹窗对表单等组件的设置值。参考**组件->弹窗扩展->打开弹窗并传递数据** + - `receiveModalDataRef`这个值暂时保留。尽量少用。后续可能会删除。 + +### ✨ Refactor + +- 表单代码优化重构 + ### 🎫 Chores - 添加部分注释 @@ -10,6 +22,7 @@ - 修复本地代理 post 接口到 https 地址超时错误 - 修复 modal 在不显示 footer 的时候全屏高度计算问题 +- 修复表单重置未删除校验信息错误 ## 2.0.0-rc.6 (2020-10-28) diff --git a/src/components/Form/src/BasicForm.vue b/src/components/Form/src/BasicForm.vue index 39b7485a887..daf60e3813a 100644 --- a/src/components/Form/src/BasicForm.vue +++ b/src/components/Form/src/BasicForm.vue @@ -25,6 +25,8 @@ diff --git a/src/views/demo/comp/modal/index.vue b/src/views/demo/comp/modal/index.vue index 55bf870e892..8fa7c9b38ad 100644 --- a/src/views/demo/comp/modal/index.vue +++ b/src/views/demo/comp/modal/index.vue @@ -48,6 +48,12 @@ data: 'content', info: 'Info', }); + // setTimeout(() => { + // transferModalData({ + // data: 'content1', + // info: 'Info1', + // }); + // }, 3000); openModal4(true); } function openModalLoading() {