Merge branch 'main' into sm2_test

This commit is contained in:
hrz
2025-09-26 19:03:23 +08:00
committed by GitHub
25 changed files with 1614 additions and 309 deletions
+26 -65
View File
@@ -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);
},
},
};