Newer
Older
import {Component, OnInit, Output, EventEmitter, ViewChild} from '@angular/core';
import {FormBuilder, FormControl, FormGroup, Validators} from '@angular/forms';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {project_type} from '../../project.constants';
import {SystemService} from '../../../system/system.service';
import {ProjectService} from '../../project.service';
import {SelectPersonComponent} from '../../../modal/select-person/select-person.component';
import {WorkService} from '../../../work/work.service';
@Component({
selector: 'smart-create-track-info',
templateUrl: './create-track-info.component.html',
styles: []
@ViewChild('smartSelectPerson') smartSelectPerson: SelectPersonComponent;
@Output() done = new EventEmitter<any>();
isVisible = false;
isOkLoading = false;
validateForm: FormGroup;
fileList: UploadFile[] = [];
opr_company_type = project_type;
constructor(private fb: FormBuilder, private systemSer: SystemService,
private workSer: WorkService,
private message: NzMessageService, private projectSer: ProjectService) {
}
componentId: [null],
maintainType: [null],
maintainId: [null],
if (title == '添加跟踪信息') {
this.validateForm.patchValue({
maintainId: id,
maintainType: maintainType
});
}
showEditModal(data, title) {
this.isVisible = true;
data.type += '';
this.title = title;
this.cID = data.id;
this.validateForm.patchValue(data);
handleCancel() {
this.isVisible = 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.isOkLoading = true;
if (this.title == '添加跟踪信息') { //运维工作
this.create();
}
if (this.title == '添加配件盘点') { //项目管理
this.add();
this.projectSer.addMaintainProjectTrackMsg(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.initForm();
this.done.emit();
this.isVisible = false;
this.isOkLoading = false;
this.message.success(`${this.title}成功`);
}
}
);
}
//备件盘点
add() {
this.workSer.addTrackMsg(this.validateForm.value).subscribe(
(res) => {
if (res.errCode == 10000) {
this.initForm();
this.done.emit();
this.isVisible = false;
this.isOkLoading = false;
this.message.success(`${this.title}成功`);
}
}
);
}
//选择人员
showPeoplemodal() {
this.smartSelectPerson.showModal('选择人员', null);
}
//设置人员
setPeolpe(e) {
const d = {
createUserId: e[0].id,
createUserName: e[0].name,
};
this.validateForm.patchValue(d);
console.log(e);
}