mirror of https://github.com/halo-dev/halo-admin
perf: reset form when close editing modal
Signed-off-by: Ryan Wang <i@ryanc.cc>pull/599/head
parent
6aeb9563c1
commit
25c6ec9119
|
@ -8,6 +8,7 @@ import { apiClient } from "@halo-dev/admin-shared";
|
||||||
import { submitForm } from "@formkit/core";
|
import { submitForm } from "@formkit/core";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { useMagicKeys } from "@vueuse/core";
|
import { useMagicKeys } from "@vueuse/core";
|
||||||
|
import { reset } from "@formkit/core";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
|
@ -87,6 +88,7 @@ watch(props, (newVal) => {
|
||||||
}
|
}
|
||||||
formState.value = cloneDeep(initialFormState);
|
formState.value = cloneDeep(initialFormState);
|
||||||
formState.value.metadata.name = uuid();
|
formState.value.metadata.name = uuid();
|
||||||
|
reset("menu-form");
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -8,6 +8,7 @@ import { apiClient } from "@halo-dev/admin-shared";
|
||||||
import { submitForm } from "@formkit/core";
|
import { submitForm } from "@formkit/core";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { useMagicKeys } from "@vueuse/core";
|
import { useMagicKeys } from "@vueuse/core";
|
||||||
|
import { reset } from "@formkit/core";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
|
@ -88,6 +89,7 @@ watch(props, (newVal) => {
|
||||||
}
|
}
|
||||||
formState.value = cloneDeep(initialFormState);
|
formState.value = cloneDeep(initialFormState);
|
||||||
formState.value.metadata.name = uuid();
|
formState.value.metadata.name = uuid();
|
||||||
|
reset("menuitem-form");
|
||||||
});
|
});
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { submitForm } from "@formkit/core";
|
import { submitForm } from "@formkit/core";
|
||||||
import { useMagicKeys } from "@vueuse/core";
|
import { useMagicKeys } from "@vueuse/core";
|
||||||
|
import { reset } from "@formkit/core";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
|
@ -70,6 +71,7 @@ watch(props, (newVal) => {
|
||||||
}
|
}
|
||||||
formState.value = cloneDeep(initialFormState);
|
formState.value = cloneDeep(initialFormState);
|
||||||
selectedRoleTemplates.value.clear();
|
selectedRoleTemplates.value.clear();
|
||||||
|
reset("role-form");
|
||||||
});
|
});
|
||||||
|
|
||||||
const tabActiveId = ref("general");
|
const tabActiveId = ref("general");
|
||||||
|
@ -96,9 +98,9 @@ const handleVisibleChange = (visible: boolean) => {
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<VModal
|
<VModal
|
||||||
|
:title="editingModalTitle"
|
||||||
:visible="visible"
|
:visible="visible"
|
||||||
:width="700"
|
:width="700"
|
||||||
:title="editingModalTitle"
|
|
||||||
@update:visible="handleVisibleChange"
|
@update:visible="handleVisibleChange"
|
||||||
>
|
>
|
||||||
<VTabs v-model:active-id="tabActiveId" type="outline">
|
<VTabs v-model:active-id="tabActiveId" type="outline">
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { rbacAnnotations } from "@/constants/annotations";
|
||||||
import YAML from "yaml";
|
import YAML from "yaml";
|
||||||
import cloneDeep from "lodash.clonedeep";
|
import cloneDeep from "lodash.clonedeep";
|
||||||
import { useMagicKeys } from "@vueuse/core";
|
import { useMagicKeys } from "@vueuse/core";
|
||||||
import { submitForm } from "@formkit/core";
|
import { reset, submitForm } from "@formkit/core";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
visible: {
|
visible: {
|
||||||
|
@ -103,6 +103,7 @@ watch(props, (newVal) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
formState.value = cloneDeep(initialFormState);
|
formState.value = cloneDeep(initialFormState);
|
||||||
|
reset("user-form");
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleFetchRoles = async () => {
|
const handleFetchRoles = async () => {
|
||||||
|
|
Loading…
Reference in New Issue