process-status-bar.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { Component, Input, signal, computed } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. // 定义流程阶段状态接口
  4. export interface ProcessStatusStage {
  5. id: string;
  6. name: string;
  7. status: 'pending' | 'in-progress' | 'completed';
  8. }
  9. @Component({
  10. selector: 'app-process-status-bar',
  11. standalone: true,
  12. imports: [CommonModule],
  13. template: `
  14. <div class="process-status-bar">
  15. @for (stage of stages(); track stage.id; let i = $index) {
  16. <div class="status-item"
  17. [class.status-completed]="stage.status === 'completed'"
  18. [class.status-in-progress]="stage.status === 'in-progress'"
  19. [class.status-pending]="stage.status === 'pending'">
  20. <span class="status-text">{{ stage.name }}</span>
  21. </div>
  22. @if (i < stages().length - 1) {
  23. <div class="status-separator"></div>
  24. }
  25. }
  26. </div>
  27. `,
  28. styleUrls: ['./process-status-bar.component.scss']
  29. })
  30. export class ProcessStatusBarComponent {
  31. @Input() set stageData(value: ProcessStatusStage[]) {
  32. console.log('ProcessStatusBarComponent 接收到数据:', value);
  33. this.stages.set(value || []);
  34. }
  35. // 内部状态管理
  36. stages = signal<ProcessStatusStage[]>([]);
  37. constructor() {
  38. console.log('ProcessStatusBarComponent 构造函数被调用');
  39. }
  40. }