Quellcode durchsuchen

Merge branch 'master' of http://git.fmode.cn:3000/nkkj/yss-project

Future vor 1 Tag
Ursprung
Commit
c2ea65c3ef

+ 36 - 32
CHANGELOG.md

@@ -5,9 +5,14 @@
 - [ ] 小程序订单:从数据库小程序商城同步订单到客服系统
     - 订单同步、项目创建、报价分配、拉群成组
 
-## 2025-10-25
+## 2025-10-26
 - [ ] 智能交付:交付页面,拖拽文件,并细化大模型识别文件类型与空间的功能
-- [ ] 报价规则:价格报价器的细节规则优化
+- [ ] 改图工单:改图是独立于初期报价,后期延续的灵活工单,需要独立设计
+- [ ] 员工问卷:专业特长及偏好问卷功能
+- [ ] 方案深化:参考图区分软装、硬装、氛围等用途标签,对应不同分析结果
+
+## 2025-10-25
+- [x] 报价规则:价格报价器的细节规则优化
     - 报价细项的优化与合并
         - 内部执行报价分为:建模阶段、软装渲染、公司分配
             - 建模阶段:占比10%
@@ -15,59 +20,58 @@
             - 公司分配:占比50%
         - 报价自动分配比例是指在原有三级报价总价基础上,自动填写三类分配金额
     - 按默认比例分配 + 人工填写报价
-- [ ] 改图工单:改图是独立于初期报价,后期延续的灵活工单,需要独立设计
-- [ ] 员工问卷:专业特长及偏好问卷功能
-- [ ] 方案深化:参考图区分软装、硬装、氛围等用途标签,对应不同分析结果
 - [x] 组员派单:根据新的空间报价,修改派单逻辑,增加已派单成员移除的功能
+- [x] 项目信息:修复小图日期、交付日期的时间选择组件,小图日期必填
+
 
 # CHANGELOG 更新日志
 
 ## 2025-10-24
 ### 项目启动访谈问卷
-- 新增项目问卷:面向客户的首次需求调研,3-5分钟选择式题目,覆盖基础需求、核心侧重、协作节奏、特殊提醒四大模块。
-- 快速入口:项目详情的客户卡片展示问卷状态;未填写显示“发送问卷”,已填写显示“查看问卷”。
-- 群聊发送:支持在企业微信群聊一键发送问卷链接,客户点击即可填写。
-- 多联系人支持:同一项目的多个联系人可分别填写,答卷独立保存。
-- 结果查看:客服/组员/组长可随时查看已填写的问卷结果。
-- 自动保存与完成标记:答题过程逐题自动保存;提交后标记完成并记录时间。
-- 联系人信息补全:问卷中填写的姓名/手机号可同步至联系人资料;手机号对非本人脱敏显示。
-- 权限与隐私:客户本人与内部成员可查看完整结果,其他外部联系人无权查看。
+- [x] 新增项目问卷:面向客户的首次需求调研,3-5分钟选择式题目,覆盖基础需求、核心侧重、协作节奏、特殊提醒四大模块。
+- [x] 快速入口:项目详情的客户卡片展示问卷状态;未填写显示“发送问卷”,已填写显示“查看问卷”。
+- [x] 群聊发送:支持在企业微信群聊一键发送问卷链接,客户点击即可填写。
+- [x] 多联系人支持:同一项目的多个联系人可分别填写,答卷独立保存。
+- [x] 结果查看:客服/组员/组长可随时查看已填写的问卷结果。
+- [x] 自动保存与完成标记:答题过程逐题自动保存;提交后标记完成并记录时间。
+- [x] 联系人信息补全:问卷中填写的姓名/手机号可同步至联系人资料;手机号对非本人脱敏显示。
+- [x] 权限与隐私:客户本人与内部成员可查看完整结果,其他外部联系人无权查看。
 
 ### 页面手机端适配
-- 项目详情-文件,标题与筛选操作栏,紧凑布局
-- 项目详情-成员,标题与筛选操作栏,紧凑布局
-- 项目详情-问题,标题与筛选操作栏,紧凑布局并全屏弹窗
+- [x] 项目详情-文件,标题与筛选操作栏,紧凑布局
+- [x] 项目详情-成员,标题与筛选操作栏,紧凑布局
+- [x] 项目详情-问题,标题与筛选操作栏,紧凑布局并全屏弹窗
 
 ### 组员分配(项目详情页)
