1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 import { TRANSFRER_FORM_ITEMS, CORE_FORM_ITEMS, ADDRESS , NexthopInfo_Options } from '@src/constants/constants'
5 selector: 'app-subnet-params-model',
6 templateUrl: './subnet-params-model.component.html',
7 styleUrls: ['./subnet-params-model.component.less']
9 export class SubnetParamsModelComponent implements OnInit {
11 @Input() showModel: boolean;
12 @Input() detailData: any;
13 @Input() title: string;
14 @Output() cancel = new EventEmitter<boolean>();
15 @Output() paramsDataChange = new EventEmitter<any>();
17 transferFormItems = TRANSFRER_FORM_ITEMS;
18 coreFormItems :object ={};
20 // 2020.08.17 Add 3 parameters for Endpoint, Comment: The following code
21 NexthopInfoOptions = NexthopInfo_Options;
22 EndpointInputs: any[] = [];
23 EndpointEnable: boolean = false; // Whether to enable the three parameters of Endpoint
24 // Comment: Above code
31 this.coreFormItems = this.title === 'An'?CORE_FORM_ITEMS.An:CORE_FORM_ITEMS.Cn;
33 // -------> 2020.08.17 Add 3 parameters for Endpoint, Comment: The following code
34 if(this.EndpointEnable){
35 this.EndpointInputs = this.title === 'An'
36 ?this.detailData["an_Endpoint"]
38 ?this.detailData["cn_Endpoint"]
41 //-------> Comment: Above code
42 if (this.title === 'An') {
43 this.AreaFormatting();
48 let areaList = [...this.detailData.an_coverage_area_ta_list];
49 this.areaList = areaList.map ( (item: any) => {
50 let arr = item.split(';');
51 item = arr.map( (ite, index) => {
55 } else if (index === 1){
63 obj.options = [{name: ite, id: ite}]
70 creatAreaList (): void {
88 this.areaList.push(arr)
91 deleteAreaList (index: number): void {
92 this.areaList.splice(index,1);
95 handleChange(area: any[], areaItem: any): void{
96 if (areaItem.key === 'province' && areaItem.options.length <= 1) {
97 areaItem.options = ADDRESS;
98 } else if (areaItem.key === 'city' && areaItem.options.length <= 1) {
99 ADDRESS.forEach( item => {
100 if(item.name === area[0].selected) {
101 areaItem.options = item.city;
104 }else if (areaItem.key === 'district' && areaItem.options.length <= 1) {
105 ADDRESS.forEach( (item: any) => {
106 item.city.forEach(city => {
107 if (city.name === area[1].selected) {
108 areaItem.options = city.county;
115 handleChangeSelected(area: any[], areaItem: any) {
116 if (areaItem.key === 'province') {
117 area[1].selected = ''
118 area[1].options = [];
119 area[2].selected = '';
120 area[2].options = [];
121 } else if (areaItem.key === 'city') {
122 area[2].selected = '';
123 area[2].options = [];
128 this.showModel = false
129 this.cancel.emit(this.showModel)
134 if (this.title === 'An') {
135 const an_coverage_area_ta_list: string[] = [];
136 this.areaList.forEach( item => {
137 let str: string = '';
138 item.forEach( area => {
139 str += area.selected + ';';
141 an_coverage_area_ta_list.push(str.substring(0, str.length-1));
143 params = {...this.detailData, an_coverage_area_ta_list}
145 params = {...this.detailData}
147 this.paramsDataChange.emit(params)