From 0de4ff29056d6c9f4cea0761ec9eb3f6b66ee9ed Mon Sep 17 00:00:00 2001 From: zhangtao <9480807882@qq.com> Date: Thu, 31 Jul 2025 00:56:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor(system):=20=E6=94=B9=E8=BF=9B=E8=A1=A8?= =?UTF-8?q?=E5=8D=95=E9=87=8D=E7=BD=AE=E9=80=BB=E8=BE=91=EF=BC=8C=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E5=88=9D=E5=A7=8B=E6=95=B0=E6=8D=AE=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 统一各系统模块的表单重置逻辑,通过定义初始表单数据常量并使用Object.assign完全重置表单状态,替代之前仅重置id字段的方式 --- frontend/src/App.vue | 8 ------ frontend/src/views/monitor/job/index.vue | 25 ++++++++++++++++-- frontend/src/views/system/config/index.vue | 13 +++++++++- frontend/src/views/system/dept/index.vue | 13 +++++++++- .../system/dict/components/DataDrawer.vue | 17 +++++++++++- frontend/src/views/system/dict/index.vue | 12 ++++++++- frontend/src/views/system/menu/index.vue | 26 ++++++++++++++++++- frontend/src/views/system/notice/index.vue | 16 ++++++++++-- frontend/src/views/system/position/index.vue | 12 ++++++++- frontend/src/views/system/role/index.vue | 12 ++++++++- frontend/src/views/system/user/index.vue | 23 +++++++++++++++- 11 files changed, 157 insertions(+), 20 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 5037385a..567706f1 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -30,12 +30,4 @@ const fontColor = computed(() => { return settingsStore.theme === ThemeMode.DARK ? "rgba(255, 255, 255, .15)" : "rgba(0, 0, 0, .15)"; }); -ElNotification({ - title: '提示', - type: 'warning', - duration: 0, - dangerouslyUseHTMLString: true, - message: - '

遇事不决,请先查阅常见问题,说不定你能找到相关解答

链接地址

' -}) diff --git a/frontend/src/views/monitor/job/index.vue b/frontend/src/views/monitor/job/index.vue index 89a7067c..9ac35d94 100644 --- a/frontend/src/views/monitor/job/index.vue +++ b/frontend/src/views/monitor/job/index.vue @@ -107,7 +107,7 @@ /> - + - + + @@ -339,13 +340,24 @@ async function handleResetQuery() { loadingData(); } +// 定义初始表单数据常量 +const initialFormData: NoticeForm = { + id: undefined, + notice_title: '', + notice_type: '', + notice_content: '', + status: true, + description: undefined, +} + // 重置表单 async function resetForm() { if (dataFormRef.value) { dataFormRef.value.resetFields(); dataFormRef.value.clearValidate(); } - formData.id = undefined; + // 完全重置 formData 为初始状态 + Object.assign(formData, initialFormData); } // 行复选框选中项变化 diff --git a/frontend/src/views/system/position/index.vue b/frontend/src/views/system/position/index.vue index 1aef3401..41fabf45 100644 --- a/frontend/src/views/system/position/index.vue +++ b/frontend/src/views/system/position/index.vue @@ -293,13 +293,23 @@ async function handleResetQuery() { loadingData(); } +// 定义初始表单数据常量 +const initialFormData: PositionForm = { + id: undefined, + name: undefined, + order: 1, + status: true, + description: undefined, +} + // 重置表单 async function resetForm() { if (dataFormRef.value) { dataFormRef.value.resetFields(); dataFormRef.value.clearValidate(); } - formData.id = undefined; + // 完全重置 formData 为初始状态 + Object.assign(formData, initialFormData); } // 行复选框选中项变化 diff --git a/frontend/src/views/system/role/index.vue b/frontend/src/views/system/role/index.vue index 31b5527a..b9c2e771 100644 --- a/frontend/src/views/system/role/index.vue +++ b/frontend/src/views/system/role/index.vue @@ -325,13 +325,23 @@ async function handleResetQuery() { loadingData(); } +// 定义初始表单数据常量 +const initialFormData: RoleForm = { + id: undefined, + name: undefined, + order: 1, + status: true, + description: undefined, +} + // 重置表单 async function resetForm() { if (dataFormRef.value) { dataFormRef.value.resetFields(); dataFormRef.value.clearValidate(); } - formData.id = undefined; + // 完全重置 formData 为初始状态 + Object.assign(formData, initialFormData); } // 关闭弹窗 diff --git a/frontend/src/views/system/user/index.vue b/frontend/src/views/system/user/index.vue index 2e78cedf..b1f74871 100644 --- a/frontend/src/views/system/user/index.vue +++ b/frontend/src/views/system/user/index.vue @@ -440,13 +440,34 @@ async function handleResetQuery() { loadingData(); } +// 定义初始表单数据常量 +const initialFormData: UserForm = { + id: undefined, + username: undefined, + name: undefined, + dept_id: undefined, + dept_name: undefined, + role_ids: undefined, + roleNames: undefined, + position_ids: undefined, + positionNames: undefined, + password: undefined, + gender: undefined, + email: undefined, + mobile: undefined, + is_superuser: false, //默认不是超管 + status: true, + description: undefined, +} + // 重置表单 async function resetForm() { if (dataFormRef.value) { dataFormRef.value.resetFields(); dataFormRef.value.clearValidate(); } - formData.id = undefined; + // 完全重置 formData 为初始状态 + Object.assign(formData, initialFormData); } // 选中项发生变化