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; // 结束加载 } }, });