import {Component, OnInit} from '@angular/core';
import {WorkService} from '../../work.service';
import {NzMessageService} from 'ng-zorro-antd';
import {ActivatedRoute} from '@angular/router';
import {CommonService} from '../../../shared/common/common.service';

@Component({
    selector: 'smart-handle-detail',
    templateUrl: './handle-detail.component.html',
    styles: [
            `
            :host ::ng-deep .ant-row {
                margin: 20px 0;
            }

            :host ::ng-deep .ant-col-4 {
                text-align: right;
            }

            h2 {
                font-weight: 400;
            }
        `
    ]
})
export class HandleDetailComponent implements OnInit {

    eventId;
    event;
    transforsList;

    constructor(private workSer: WorkService, private message: NzMessageService,
                private routrInfo: ActivatedRoute,private commonSer:CommonService) {
        this.routrInfo.queryParams.subscribe(
            (res) => {
                this.eventId = res.eventId;
            }
        );
    }

    ngOnInit() {
        this.getDetail();
    }

    getDetail() {
        this.workSer.findByNo(this.eventId).subscribe(
            (res) => {
                this.event = res.data;
            }
        );
    }

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

}
