修改分页请求参数和响应
This commit is contained in:
@ -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 = []; // 请求失败时清空列表
|
||||
|
Reference in New Issue
Block a user