Newer
Older
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {opr_company_type} from '../../../project-manager/project.constants';
import {SystemService} from '../../../system/system.service';
import {ProjectService} from '../../../project-manager/project.service';
import {cost_type} from '../../work.constants';
@Component({
selector: 'smart-cost-releation',
templateUrl: './cost-releation.component.html',
styles: []
@Output() done = new EventEmitter<any>();
tabNum = 0; //tabs面板的序列号
title;
isVisible = false;
isOkLoading = false;
validateForm: FormGroup;
fileList: UploadFile[] = [];
cost_type = cost_type;
constructor(private fb: FormBuilder, private systemSer: SystemService,
private message: NzMessageService, private projectSer: ProjectService) {
}
initForm() {
this.validateForm = this.fb.group({
costTypeId: [null],
amount: [null],
remark: [null],
});
}
showAddModal(title) {
this.isVisible = true;
this.title = title;
}
showEditModal(data, title) {
this.isVisible = true;
data.type += '';
this.title = title;
this.cID = data.id;
console.log(data);
this.validateForm.patchValue(data);
}
handleCancel() {
this.isVisible = false;
this.isOkLoading = false;
this.initForm();
handleOk() {
for (let i in this.validateForm.controls) {
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
if (this.validateForm.invalid) {
return false;
}
this.done.emit(this.validateForm.value);
this.isVisible = false;
this.initForm();
//tabs切换
tabsChange(num) {
this.tabNum = num;
}