From 1dcd4ab0cd41ca2a5f69876616d37fd16b0f72fc Mon Sep 17 00:00:00 2001
From: hxr <1490493387@qq.com>
Date: Tue, 25 Jun 2024 22:02:57 +0800
Subject: [PATCH] =?UTF-8?q?refactor:=20:recycle:=20=E5=88=A0=E9=99=A4?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=20loading=20=E5=92=8C=E5=8F=96=E6=B6=88?=
=?UTF-8?q?=E5=88=A0=E9=99=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/system/dept/index.vue | 20 ++++++++++++++------
src/views/system/dict/index.vue | 23 ++++++++++++++---------
src/views/system/menu/index.vue | 24 ++++++++++++++++--------
src/views/system/role/index.vue | 23 ++++++++++++++---------
src/views/system/user/index.vue | 22 +++++++++++++++-------
5 files changed, 73 insertions(+), 39 deletions(-)
diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index e9234e33..ec6722ca 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -283,12 +283,20 @@ function handleDelete(deptId?: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- }).then(() => {
- DeptAPI.deleteByIds(deptIds).then(() => {
- ElMessage.success("删除成功");
- handleResetQuery();
- });
- });
+ }).then(
+ () => {
+ loading.value = true;
+ DeptAPI.deleteByIds(deptIds)
+ .then(() => {
+ ElMessage.success("删除成功");
+ handleResetQuery();
+ })
+ .finally(() => (loading.value = false));
+ },
+ () => {
+ ElMessage.info("已取消删除");
+ }
+ );
}
/** 关闭弹窗 */
diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue
index 9e69f0b7..273560ce 100644
--- a/src/views/system/dict/index.vue
+++ b/src/views/system/dict/index.vue
@@ -30,7 +30,7 @@
删除
@@ -75,7 +75,7 @@
type="danger"
link
size="small"
- @click.stop="handleDeleteClick(scope.row.id)"
+ @click.stop="handleDelete(scope.row.id)"
>删除
@@ -333,7 +333,7 @@ function handleCloseDialog() {
*
* @param id 字典ID
*/
-function handleDeleteClick(id?: number) {
+function handleDelete(id?: number) {
const attrGroupIds = [id || ids.value].join(",");
if (!attrGroupIds) {
ElMessage.warning("请勾选删除项");
@@ -343,12 +343,17 @@ function handleDeleteClick(id?: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- }).then(() => {
- DictAPI.deleteByIds(attrGroupIds).then(() => {
- ElMessage.success("删除成功");
- handleResetClick();
- });
- });
+ }).then(
+ () => {
+ DictAPI.deleteByIds(attrGroupIds).then(() => {
+ ElMessage.success("删除成功");
+ handleResetClick();
+ });
+ },
+ () => {
+ ElMessage.info("已取消删除");
+ }
+ );
}
// 新增字典
diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue
index e67ad2ad..d4dbace2 100644
--- a/src/views/system/menu/index.vue
+++ b/src/views/system/menu/index.vue
@@ -592,14 +592,22 @@ function handleDelete(menuId: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- })
- .then(() => {
- MenuAPI.deleteById(menuId).then(() => {
- ElMessage.success("删除成功");
- handleQuery();
- });
- })
- .catch(() => ElMessage.info("已取消删除"));
+ }).then(
+ () => {
+ loading.value = true;
+ MenuAPI.deleteById(menuId)
+ .then(() => {
+ ElMessage.success("删除成功");
+ handleQuery();
+ })
+ .finally(() => {
+ loading.value = false;
+ });
+ },
+ () => {
+ ElMessage.info("已取消删除");
+ }
+ );
}
// 关闭弹窗
diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue
index 968a1173..b64ffa95 100644
--- a/src/views/system/role/index.vue
+++ b/src/views/system/role/index.vue
@@ -363,15 +363,20 @@ function handleDelete(roleId?: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- }).then(() => {
- loading.value = true;
- RoleAPI.deleteByIds(roleIds)
- .then(() => {
- ElMessage.success("删除成功");
- handleResetQuery();
- })
- .finally(() => (loading.value = false));
- });
+ }).then(
+ () => {
+ loading.value = true;
+ RoleAPI.deleteByIds(roleIds)
+ .then(() => {
+ ElMessage.success("删除成功");
+ handleResetQuery();
+ })
+ .finally(() => (loading.value = false));
+ },
+ () => {
+ ElMessage.info("已取消删除");
+ }
+ );
}
/** 打开分配菜单权限弹窗 */
diff --git a/src/views/system/user/index.vue b/src/views/system/user/index.vue
index 6124a205..544c620e 100644
--- a/src/views/system/user/index.vue
+++ b/src/views/system/user/index.vue
@@ -375,7 +375,7 @@ function handleResetQuery() {
handleQuery();
}
-/** 行选中 */
+/** 行复选框选中记录选中ID集合 */
function handleSelectionChange(selection: any) {
removeIds.value = selection.map((item: any) => item.id);
}
@@ -472,12 +472,20 @@ function handleDelete(id?: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- }).then(function () {
- UserAPI.deleteByIds(userIds).then(() => {
- ElMessage.success("删除成功");
- handleResetQuery();
- });
- });
+ }).then(
+ function () {
+ loading.value = true;
+ UserAPI.deleteByIds(userIds)
+ .then(() => {
+ ElMessage.success("删除成功");
+ handleResetQuery();
+ })
+ .finally(() => (loading.value = false));
+ },
+ function () {
+ ElMessage.info("已取消删除");
+ }
+ );
}
/** 打开导入弹窗 */
function handleOpenImportDialog() {