1 import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
2 import { WIRELESS_FORM_ITEMS, TRANSFRER_FORM_ITEMS, CORE_FORM_ITEMS, ADDRESS } 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 = CORE_FORM_ITEMS;
19 wirelessFormItems = WIRELESS_FORM_ITEMS;
27 if (this.title === 'An') {
28 this.AreaFormatting();
33 let areaList = [...this.detailData.an_coverage_area_ta_list];
34 this.areaList = areaList.map ( (item: any) => {
35 let arr = item.split(';');
36 item = arr.map( (ite, index) => {
40 } else if (index === 1){
48 obj.options = [{name: ite, id: ite}]
55 creatAreaList (): void {
73 this.areaList.push(arr)
76 deleteAreaList (index: number): void {
77 this.areaList.splice(index,1);
80 handleChange(area: any[], areaItem: any): void{
81 if (areaItem.key === 'province' && areaItem.options.length <= 1) {
82 areaItem.options = ADDRESS;
83 } else if (areaItem.key === 'city' && areaItem.options.length <= 1) {
84 ADDRESS.forEach( item => {
85 if(item.name === area[0].selected) {
86 areaItem.options = item.city;
89 }else if (areaItem.key === 'district' && areaItem.options.length <= 1) {
90 ADDRESS.forEach( (item: any) => {
91 item.city.forEach(city => {
92 if (city.name === area[1].selected) {
93 areaItem.options = city.county;
100 handleChangeSelected(area: any[], areaItem: any) {
101 if (areaItem.key === 'province') {
102 area[1].selected = ''
103 area[1].options = [];
104 area[2].selected = '';
105 area[2].options = [];
106 } else if (areaItem.key === 'city') {
107 area[2].selected = '';
108 area[2].options = [];
113 this.showModel = false
114 this.cancel.emit(this.showModel)
119 if (this.title === 'An') {
120 const an_coverage_area_ta_list: string[] = [];
121 this.areaList.forEach( item => {
122 let str: string = '';
123 item.forEach( area => {
124 str += area.selected + ';';
126 an_coverage_area_ta_list.push(str.substring(0, str.length-1));
128 params = {...this.detailData, an_coverage_area_ta_list}
130 params = {...this.detailData}
132 this.paramsDataChange.emit(params)