瀏覽代碼

fix: quotation edit divide

Future 1 天之前
父節點
當前提交
3c44efebe3

+ 45 - 3
src/modules/project/components/quotation-editor.component.ts

@@ -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);
+    }
+  }
 }

+ 1 - 24
src/modules/project/pages/project-detail/stages/stage-order.component.html

@@ -89,7 +89,6 @@
               <select
                 class="form-select"
                 [(ngModel)]="projectInfo.renderType"
-                (change)="onHomeSceneChange()"
                 [disabled]="!canEdit">
                 <option value="">请选择渲染类型</option>
                 <option value="静态单张">静态单张</option>
@@ -161,7 +160,6 @@
                       name="spaceType"
                       [value]="spaceType"
                       [(ngModel)]="homeScenes.spaceType"
-                      (change)="onHomeSceneChange()"
                       [disabled]="!canEdit" />
                     <span class="radio-text">{{ spaceType }}</span>
                   </label>
@@ -180,7 +178,6 @@
                       name="styleLevel"
                       [value]="styleLevel"
                       [(ngModel)]="homeScenes.styleLevel"
-                      (change)="onHomeSceneChange()"
                       [disabled]="!canEdit" />
                     <span class="radio-text">{{ styleLevel }}</span>
                   </label>
@@ -250,16 +247,6 @@
                 }
               </div>
 
-              <button
-                class="btn btn-primary generate-quotation-btn"
-                (click)="generateQuotation()"
-                [disabled]="hasRoomsDisabled()">
-                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
-                  <path fill="currentColor" d="M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z"/>
-                  <path fill="currentColor" d="M256 56v120a32 32 0 0032 32h120"/>
-                </svg>
-                生成报价表
-              </button>
             </div>
           }
         </div>
@@ -285,7 +272,6 @@
             <select
               class="form-select"
               [(ngModel)]="commercialScenes.businessType"
-              (change)="onCommercialTypeChange()"
               [disabled]="!canEdit">
               <option value="">请选择业态类型</option>
               @for (type of businessTypes; track type) {
@@ -365,16 +351,6 @@
                 }
               </div>
 
-              <button
-                class="btn btn-primary generate-quotation-btn"
-                (click)="generateQuotation()"
-                [disabled]="hasSpacesDisabled()">
-                <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
-                  <path fill="currentColor" d="M416 221.25V416a48 48 0 01-48 48H144a48 48 0 01-48-48V96a48 48 0 0148-48h98.75a32 32 0 0122.62 9.37l141.26 141.26a32 32 0 019.37 22.62z"/>
-                  <path fill="currentColor" d="M256 56v120a32 32 0 0032 32h120"/>
-                </svg>
-                生成报价表
-              </button>
             </div>
           }
         </div>
@@ -396,6 +372,7 @@
       <div class="card-content">
         <app-quotation-editor
           [projectId]="projectId"
+          [project]="project"
           [canEdit]="canEdit"
           [viewMode]="'card'"
           [currentUser]="currentUser"

+ 0 - 14
src/modules/project/pages/project-detail/stages/stage-order.component.ts

@@ -685,20 +685,6 @@ export class StageOrderComponent implements OnInit {
     this.quotation.total = total;
   }
 
-  /**
-   * 空方法保持兼容性
-   */
-  onHomeSceneChange() {
-    // 空实现,功能已移至quotation-editor组件
-  }
-
-  onCommercialTypeChange() {
-    // 空实现,功能已移至quotation-editor组件
-  }
-
-  generateQuotation() {
-    // 空实现,功能已移至quotation-editor组件
-  }
 
   /**
    * 获取空间进度