日期: 2025年10月24日
问题: 管理员端项目管理页面无法显示Parse Server的真实数据
状态: ✅ 已修复
管理员端项目管理页面显示"没有找到符合条件的项目",经检查发现是数据库字段名称不匹配导致的。
在 ProjectService 中使用了错误的字段名称:
customer 字段contact 字段Parse Server数据库中的Project表使用 contact 字段来关联客户信息(ContactInfo表),而不是 customer。
src/app/pages/admin/services/project.service.ts// 修复前
include: ['customer', 'assignee']
// 修复后
include: ['contact', 'assignee'] // 使用 contact 而不是 customer
// 修复前
return await this.adminData.getById('Project', objectId, [
'customer',
'assignee'
]);
// 修复后
return await this.adminData.getById('Project', objectId, [
'contact', // 使用 contact 而不是 customer
'assignee'
]);
// 修复前
if (data.customerId) {
projectData.customer = {
__type: 'Pointer',
className: 'ContactInfo',
objectId: data.customerId
};
}
// 修复后
if (data.customerId) {
projectData.contact = { // 使用 contact 而不是 customer
__type: 'Pointer',
className: 'ContactInfo',
objectId: data.customerId
};
}
// 修复前
if (updates.customerId !== undefined) {
project.set('customer', {
__type: 'Pointer',
className: 'ContactInfo',
objectId: updates.customerId
});
}
// 修复后
if (updates.customerId !== undefined) {
project.set('contact', { // 使用 contact 而不是 customer
__type: 'Pointer',
className: 'ContactInfo',
objectId: updates.customerId
});
}
// 修复前
if (json.customer && typeof json.customer === 'object') {
json.customerName = json.customer.name || '';
json.customerId = json.customer.objectId;
}
// 修复后
if (json.contact && typeof json.contact === 'object') {
json.customerName = json.contact.name || '';
json.customerId = json.contact.objectId;
}
| 字段名 | 类型 | 说明 | 关联表 |
|---|---|---|---|
title |
String | 项目标题 | - |
contact |
Pointer | 客户信息(正确) | ContactInfo |
assignee |
Pointer | 负责人 | Profile |
status |
String | 项目状态 | - |
currentStage |
String | 当前阶段 | - |
company |
Pointer | 所属公司 | Company |
isDeleted |
Boolean | 是否删除 | - |
createdAt |
Date | 创建时间 | - |
updatedAt |
Date | 更新时间 | - |
修复后的效果:
src/app/pages/admin/services/admin-data.service.tssrc/app/pages/admin/services/project.service.ts字段命名统一性
contact 表示客户customerName、customerId 保持语义清晰关联查询
include: ['contact', 'assignee'] 进行关联查询公司隔离
软删除
isDeleted 字段标记删除状态统一数据模型文档
类型定义优化
错误处理增强
本次修复解决了管理员端项目管理页面无法显示数据的问题,根本原因是字段名称不匹配。通过将所有 customer 字段统一修改为 contact,使代码与Parse Server数据库结构保持一致,数据现在可以正常显示。
修复涉及5处代码修改,全部位于 ProjectService 中,不影响其他模块。修复后经过完整测试,所有功能正常运行。