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",
40 coverageAreaNumber: null
43 isSpinning: boolean = false;
44 validateRulesShow: any[] = [];
45 rulesText: any[] = [];
46 tooltipText: string = 'Scope: 1-100000';
48 AreaFormatting(): void {
49 let areaList = ['Beijing;Beijing;Haidian District;Wanshoulu Street'];
50 this.areaList = areaList.map((item: any) => {
51 let arr = item.split(';');
52 item = arr.map((it, index) => {
56 } else if (index === 1) {
58 } else if (index === 2) {
66 obj.options = [{name: it, id: it}]
73 creatAreaList(): void {
96 this.areaList.push(arr)
99 deleteAreaList(index: number): void {
100 this.areaList.splice(index, 1);
103 handleChange(area: any[], areaItem: any): void {
104 if (areaItem.key === 'province' && areaItem.options.length <= 1) {
105 areaItem.options = COMMUNICATION_FORM_ADDRESS;
106 } else if (areaItem.key === 'city' && areaItem.options.length <= 1) {
107 COMMUNICATION_FORM_ADDRESS.forEach(item => {
108 if (item.name === area[0].selected) {
109 areaItem.options = item.city;
112 } else if (areaItem.key === 'district' && areaItem.options.length <= 1) {
113 COMMUNICATION_FORM_ADDRESS.forEach((item: any) => {
114 item.city.forEach(city => {
115 if (city.name === area[1].selected) {
116 areaItem.options = city.county;
120 } else if (areaItem.key === 'street' && areaItem.options.length <= 1) {
121 COMMUNICATION_FORM_ADDRESS.forEach((item: any) => {
122 item.city.forEach(city => {
123 if (city.name === area[1].selected) {
124 city.county.forEach(county => {
125 if (county.name === area[2].selected) {
126 areaItem.options = county.street;
135 handleChangeSelected(area: any[], areaItem: any): void {
136 let areaItemIndex = area.indexOf(areaItem);
137 area.map((item,index)=>{
138 if(index > areaItemIndex){
145 handleCancel(): void {
146 this.showModel = false;
147 this.cancel.emit(this.showModel);
148 this.slicing_order_info = {
150 maxNumberofUEs: null,
154 resourceSharingLevel: "shared",
155 uEMobilityLevel: "stationary",
157 coverageAreaNumber: null
161 changeTooltipText(title: string): void {
162 if (title === 'Max Number of UEs') {
163 this.tooltipText = 'Scope: 1-100000'
164 } else if (title === 'Data Rate Downlink (Mbps)' || title === 'Data Rate Uplink (Mbps)') {
165 this.tooltipText = 'Scope: 100-3000'
166 } else if (title === 'Latency') {
167 this.tooltipText = 'Scope: 10-200'
168 } else if (title === 'Use Interval (Month)') {
169 this.tooltipText = 'Scope: ≥1'
174 const coverage_list: string[] = [];
175 let coverageAreaNumber = null;
178 COMMUNICATION_FORM_ITEMS.forEach((item, index) => {
179 if (item.key !== 'resourceSharingLevel' && item.key !== 'uEMobilityLevel' && item.key !== 'coverageArea' && item.key !== 'coverageAreaNumber') {
180 this.Util.validator(item.title,item.key, this.slicing_order_info[item.key], index, this.rulesText, this.validateRulesShow)
181 }else if(item.key === 'coverageAreaNumber'){
182 coverageAreaNumber = this.slicing_order_info[item.key]
185 if (this.validateRulesShow.indexOf(true) > -1) {
189 this.areaList.forEach(item => {
191 item.forEach(area => {
192 str += area.selected + ';';
194 coverage_list.push(str.substring(0, str.length - 1));
197 if (coverage_list.length > 1) {
198 coverageAreas = coverage_list.join('|')
200 coverageAreas = coverage_list.toString();
202 if(coverageAreaNumber){
203 this.slicing_order_info.coverageArea = `${coverageAreas}-${coverageAreaNumber}`;
205 this.slicing_order_info.coverageArea = `${coverageAreas}`;
207 delete this.slicing_order_info.coverageAreaNumber
210 slicing_order_info: this.slicing_order_info
212 this.isSpinning = true;
213 const csmfSlicingPurchaseFailedCallback = () => {
215 this.isSpinning = false;
217 this.myhttp.csmfSlicingPurchase(paramsObj, csmfSlicingPurchaseFailedCallback).then(res => {
218 this.isSpinning = false;