修改分页请求参数和响应

This commit is contained in:
lcj
2025-03-18 09:59:59 +08:00
parent 6c313c9256
commit 8eb4dd4207
36 changed files with 127 additions and 235 deletions

View File

@ -22,13 +22,13 @@ const props = defineProps<{ userId: number | string }>();
const allProjects = ref<{ key: number | string; label: string }[]>([]);
// **已关联的项目 ID 列表**
const selectedProjects = ref<number[]>([]);
const selectedProjects = ref<(number | string)[]>([]);
// **获取所有项目列表**
const getProjectList = async () => {
try {
const res = await listProject();
allProjects.value = res.data.records.map((project) => ({
allProjects.value = res.rows.map((project) => ({
key: project.id,
label: project.projectName
}));
@ -36,15 +36,11 @@ const getProjectList = async () => {
console.error('获取项目列表失败:', error);
}
};
const getUserProjects = async () => {
const getUserProjects = async (s: string = '') => {
if (!props.userId) return;
try {
const res = await listUserProjects({ userId: props.userId });
// 修改这里,使用 res.records 而不是 res.rows
selectedProjects.value = Array.isArray(res.data.records) ? res.data.records.map((item: ProjectRelevancyVO) => item.projectId) : [];
console.log('已加载用户关联项目:', selectedProjects.value);
selectedProjects.value = Array.isArray(res.rows) ? res.rows.map((item: ProjectRelevancyVO) => item.projectId) : [];s
} catch (error) {
console.error('获取用户关联的项目失败:', error);
selectedProjects.value = []; // 请求失败时清空列表