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-serial-number-setting-detail",
  templateUrl: "./serial-number-setting-detail.component.html",
  styleUrls: ["./serial-number-setting-detail.component.less"],
})
export class SerialNumberSettingDetailComponent implements OnInit {
  constructor(
    private message: NzMessageService,
    private router: Router,
    private mainService: MainService,
    private routerInfo: ActivatedRoute
  ) {}

  id: number;
  info: any = {};
  ngOnInit() {
    this.getDetail();
  }
  hideModal() {
    history.go(-1);
  }

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