-- 增加删除组员功能,将组员移出项目组
-- 企业微信SDK:添加成员后,自动邀请进群(企业微信PC/手机端)
+- [x] 增加删除组员功能,将组员移出项目组
+- [x] 企业微信SDK:添加成员后,自动邀请进群(企业微信PC/手机端)
 
 ## 2025-10-23
 
 ### 员工管理(后台)
-- 员工列表显示头像与职位,缺失头像自动使用统一占位图,列表更整齐。
-- 员工详情弹窗更丰富:手机号、邮箱、企微ID、身份、部门、入职时间、技能与工作量等一目了然。
-- 弹窗样式与布局优化,对齐与间距更合理,信息更易读。
+- [x] 员工列表显示头像与职位,缺失头像自动使用统一占位图,列表更整齐。
+- [x] 员工详情弹窗更丰富:手机号、邮箱、企微ID、身份、部门、入职时间、技能与工作量等一目了然。
+- [x] 弹窗样式与布局优化,对齐与间距更合理,信息更易读。
 
 ### 表格与界面一致性
-- 多页面的列宽与对齐优化,整体信息密度与可读性提升,浏览体验更统一。
+- [x] 多页面的列宽与对齐优化,整体信息密度与可读性提升,浏览体验更统一。
 
 ### 稳定性与兼容性
-- 刷新后列表自动同步最新数据,减少信息不一致的情况。
-- 无跟进记录时自动显示历史跟进信息,保证页面内容完整性。
+- [x] 刷新后列表自动同步最新数据,减少信息不一致的情况。
+- [x] 无跟进记录时自动显示历史跟进信息,保证页面内容完整性。
 ## 2025-10-22
 
 ### 客户选择与详情体验
-- 项目页支持便捷选择或创建客户,已建档/未建档清晰分区,搜索更高效。
-- 新增“一键刷新客户信息”,可同步企业微信的最新资料,名单与详情保持一致。
-- 客户详情以侧栏弹窗方式展示,点击返回或遮罩即可关闭,不会跳转到错误页面。
-- 跟进记录默认显示当前项目的记录,支持切换查看该客户的全部跟进历史。
+- [x] 项目页支持便捷选择或创建客户,已建档/未建档清晰分区,搜索更高效。
+- [x] 新增“一键刷新客户信息”,可同步企业微信的最新资料,名单与详情保持一致。
+- [x] 客户详情以侧栏弹窗方式展示,点击返回或遮罩即可关闭,不会跳转到错误页面。
+- [x] 跟进记录默认显示当前项目的记录,支持切换查看该客户的全部跟进历史。
 
 ### 客户信息显示优化
-- 统一头像占位图为 `/assets/images/default-avatar.svg`,列表与详情一致,缺失头像时显示更友好。
-- “所在群聊”改为纵向列表,信息展示更完整,阅读更舒适。
+- [x] 统一头像占位图为 `/assets/images/default-avatar.svg`,列表与详情一致,缺失头像时显示更友好。
+- [x] “所在群聊”改为纵向列表,信息展示更完整,阅读更舒适。
 
 ### 客户管理(后台)
-- 客户列表增加头像、类型、名称等信息显示,点击即可查看详情。
-- 在详情中可直接刷新客户数据,确保资料实时准确。
+- [x] 客户列表增加头像、类型、名称等信息显示,点击即可查看详情。
+- [x] 在详情中可直接刷新客户数据,确保资料实时准确。
 

+ 1 - 0
rules/schemas.md

@@ -385,6 +385,7 @@ GroupChat "n" --> "1" Project : 关联项目(可选)
 | assignee | Pointer | 否 | 负责设计师 | → Profile |
 | status | String | 是 | 项目状态 | "进行中" |
 | currentStage | String | 是 | 当前阶段 | "建模" |
+| demoday | Date | 否 | 小图时间 | 2024-12-31T00:00:00.000Z |
 | deadline | Date | 否 | 截止时间 | 2024-12-31T00:00:00.000Z |
 | data | Object | 否 | 扩展数据 | { requirements, stageHistory, ... } |
 | isDeleted | Boolean | 否 | 软删除标记 | false |

