1 import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2 import { IntentManagementService } from '../../../core/services/intentManagement.service';
3 import { Util } from '../../../shared/utils/utils';
4 import {NzMessageService} from "ng-zorro-antd";
7 selector: 'app-input-intent-management',
8 templateUrl: './input-intent-management.component.html',
9 styleUrls: ['../intent-management.component.less']
11 export class InputIntentManagementComponent implements OnInit {
14 private myhttp: IntentManagementService,
16 private message: NzMessageService,
18 defaultParams:Object={
46 currentIndex:number = -1;
47 intentExpectationShow: boolean = false;
48 editExpectationTableList: Object={};
50 listOfData: any[] = [];
52 @Input() showModel: boolean;
53 @Input() editIntentTableData;
54 @Output() modalOpreation = new EventEmitter();
59 if (JSON.stringify(this.editIntentTableData)!=='{}') {
60 this.defaultParams=this.editIntentTableData
61 this.listOfData=this.editIntentTableData['intentExpectations']
66 handleCancel(): void {
67 this.showModel = false;
68 this.clearIntentData()
69 this.modalOpreation.emit({ "cancel": true });
72 if(JSON.stringify(this.editIntentTableData)==='{}'){
73 this.defaultParams['intentId']=this.Util.getUuid()
74 this.createIntentInstance()
76 this.editIntentInstanceData()
78 this.clearIntentData()
80 clearIntentData(): void{
81 this.defaultParams = {
112 inputIntentExpectationShow(): void {
113 this.intentExpectationShow = true;
115 inputIntentExpectationClose($event: any): void {
116 this.intentExpectationShow = false;
117 this.editExpectationTableList={}
121 if(this.currentIndex>-1){
122 this.listOfData[this.currentIndex]=$event.param
125 this.listOfData.push($event.param)
127 this.defaultParams['intentExpectations']=this.listOfData
129 editExpectationList(data,i): void {
130 this.editExpectationTableList=JSON.parse(JSON.stringify(data))
132 this.intentExpectationShow = true
134 deleteExpectationList(i): void{
135 this.listOfData.splice(i,1)
138 createIntentInstance(): void {
139 this.myhttp.createIntentManagement({
140 ...this.defaultParams
143 this.showModel = false;
144 this.modalOpreation.emit({ "cancel": false });
145 if(response.result_header.result_code===200){
146 this.message.success('Created successfully');
148 this.message.error(response.result_header.result_message);
152 this.showModel = false;
153 this.message.error('Created failed');
157 editIntentInstanceData(): void {
158 let id = this.defaultParams['intentId'];
159 let obj = this.defaultParams;
160 this.myhttp.updateIntentManagementData(id,obj).subscribe(
162 this.showModel = false;
163 this.modalOpreation.emit({ "cancel": false});
164 if(response.result_header.result_code===200){
165 this.message.success('Modification succeeded');
167 this.message.error(response.result_header.result_message);
171 this.showModel = false;
172 this.message.error('upload fail');