diff --git a/main/manager-web/src/i18n/en.js b/main/manager-web/src/i18n/en.js index 5e00c9b0..a4dbfa06 100644 --- a/main/manager-web/src/i18n/en.js +++ b/main/manager-web/src/i18n/en.js @@ -612,6 +612,7 @@ 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', @@ -648,6 +649,7 @@ export default { 'common.nextPage': 'Next Page', 'common.totalRecords': 'Total {number} records', 'common.addProvider': 'Add Provider', + 'common.success': 'Success', 'common.editProvider': 'Edit Provider', 'common.updateSuccess': 'Update Success', 'common.addSuccess': 'Add Success', diff --git a/main/manager-web/src/i18n/zh_CN.js b/main/manager-web/src/i18n/zh_CN.js index d71d51b1..26f66660 100644 --- a/main/manager-web/src/i18n/zh_CN.js +++ b/main/manager-web/src/i18n/zh_CN.js @@ -612,6 +612,7 @@ export default { 'user.deleteCancelled': '已取消删除', 'user.confirmResetPassword': '重置后将会生成新密码,是否继续?', 'user.resetPasswordSuccess': '密码已重置,请通知用户使用新密码登录', + 'user.generatedPassword': '生成的默认密码', 'user.confirmDeleteUser': '确定要删除该用户吗?', 'user.deleteUserSuccess': '删除成功', 'user.operationFailed': '操作失败,请重试', @@ -648,6 +649,7 @@ export default { 'common.nextPage': '下一页', 'common.totalRecords': '共{number}条记录', 'common.addProvider': '新增供应器', + 'common.success': '成功', 'common.editProvider': '编辑供应器', 'common.updateSuccess': '修改成功', 'common.addSuccess': '新增成功', diff --git a/main/manager-web/src/i18n/zh_TW.js b/main/manager-web/src/i18n/zh_TW.js index 173ebbd8..0c7f7bd1 100644 --- a/main/manager-web/src/i18n/zh_TW.js +++ b/main/manager-web/src/i18n/zh_TW.js @@ -612,6 +612,7 @@ export default { 'user.deleteCancelled': '已取消刪除', 'user.confirmResetPassword': '重置後將會生成新密碼,是否繼續?', 'user.resetPasswordSuccess': '密碼已重置,請通知用戶使用新密碼登錄', + 'user.generatedPassword': '生成的默認密碼', 'user.confirmDeleteUser': '確定要刪除該用戶嗎?', 'user.deleteUserSuccess': '刪除成功', 'user.operationFailed': '操作失敗,請重試', @@ -648,6 +649,7 @@ export default { 'common.nextPage': '下一頁', 'common.totalRecords': '共{number}條記錄', 'common.addProvider': '新增供應器', + 'common.success': '成功', 'common.editProvider': '編輯供應器', 'common.updateSuccess': '修改成功', 'common.addSuccess': '新增成功', diff --git a/main/manager-web/src/views/UserManagement.vue b/main/manager-web/src/views/UserManagement.vue index c61ca6df..8132ba01 100644 --- a/main/manager-web/src/views/UserManagement.vue +++ b/main/manager-web/src/views/UserManagement.vue @@ -257,11 +257,17 @@ export default { cancelButtonText: this.$t('common.cancel'), type: 'warning' }).then(() => { - resetPassword(row.userId).then(() => { - this.$message.success(this.$t('user.resetPasswordSuccess')); - this.getList(); - }).catch(() => { - this.$message.error(this.$t('user.operationFailed')); + 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')); + } }); }).catch(() => { this.$message.info(this.$t('common.deleteCancelled')); @@ -273,11 +279,13 @@ export default { cancelButtonText: this.$t('common.cancel'), type: 'warning' }).then(() => { - deleteUser(row.userId).then(() => { - this.$message.success(this.$t('user.deleteUserSuccess')); - this.getList(); - }).catch(() => { - this.$message.error(this.$t('user.operationFailed')); + 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')); + } }); }).catch(() => { this.$message.info(this.$t('common.deleteCancelled')); @@ -338,67 +346,20 @@ export default { // 用户取消操作 }); }, + // 这个方法已被batchDelete替代,保留用于向后兼容 handleBatchDelete() { - if (!this.selection || this.selection.length === 0) { - this.$message.warning(this.$t('user.selectUsersFirst')); - return; - } - - 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')); - }); + this.batchDelete(); }, + // This method has been fixed to use existing functionality handleBatchStatusChange(status) { - if (!this.selection || this.selection.length === 0) { + const selectedUsers = this.userList.filter(user => user.selected); + if (selectedUsers.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')); - }); + + // Call the existing handleChangeStatus method which already handles both single and multiple users + this.handleChangeStatus(selectedUsers, status); }, }, };