From 7067050006d943181ac1ad447cb76431bad21935 Mon Sep 17 00:00:00 2001 From: rainv123 <2148537152@qq.com> Date: Tue, 23 Sep 2025 10:03:43 +0800 Subject: [PATCH] =?UTF-8?q?Revert=20"fix:=E4=BF=AE=E6=94=B9=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E7=AE=A1=E7=90=86=E7=95=8C=E9=9D=A2=E7=9A=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E5=AF=86=E7=A0=81=E9=87=8D=E7=BD=AE=E3=80=81=E7=A6=81?= =?UTF-8?q?=E7=94=A8=E3=80=81=E5=88=A0=E9=99=A4=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 9f303d840ac5518d5828691f49891d56437c4dcb. --- main/manager-web/src/i18n/en.js | 2 - main/manager-web/src/i18n/zh_CN.js | 2 - main/manager-web/src/i18n/zh_TW.js | 2 - main/manager-web/src/views/UserManagement.vue | 95 +++++++++++++------ 4 files changed, 67 insertions(+), 34 deletions(-) diff --git a/main/manager-web/src/i18n/en.js b/main/manager-web/src/i18n/en.js index 5d8f22f0..14f4d5a6 100644 --- a/main/manager-web/src/i18n/en.js +++ b/main/manager-web/src/i18n/en.js @@ -625,7 +625,6 @@ export default { 'common.confirm': 'Confirm', 'common.cancel': 'Cancel', 'common.sensitive': 'Sensitive', - 'common.success': 'Operation Successful', 'user.userid': 'User ID', 'user.deviceCount': 'Device Count', 'user.createDate': 'Registration Time', @@ -651,7 +650,6 @@ export default { 'user.deleteCancelled': 'Deletion cancelled', 'user.confirmResetPassword': 'A new password will be generated after reset. Continue?', 'user.resetPasswordSuccess': 'Password has been reset, please notify the user to log in with the new password', - 'user.generatedPassword': 'Generated Default Password', 'user.confirmDeleteUser': 'Are you sure you want to delete this user?', 'user.deleteUserSuccess': 'Deletion successful', 'user.operationFailed': 'Operation failed, please try again', diff --git a/main/manager-web/src/i18n/zh_CN.js b/main/manager-web/src/i18n/zh_CN.js index 09ecd331..27b0b9e0 100644 --- a/main/manager-web/src/i18n/zh_CN.js +++ b/main/manager-web/src/i18n/zh_CN.js @@ -625,7 +625,6 @@ export default { 'common.confirm': '确定', 'common.cancel': '取消', 'common.sensitive': '敏感', - 'common.success': '操作成功', 'user.userid': '用户Id', 'user.deviceCount': '设备数量', 'user.createDate': '注册时间', @@ -651,7 +650,6 @@ export default { 'user.deleteCancelled': '已取消删除', 'user.confirmResetPassword': '重置后将会生成新密码,是否继续?', 'user.resetPasswordSuccess': '密码已重置,请通知用户使用新密码登录', - 'user.generatedPassword': '生成的默认密码', 'user.confirmDeleteUser': '确定要删除该用户吗?', 'user.deleteUserSuccess': '删除成功', 'user.operationFailed': '操作失败,请重试', diff --git a/main/manager-web/src/i18n/zh_TW.js b/main/manager-web/src/i18n/zh_TW.js index b53a7242..a9f224f1 100644 --- a/main/manager-web/src/i18n/zh_TW.js +++ b/main/manager-web/src/i18n/zh_TW.js @@ -577,7 +577,6 @@ export default { 'user.deleteCancelled': '已取消刪除', 'user.confirmResetPassword': '重置後將會生成新密碼,是否繼續?', 'user.resetPasswordSuccess': '密碼已重置,請通知用戶使用新密碼登錄', - 'user.generatedPassword': '生成的默認密碼', 'user.confirmDeleteUser': '確定要刪除該用戶嗎?', 'user.deleteUserSuccess': '刪除成功', 'user.operationFailed': '操作失敗,請重試', @@ -662,7 +661,6 @@ export default { 'common.confirm': '確定', 'common.cancel': '取消', 'common.sensitive': '敏感', - 'common.success': '操作成功', 'paramManagement.totalRecords': '共{total}條記錄', 'paramManagement.addParam': '新增參數', 'paramManagement.editParam': '編輯參數', diff --git a/main/manager-web/src/views/UserManagement.vue b/main/manager-web/src/views/UserManagement.vue index 8132ba01..c61ca6df 100644 --- a/main/manager-web/src/views/UserManagement.vue +++ b/main/manager-web/src/views/UserManagement.vue @@ -257,17 +257,11 @@ export default { cancelButtonText: this.$t('common.cancel'), type: 'warning' }).then(() => { - Api.admin.resetUserPassword(row.userid, ({ data }) => { - if (data.code === 0) { - // 显示生成的默认密码 - this.$alert(this.$t('user.resetPasswordSuccess') + '\n\n' + this.$t('user.generatedPassword') + ': ' + data.data, this.$t('common.success'), { - confirmButtonText: this.$t('common.confirm'), - dangerouslyUseHTMLString: true - }); - this.fetchUsers(); - } else { - this.$message.error(data.msg || this.$t('user.operationFailed')); - } + resetPassword(row.userId).then(() => { + this.$message.success(this.$t('user.resetPasswordSuccess')); + this.getList(); + }).catch(() => { + this.$message.error(this.$t('user.operationFailed')); }); }).catch(() => { this.$message.info(this.$t('common.deleteCancelled')); @@ -279,13 +273,11 @@ export default { cancelButtonText: this.$t('common.cancel'), type: 'warning' }).then(() => { - Api.admin.deleteUser(row.userid, ({ data }) => { - if (data.code === 0) { - this.$message.success(this.$t('user.deleteUserSuccess')); - this.fetchUsers(); - } else { - this.$message.error(data.msg || this.$t('user.operationFailed')); - } + deleteUser(row.userId).then(() => { + this.$message.success(this.$t('user.deleteUserSuccess')); + this.getList(); + }).catch(() => { + this.$message.error(this.$t('user.operationFailed')); }); }).catch(() => { this.$message.info(this.$t('common.deleteCancelled')); @@ -346,20 +338,67 @@ export default { // 用户取消操作 }); }, - // 这个方法已被batchDelete替代,保留用于向后兼容 handleBatchDelete() { - this.batchDelete(); - }, - // This method has been fixed to use existing functionality - handleBatchStatusChange(status) { - const selectedUsers = this.userList.filter(user => user.selected); - if (selectedUsers.length === 0) { + if (!this.selection || this.selection.length === 0) { this.$message.warning(this.$t('user.selectUsersFirst')); return; } - - // Call the existing handleChangeStatus method which already handles both single and multiple users - this.handleChangeStatus(selectedUsers, status); + + const userIds = this.selection.map(item => item.userId); + this.$confirm(this.$t('user.confirmDeleteSelected', { count: this.selection.length }), this.$t('common.warning'), { + confirmButtonText: this.$t('common.confirm'), + cancelButtonText: this.$t('common.cancel'), + type: 'warning' + }).then(() => { + this.loading = true; + batchDeleteUsers(userIds).then(res => { + this.loading = false; + this.getList(); + this.selection = []; + if (res.successCount === userIds.length) { + this.$message.success(this.$t('user.deleteSuccess', { count: res.successCount })); + } else if (res.successCount === 0) { + this.$message.error(this.$t('user.deleteFailed')); + } else { + this.$message.warning(this.$t('user.partialDelete', { successCount: res.successCount, failCount: res.failCount })); + } + }).catch(() => { + this.loading = false; + this.$message.error(this.$t('user.deleteError')); + }); + }).catch(() => { + this.loading = false; + this.$message.info(this.$t('user.deleteCancelled')); + }); + }, + handleBatchStatusChange(status) { + if (!this.selection || this.selection.length === 0) { + this.$message.warning(this.$t('user.selectUsersFirst')); + return; + } + + const actionText = status === 1 ? this.$t('user.enable') : this.$t('user.disable'); + const userIds = this.selection.map(item => item.userId); + + this.$confirm(this.$t('user.confirmStatusChange', { action: actionText, count: this.selection.length }), this.$t('common.warning'), { + confirmButtonText: this.$t('common.confirm'), + cancelButtonText: this.$t('common.cancel'), + type: 'warning' + }).then(() => { + this.loading = true; + updateUserStatus(userIds, status).then(() => { + this.loading = false; + this.getList(); + this.selection = []; + this.$message.success(this.$t('user.statusChangeSuccess', { action: actionText, count: userIds.length })); + }).catch(() => { + this.loading = false; + this.$message.error(this.$t('user.operationFailed')); + }); + }).catch(() => { + this.loading = false; + this.$message.info(this.$t('common.deleteCancelled')); + }); }, }, };