import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { CommonCompModule } from '../../../services/common.modules';
import { Router, ActivatedRoute } from '@angular/router';
import { ReactiveFormsModule } from '@angular/forms';
import Parse from 'parse';
import { ExportFileComponent } from './export-file/export-file.component';
import { ExportListComponent } from './export-list/export-list.component';
import { CompleteComponent } from './complete/complete.component';
@Component({
  selector: 'app-submitted',
  templateUrl: './submitted.component.html',
  styleUrls: ['./submitted.component.scss'],
  imports: [
    CommonCompModule,
    ReactiveFormsModule,
    ExportFileComponent,
    ExportListComponent,
    CompleteComponent
  ],
  standalone: true,
})
export class SubmittedComponent implements OnInit {
  eduProcess?: Parse.Object;

  state: number = 0;
  get stateMap() {
    let map: any = {
      '0': '导出函报文件',
      '1': '导出公示教材列表',
      '2': '完成报送',
    };
    return map[this.state];
  }
  constructor(private router: Router, private activeRoute: ActivatedRoute) {}

  ngOnInit() {
    this.activeRoute.paramMap.subscribe(async (params) => {
      let id = params.get('id');
      let query = new Parse.Query('EduProcess');
      query.include('department');
      query.equalTo('objectId', id);
      this.eduProcess = await query.first();
      if(this.eduProcess?.get('status') == '300' || this.eduProcess?.get('status') == '400'){
        this.state = 2
      }
    });
  }
  back() {
    history.back();
  }
  onChange(e: any) {
    console.log(e);
    if (e == 'next') {
      this.state++;
    } else {
      this.state--;
    }
  }
}
