Newer
Older
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
@Component({
selector: 'smart-assets',
templateUrl: './assets.component.html',
styles: []
})
export class AssetsComponent implements OnInit {
constructor(private workSer:WorkService,private fb:FormBuilder,
private message:NzMessageService) {
}
ngOnInit() {
this.initForm();
}
initForm(){
this.validateForm = this.fb.group({
serialnoA:[null],
invertoryname:[null],
hostid:[null],
person:[null],
ip:[null],
equipmentTypeid:[null],
inventorycount:[null],
secondlevelTypeid:[null],
stock:[null],
usedcount:[null],
lendcount:[null],
mac:[null],
repaircount:[null],
maintenanceExpiration:[null],
scrapcount:[null],
storageLocation:[null],
groupid:[null],
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
});
}
//父级分类
getParentType(){
this.workSer.findByParentType().subscribe(
(res)=>{
const data = res.data;
this.parentTypeList = data;
}
)
}
//通过父级分类查询子级分类
getTypeByParent(parentid){
this.workSer.findByParentidCount(parentid).subscribe(
(res)=>{
const data = res.data;
this.typeList = data;
}
)
}
showAddModal(title) {
this.title = title;
this.isVisible = true;
this.getParentType();
}
showEditModal(title) {
this.title = title;
this.isVisible = true;
this.getParentType();
}
handEditleOk() {
for(let i in this.validateForm.controls){
this.validateForm.controls[i].markAsDirty();
this.validateForm.controls[i].updateValueAndValidity();
}
if(this.validateForm.invalid){
return false;
}
this.update();
}
}
create(){
this.workSer.createInventory(this.validateForm.value).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("添加资产成功");
this.isVisible = false;
this.done.emit();
}else{
this.message.error(res.errMsg);
}