+ 4 - 4
src/modules/project/components/quotation-editor.component.html

@@ -123,7 +123,7 @@
                 </div>
                 <div class="product-actions">
                   @if (canEdit) {
-                    <button class="btn-icon" (click)="editProduct(space.productId); $event.stopPropagation()" title="编辑">
+                    <button class="btn-icon" (click)="openEditProductModal(space.productId); $event.stopPropagation()" title="编辑">
                       <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
                         <path fill="currentColor" d="M362.7 19.32C387.7-5.678 428.3-5.678 453.3 19.32l39.38 39.38c25 25 25 65.62 0 90.62l-109.5 109.5c-25 25-65.62 25-90.62 0l-109.5-109.5c-25-25-25-65.62 0-90.62L272.1 19.32z"/>
                       </svg>
@@ -347,12 +347,12 @@
   }
 </div>
 
-<!-- 产品添加模态框 -->
+<!-- 产品添加/编辑模态框 -->
 @if (showAddProductModal) {
   <div class="modal-overlay" (click)="closeAddProductModal()">
     <div class="modal-container add-product-modal" (click)="$event.stopPropagation()">
       <div class="modal-header">
-        <h3>添加设计产品</h3>
+        <h3>{{ isEditMode ? '编辑设计产品' : '添加设计产品' }}</h3>
         <button class="close-btn" (click)="closeAddProductModal()">
           <svg class="icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
             <path fill="currentColor" d="M256 48C141.1 48 48 141.1 48 256s93.1 208 208 208 208-93.1 208-208S370.9 48 256 48zm52.7 283.3L256 278.6l-52.7 52.7c-6.2 6.2-16.4 6.2-22.6 0-3.1-3.1-4.7-7.2-4.7-11.3 0-4.1 1.6-8.2 4.7-11.3l52.7-52.7-52.7-52.7c-3.1-3.1-4.7-7.2-4.7-11.3 0-4.1 1.6-8.2 4.7-11.3 6.2-6.2 16.4-6.2 22.6 0l52.7 52.7 52.7-52.7c6.2-6.2 16.4-6.2 22.6 0 6.2 6.2 6.2 16.4 0 22.6L278.6 256l52.7 52.7c6.2 6.2 6.2 16.4 0 22.6-6.2 6.3-16.4 6.3-22.6 0z"/>
@@ -551,7 +551,7 @@
           class="btn-primary"
           (click)="confirmAddProduct()"
           [disabled]="!isNewProductValid()">
-          确认添加
+          {{ isEditMode ? '确认修改' : '确认添加' }}
         </button>
       </div>
     </div>

+ 192 - 30
src/modules/project/components/quotation-editor.component.ts

@@ -105,8 +105,10 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
     '建筑类': ['门头', '小型单体', '大型单体', '鸟瞰']
   };
 
-  // 产品添加模态框状态
+  // 产品添加/编辑模态框状态
   showAddProductModal: boolean = false;
