|
@@ -27,6 +27,7 @@ const Parse = FmodeParse.with('nova');
|
|
|
export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
// 输入属性
|
|
|
@Input() projectId: string = '';
|
|
|
+ @Input() project: any = null;
|
|
|
@Input() canEdit: boolean = false;
|
|
|
@Input() viewMode: 'table' | 'card' = 'card';
|
|
|
@Input() currentUser: any = null;
|
|
@@ -39,7 +40,6 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
|
|
|
// 数据状态
|
|
|
loading: boolean = false;
|
|
|
- project: any = null;
|
|
|
products: any[] = [];
|
|
|
projectInfo: any = {
|
|
|
title: '',
|
|
@@ -85,13 +85,17 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
|
|
|
ngOnInit() {
|
|
|
this.loadQuotationConfig();
|
|
|
- if (this.projectId) {
|
|
|
+ if (this.project) {
|
|
|
+ this.loadProjectDataFromProject();
|
|
|
+ } else if (this.projectId) {
|
|
|
this.loadProjectData();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges) {
|
|
|
- if (changes['projectId'] && changes['projectId'].currentValue) {
|
|
|
+ if (changes['project'] && changes['project'].currentValue) {
|
|
|
+ this.loadProjectDataFromProject();
|
|
|
+ } else if (changes['projectId'] && changes['projectId'].currentValue) {
|
|
|
this.loadProjectData();
|
|
|
}
|
|
|
|
|
@@ -873,4 +877,42 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
|
|
|
const breakdown = this.quotation.spaceBreakdown.find((b: any) => b.spaceId === spaceId);
|
|
|
return breakdown?.percentage || 0;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 从传入的项目对象初始化数据
|
|
|
+ */
|
|
|
+ private async loadProjectDataFromProject(): Promise<void> {
|
|
|
+ if (!this.project) return;
|
|
|
+
|
|
|
+ try {
|
|
|
+ this.loading = true;
|
|
|
+ this.loadingChange.emit(true);
|
|
|
+
|
|
|
+ // 项目信息
|
|
|
+ this.projectInfo.title = this.project.get('title') || '';
|
|
|
+ this.projectInfo.projectType = this.project.get('projectType') || '';
|
|
|
+ this.projectInfo.renderType = this.project.get('renderType') || '';
|
|
|
+ this.projectInfo.deadline = this.project.get('deadline') || '';
|
|
|
+ this.projectInfo.description = this.project.get('description') || '';
|
|
|
+
|
|
|
+ const data = this.project.get('data') || {};
|
|
|
+ if (data.priceLevel) {
|
|
|
+ this.projectInfo.priceLevel = data.priceLevel;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 加载产品列表
|
|
|
+ await this.loadProjectProducts();
|
|
|
+
|
|
|
+ // 加载现有报价
|
|
|
+ if (data.quotation) {
|
|
|
+ this.quotation = data.quotation;
|
|
|
+ this.updateProductsFromQuotation();
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ console.error('从项目对象加载数据失败:', error);
|
|
|
+ } finally {
|
|
|
+ this.loading = false;
|
|
|
+ this.loadingChange.emit(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|