Skip to content
pararms.component.ts 2.67 KiB
Newer Older
wangqinghua's avatar
wangqinghua committed
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',
wangqinghua's avatar
wangqinghua committed
  styles: [
      `
wangqinghua's avatar
wangqinghua committed
          :host ::ng-deep .content-params .ant-row,
          .handle{
wangqinghua's avatar
wangqinghua committed
              margin: 10px 0;
          }
      `
  ]
wangqinghua's avatar
wangqinghua committed
})
export class PararmsComponent implements OnInit {
  @ViewChild('smartParamstype') smartParamstype:ParamsTypeComponent;

    eventList;
    planList;
    isDisabled = true;
wangqinghua's avatar
wangqinghua committed
    eventPre = {
        eventNoPre:"",
        id:""
    }
wangqinghua's avatar
wangqinghua committed
  constructor(private workSer:WorkService,private message:NzMessageService,
              private commomSer:CommonService) { }

  ngOnInit() {
    this.getList();
wangqinghua's avatar
wangqinghua committed
    this.getEventPre();
wangqinghua's avatar
wangqinghua committed
  }

wangqinghua's avatar
wangqinghua committed
  //获取事件前缀
   getEventPre(){
      this.workSer.getEventNoPre().subscribe(
          (res)=>{
              this.eventPre = res.data;
          }
      )
   }

wangqinghua's avatar
wangqinghua committed
  //获取分类列表
  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){
wangqinghua's avatar
wangqinghua committed
    this.commomSer.confirmThing("删除","确定删除该分类?",()=>{
wangqinghua's avatar
wangqinghua committed
      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;
    }

wangqinghua's avatar
wangqinghua committed
    //保存修改的事件前缀
wangqinghua's avatar
wangqinghua committed
    saveType(){
      this.isDisabled = true;
wangqinghua's avatar
wangqinghua committed
      const data = {
wangqinghua's avatar
wangqinghua committed
          eventNoPre:this.eventPre.eventNoPre
wangqinghua's avatar
wangqinghua committed
      }
      this.workSer.updateEventNoPre(data).subscribe(
          (res)=>{
              if(res.errCode == 10000){
                  this.message.success("修改成功");
                  this.getEventPre()
              }else{
                  this.message.error(res.errMsg);
              }
          }
      )
wangqinghua's avatar
wangqinghua committed
    }

}