import { Component, OnInit } from "@angular/core";
import { Router, ActivatedRoute } from "@angular/router";
import { NzMessageService } from "ng-zorro-antd";

import { MainService } from "../../services/main.service";

@Component({
  selector: "app-round-robin-detail",
  templateUrl: "./round-robin-detail.component.html",
  styleUrls: ["./round-robin-detail.component.less"],
})
export class RoundRobinDetailComponent implements OnInit {
  constructor(
    private message: NzMessageService,
    private router: Router,
    private mainService: MainService,
    private routerInfo: ActivatedRoute
  ) {}

  id: number;
  userInfo: any = null;
  dayType = ["全部", "节假日", "工作日"]; //执行策略里的复选框数据字典
  ngOnInit() {
    this.getDetail();
  }
  hideModal() {
    this.router.navigateByUrl("/main/roundRobin");
  }

  // 获取详情
  maskFlag: any = false;
  getDetail() {
    this.id = this.routerInfo.snapshot.params["id"];
    this.maskFlag = this.message.loading("正在加载中..", {
      nzDuration: 0,
    }).messageId;
    this.mainService
      .getFetchData("api", "orderPlan", this.id)
      .subscribe((data) => {
        this.message.remove(this.maskFlag);
        this.maskFlag = false;
        if (data.status == 200) {
          this.userInfo = data.data;
        }
      });
  }
}
