1 import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
2 import {COMMUNICATION_FORM_ITEMS, COMMUNICATION_FORM_ADDRESS} from "./constants";
3 import { Util } from '../../../../../shared/utils/utils';
4 import {SlicingTaskServices} from "../../../../../core/services/slicingTaskServices";
5 import {NzMessageService} from "ng-zorro-antd";
8 selector: 'app-business-order',
9 templateUrl: './business-order.component.html',
10 styleUrls: ['./business-order.component.less']
12 export class BusinessOrderComponent implements OnInit {
15 private myhttp: SlicingTaskServices,
16 private message: NzMessageService,
25 this.AreaFormatting();
28 @Input() showModel: boolean;
29 @Output() cancel = new EventEmitter<boolean>();
30 comunicationFormItems = COMMUNICATION_FORM_ITEMS;
31 slicing_order_info = {
37 resourceSharingLevel: "shared",
38 uEMobilityLevel: "stationary",
40 coverageAreaNumber: null
43 validateRulesShow: any[] = [];
44 rulesText: any[] = [];
46 AreaFormatting(): void {
47 let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street'];
48 this.areaList = areaList.map((item: any) => {
49 let arr = item.split(';');
50 item = arr.map((it, index) => {
54 } else if (index === 1) {
56 } else if (index === 2) {
64 obj.options = [{name: it, id: it}]
71 creatAreaList(): void {
94 this.areaList.push(arr)
97 deleteAreaList(index: number): void {
98 this.areaList.splice(index, 1);
101 handleChange(area: any[], areaItem: any): void {
102 if (areaItem.key === 'province' && areaItem.options.length <= 1) {
103 areaItem.options = COMMUNICATION_FORM_ADDRESS;
104 } else if (areaItem.key === 'city' && areaItem.options.length <= 1) {
105 COMMUNICATION_FORM_ADDRESS.forEach(item => {
106 if (item.name === area[0].selected) {
107 areaItem.options = item.city;
110 } else if (areaItem.key === 'district' && areaItem.options.length <= 1) {
111 COMMUNICATION_FORM_ADDRESS.forEach((item: any) => {
112 item.city.forEach(city => {
113 if (city.name === area[1].selected) {
114 areaItem.options = city.county;
118 } else if (areaItem.key === 'street' && areaItem.options.length <= 1) {
119 COMMUNICATION_FORM_ADDRESS.forEach((item: any) => {
120 item.city.forEach(city => {
121 if (city.name === area[1].selected) {
122 city.county.forEach(county => {
123 if (county.name === area[2].selected) {
124 areaItem.options = county.street;
133 handleChangeSelected(area: any[], areaItem: any): void {
134 let areaItemIndex = area.indexOf(areaItem);
135 area.map((item,index)=>{
136 if(index > areaItemIndex){
143 handleCancel(): void {
144 this.showModel = false;
145 this.cancel.emit(this.showModel);
146 this.slicing_order_info = {
148 maxNumberofUEs: null,
152 resourceSharingLevel: "shared",
153 uEMobilityLevel: "stationary",
155 coverageAreaNumber: null
157 this.validateRulesShow = []
161 const coverage_list: string[] = [];
164 COMMUNICATION_FORM_ITEMS.forEach((item, index) => {
165 if (item.required && item.type==="input") {
166 this.Util.validator(item.title,item.key, this.slicing_order_info[item.key], index, this.rulesText, this.validateRulesShow)
169 if (this.validateRulesShow.indexOf(true) > -1) {
173 this.areaList.forEach(item => {
175 item.forEach(area => {
176 str += area.selected + ';';
178 coverage_list.push(str.substring(0, str.length - 1));
180 if (coverage_list.length > 1) {
181 coverageAreas = coverage_list.join('|')
183 coverageAreas = coverage_list.toString();
185 const coverageAreaNumber = this.slicing_order_info["coverageAreaNumber"];
186 if(coverageAreaNumber){
187 this.slicing_order_info.coverageArea = `${coverageAreas}-${coverageAreaNumber}`;
189 this.slicing_order_info.coverageArea = `${coverageAreas}`;
191 delete this.slicing_order_info.coverageAreaNumber
194 slicing_order_info: this.slicing_order_info
196 const csmfSlicingPurchaseFailedCallback = () => {
199 this.myhttp.csmfSlicingPurchase(paramsObj, csmfSlicingPurchaseFailedCallback).then(res => {
200 const result = res.result_header;
201 if(result&&result.result_code&&+result.result_code===200){
204 this.message.create('error','Network error')