Commit 38f5072695f63b30c6ce6b2741b003db605abd82
1 parent
b92b8a3c
fix(form): remove field binding when deleting schema #471
Showing
5 changed files
with
8 additions
and
12 deletions
CHANGELOG.zh_CN.md
build/vite/plugin/index.ts
@@ -16,7 +16,7 @@ import { configThemePlugin } from './theme'; | @@ -16,7 +16,7 @@ import { configThemePlugin } from './theme'; | ||
16 | import { configImageminPlugin } from './imagemin'; | 16 | import { configImageminPlugin } from './imagemin'; |
17 | import { configWindiCssPlugin } from './windicss'; | 17 | import { configWindiCssPlugin } from './windicss'; |
18 | import { configSvgIconsPlugin } from './svgSprite'; | 18 | import { configSvgIconsPlugin } from './svgSprite'; |
19 | -// import { configHmrPlugin } from './hmr'; | 19 | +import { configHmrPlugin } from './hmr'; |
20 | 20 | ||
21 | export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { | 21 | export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { |
22 | const { | 22 | const { |
@@ -35,7 +35,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { | @@ -35,7 +35,7 @@ export function createVitePlugins(viteEnv: ViteEnv, isBuild: boolean) { | ||
35 | ]; | 35 | ]; |
36 | 36 | ||
37 | // TODO | 37 | // TODO |
38 | - // !isBuild && vitePlugins.push(configHmrPlugin()); | 38 | + !isBuild && vitePlugins.push(configHmrPlugin()); |
39 | 39 | ||
40 | // @vitejs/plugin-legacy | 40 | // @vitejs/plugin-legacy |
41 | VITE_LEGACY && isBuild && vitePlugins.push(legacy()); | 41 | VITE_LEGACY && isBuild && vitePlugins.push(legacy()); |
src/components/Form/src/hooks/useForm.ts
@@ -77,8 +77,7 @@ export function useForm(props?: Props): UseFormReturnType { | @@ -77,8 +77,7 @@ export function useForm(props?: Props): UseFormReturnType { | ||
77 | }, | 77 | }, |
78 | 78 | ||
79 | removeSchemaByFiled: async (field: string | string[]) => { | 79 | removeSchemaByFiled: async (field: string | string[]) => { |
80 | - const form = await getForm(); | ||
81 | - form.removeSchemaByFiled(field); | 80 | + unref(formRef)?.removeSchemaByFiled(field); |
82 | }, | 81 | }, |
83 | 82 | ||
84 | // TODO promisify | 83 | // TODO promisify |
src/components/Form/src/hooks/useFormEvents.ts
@@ -88,7 +88,9 @@ export function useFormEvents({ | @@ -88,7 +88,9 @@ export function useFormEvents({ | ||
88 | */ | 88 | */ |
89 | async function removeSchemaByFiled(fields: string | string[]): Promise<void> { | 89 | async function removeSchemaByFiled(fields: string | string[]): Promise<void> { |
90 | const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); | 90 | const schemaList: FormSchema[] = cloneDeep(unref(getSchema)); |
91 | - if (!fields) return; | 91 | + if (!fields) { |
92 | + return; | ||
93 | + } | ||
92 | 94 | ||
93 | let fieldList: string[] = isString(fields) ? [fields] : fields; | 95 | let fieldList: string[] = isString(fields) ? [fields] : fields; |
94 | if (isString(fields)) { | 96 | if (isString(fields)) { |
@@ -107,6 +109,7 @@ export function useFormEvents({ | @@ -107,6 +109,7 @@ export function useFormEvents({ | ||
107 | if (isString(field)) { | 109 | if (isString(field)) { |
108 | const index = schemaList.findIndex((schema) => schema.field === field); | 110 | const index = schemaList.findIndex((schema) => schema.field === field); |
109 | if (index !== -1) { | 111 | if (index !== -1) { |
112 | + delete formModel[field]; | ||
110 | schemaList.splice(index, 1); | 113 | schemaList.splice(index, 1); |
111 | } | 114 | } |
112 | } | 115 | } |