
import { FormBuilder, Validators } from '@angular/forms';
import { CustomValidators } from 'ng2-validation';
import { BsModalService } from "ngx-bootstrap/modal";
import { AppComponent } from "../../../../app.component";
import { FrameRequest } from "../../../../shared/frame/frame-request";

import * as _ from 'lodash';
import { FlexTableComponent } from '../../../../shared/common/FlexTable.component';
import { OnInit, Component } from '@angular/core';

@Component({
    selector: 'sys-operate-log',
    templateUrl: './sys-operate-log.component.html',
    styleUrls: ['./sys-operate-log.component.scss']
})
export class SysOperateLogComponent extends FlexTableComponent implements OnInit {

	msg: any;
    public query = {
		query:"",
        name: "",
		startTime: "",
		endTime: "",
		port:''
    };

    //TODO
    QUERY_URL = "sys/sysOperateLog/page.htm";
	EXPROT_URL = "sys/sysOperateLog/exprotDbf.htm";

    constructor(
        public bsModalService: BsModalService
    ) {
        super();
	}
	search(param) {
		param.query = this.query.query;
		if (!this.query.name) {
			this.query.name = "";
		}
		if (!this.query.startTime) {
			this.query.startTime = "";
		}
		if (!this.query.endTime) {
			this.query.endTime = "";
		}
		if (!this.query.port) {
			this.query.port = "";
		}
		
		param.name = this.query.name;
		param.startTime = this.query.startTime;
		param.endTime = this.query.endTime;
		param.port = this.query.port;
	}

	massage(template,editShowType,modalcss,msg){

		   if(!this.item) {
			 this.item = {};
		   } 
		   this.showEdit(template, editShowType, modalcss);
			this.msg=msg;
		//AppComponent.alert({ "title": "详细", "text": msg });
	}

	exportDbf() {
		if (!this.query.name) {
			this.query.name = "";
		}
		if (!this.query.startTime) {
			this.query.startTime = "";
		}
		if (!this.query.endTime) {
			this.query.endTime = "";
		}
		if (!this.query.query) {
			this.query.query = "";
		}
		if (!this.query.port) {
			this.query.port = "";
		}
		let parm = {
			query:this.query.query,
			name: this.query.name,
			startTime: this.query.startTime,
			endTime: this.query.endTime,
			port : this.query.port
		}
		

		AppComponent.GobalComponent.setLoading(true);
		FrameRequest.download(this.EXPROT_URL, parm, ()=>{
			AppComponent.GobalComponent.setLoading(false);
			AppComponent.GobalComponent.successMsg("下载成功!");
		  });
	  }
}


