mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-29 18:23:59 +08:00
fix:修改用户管理界面的用户密码重置、禁用、删除的逻辑
This commit is contained in:
@@ -625,6 +625,7 @@ export default {
|
|||||||
'common.confirm': 'Confirm',
|
'common.confirm': 'Confirm',
|
||||||
'common.cancel': 'Cancel',
|
'common.cancel': 'Cancel',
|
||||||
'common.sensitive': 'Sensitive',
|
'common.sensitive': 'Sensitive',
|
||||||
|
'common.success': 'Operation Successful',
|
||||||
'user.userid': 'User ID',
|
'user.userid': 'User ID',
|
||||||
'user.deviceCount': 'Device Count',
|
'user.deviceCount': 'Device Count',
|
||||||
'user.createDate': 'Registration Time',
|
'user.createDate': 'Registration Time',
|
||||||
@@ -650,6 +651,7 @@ export default {
|
|||||||
'user.deleteCancelled': 'Deletion cancelled',
|
'user.deleteCancelled': 'Deletion cancelled',
|
||||||
'user.confirmResetPassword': 'A new password will be generated after reset. Continue?',
|
'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.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.confirmDeleteUser': 'Are you sure you want to delete this user?',
|
||||||
'user.deleteUserSuccess': 'Deletion successful',
|
'user.deleteUserSuccess': 'Deletion successful',
|
||||||
'user.operationFailed': 'Operation failed, please try again',
|
'user.operationFailed': 'Operation failed, please try again',
|
||||||
|
|||||||
@@ -625,6 +625,7 @@ export default {
|
|||||||
'common.confirm': '确定',
|
'common.confirm': '确定',
|
||||||
'common.cancel': '取消',
|
'common.cancel': '取消',
|
||||||
'common.sensitive': '敏感',
|
'common.sensitive': '敏感',
|
||||||
|
'common.success': '操作成功',
|
||||||
'user.userid': '用户Id',
|
'user.userid': '用户Id',
|
||||||
'user.deviceCount': '设备数量',
|
'user.deviceCount': '设备数量',
|
||||||
'user.createDate': '注册时间',
|
'user.createDate': '注册时间',
|
||||||
@@ -650,6 +651,7 @@ export default {
|
|||||||
'user.deleteCancelled': '已取消删除',
|
'user.deleteCancelled': '已取消删除',
|
||||||
'user.confirmResetPassword': '重置后将会生成新密码,是否继续?',
|
'user.confirmResetPassword': '重置后将会生成新密码,是否继续?',
|
||||||
'user.resetPasswordSuccess': '密码已重置,请通知用户使用新密码登录',
|
'user.resetPasswordSuccess': '密码已重置,请通知用户使用新密码登录',
|
||||||
|
'user.generatedPassword': '生成的默认密码',
|
||||||
'user.confirmDeleteUser': '确定要删除该用户吗?',
|
'user.confirmDeleteUser': '确定要删除该用户吗?',
|
||||||
'user.deleteUserSuccess': '删除成功',
|
'user.deleteUserSuccess': '删除成功',
|
||||||
'user.operationFailed': '操作失败,请重试',
|
'user.operationFailed': '操作失败,请重试',
|
||||||
|
|||||||
@@ -577,6 +577,7 @@ export default {
|
|||||||
'user.deleteCancelled': '已取消刪除',
|
'user.deleteCancelled': '已取消刪除',
|
||||||
'user.confirmResetPassword': '重置後將會生成新密碼,是否繼續?',
|
'user.confirmResetPassword': '重置後將會生成新密碼,是否繼續?',
|
||||||
'user.resetPasswordSuccess': '密碼已重置,請通知用戶使用新密碼登錄',
|
'user.resetPasswordSuccess': '密碼已重置,請通知用戶使用新密碼登錄',
|
||||||
|
'user.generatedPassword': '生成的默認密碼',
|
||||||
'user.confirmDeleteUser': '確定要刪除該用戶嗎?',
|
'user.confirmDeleteUser': '確定要刪除該用戶嗎?',
|
||||||
'user.deleteUserSuccess': '刪除成功',
|
'user.deleteUserSuccess': '刪除成功',
|
||||||
'user.operationFailed': '操作失敗,請重試',
|
'user.operationFailed': '操作失敗,請重試',
|
||||||
@@ -661,6 +662,7 @@ export default {
|
|||||||
'common.confirm': '確定',
|
'common.confirm': '確定',
|
||||||
'common.cancel': '取消',
|
'common.cancel': '取消',
|
||||||
'common.sensitive': '敏感',
|
'common.sensitive': '敏感',
|
||||||
|
'common.success': '操作成功',
|
||||||
'paramManagement.totalRecords': '共{total}條記錄',
|
'paramManagement.totalRecords': '共{total}條記錄',
|
||||||
'paramManagement.addParam': '新增參數',
|
'paramManagement.addParam': '新增參數',
|
||||||
'paramManagement.editParam': '編輯參數',
|
'paramManagement.editParam': '編輯參數',
|
||||||
|
|||||||
@@ -257,11 +257,17 @@ export default {
|
|||||||
cancelButtonText: this.$t('common.cancel'),
|
cancelButtonText: this.$t('common.cancel'),
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
resetPassword(row.userId).then(() => {
|
Api.admin.resetUserPassword(row.userid, ({ data }) => {
|
||||||
this.$message.success(this.$t('user.resetPasswordSuccess'));
|
if (data.code === 0) {
|
||||||
this.getList();
|
// 显示生成的默认密码
|
||||||
}).catch(() => {
|
this.$alert(this.$t('user.resetPasswordSuccess') + '\n\n' + this.$t('user.generatedPassword') + ': ' + data.data, this.$t('common.success'), {
|
||||||
this.$message.error(this.$t('user.operationFailed'));
|
confirmButtonText: this.$t('common.confirm'),
|
||||||
|
dangerouslyUseHTMLString: true
|
||||||
|
});
|
||||||
|
this.fetchUsers();
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg || this.$t('user.operationFailed'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.$message.info(this.$t('common.deleteCancelled'));
|
this.$message.info(this.$t('common.deleteCancelled'));
|
||||||
@@ -273,11 +279,13 @@ export default {
|
|||||||
cancelButtonText: this.$t('common.cancel'),
|
cancelButtonText: this.$t('common.cancel'),
|
||||||
type: 'warning'
|
type: 'warning'
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
deleteUser(row.userId).then(() => {
|
Api.admin.deleteUser(row.userid, ({ data }) => {
|
||||||
this.$message.success(this.$t('user.deleteUserSuccess'));
|
if (data.code === 0) {
|
||||||
this.getList();
|
this.$message.success(this.$t('user.deleteUserSuccess'));
|
||||||
}).catch(() => {
|
this.fetchUsers();
|
||||||
this.$message.error(this.$t('user.operationFailed'));
|
} else {
|
||||||
|
this.$message.error(data.msg || this.$t('user.operationFailed'));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.$message.info(this.$t('common.deleteCancelled'));
|
this.$message.info(this.$t('common.deleteCancelled'));
|
||||||
@@ -338,67 +346,20 @@ export default {
|
|||||||
// 用户取消操作
|
// 用户取消操作
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
// 这个方法已被batchDelete替代,保留用于向后兼容
|
||||||
handleBatchDelete() {
|
handleBatchDelete() {
|
||||||
if (!this.selection || this.selection.length === 0) {
|
this.batchDelete();
|
||||||
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 method has been fixed to use existing functionality
|
||||||
handleBatchStatusChange(status) {
|
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'));
|
this.$message.warning(this.$t('user.selectUsersFirst'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const actionText = status === 1 ? this.$t('user.enable') : this.$t('user.disable');
|
// Call the existing handleChangeStatus method which already handles both single and multiple users
|
||||||
const userIds = this.selection.map(item => item.userId);
|
this.handleChangeStatus(selectedUsers, status);
|
||||||
|
|
||||||
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'));
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user