1 import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
2 import {COMMUNICATION_FORM_ITEMS, COMMUNICATION_FORM_ADDRESS} from "../../../../../../constants/constants";
3 import {SlicingTaskServices} from "../../../../../core/services/slicingTaskServices";
4 import {NzMessageService} from "ng-zorro-antd";
7 selector: 'app-business-order',
8 templateUrl: './business-order.component.html',
9 styleUrls: ['./business-order.component.less']
11 export class BusinessOrderComponent implements OnInit {
14 private myhttp: SlicingTaskServices,
15 private message: NzMessageService
22 this.AreaFormatting();
24 @Input() showModel: boolean;
25 @Output() cancel = new EventEmitter<boolean>();
26 comunicationFormItems = COMMUNICATION_FORM_ITEMS;
27 slicing_order_info = {
33 resourceSharingLevel: "shared",
34 uEMobilityLevel: null,
39 isSpinning: boolean = false;
41 let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street'];
42 this.areaList = areaList.map((item: any) => {
43 let arr = item.split(';');
44 item = arr.map((ite, index) => {
48 } else if (index === 1) {
50 } else if (index === 2) {
58 obj.options = [{name: ite, id: ite}]
65 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 = COMMUNICATION_FORM_ADDRESS;
98 } else if (areaItem.key === 'city' && areaItem.options.length <= 1) {
99 COMMUNICATION_FORM_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 COMMUNICATION_FORM_ADDRESS.forEach( (item: any) => {
106 item.city.forEach(city => {
107 if (city.name === area[1].selected) {
108 areaItem.options = city.county;
112 }else if (areaItem.key === 'street' && areaItem.options.length <= 1) {
113 COMMUNICATION_FORM_ADDRESS.forEach( (item: any) => {
114 item.city.forEach(city => {
115 if (city.name === area[1].selected) {
116 city.county.forEach(county => {
117 if (county.name === area[2].selected) {
118 areaItem.options = county.street;
127 handleChangeSelected(area: any[], areaItem: any) {
128 if (areaItem.key === 'province') {
129 area[1].selected = ''
130 area[1].options = [];
131 area[2].selected = '';
132 area[2].options = [];
133 area[3].selected = '';
134 area[3].options = [];
135 } else if (areaItem.key === 'city') {
136 area[2].selected = '';
137 area[2].options = [];
138 area[3].selected = '';
139 area[3].options = [];
140 }else if (areaItem.key === 'district') {
141 area[3].selected = '';
142 area[3].options = [];
147 this.showModel = false;
148 this.cancel.emit(this.showModel)
152 const coverage_list: string[] = [];
153 this.areaList.forEach( item => {
154 let str: string = '';
155 item.forEach( area => {
156 str += area.selected + ';';
158 coverage_list.push(str.substring(0, str.length-1));
160 if(coverage_list.length>1){
161 this.slicing_order_info.coverageArea = coverage_list.join('|')
163 this.slicing_order_info.coverageArea = coverage_list.toString();
166 slicing_order_info:this.slicing_order_info
168 console.log(paramsObj,"-----paramsObj");
169 this.isSpinning = true;
170 this.myhttp.csmfSlicingPurchase(paramsObj).subscribe(res => {
171 const { result_header: { result_code, result_message }, result_body: { service_id,operation_id } } = res;
172 if (+result_code === 200) {
173 this.isSpinning = false;
177 this.message.error(err);
179 this.isSpinning = false;