mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 09:03:54 +08:00
fix:修改用户管理界面用户的密码重置、禁用、删除的逻辑
This commit is contained in:
@@ -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);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user