From 7ad6f1f0937192d8d71ff70744a26d46279f00a0 Mon Sep 17 00:00:00 2001 From: LiuYuanchi Date: Sun, 27 Apr 2025 12:33:59 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E6=B7=BB=E5=8A=A0=E4=BA=86=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E7=AE=A1=E7=90=86=E7=9A=84=E5=8A=A0=E8=BD=BD=E5=8A=A8?= =?UTF-8?q?=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/typings/components.d.ts | 1 + src/views/department/index.vue | 87 +++++++++++++++++++--------------- 2 files changed, 50 insertions(+), 38 deletions(-) diff --git a/src/typings/components.d.ts b/src/typings/components.d.ts index f5f2db9..63b95ed 100644 --- a/src/typings/components.d.ts +++ b/src/typings/components.d.ts @@ -40,6 +40,7 @@ declare module 'vue' { ASelect: typeof import('ant-design-vue/es')['Select'] ASelectOption: typeof import('ant-design-vue/es')['SelectOption'] ASpace: typeof import('ant-design-vue/es')['Space'] + ASpin: typeof import('ant-design-vue/es')['Spin'] AStatistic: typeof import('ant-design-vue/es')['Statistic'] ASwitch: typeof import('ant-design-vue/es')['Switch'] ATable: typeof import('ant-design-vue/es')['Table'] diff --git a/src/views/department/index.vue b/src/views/department/index.vue index 699f9c5..3a23025 100644 --- a/src/views/department/index.vue +++ b/src/views/department/index.vue @@ -6,44 +6,46 @@
添加部门
- - + + + @@ -74,10 +76,13 @@ import { ref, onMounted } from 'vue'; import { message, Modal } from 'ant-design-vue'; import axios from 'axios'; -import { apiRequestGet } from '@/utils/api' +import { apiRequestGet } from '@/utils/api'; import { localStg } from '@/utils/storage'; + // 部门树数据 const treeData = ref([]); +// 加载状态 +const loading = ref(false); // 弹窗相关 const modalVisible = ref(false); const modalTitle = ref('添加部门'); @@ -97,6 +102,7 @@ const selectedKeys = ref([]); // 获取部门数据 const fetchDepartments = async () => { try { + loading.value = true; // 开始加载 const response = await apiRequestGet('/department/allDepartment'); if (response.data.success) { @@ -125,6 +131,8 @@ const fetchDepartments = async () => { } } catch (error) { message.error('请求失败: ' + error.message); + } finally { + loading.value = false; // 结束加载 } }; @@ -195,11 +203,14 @@ const confirmDelete = (dept) => { content: `确定要删除部门 ${dept.departmentName} 吗?`, async onOk() { try { + loading.value = true; // 开始加载 await axios.delete(`http://localhost:8080/api/departments/${dept.key}`); message.success('删除成功'); fetchDepartments(); // 刷新数据 } catch (error) { message.error('删除失败: ' + error.message); + } finally { + loading.value = false; // 结束加载 } }, });