+  isEditMode: boolean = false; // 是否为编辑模式
+  editingProductId: string = ''; // 正在编辑的产品ID
   newProduct: any = {
     isCustom: false,
     sceneName: '',
@@ -937,14 +939,55 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
   openAddProductModal(): void {
     // 重置表单
     this.resetNewProductForm();
+    this.isEditMode = false;
+    this.editingProductId = '';
     this.showAddProductModal = true;
   }
 
   /**
-   * 关闭添加产品模态框
+   * 打开编辑产品模态框
+   */
+  openEditProductModal(productId: string): void {
+    const product = this.products.find(p => p.id === productId);
+    if (!product) return;
+
+    // 预填充产品数据
+    const space = product.get('space') || {};
+    const quotation = product.get('quotation') || {};
+    const adjustments = quotation.adjustments || {};
+
+    // 判断是否为自定义名称
+    const presetScenes = this.getPresetScenes();
+    const isPreset = presetScenes.includes(product.get('productName'));
+
+    this.newProduct = {
+      isCustom: !isPreset,
+      sceneName: isPreset ? product.get('productName') : '',
+      productName: product.get('productName'),
+      spaceType: space.spaceType || this.getDefaultSpaceType(),
+      styleLevel: space.styleLevel || '基础风格组',
+      businessType: space.businessType || '办公空间',
+      architectureType: space.architectureType || '门头',
+      adjustments: {
+        extraFunction: adjustments.extraFunction || 0,
+        complexity: adjustments.complexity || 0,
+        design: adjustments.design || false,
+        panoramic: adjustments.panoramic || false
+      }
+    };
+
+    this.isEditMode = true;
+    this.editingProductId = productId;
+    this.showAddProductModal = true;
+  }
+
+  /**
+   * 关闭添加/编辑产品模态框
    */
   closeAddProductModal(): void {
     this.showAddProductModal = false;
+    this.isEditMode = false;
+    this.editingProductId = '';
     this.resetNewProductForm();
   }
 
@@ -1096,7 +1139,7 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
   }
 
   /**
-   * 确认添加产品
+   * 确认添加/编辑产品
    */
   async confirmAddProduct(): Promise<void> {
     if (!this.isNewProductValid()) {
@@ -1105,44 +1148,163 @@ export class QuotationEditorComponent implements OnInit, OnChanges, OnDestroy {
     }
 
     try {
-      const productName = this.newProduct.isCustom
-        ? this.newProduct.productName
-        : this.newProduct.sceneName;
+      if (this.isEditMode) {
+        await this.updateExistingProduct();
+      } else {
+        await this.createNewProduct();
+      }
+    } catch (error) {
+      console.error(this.isEditMode ? '编辑产品失败:' : '添加产品失败:', error);
+      alert(this.isEditMode ? '编辑产品失败,请重试' : '添加产品失败,请重试');
+    }
+  }
 
-      const config: any = {
-        spaceType: this.newProduct.spaceType
-      };
+  /**
+   * 创建新产品
+   */
+  private async createNewProduct(): Promise<void> {
+    const productName = this.newProduct.isCustom
+      ? this.newProduct.productName
+      : this.newProduct.sceneName;
+
+    const config: any = {
+      spaceType: this.newProduct.spaceType
+    };
 
+    if (this.projectInfo.projectType === '家装') {
+      config.styleLevel = this.newProduct.styleLevel;
+    } else if (this.projectInfo.projectType === '工装') {
+      config.businessType = this.newProduct.businessType;
+    } else if (this.projectInfo.projectType === '建筑类') {
+      config.architectureType = this.newProduct.architectureType;
+    }
+
+    // 创建产品
+    const product = await this.createProductWithAdjustments(productName, config);
+
+    if (product) {
+      // 重新加载产品列表
+      await this.loadProjectProducts();
+
+      // 重新生成报价
+      await this.generateQuotationFromProducts();
+
+      // 关闭模态框
+      this.closeAddProductModal();
+
+      alert(`成功添加产品: ${productName}`);
+    } else {
+      throw new Error('创建产品失败');
+    }
+  }
+
+  /**
+   * 更新现有产品
+   */
+  private async updateExistingProduct(): Promise<void> {
+    const product = this.products.find(p => p.id === this.editingProductId);
+    if (!product) {
+      throw new Error('找不到要编辑的产品');
+    }
+
+    const productName = this.newProduct.isCustom
+      ? this.newProduct.productName
+      : this.newProduct.sceneName;
+
+    // 更新产品名称和类型
+    product.set('productName', productName);
+    product.set('productType', this.inferProductType(productName));
+
+    // 确定配置
+    const spaceType = this.newProduct.spaceType;
+    const styleLevel = this.newProduct.styleLevel;
+    const businessType = this.newProduct.businessType;
+    const architectureType = this.newProduct.architectureType;
+
+    // 更新空间信息
+    const space = product.get('space') || {};
+    space.spaceName = productName;
+    space.spaceType = spaceType;
+    space.styleLevel = styleLevel;
+    space.businessType = businessType;
+    space.architectureType = architectureType;
+    product.set('space', space);
+
+    // 重新计算基础价格
+    let basePrice = this.calculateBasePrice({
+      priceLevel: this.projectInfo.priceLevel,
+      projectType: this.projectInfo.projectType,
+      renderType: this.projectInfo.renderType,
+      spaceType: spaceType,
+      styleLevel: styleLevel,
+      businessType: businessType,
+      architectureType: architectureType
+    });
+
+    // 应用加价规则
+    let finalPrice = basePrice;
+    const adjustments = this.newProduct.adjustments;
+
+    // 功能区加价
+    if (adjustments.extraFunction > 0) {
       if (this.projectInfo.projectType === '家装') {
-        config.styleLevel = this.newProduct.styleLevel;
+        finalPrice += adjustments.extraFunction * 100;
       } else if (this.projectInfo.projectType === '工装') {
-        config.businessType = this.newProduct.businessType;
-      } else if (this.projectInfo.projectType === '建筑类') {
-        config.architectureType = this.newProduct.architectureType;
+        finalPrice += adjustments.extraFunction * 400;
       }
+    }
 
-      // 创建产品
-      const product = await this.createProductWithAdjustments(productName, config);
+    // 造型复杂度加价
+    if (adjustments.complexity > 0) {
+      finalPrice += adjustments.complexity;
+    }
 
-      if (product) {
-        // 重新加载产品列表
-        await this.loadProjectProducts();
+    // 设计服务倍增
+    if (adjustments.design) {
+      finalPrice *= 2;
+    }
+
+    // 全景渲染倍增(仅工装)
+    if (this.projectInfo.projectType === '工装' && adjustments.panoramic) {
+      finalPrice *= 2;
+    }
 
-        // 重新生成报价
-        await this.generateQuotationFromProducts();
+    finalPrice = Math.round(finalPrice);
+
+    // 更新报价信息
+    const quotation = product.get('quotation') || {};
+    quotation.basePrice = Math.round(basePrice);
+    quotation.price = finalPrice;
+    quotation.adjustments = {
+      extraFunction: adjustments.extraFunction,
+      complexity: adjustments.complexity,
+      design: adjustments.design,
+      panoramic: adjustments.panoramic
+    };
+    quotation.breakdown = this.calculatePriceBreakdown(finalPrice);
+    product.set('quotation', quotation);
+
+    // 保存产品
+    await product.save();
+
+    // 更新报价中的空间数据
+    const spaceData = this.quotation.spaces.find((s: any) => s.productId === this.editingProductId);
+    if (spaceData) {
+      spaceData.name = productName;
+      // 重新生成该空间的分配
+      spaceData.processes = this.generateDefaultProcesses(finalPrice);
+    }
 
-        // 关闭模态框
-        this.closeAddProductModal();
+    // 重新加载产品列表
+    await this.loadProjectProducts();
 
-        alert(`成功添加产品: ${productName}`);
-      } else {
-        throw new Error('创建产品失败');
-      }
+    // 重新生成报价
+    await this.generateQuotationFromProducts();
 
-    } catch (error) {
-      console.error('添加产品失败:', error);
-      alert('添加产品失败,请重试');
-    }
+    // 关闭模态框
+    this.closeAddProductModal();
+
+    alert(`成功更新产品: ${productName}`);
   }
 
   /**

+ 1 - 2
src/modules/project/pages/project-detail/stages/stage-aftercare.component.ts

@@ -5,7 +5,7 @@ import { ActivatedRoute } from '@angular/router';
 import { FmodeObject, FmodeParse } from 'fmode-ng/parse';
 import { ProjectFileService } from '../../../services/project-file.service';
 import { ProductSpaceService, Project } from '../../../services/product-space.service';
-import { WxworkAuth } from 'fmode-ng/social';
+import { WxworkAuth } from 'fmode-ng/core';
 
 const Parse = FmodeParse.with('nova');
 
@@ -343,7 +343,6 @@ export class StageAftercareComponent implements OnInit {
       this.cid = params['cid'] || localStorage.getItem("company") || '';
       this.projectId = params['projectId'] || this.project?.id || '';
       
-      // @ts-ignore - WxworkAuth type issue with fmode-ng
       let wwauth = new WxworkAuth({cid:this.cid})
       this.currentUser = await wwauth.currentProfile();
       await this.loadData();

+ 26 - 6
src/modules/project/pages/project-detail/stages/stage-order.component.html

@@ -78,12 +78,32 @@
 
           <!-- 交付期限 -->
           <div class="form-group">
-            <label class="form-label">交付期限 <span class="required">*</span></label>
-            <input
-              class="form-input"
-              type="date"
-              [(ngModel)]="projectInfo.deadline"
-              [disabled]="!canEdit" />
+            <label class="form-label">小图日期 <span class="required">*</span></label>
+            <mat-form-field appearance="outline" class="date-picker-field">
+              <input
+                matInput
+                [matDatepicker]="demodayPicker"
+                [(ngModel)]="projectInfo.demoday"
+                [disabled]="!canEdit"
+                placeholder="选择小图日期">
+              <mat-datepicker-toggle matIconSuffix [for]="demodayPicker"></mat-datepicker-toggle>
+              <mat-datepicker #demodayPicker></mat-datepicker>
+            </mat-form-field>
+          </div>
+
+          <!-- 交付期限 -->
+          <div class="form-group">
+            <label class="form-label">交付日期 </label>
+            <mat-form-field appearance="outline" class="date-picker-field">
+              <input
+                matInput
+                [matDatepicker]="deadlinePicker"
+                [(ngModel)]="projectInfo.deadline"
+                [disabled]="!canEdit"
+                placeholder="选择交付日期">
+              <mat-datepicker-toggle matIconSuffix [for]="deadlinePicker"></mat-datepicker-toggle>
+              <mat-datepicker #deadlinePicker></mat-datepicker>
+            </mat-form-field>
           </div>
 
           <!-- 项目描述 -->

+ 76 - 0
src/modules/project/pages/project-detail/stages/stage-order.component.scss

@@ -1,5 +1,81 @@
 // 订单分配阶段样式 - 纯 div+scss 实现
 
+// ============ Material DatePicker 样式 ============
+.date-picker-field {
+  width: 100%;
+
+  ::ng-deep {
+    .mat-mdc-form-field-infix {
+      padding-top: 8px;
+      padding-bottom: 8px;
+    }
+
+    .mat-mdc-text-field-wrapper {
+      padding-left: 0;
+      padding-right: 0;
+    }
+
+    .mat-mdc-form-field-subscript-wrapper {
+      display: none; // 隐藏底部的提示文本区域
+    }
+
+    .mat-mdc-form-field-focus-overlay {
+      background-color: transparent;
+    }
+
+    .mat-datepicker-toggle {
+      color: var(--ion-color-primary, #3880ff);
+    }
+
+    input.mat-mdc-input-element {
+      padding: 10px 14px;
+      font-size: 14px;
+      color: #111827;
+
+      &::placeholder {
+        color: #9ca3af;
+      }
+
+      &:disabled {
+        color: #6b7280;
+        cursor: not-allowed;
+      }
+    }
+
+    .mat-mdc-form-field-outline {
+      border-radius: 8px;
+    }
+
+    .mdc-notched-outline__leading,
+    .mdc-notched-outline__notch,
+    .mdc-notched-outline__trailing {
+      border-color: #e5e7eb;
+      border-width: 1.5px;
+    }
+
+    .mdc-notched-outline:hover .mdc-notched-outline__leading,
+    .mdc-notched-outline:hover .mdc-notched-outline__notch,
+    .mdc-notched-outline:hover .mdc-notched-outline__trailing {
+      border-color: var(--ion-color-primary, #3880ff);
+    }
+
+    .mat-mdc-form-field.mat-focused .mdc-notched-outline__leading,
+    .mat-mdc-form-field.mat-focused .mdc-notched-outline__notch,
+    .mat-mdc-form-field.mat-focused .mdc-notched-outline__trailing {
+      border-color: var(--ion-color-primary, #3880ff);
+    }
+
+    .mat-mdc-form-field.mat-form-field-disabled {
+      .mdc-notched-outline__leading,
+      .mdc-notched-outline__notch,
+      .mdc-notched-outline__trailing {
+        border-color: #d1d5db;
+        background-color: #f3f4f6;
+      }
+    }
+  }
+}
+
 // 文件上传相关样式
 .files-card {
   .wx-support-indicator {

+ 32 - 11
src/modules/project/pages/project-detail/stages/stage-order.component.ts

@@ -2,7 +2,11 @@ import { Component, OnInit, Input, ViewChild, ElementRef, ChangeDetectionStrateg
 import { CommonModule } from '@angular/common';
 import { FormsModule } from '@angular/forms';
 import { ActivatedRoute } from '@angular/router';
-import { FmodeObject, FmodeParse, WxworkSDK } from 'fmode-ng/core';
+import { FmodeObject, FmodeParse, WxworkAuth, WxworkSDK } from 'fmode-ng/core';
+import { MatDatepickerModule } from '@angular/material/datepicker';
+import { MatInputModule } from '@angular/material/input';
+import { MatNativeDateModule } from '@angular/material/core';
+import { MatFormFieldModule } from '@angular/material/form-field';
 
 import { ProjectFileService } from '../../../services/project-file.service';
 import { ProductSpaceService, Project } from '../../../services/product-space.service';
@@ -35,7 +39,16 @@ const Parse = FmodeParse.with('nova');
 @Component({
   selector: 'app-stage-order',
   standalone: true,
-  imports: [CommonModule, FormsModule, QuotationEditorComponent, TeamAssignComponent],
+  imports: [
+    CommonModule,
+    FormsModule,
+    MatDatepickerModule,
+    MatInputModule,
+    MatNativeDateModule,
+    MatFormFieldModule,
+    QuotationEditorComponent,
+    TeamAssignComponent
+  ],
   templateUrl: './stage-order.component.html',
   styleUrls: ['./stage-order.component.scss'],
   changeDetection: ChangeDetectionStrategy.OnPush
@@ -54,12 +67,14 @@ export class StageOrderComponent implements OnInit {
     title: '',
     projectType: '', // 家装 | 工装
     renderType: '', // 静态单张 | 360全景
-    deadline: '',
+    demoday: new Date() as Date | null,
+    deadline: new Date() as Date | null,
     description: '',
     priceLevel: '一级', // 一级(老客户) | 二级(中端组) | 三级(高端组)
     spaceType: 'single' // single | multi
   };
 
+  
   // 空间管理
   projectSpaces: Project[] = [];
   isMultiSpaceProject: boolean = false;
@@ -285,8 +300,8 @@ export class StageOrderComponent implements OnInit {
       }
 
       if (!this.currentUser && this.cid) {
-        const wxwork = new WxworkSDK({ cid: this.cid, appId: 'crm' });
-        this.currentUser = await wxwork.getCurrentUser();
+        const wxwork = new WxworkAuth({ cid: this.cid, appId: 'crm' });
+        this.currentUser = await wxwork.currentProfile();
 
         const role = this.currentUser?.get('roleName') || '';
         this.canEdit = ['客服', '组员', '组长', '管理员'].includes(role);
@@ -297,7 +312,8 @@ export class StageOrderComponent implements OnInit {
         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.deadline = this.project.get('deadline') || new Date();
+        this.projectInfo.demoday = this.project.get('demoday') || new Date();
         this.projectInfo.description = this.project.get('description') || '';
 
         const data = this.project.get('data') || {};
@@ -739,6 +755,7 @@ export class StageOrderComponent implements OnInit {
       this.project.set('projectType', this.projectInfo.projectType);
       this.project.set('renderType', this.projectInfo.renderType);
       this.project.set('deadline', this.projectInfo.deadline);
+      this.project.set('demoday', this.projectInfo.demoday);
       this.project.set('description', this.projectInfo.description);
       this.project.set('spaceType', this.projectInfo.spaceType);
 
@@ -777,10 +794,14 @@ export class StageOrderComponent implements OnInit {
       alert('请选择项目类型');
       return;
     }
-    if (!this.projectInfo.deadline) {
-      alert('请选择交付期限');
+    if (!this.projectInfo.demoday) {
+      alert('请选择小图日期');
       return;
     }
+    // if (!this.projectInfo.deadline) {
+    //   alert('请选择交付期限');
+    //   return;
+    // }
     if (this.quotation.total === 0) {
       alert('请配置报价明细');
       return;
@@ -823,9 +844,9 @@ export class StageOrderComponent implements OnInit {
       approvalHistory.push({
         stage: '订单分配',
         submitter: {
-          id: this.currentUser!.id,
-          name: this.currentUser!.get('name'),
-          role: this.currentUser!.get('roleName')
+          id: this.currentUser?.id,
+          name: this.currentUser?.get('name'),
+          role: this.currentUser?.get('roleName')
         },
         submitTime: new Date(),
         status: 'confirm',