1 import {Component, EventEmitter, Input, OnInit, Output} from '@angular/core';
2 import {COMMUNICATION_FORM_ITEMS, COMMUNICATION_FORM_ADDRESS} from "../../../../../../constants/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",
42 isSpinning: boolean = false;
43 validateRulesShow: any[] = [];
44 rulesText: any[] = [];
45 tooltipText: string = 'Scope: 1-100000';
47 AreaFormatting(): void {
48 let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street'];
49 this.areaList = areaList.map((item: any) => {
50 let arr = item.split(';');
51 item = arr.map((it, index) => {
55 } else if (index === 1) {
57 } else if (index === 2) {
65 obj.options = [{name: it, id: it}]
72 creatAreaList(): void {
95 this.areaList.push(arr)
98 deleteAreaList(index: number): void {
99 this.areaList.splice(index, 1);
102 handleChange(area: any[], areaItem: any): void {
103 if (areaItem.key === 'province' && areaItem.options.length <= 1) {
104 areaItem.options = COMMUNICATION_FORM_ADDRESS;
105 } else if (areaItem.key === 'city' && areaItem.options.length <= 1) {
106 COMMUNICATION_FORM_ADDRESS.forEach(item => {
107 if (item.name === area[0].selected) {
108 areaItem.options = item.city;
111 } else if (areaItem.key === 'district' && areaItem.options.length <= 1) {
112 COMMUNICATION_FORM_ADDRESS.forEach((item: any) => {
113 item.city.forEach(city => {
114 if (city.name === area[1].selected) {
115 areaItem.options = city.county;
119 } else if (areaItem.key === 'street' && areaItem.options.length <= 1) {
120 COMMUNICATION_FORM_ADDRESS.forEach((item: any) => {
121 item.city.forEach(city => {
122 if (city.name === area[1].selected) {
123 city.county.forEach(county => {
124 if (county.name === area[2].selected) {
125 areaItem.options = county.street;
134 handleChangeSelected(area: any[], areaItem: any): void {
135 let areaItemIndex = area.indexOf(areaItem);
136 area.map((item,index)=>{
137 if(index > areaItemIndex){
144 handleCancel(): void {
145 this.showModel = false;
146 this.cancel.emit(this.showModel);
147 this.slicing_order_info = {
149 maxNumberofUEs: null,
153 resourceSharingLevel: "shared",
154 uEMobilityLevel: "stationary",
159 changeTooltipText(title: string): void {
160 if (title === 'Max Number of UEs') {
161 this.tooltipText = 'Scope: 1-100000'
162 } else if (title === 'Data Rate Downlink (Mbps)' || title === 'Data Rate Uplink (Mbps)') {
163 this.tooltipText = 'Scope: 100-3000'
164 } else if (title === 'Latency') {
165 this.tooltipText = 'Scope: 10-200'
166 } else if (title === 'Use Interval (Month)') {
167 this.tooltipText = 'Scope: ≥1'
172 COMMUNICATION_FORM_ITEMS.forEach((item, index) => {
173 if (item.key !== 'resourceSharingLevel' && item.key !== 'uEMobilityLevel' && item.key !== 'coverageArea') {
174 this.Util.validator(item.title,item.key, this.slicing_order_info[item.key], index, this.rulesText, this.validateRulesShow)
177 if (this.validateRulesShow.indexOf(true) > -1) {
180 const coverage_list: string[] = [];
181 this.areaList.forEach(item => {
183 item.forEach(area => {
184 str += area.selected + ';';
186 coverage_list.push(str.substring(0, str.length - 1));
188 if (coverage_list.length > 1) {
189 this.slicing_order_info.coverageArea = coverage_list.join('|')
191 this.slicing_order_info.coverageArea = coverage_list.toString();
194 slicing_order_info: this.slicing_order_info
196 this.isSpinning = true;
197 let csmfSlicingPurchaseFailedCallback = () => {
199 this.isSpinning = false;
201 this.myhttp.csmfSlicingPurchase(paramsObj, csmfSlicingPurchaseFailedCallback).then(res => {
202 this.isSpinning = false;