import { Component, OnInit } from '@angular/core';
import {WorkService} from '../../work.service';
import {fileUrl} from '../../../app.constants';
import {CommonService} from '../../../shared/common/common.service';

@Component({
  selector: 'smart-look-plan',
  templateUrl: './look-plan.component.html',
  styles: []
})
export class LookPlanComponent implements OnInit {

  isVisible = false;
  title;
  plan;
  planId;
  url = fileUrl + "/planFile/";

  constructor(private workSer:WorkService,private commonSer:CommonService) { }

  ngOnInit() {
  }

  showModal(id,name){
      this.planId = id;
    this.title = "计划："+name;
    this.isVisible = true;
    this.workSer.findPlan(id).subscribe(
        (res)=>{
          if(res.errCode == 10000){
            this.plan = res.data;
          }
        }
    )
  }

    handleEditCancel(){
    this.isVisible = false;
    }

    downLoad(){
        this.workSer.downloadTemplate("plan",this.planId).subscribe(
            (data)=>{
                this.commonSer.downloadFile(this.plan.fileName,data)
            }
        )
    }

}
