Newer
Older
import {Component, OnInit, ViewChild} from '@angular/core';
import {WorkService} from '../work.service';
import {NzMessageService} from 'ng-zorro-antd';
import {ParamsTypeComponent} from '../modal/params-type/params-type.component';
import {CommonService} from '../../shared/common/common.service';
@Component({
selector: 'smart-pararms',
templateUrl: './pararms.component.html',
})
export class PararmsComponent implements OnInit {
@ViewChild('smartParamstype') smartParamstype:ParamsTypeComponent;
eventList;
planList;
isDisabled = true;
constructor(private workSer:WorkService,private message:NzMessageService,
private commomSer:CommonService) { }
ngOnInit() {
this.getList();
//获取事件前缀
getEventPre(){
this.workSer.getEventNoPre().subscribe(
(res)=>{
this.eventPre = res.data;
}
)
}
//获取分类列表
getList(){
const data = {
type:0
};
this.workSer.findParamsByType(data).subscribe(
(res)=>{
this.eventList = res.data;
}
);
data.type = 1;
this.workSer.findParamsByType(data).subscribe(
(res)=>{
this.planList = res.data;
}
)
}
//0=事件分类, 1=计划分类
showAddModal(title,type){
this.smartParamstype.showAddModal(title,type);
}
showEditModal(title,type,item){
this.smartParamstype.showEditModal(title,type,item.id,item);
}
//删除分类
deleteItem(item){
const data = {
ids:[]
};
data.ids.push(item.id);
this.workSer.deleteTypeByparams(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("删除成功");
this.getList()
}else{
this.message.error(res.errMsg);
}
}
)
})
}
editType(){
this.isDisabled = false;
}
}
this.workSer.updateEventNoPre(data).subscribe(
(res)=>{
if(res.errCode == 10000){
this.message.success("修改成功");
this.getEventPre()
}else{
this.message.error(res.errMsg);
}
}
)