|
@@ -35,7 +35,7 @@ interface Customer {
|
|
|
templateUrl: './consultation-order-panel.component.html',
|
|
|
styleUrls: ['./consultation-order-panel.component.scss']
|
|
|
})
|
|
|
-export class ConsultationOrderPanelComponent {
|
|
|
+export class ConsultationOrderPanelComponent implements OnInit {
|
|
|
@Output() orderCreated = new EventEmitter<any>();
|
|
|
@Output() projectCreated = new EventEmitter<any>(); // 新增项目创建成功事件
|
|
|
|
|
@@ -86,11 +86,7 @@ export class ConsultationOrderPanelComponent {
|
|
|
constructor(private fb: FormBuilder) {
|
|
|
// 初始化需求表单
|
|
|
this.requirementForm = this.fb.group({
|
|
|
- decorationType: ['', Validators.required],
|
|
|
downPayment: ['', [Validators.required, Validators.min(0)]],
|
|
|
- firstDraftDate: ['', Validators.required],
|
|
|
- style: [''],
|
|
|
- projectGroup: [''],
|
|
|
budget: ['', Validators.required],
|
|
|
area: ['', [Validators.required, Validators.min(1)]],
|
|
|
smallImageTime: [''],
|
|
@@ -111,8 +107,6 @@ export class ConsultationOrderPanelComponent {
|
|
|
|
|
|
// 初始化客户表单
|
|
|
this.customerForm = this.fb.group({
|
|
|
- name: ['', Validators.required],
|
|
|
- phone: ['', [Validators.required, Validators.pattern(/^(1[3-9]\d{9}|1[3-9]\d{1}\*{4}\d{4})$/)]],
|
|
|
wechat: [''],
|
|
|
customerType: ['新客户'],
|
|
|
source: [''],
|
|
@@ -122,6 +116,20 @@ export class ConsultationOrderPanelComponent {
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ ngOnInit(): void {
|
|
|
+ // 监听表单变化,实时更新阶段状态
|
|
|
+ this.customerForm.valueChanges.subscribe(() => {
|
|
|
+ this.checkStageCompletion();
|
|
|
+ });
|
|
|
+
|
|
|
+ this.requirementForm.valueChanges.subscribe(() => {
|
|
|
+ this.checkStageCompletion();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 初始检查阶段状态
|
|
|
+ this.checkStageCompletion();
|
|
|
+ }
|
|
|
+
|
|
|
// 搜索客户
|
|
|
searchCustomer() {
|
|
|
if (this.searchKeyword.length >= 2) {
|
|
@@ -189,28 +197,92 @@ export class ConsultationOrderPanelComponent {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // 流程状态管理
|
|
|
+ stageCompletionStatus = {
|
|
|
+ customerInfo: false,
|
|
|
+ projectRequirements: false,
|
|
|
+ teamAssignment: false,
|
|
|
+ orderConfirmation: false
|
|
|
+ };
|
|
|
+
|
|
|
+ // 获取阶段状态文本
|
|
|
+ getStageStatusText(stage: keyof typeof this.stageCompletionStatus): string {
|
|
|
+ if (this.stageCompletionStatus[stage]) {
|
|
|
+ return '已完成';
|
|
|
+ } else {
|
|
|
+ // 检查是否为未开始状态
|
|
|
+ const stages = ['customerInfo', 'projectRequirements', 'teamAssignment', 'orderConfirmation'];
|
|
|
+ const currentIndex = stages.indexOf(stage);
|
|
|
+
|
|
|
+ // 检查前面的阶段是否都已完成
|
|
|
+ let allPreviousCompleted = true;
|
|
|
+ for (let i = 0; i < currentIndex; i++) {
|
|
|
+ if (!this.stageCompletionStatus[stages[i] as keyof typeof this.stageCompletionStatus]) {
|
|
|
+ allPreviousCompleted = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return allPreviousCompleted ? '进行中' : '未进行';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取阶段状态类名
|
|
|
+ getStageStatusClass(stage: keyof typeof this.stageCompletionStatus): string {
|
|
|
+ if (this.stageCompletionStatus[stage]) {
|
|
|
+ return 'stage-completed';
|
|
|
+ } else {
|
|
|
+ // 检查是否为未开始状态
|
|
|
+ const stages = ['customerInfo', 'projectRequirements', 'teamAssignment', 'orderConfirmation'];
|
|
|
+ const currentIndex = stages.indexOf(stage);
|
|
|
+
|
|
|
+ // 检查前面的阶段是否都已完成
|
|
|
+ let allPreviousCompleted = true;
|
|
|
+ for (let i = 0; i < currentIndex; i++) {
|
|
|
+ if (!this.stageCompletionStatus[stages[i] as keyof typeof this.stageCompletionStatus]) {
|
|
|
+ allPreviousCompleted = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return allPreviousCompleted ? 'stage-in-progress' : 'stage-pending';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取进度百分比
|
|
|
+ getProgressPercentage(): number {
|
|
|
+ const completedStages = Object.values(this.stageCompletionStatus).filter(status => status).length;
|
|
|
+ return Math.round((completedStages / 4) * 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查阶段完成状态
|
|
|
+ private checkStageCompletion(): void {
|
|
|
+ // 检查客户信息阶段 - 客户信息表单有效
|
|
|
+ this.stageCompletionStatus.customerInfo = this.customerForm.valid;
|
|
|
+
|
|
|
+ // 检查项目需求阶段 - 需求表单有效
|
|
|
+ this.stageCompletionStatus.projectRequirements = this.requirementForm.valid;
|
|
|
+
|
|
|
+ // 检查团队分配阶段 - 已选择设计师
|
|
|
+ this.stageCompletionStatus.teamAssignment = !!this.selectedDesigner;
|
|
|
+
|
|
|
+ // 检查订单确认阶段 - 所有前面阶段都完成
|
|
|
+ this.stageCompletionStatus.orderConfirmation = this.stageCompletionStatus.customerInfo &&
|
|
|
+ this.stageCompletionStatus.projectRequirements &&
|
|
|
+ this.stageCompletionStatus.teamAssignment;
|
|
|
+ }
|
|
|
+
|
|
|
// 检查表单是否有效
|
|
|
isFormValid(): boolean {
|
|
|
return this.customerForm.valid && this.requirementForm.valid;
|
|
|
}
|
|
|
|
|
|
- // 提交表单
|
|
|
+ // 提交表单 - 优化流程:直接进入团队分配
|
|
|
submitForm() {
|
|
|
if (this.isFormValid()) {
|
|
|
this.isSubmitting = true;
|
|
|
|
|
|
- const formData = {
|
|
|
- customerInfo: this.customerForm.value,
|
|
|
- requirementInfo: this.requirementForm.value,
|
|
|
- preferenceTags: this.preferenceTags,
|
|
|
- roleContext: this.roleContext, // 添加角色上下文信息
|
|
|
- createdAt: new Date()
|
|
|
- };
|
|
|
-
|
|
|
- // 直接触发订单创建事件,不需要延迟
|
|
|
- this.orderCreated.emit(formData);
|
|
|
-
|
|
|
- // 立即显示团队分配弹窗
|
|
|
+ // 直接显示团队分配弹窗,无需先触发订单创建事件
|
|
|
this.showTeamAssignmentModal = true;
|
|
|
}
|
|
|
}
|
|
@@ -220,13 +292,24 @@ export class ConsultationOrderPanelComponent {
|
|
|
this.showTeamAssignmentModal = false;
|
|
|
}
|
|
|
|
|
|
- // 确认团队分配
|
|
|
+ // 确认团队分配 - 优化流程:同时触发订单创建和项目创建事件
|
|
|
confirmTeamAssignment(designer: Designer) {
|
|
|
this.selectedDesigner = designer;
|
|
|
this.showTeamAssignmentModal = false;
|
|
|
this.isSubmitting = false; // 重置提交状态
|
|
|
|
|
|
- // 发出项目创建成功事件
|
|
|
+ // 更新阶段状态
|
|
|
+ this.checkStageCompletion();
|
|
|
+
|
|
|
+ // 构建完整的项目数据
|
|
|
+ const formData = {
|
|
|
+ customerInfo: this.customerForm.value,
|
|
|
+ requirementInfo: this.requirementForm.value,
|
|
|
+ preferenceTags: this.preferenceTags,
|
|
|
+ roleContext: this.roleContext, // 添加角色上下文信息
|
|
|
+ createdAt: new Date()
|
|
|
+ };
|
|
|
+
|
|
|
const projectData = {
|
|
|
customerInfo: this.customerForm.value,
|
|
|
requirementInfo: this.requirementForm.value,
|
|
@@ -235,6 +318,10 @@ export class ConsultationOrderPanelComponent {
|
|
|
createdAt: new Date()
|
|
|
};
|
|
|
|
|
|
+ // 先触发订单创建事件(用于数据同步)
|
|
|
+ this.orderCreated.emit(formData);
|
|
|
+
|
|
|
+ // 再触发项目创建成功事件(用于阶段推进)
|
|
|
this.projectCreated.emit(projectData);
|
|
|
|
|
|
// 重置表单
|