从截图和代码分析发现:
Product {
project: Pointer // 关联项目
productName: string // 空间名称(如"客厅")
productType: string // 产品类型
status: string // 状态
space: { // 空间信息
spaceName: string
area: number
spaceType: string
styleLevel: string
complexity: string
}
quotation: { // 报价信息
price: number
basePrice: number
priceLevel: string
}
requirements: {} // 需求信息
profile: Pointer // 分配的设计师
}
创建位置:quotation-editor.component.ts 第336-414行
ngOnInit()
→ loadProjectProducts() // 查询Product表
→ 去重(按productName)
→ generateQuotationFromProducts() // 生成报价
→ saveQuotationToProject() // 保存到Project.data
addProduct()
→ createProduct() // 创建Product记录
→ product.save() // 保存到Product表
→ loadProjectProducts() // 重新加载
→ generateQuotationFromProducts()
→ saveQuotationToProject()
deleteProduct()
→ product.destroy() // 删除Product记录
→ 更新this.products
→ 更新quotation.spaces
→ saveQuotationToProject()
确认需求、交付执行都通过:
this.projectProducts = await this.productSpaceService.getProjectProductSpaces(projectId);
ProductSpaceService.getProjectProductSpaces():
现象:
原因:
检测方法:
// quotation-editor已有检测逻辑
async generateQuotationFromProducts() {
const spaceMap = new Map<string, any>();
const duplicateProductIds: string[] = [];
for (const product of this.products) {
if (spaceMap.has(productName)) {
duplicateProductIds.push(product.id);
}
}
// 提示清理重复产品
if (duplicateProductIds.length > 0) {
await this.removeDuplicateProducts(duplicateProductIds);
}
}
// quotation-editor.component.ts
@Output() productsUpdated = new EventEmitter<void>();
async addProduct() {
await this.createProduct(name);
await this.loadProjectProducts();
await this.generateQuotationFromProducts();
this.productsUpdated.emit(); // 🔥 发出事件
}
async deleteProduct() {
// ...
await this.saveQuotationToProject();
this.productsUpdated.emit(); // 🔥 发出事件
}
// stage-order.component.html
<app-quotation-editor
(productsUpdated)="onProductsUpdated()"
></app-quotation-editor>
// stage-order.component.ts
onProductsUpdated() {
// 发出全局事件
const event = new CustomEvent('product-spaces-updated', {
detail: { projectId: this.project.id },
bubbles: true
});
document.dispatchEvent(event);
}
// stage-requirements/stage-delivery
ngOnInit() {
document.addEventListener('product-spaces-updated', (event: any) => {
if (event.detail?.projectId === this.projectId) {
this.loadProjectProducts(); // 重新加载
}
});
}
// 每次进入阶段时重新加载
async ngOnInit() {
await this.loadProjectProducts(); // 强制刷新
}
<button (click)="refreshProductSpaces()">
刷新空间列表
</button>
quotation-editor.component.ts
@Output() productsUpdatedstage-order.component.ts/html
stage-requirements.component.ts
stage-delivery.component.ts