Newer
Older
import {Component, EventEmitter, OnInit, Output} from '@angular/core';
import {NzMessageService, UploadFile} from 'ng-zorro-antd';
import {FormBuilder, FormGroup, Validator, Validators} from '@angular/forms';
selector: 'smart-icon',
templateUrl: './icon.component.html',
styles: []
title;
firstTypeId; //分类ID
iconId; //图标ID
options; //一级分类list;
constructor(private topologySer: TopologyService, private message: NzMessageService,
private fb: FormBuilder) {
}
showAddModal(title) {
this.title = title;
this.isVisible = true;
}
showEditModal(title,id) {
this.iconId = id;
this.title = title;
handleOk() {
if (this.fileList.length == 0) {
this.message.error('请选择图标');
if(this.title == "添加图标"){
if (!this.firstTypeId) {
this.message.error('请选择一级分类');
return false;
}else{
this.create();
}
const formData = new FormData();
this.fileList.forEach((file: any) => {
(res) => {
if (res.errCode == 10000) {
this.message.success('添加成功');
update(){
const formData = new FormData();
this.fileList.forEach((file: any) => {
formData.append('file', file);
formData.append('id', this.iconId);
this.topologySer.updateIcon(formData).subscribe(
(res) => {
if (res.errCode == 10000) {
this.message.success('添加成功');
this.isVisible = false;
this.initForm();
this.done.emit();
} else {
this.message.error(res.errMsg);
}
}
);